linkToReference function

TypeReference linkToReference(
  1. TypeLink link,
  2. LibraryReader library
)

Returns as a code_builder TypeReference for code generation.

Implementation

TypeReference linkToReference(TypeLink link, LibraryReader library) {
  if (link.isDynamic || link.isPrivate) {
    return _dynamic;
  }
  return TypeReference((b) => b
    ..symbol = link.symbol
    ..url = library.pathToUrl(link.import).toString()
    ..types.addAll(link.generics.map((t) => linkToReference(t, library))));
}