@@ -99,16 +99,23 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
9999 void addSpecialLibraryToGraph (DartDocResolvedLibrary resolvedLibrary) {
100100 allLibrariesAdded = true ;
101101 assert (! _localDocumentationBuilt);
102- findOrCreateLibraryFor (resolvedLibrary);
102+ final libraryElement = resolvedLibrary.element.library;
103+ allLibraries.putIfAbsent (
104+ libraryElement.source.fullName,
105+ () => Library .fromLibraryResult (
106+ resolvedLibrary,
107+ this ,
108+ Package .fromPackageMeta (
109+ packageMetaProvider.fromElement (libraryElement, config.sdkDir)! ,
110+ packageGraph),
111+ ),
112+ );
103113 }
104114
105115 /// Call after all libraries are added.
106116 Future <void > initializePackageGraph () async {
107117 assert (! _localDocumentationBuilt);
108118 allLibrariesAdded = true ;
109- // From here on in, we might find special objects. Initialize the
110- // specialClasses handler so when we find them, they get added.
111- specialClasses = SpecialClasses ();
112119 // Go through docs of every ModelElement in package to pre-build the macros
113120 // index.
114121 await Future .wait (_precacheLocalDocs ());
@@ -137,9 +144,10 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
137144 }
138145
139146 /// Generate a list of futures for any docs that actually require precaching.
140- Iterable <Future <void >> _precacheLocalDocs () sync * {
147+ Iterable <Future <void >> _precacheLocalDocs () {
141148 // Prevent reentrancy.
142149 var precachedElements = < ModelElement > {};
150+ var futures = < Future <void >> [];
143151
144152 for (var element in _allModelElements) {
145153 // Only precache elements which are canonical, have a canonical element
@@ -153,22 +161,23 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
153161 .where ((d) => d.hasDocumentationComment)) {
154162 if (d.needsPrecache && ! precachedElements.contains (d)) {
155163 precachedElements.add (d as ModelElement );
156- yield d.precacheLocalDocs ();
164+ futures. add ( d.precacheLocalDocs () );
157165 logProgress (d.name);
158166 // [TopLevelVariable]s get their documentation from getters and
159167 // setters, so should be precached if either has a template.
160168 if (element is TopLevelVariable &&
161169 ! precachedElements.contains (element)) {
162170 precachedElements.add (element);
163- yield element.precacheLocalDocs ();
171+ futures. add ( element.precacheLocalDocs () );
164172 logProgress (d.name);
165173 }
166174 }
167175 }
168176 }
169177 }
170178 // Now wait for any of the tasks still running to complete.
171- yield config.tools.runner.wait ();
179+ futures.add (config.tools.runner.wait ());
180+ return futures;
172181 }
173182
174183 /// Initializes the category mappings in all [packages] .
@@ -178,10 +187,13 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
178187 }
179188 }
180189
181- // Many ModelElements have the same ModelNode; don't build/cache this data more
182- // than once for them.
190+ // Many ModelElements have the same ModelNode; don't build/cache this data
191+ // more than once for them.
183192 final Map <Element , ModelNode > _modelNodes = {};
184193
194+ /// The collection of "special" classes for which we need some special access.
195+ final specialClasses = SpecialClasses ();
196+
185197 /// Populate's [_modelNodes] with elements in [resolvedLibrary] .
186198 ///
187199 /// This is done as [Library] model objects are created, while we are holding
@@ -253,8 +265,6 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
253265
254266 ModelNode ? getModelNodeFor (Element element) => _modelNodes[element];
255267
256- late SpecialClasses specialClasses;
257-
258268 /// It is safe to cache values derived from the [_implementors] table if this
259269 /// is true.
260270 bool allImplementorsAdded = false ;
@@ -639,8 +649,7 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
639649 ? .linkedName ??
640650 'Object' ;
641651
642- /// Return the set of [Class] es which objects should inherit through if they
643- /// show up in the inheritance chain.
652+ /// The set of [Class] es which should _not_ be presented as implementors.
644653 ///
645654 /// Add classes here if they are similar to Interceptor in that they are to be
646655 /// ignored even when they are the implementors of [Inheritable] s, and the
@@ -856,24 +865,6 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
856865 return allLibraries[e.library? .source.fullName];
857866 }
858867
859- /// This is used when we might need a [Library] that isn't actually a
860- /// documentation entry point (for elements that have no [Library] within the
861- /// set of canonical libraries).
862- Library findOrCreateLibraryFor (DartDocResolvedLibrary resolvedLibrary) {
863- final libraryElement = resolvedLibrary.element.library;
864- var foundLibrary = findButDoNotCreateLibraryFor (libraryElement);
865- if (foundLibrary != null ) return foundLibrary;
866-
867- foundLibrary = Library .fromLibraryResult (
868- resolvedLibrary,
869- this ,
870- Package .fromPackageMeta (
871- packageMetaProvider.fromElement (libraryElement, config.sdkDir)! ,
872- packageGraph));
873- allLibraries[libraryElement.source.fullName] = foundLibrary;
874- return foundLibrary;
875- }
876-
877868 late final Iterable <ModelElement > _allModelElements = () {
878869 assert (allLibrariesAdded);
879870 var allElements = < ModelElement > [];
0 commit comments