allocate method

  1. @override
String allocate(
  1. Reference reference
)

Returns a reference string given a reference object.

For example, a no-op implementation:

allocate(const Reference('List', 'dart:core')); // Returns 'List'.

Where-as an implementation that prefixes imports might output:

allocate(const Reference('Foo', 'package:foo')); // Returns '_i1.Foo'.

Implementation

@override
String allocate(Reference reference) {
  final symbol = reference.symbol;
  _url = reference.url;
  if (_url == null || _doNotPrefix.contains(_url)) {
    return symbol!;
  }

  return '_i${_imports.putIfAbsent(_url!, _hashedUrl)}.$symbol';
}