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 = () {
var children = <String, CommentReferable>{};
// 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);
// Packages are the top priority.
children.addEntries(sortedPackages.generateEntries());
// 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.
children.addEntriesIfAbsent(sortedDocumentedPackages
.expand((p) => p.publicLibrariesSorted)
.generateEntries());
// 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.
children.addEntriesIfAbsent(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,
])
.generateEntries());
return children;
}();