referenceChildren property

Map<String, CommentReferable> referenceChildren

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
Map<String, CommentReferable> get referenceChildren {
  if (_referenceChildren == null) {
    _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()..sort(byName);
    var sortedDocumentedPackages = documentedPackages.toList()..sort(byName);
    // Packages are the top priority.
    _referenceChildren.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.
    _referenceChildren.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.
    _referenceChildren.addEntriesIfAbsent(sortedDocumentedPackages
        .expand((p) => p.publicLibrariesSorted)
        .expand((l) => [
              ...l.publicConstants,
              ...l.publicFunctions,
              ...l.publicProperties,
              ...l.publicTypedefs,
              ...l.publicExtensions,
              ...l.publicClasses,
              ...l.publicEnums,
              ...l.publicMixins
            ])
        .generateEntries());
  }
  return _referenceChildren;
}