addLibraryPartOf method

  1. @override
void addLibraryPartOf(
  1. String stringUri,
  2. Asset asset
)
inherited

Adds a library part-of directive to the asset graph.

this is treated differently than the regular part-of directive as library part-of do not directly point to an actual file

Implementation

@override
void addLibraryPartOf(String stringUri, Asset asset) {
  final List<List<dynamic>> fileDirectives = <List<dynamic>>[
    ...?directives[asset.id],
  ];
  if (fileDirectives.isEmpty) {
    directives[asset.id] = <List<dynamic>>[
      <dynamic>[DirectiveStatement.partOfLibrary, '', stringUri],
    ];
  } else {
    // avoid duplicate entries
    for (final List<dynamic> directive in fileDirectives) {
      if (directive[GraphIndex.directiveType] == DirectiveStatement.partOfLibrary &&
          directive[GraphIndex.directiveStringUri] == stringUri) {
        return;
      }
    }
    directives[asset.id] = <List<dynamic>>[
      ...fileDirectives,
      <dynamic>[DirectiveStatement.partOfLibrary, '', stringUri],
    ];
  }
}