diff --git a/lib/src/generator/templates.runtime_renderers.dart b/lib/src/generator/templates.runtime_renderers.dart index d7d5beabba..141ea443f5 100644 --- a/lib/src/generator/templates.runtime_renderers.dart +++ b/lib/src/generator/templates.runtime_renderers.dart @@ -16641,6 +16641,7 @@ const _invisibleGetters = { 'specialClasses', 'allImplementorsAdded', 'allExtensionsAdded', + 'documentedExtensions', 'allLibraries', 'allConstructedModelElements', 'allInheritableElements', @@ -16648,37 +16649,36 @@ const _invisibleGetters = { 'config', 'rendererFactory', 'packageMetaProvider', + 'defaultPackage', 'hasEmbedderSdk', 'packageMap', 'sdk', + 'sdkLibrarySources', 'allLibrariesAdded', 'packageWarningCounter', + 'publicPackages', + 'publicLibraries', + 'localLibraries', 'localPublicLibraries', + 'inheritThrough', + 'invisibleAnnotations', + 'allModelElements', + 'allLocalModelElements', + 'allCanonicalModelElements', + 'referenceChildren', 'name', 'implementors', - 'documentedExtensions', 'extensions', 'defaultPackageName', - 'defaultPackage', 'hasFooterVersion', 'packageGraph', 'resourceProvider', - 'sdkLibrarySources', 'packages', - 'publicPackages', 'localPackages', 'documentedPackages', 'libraryElementReexportedBy', 'allHrefs', 'libraries', - 'publicLibraries', - 'localLibraries', - 'inheritThrough', - 'invisibleAnnotations', - 'allModelElements', - 'allLocalModelElements', - 'allCanonicalModelElements', - 'referenceChildren', 'referenceParents' }, 'PackageMeta': { diff --git a/lib/src/model/accessor.dart b/lib/src/model/accessor.dart index 50b2944fe9..2f267c413a 100644 --- a/lib/src/model/accessor.dart +++ b/lib/src/model/accessor.dart @@ -90,7 +90,7 @@ class Accessor extends ModelElement implements EnclosedElement { /// for a synthetic accessor just in case it is inherited somewhere /// down the line due to split inheritance. bool get _hasSyntheticDocumentationComment => - (isGetter || definingCombo.hasNodoc! || _comboDocsAreIndependent()) && + (isGetter || definingCombo.hasNodoc || _comboDocsAreIndependent()) && definingCombo.hasDocumentationComment; // If we're a setter, and a getter exists, do not add synthetic diff --git a/lib/src/model/documentation_comment.dart b/lib/src/model/documentation_comment.dart index 0b9fb0832c..e6db74509c 100644 --- a/lib/src/model/documentation_comment.dart +++ b/lib/src/model/documentation_comment.dart @@ -83,7 +83,7 @@ mixin DocumentationComment bool get hasDocumentationComment; /// Returns true if the raw documentation comment has a nodoc indication. - bool? get hasNodoc { + bool get hasNodoc { if (hasDocumentationComment && (documentationComment.contains('@nodoc') || documentationComment.contains(''))) { diff --git a/lib/src/model/extension_target.dart b/lib/src/model/extension_target.dart index 27e7893024..c955b48ae0 100644 --- a/lib/src/model/extension_target.dart +++ b/lib/src/model/extension_target.dart @@ -21,7 +21,7 @@ mixin ExtensionTarget on ModelElement { /// defined by [element] can exist where this extension applies, not including /// any extension that applies to every type. Iterable? get potentiallyApplicableExtensions { - _potentiallyApplicableExtensions ??= packageGraph.documentedExtensions! + _potentiallyApplicableExtensions ??= packageGraph.documentedExtensions .where((e) => !e.alwaysApplies) .where((e) => e.couldApplyTo(this)) .toList(growable: false); diff --git a/lib/src/model/inheritable.dart b/lib/src/model/inheritable.dart index 37f0c777a8..33efb9f3b9 100644 --- a/lib/src/model/inheritable.dart +++ b/lib/src/model/inheritable.dart @@ -70,9 +70,9 @@ mixin Inheritable on ContainerMember { for (var c in inheritance.reversed) { // Filter out mixins. if (c!.containsElement(searchElement)) { - if ((packageGraph.inheritThrough!.contains(previous) && + if ((packageGraph.inheritThrough.contains(previous) && c != definingEnclosingContainer) || - (packageGraph.inheritThrough!.contains(c) && + (packageGraph.inheritThrough.contains(c) && c == definingEnclosingContainer)) { return previousNonSkippable! .memberByExample(this) @@ -90,7 +90,7 @@ mixin Inheritable on ContainerMember { } } previous = c; - if (!packageGraph.inheritThrough!.contains(c)) { + if (!packageGraph.inheritThrough.contains(c)) { previousNonSkippable = c; } } diff --git a/lib/src/model/library.dart b/lib/src/model/library.dart index 24d60d9cfc..54b9be2695 100644 --- a/lib/src/model/library.dart +++ b/lib/src/model/library.dart @@ -184,8 +184,8 @@ class Library extends ModelElement with Categorization, TopLevelContainer { .toList(growable: false); SdkLibrary? get sdkLib { - if (packageGraph.sdkLibrarySources!.containsKey(element.librarySource)) { - return packageGraph.sdkLibrarySources![element.librarySource]; + if (packageGraph.sdkLibrarySources.containsKey(element.librarySource)) { + return packageGraph.sdkLibrarySources[element.librarySource]; } return null; } diff --git a/lib/src/model/model_element.dart b/lib/src/model/model_element.dart index 4ecc60a230..d3995df40c 100644 --- a/lib/src/model/model_element.dart +++ b/lib/src/model/model_element.dart @@ -404,7 +404,7 @@ abstract class ModelElement extends Canonicalization @override late final bool isPublic = () { - if (name == '') { + if (name.isEmpty) { return false; } if (this is! Library && (library == null || !library!.isPublic)) { @@ -417,7 +417,7 @@ abstract class ModelElement extends Canonicalization !(enclosingElement as Extension).isPublic) { return false; } - return utils.hasPublicName(element!) && !hasNodoc!; + return utils.hasPublicName(element!) && !hasNodoc; }(); @override @@ -543,7 +543,7 @@ abstract class ModelElement extends Canonicalization if (this is Inheritable && !config.linkToRemote) { if ((this as Inheritable).isInherited && _canonicalLibrary == null && - packageGraph.publicLibraries!.contains(library)) { + packageGraph.publicLibraries.contains(library)) { // In the event we've inherited a field from an object that isn't // directly reexported, we may need to pretend we are canonical for // this. @@ -553,7 +553,7 @@ abstract class ModelElement extends Canonicalization _canonicalLibraryIsSet = true; } assert(_canonicalLibrary == null || - packageGraph.publicLibraries!.contains(_canonicalLibrary)); + packageGraph.publicLibraries.contains(_canonicalLibrary)); return _canonicalLibrary; } diff --git a/lib/src/model/package_graph.dart b/lib/src/model/package_graph.dart index bbce8b22e5..54ea8fbd1b 100644 --- a/lib/src/model/package_graph.dart +++ b/lib/src/model/package_graph.dart @@ -137,7 +137,7 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { } } - for (var m in allModelElements!) { + for (var m in allModelElements) { // Skip if there is a canonicalModelElement somewhere else we can run this // for and we won't need a one line document that is precached. // Not the same as allCanonicalModelElements since we need to run @@ -188,12 +188,8 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { return _implementors; } - List? _documentedExtensions; - Iterable? get documentedExtensions { - _documentedExtensions ??= - utils.filterNonDocumented(extensions).toList(growable: false); - return _documentedExtensions; - } + late final Iterable documentedExtensions = + utils.filterNonDocumented(extensions).toList(growable: false); Iterable get extensions { assert(allExtensionsAdded); @@ -244,10 +240,8 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { /// PackageMeta Provider for building [PackageMeta]s. final PackageMetaProvider packageMetaProvider; - Package? _defaultPackage; - - Package get defaultPackage => - _defaultPackage ??= Package.fromPackageMeta(packageMeta, this); + late final Package defaultPackage = + Package.fromPackageMeta(packageMeta, this); final bool hasEmbedderSdk; @@ -263,17 +257,9 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { final DartSdk sdk; - Map? _sdkLibrarySources; - - Map? get sdkLibrarySources { - if (_sdkLibrarySources == null) { - _sdkLibrarySources = {}; - for (var lib in sdk.sdkLibraries) { - _sdkLibrarySources![sdk.mapDartUri(lib.shortName)] = lib; - } - } - return _sdkLibrarySources; - } + late final Map sdkLibrarySources = { + for (var lib in sdk.sdkLibraries) sdk.mapDartUri(lib.shortName): lib + }; final Map _macros = {}; final Map _htmlFragments = {}; @@ -311,9 +297,10 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { if (warnable != null) { // This sort of warning is only applicable to top level elements. if (kind == PackageWarning.ambiguousReexport) { - while (warnable!.enclosingElement is! Library && - warnable.enclosingElement != null) { - warnable = warnable.enclosingElement; + var enclosingElement = warnable.enclosingElement; + while (enclosingElement != null && enclosingElement is! Library) { + warnable = enclosingElement; + enclosingElement = warnable.enclosingElement; } } } else { @@ -341,7 +328,7 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { var warnablePrefix = 'from'; var referredFromPrefix = 'referred to by'; - String? warningMessage; + String warningMessage; switch (kind) { case PackageWarning.noCanonicalFound: // Fix these warnings by adding libraries with --include, or by using @@ -452,7 +439,7 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { break; } - var messageParts = [warningMessage]; + var messageParts = [warningMessage]; if (warnable != null) { messageParts.add('$warnablePrefix $warnableName: ${warnable.location}'); } @@ -483,28 +470,22 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { List get packages => packageMap.values.toList(); - List? _publicPackages; - - List? get publicPackages { - if (_publicPackages == null) { - assert(allLibrariesAdded); - // Help the user if they pass us a package that doesn't exist. - for (var packageName in config.packageOrder) { - if (!packages.map((p) => p.name).contains(packageName)) { - warnOnElement( - null, PackageWarning.packageOrderGivesMissingPackageName, - message: - "$packageName, packages: ${packages.map((p) => p.name).join(',')}"); - } + late final List publicPackages = () { + assert(allLibrariesAdded); + // Help the user if they pass us a package that doesn't exist. + for (var packageName in config.packageOrder) { + if (!packages.map((p) => p.name).contains(packageName)) { + warnOnElement(null, PackageWarning.packageOrderGivesMissingPackageName, + message: + "$packageName, packages: ${packages.map((p) => p.name).join(',')}"); } - _publicPackages = packages.where((p) => p.isPublic).toList()..sort(); } - return _publicPackages; - } + return packages.where((p) => p.isPublic).toList()..sort(); + }(); /// Local packages are to be documented locally vs. remote or not at all. List get localPackages => - publicPackages!.where((p) => p.isLocal).toList(); + publicPackages.where((p) => p.isLocal).toList(); /// Documented packages are documented somewhere (local or remote). Iterable get documentedPackages => @@ -550,7 +531,7 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { _lastSizeOfAllLibraries = allLibraries.keys.length; _libraryElementReexportedBy = >{}; _reexportsTagged = {}; - for (var library in publicLibraries!) { + for (var library in publicLibraries) { _tagReexportsFor(library, library.element); } } @@ -574,7 +555,8 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { if (modelElement is Dynamic) continue; // TODO: see [Accessor.enclosingCombo] if (modelElement is Accessor) continue; - final href = modelElement!.href; + if (modelElement == null) continue; + final href = modelElement.href; if (href == null) continue; hrefMap.putIfAbsent(href, () => {}).add(modelElement); @@ -603,8 +585,7 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { } implemented = implemented.canonicalModelElement as InheritingContainer? ?? implemented; - _implementors.putIfAbsent(implemented, () => []); - var list = _implementors[implemented]!; + var list = _implementors.putIfAbsent(implemented, () => []); // TODO(srawlins): This would be more efficient if we created a // SplayTreeSet keyed off of `.element`. if (!list.any((l) => l.element == implementor.element)) { @@ -613,9 +594,10 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { } void addImplementor(InheritingContainer clazz) { - if (clazz.supertype != null) { + var supertype = clazz.supertype; + if (supertype != null) { checkAndAddContainer( - clazz.supertype!.modelElement as InheritingContainer, clazz); + supertype.modelElement as InheritingContainer, clazz); } if (clazz is Class) { for (var type in clazz.mixedInTypes) { @@ -642,53 +624,44 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { Iterable get libraries => packages.expand((p) => p.libraries).toList()..sort(); - List? _publicLibraries; - - Iterable? get publicLibraries { - if (_publicLibraries == null) { - assert(allLibrariesAdded); - _publicLibraries = utils.filterNonPublic(libraries).toList(); - } - return _publicLibraries; - } - - List? _localLibraries; + late final Iterable publicLibraries = () { + assert(allLibrariesAdded); + return utils.filterNonPublic(libraries).toList(); + }(); - Iterable? get localLibraries { - if (_localLibraries == null) { - assert(allLibrariesAdded); - _localLibraries = localPackages.expand((p) => p.libraries).toList() - ..sort(); - } - return _localLibraries; - } + late final Iterable localLibraries = () { + assert(allLibrariesAdded); + return localPackages.expand((p) => p.libraries).toList()..sort(); + }(); late final Iterable localPublicLibraries = () { assert(allLibrariesAdded); - return utils.filterNonPublic(localLibraries!).toList(); + return utils.filterNonPublic(localLibraries).toList(); }(); - Set? _inheritThrough; - /// Return the set of [Class]es objects should inherit through if they /// show up in the inheritance chain. Do not call before interceptorElement is /// found. Add classes here if they are similar to Interceptor in that they /// are to be ignored even when they are the implementors of [Inheritable]s, /// and the class these inherit from should instead claim implementation. - Set? get inheritThrough { - if (_inheritThrough == null) { - _inheritThrough = {}; - _inheritThrough!.add(specialClasses[SpecialClass.interceptor]); + late final Set inheritThrough = () { + var interceptorSpecialClass = specialClasses[SpecialClass.interceptor]; + if (interceptorSpecialClass == null) { + return const {}; } - return _inheritThrough; - } - Set? _invisibleAnnotations; + return {interceptorSpecialClass}; + }(); - /// Returns the set of [Class] objects that are similar to pragma + /// The set of [Class] objects that are similar to pragma /// in that we should never count them as documentable annotations. - Set get invisibleAnnotations => - _invisibleAnnotations ??= {specialClasses[SpecialClass.pragma]}; + late final Set invisibleAnnotations = () { + var pragmaSpecialClass = specialClasses[SpecialClass.pragma]; + if (pragmaSpecialClass == null) { + return const {}; + } + return {pragmaSpecialClass}; + }(); bool isAnnotationVisible(Class clazz) => !invisibleAnnotations.contains(clazz); @@ -728,7 +701,7 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { return _canonicalLibraryFor[e]; } _canonicalLibraryFor[e] = null; - for (var library in publicLibraries!) { + for (var library in publicLibraries) { if (library.modelElementsMap.containsKey(searchElement)) { for (var modelElement in library.modelElementsMap[searchElement!]!) { if (modelElement.isCanonical) { @@ -759,36 +732,39 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { if (lib == null && preferredClass != null) { lib = findCanonicalLibraryFor(preferredClass.element); } - ModelElement? modelElement; // For elements defined in extensions, they are canonical. - if (e?.enclosingElement is ExtensionElement) { - lib ??= - modelBuilder.fromElement(e!.enclosingElement!.library!) as Library?; + var enclosingElement = e?.enclosingElement; + if (enclosingElement is ExtensionElement) { + lib ??= modelBuilder.fromElement(enclosingElement.library) as Library?; // (TODO:keertip) Find a better way to exclude members of extensions // when libraries are specified using the "--include" flag if (lib?.isDocumented == true) { return modelBuilder.from(e!, lib!); } } + ModelElement? modelElement; // TODO(jcollins-g): Special cases are pretty large here. Refactor to split // out into helpers. // TODO(jcollins-g): The data structures should be changed to eliminate guesswork // with member elements. - if (e is ClassMemberElement || e is PropertyAccessorElement) { - e = e!.declaration; - var candidates = {}; - var iKey = Tuple2(e, lib); + var declaration = e?.declaration; + if (declaration != null && + (e is ClassMemberElement || e is PropertyAccessorElement)) { + e = declaration; + var candidates = {}; + var iKey = Tuple2(e, lib); var key = - Tuple4(e, lib, null, null); - var keyWithClass = Tuple4( + Tuple4(e, lib, null, null); + var keyWithClass = Tuple4( e, lib, preferredClass as Class?, null); - if (allConstructedModelElements.containsKey(key)) { - candidates.add(allConstructedModelElements[ - key as Tuple3]); + var constructedWithKey = allConstructedModelElements[key]; + if (constructedWithKey != null) { + candidates.add(constructedWithKey); } - if (allConstructedModelElements.containsKey(keyWithClass)) { - candidates.add(allConstructedModelElements[ - keyWithClass as Tuple3]); + var constructedWithKeyWithClass = + allConstructedModelElements[keyWithClass]; + if (constructedWithKeyWithClass != null) { + candidates.add(constructedWithKeyWithClass); } if (candidates.isEmpty && allInheritableElements.containsKey(iKey)) { candidates.addAll( @@ -796,15 +772,13 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { .where((me) => me.isCanonical)); } Class? canonicalClass = - findCanonicalModelElementFor(e!.enclosingElement) as Class?; + findCanonicalModelElementFor(e.enclosingElement) as Class?; if (canonicalClass != null) { candidates.addAll(canonicalClass.allCanonicalModelElements.where((m) { return m.element == e; })); } - var matches = { - ...candidates.where((me) => me!.isCanonical) - }; + var matches = {...candidates.where((me) => me.isCanonical)}; // It's possible to find accessors but no combos. Be sure that if we // have Accessors, we find their combos too. @@ -901,62 +875,47 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { return foundLibrary; } - List? _allModelElements; - - Iterable? get allModelElements { + late final Iterable allModelElements = () { assert(allLibrariesAdded); - if (_allModelElements == null) { - _allModelElements = []; - var packagesToDo = packages.toSet(); - var completedPackages = {}; - while (packagesToDo.length > completedPackages.length) { - packagesToDo.difference(completedPackages).forEach((Package p) { - var librariesToDo = p.allLibraries.toSet(); - var completedLibraries = {}; - while (librariesToDo.length > completedLibraries.length) { - librariesToDo - .difference(completedLibraries) - .forEach((Library library) { - _allModelElements!.addAll(library.allModelElements); - completedLibraries.add(library); - }); - librariesToDo.addAll(p.allLibraries); - } - completedPackages.add(p); - }); - packagesToDo.addAll(packages); - } + var allElements = []; + var packagesToDo = packages.toSet(); + var completedPackages = {}; + while (packagesToDo.length > completedPackages.length) { + packagesToDo.difference(completedPackages).forEach((Package p) { + var librariesToDo = p.allLibraries.toSet(); + var completedLibraries = {}; + while (librariesToDo.length > completedLibraries.length) { + librariesToDo + .difference(completedLibraries) + .forEach((Library library) { + allElements.addAll(library.allModelElements); + completedLibraries.add(library); + }); + librariesToDo.addAll(p.allLibraries); + } + completedPackages.add(p); + }); + packagesToDo.addAll(packages); } - return _allModelElements; - } - - List? _allLocalModelElements; - Iterable? get allLocalModelElements { - assert(allLibrariesAdded); - if (_allLocalModelElements == null) { - _allLocalModelElements = []; - for (var library in localLibraries!) { - _allLocalModelElements!.addAll(library.allModelElements); - } - } - return _allLocalModelElements; - } + return allElements; + }(); - List? _allCanonicalModelElements; + late final Iterable allLocalModelElements = [ + for (var library in localLibraries) ...library.allModelElements + ]; - Iterable get allCanonicalModelElements { - return _allCanonicalModelElements ??= - allLocalModelElements!.where((e) => e.isCanonical).toList(); - } + late final Iterable allCanonicalModelElements = + allLocalModelElements.where((e) => e.isCanonical).toList(); /// Glob lookups can be expensive. Cache per filename. final _configSetsNodocFor = HashMap(); /// Given an element's location, look up the nodoc configuration data and /// determine whether to unconditionally treat the element as "nodoc". - bool? configSetsNodocFor(String fullName) { - if (!_configSetsNodocFor.containsKey(fullName)) { + bool configSetsNodocFor(String fullName) { + var noDocForName = _configSetsNodocFor[fullName]; + if (noDocForName == null) { var file = resourceProvider.getFile(fullName); // Direct lookup instead of generating a custom context will save some // cycles. We can't use the element's [DartdocOptionContext] because that @@ -964,14 +923,18 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { // for nodoc's semantics. Looking up the defining element just to pull // a context is again, slow. List globs = config.optionSet['nodoc'].valueAt(file.parent2); - _configSetsNodocFor[fullName] = utils.matchGlobs(globs, fullName); + noDocForName = utils.matchGlobs(globs, fullName); + _configSetsNodocFor[fullName] = noDocForName; } - return _configSetsNodocFor[fullName]; + return noDocForName; } String? getMacro(String? name) { assert(_localDocumentationBuilt); - return _macros[name!]; + if (name == null) { + return null; + } + return _macros[name]; } void addMacro(String name, String content) { @@ -985,7 +948,10 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { String? getHtmlFragment(String? name) { assert(_localDocumentationBuilt); - return _htmlFragments[name!]; + if (name == null) { + return null; + } + return _htmlFragments[name]; } void addHtmlFragment(String name, String content) { @@ -997,46 +963,44 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder { _htmlFragments[name] = content; } - Map? _referenceChildren; @override - Map 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!; - } + late final Map referenceChildren = () { + var children = {}; + // 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. + 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.publicConstants, + ...l.publicFunctions, + ...l.publicProperties, + ...l.publicTypedefs, + ...l.publicExtensions, + ...l.publicClasses, + ...l.publicEnums, + ...l.publicMixins + ]) + .generateEntries()); + + return children; + }(); @override Iterable get referenceParents => [];