@@ -99,16 +99,23 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
99
99
void addSpecialLibraryToGraph (DartDocResolvedLibrary resolvedLibrary) {
100
100
allLibrariesAdded = true ;
101
101
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
+ );
103
113
}
104
114
105
115
/// Call after all libraries are added.
106
116
Future <void > initializePackageGraph () async {
107
117
assert (! _localDocumentationBuilt);
108
118
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 ();
112
119
// Go through docs of every ModelElement in package to pre-build the macros
113
120
// index.
114
121
await Future .wait (_precacheLocalDocs ());
@@ -137,9 +144,10 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
137
144
}
138
145
139
146
/// Generate a list of futures for any docs that actually require precaching.
140
- Iterable <Future <void >> _precacheLocalDocs () sync * {
147
+ Iterable <Future <void >> _precacheLocalDocs () {
141
148
// Prevent reentrancy.
142
149
var precachedElements = < ModelElement > {};
150
+ var futures = < Future <void >> [];
143
151
144
152
for (var element in _allModelElements) {
145
153
// Only precache elements which are canonical, have a canonical element
@@ -153,22 +161,23 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
153
161
.where ((d) => d.hasDocumentationComment)) {
154
162
if (d.needsPrecache && ! precachedElements.contains (d)) {
155
163
precachedElements.add (d as ModelElement );
156
- yield d.precacheLocalDocs ();
164
+ futures. add ( d.precacheLocalDocs () );
157
165
logProgress (d.name);
158
166
// [TopLevelVariable]s get their documentation from getters and
159
167
// setters, so should be precached if either has a template.
160
168
if (element is TopLevelVariable &&
161
169
! precachedElements.contains (element)) {
162
170
precachedElements.add (element);
163
- yield element.precacheLocalDocs ();
171
+ futures. add ( element.precacheLocalDocs () );
164
172
logProgress (d.name);
165
173
}
166
174
}
167
175
}
168
176
}
169
177
}
170
178
// 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;
172
181
}
173
182
174
183
/// Initializes the category mappings in all [packages] .
@@ -178,10 +187,13 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
178
187
}
179
188
}
180
189
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.
183
192
final Map <Element , ModelNode > _modelNodes = {};
184
193
194
+ /// The collection of "special" classes for which we need some special access.
195
+ final specialClasses = SpecialClasses ();
196
+
185
197
/// Populate's [_modelNodes] with elements in [resolvedLibrary] .
186
198
///
187
199
/// This is done as [Library] model objects are created, while we are holding
@@ -253,8 +265,6 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
253
265
254
266
ModelNode ? getModelNodeFor (Element element) => _modelNodes[element];
255
267
256
- late SpecialClasses specialClasses;
257
-
258
268
/// It is safe to cache values derived from the [_implementors] table if this
259
269
/// is true.
260
270
bool allImplementorsAdded = false ;
@@ -639,8 +649,7 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
639
649
? .linkedName ??
640
650
'Object' ;
641
651
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.
644
653
///
645
654
/// Add classes here if they are similar to Interceptor in that they are to be
646
655
/// ignored even when they are the implementors of [Inheritable] s, and the
@@ -856,24 +865,6 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
856
865
return allLibraries[e.library? .source.fullName];
857
866
}
858
867
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
-
877
868
late final Iterable <ModelElement > _allModelElements = () {
878
869
assert (allLibrariesAdded);
879
870
var allElements = < ModelElement > [];
0 commit comments