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.


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.

    // 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.
        .expand((p) => p.publicLibrariesSorted)

    // 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.
        .expand((p) => p.publicLibrariesSorted)
        .expand((l) => [
  return _referenceChildren;