referenceChildren property
Map of referenceName to the elements that are a member of this, but
not this model element itself. Can be cached.
There is no need to duplicate references here that can be found via scope.
Implementation
@override
late final Map<String, CommentReferable> referenceChildren = () {
// We have to use a stable order or otherwise references depending on
// ambiguous resolution (see below) will change where they resolve based on
// internal implementation details.
var sortedPackages = packages.toList(growable: false)..sort(byName);
var sortedDocumentedPackages = _documentedPackages.toList(growable: false)
..sort(byName);
return {
// TODO(jcollins-g): Warn about directly referencing top level items out
// of scope? Doing this will be even more ambiguous and potentially
// confusing than doing so with libraries.
...sortedDocumentedPackages
.expand((p) => p.publicLibrariesSorted)
.expand((l) => [
...l.constants.wherePublic,
...l.functions.wherePublic,
...l.properties.wherePublic,
...l.typedefs.wherePublic,
...l.extensions.wherePublic,
...l.extensionTypes.wherePublic,
...l.classes.wherePublic,
...l.enums.wherePublic,
...l.mixins.wherePublic,
])
.asMapByName,
// Libraries are next.
// TODO(jcollins-g): Warn about directly referencing libraries out of
// scope? Doing this is always going to be ambiguous and potentially
// confusing.
...sortedDocumentedPackages
.expand((p) => p.publicLibrariesSorted)
.asMapByName,
// Packages are the top priority.
...sortedPackages.asMapByName,
};
}();