@@ -193,7 +193,7 @@ class PubPackageBuilder implements PackageBuilder {
193
193
/// If [filePath] is not a library, returns null.
194
194
Future <DartDocResolvedLibrary > processLibrary (String filePath) async {
195
195
var name = filePath;
196
- var directoryCurrentPath = config. resourceProvider.pathContext.current;
196
+ var directoryCurrentPath = resourceProvider.pathContext.current;
197
197
198
198
if (name.startsWith (directoryCurrentPath)) {
199
199
name = name.substring (directoryCurrentPath.length);
@@ -235,20 +235,15 @@ class PubPackageBuilder implements PackageBuilder {
235
235
return null ;
236
236
}
237
237
238
- Set <PackageMeta > _packageMetasForFiles (Iterable <String > files) {
239
- var metas = < PackageMeta > {};
240
- for (var filename in files) {
241
- metas.add (packageMetaProvider.fromFilename (filename));
242
- }
243
- return metas;
244
- }
238
+ Set <PackageMeta > _packageMetasForFiles (Iterable <String > files) => {
239
+ for (var filename in files) packageMetaProvider.fromFilename (filename),
240
+ };
245
241
246
- /// Parse libraries with the analyzer and invoke a callback with the
242
+ /// Parses libraries with the analyzer and invokes [libraryAdder] with each
247
243
/// result.
248
244
///
249
- /// Uses the [libraries] parameter to prevent calling
250
- /// the callback more than once with the same [LibraryElement] .
251
- /// Adds [LibraryElement] s found to that parameter.
245
+ /// Uses [libraries] to prevent calling the callback more than once with the
246
+ /// same [LibraryElement] . Adds each [LibraryElement] found to [libraries] .
252
247
Future <void > _parseLibraries (
253
248
void Function (DartDocResolvedLibrary ) libraryAdder,
254
249
Set <LibraryElement > libraries,
@@ -257,17 +252,20 @@ class PubPackageBuilder implements PackageBuilder {
257
252
isLibraryIncluded ?? = (_) => true ;
258
253
var lastPass = < PackageMeta > {};
259
254
Set <PackageMeta > current;
255
+ var knownParts = < String > {};
260
256
do {
261
257
lastPass = _packageMetasForFiles (files);
262
258
263
259
// Be careful here not to accidentally stack up multiple
264
- // DartDocResolvedLibrarys , as those eat our heap.
265
- for (var f in files) {
260
+ // [DartDocResolvedLibrary]s , as those eat our heap.
261
+ for (var f in files. difference (knownParts) ) {
266
262
logProgress (f);
267
263
var r = await processLibrary (f);
268
- if (r != null &&
269
- ! libraries.contains (r.element) &&
270
- isLibraryIncluded (r.element)) {
264
+ if (r == null ) {
265
+ knownParts.add (f);
266
+ continue ;
267
+ }
268
+ if (! libraries.contains (r.element) && isLibraryIncluded (r.element)) {
271
269
logDebug ('parsing ${f }...' );
272
270
libraryAdder (r);
273
271
libraries.add (r.element);
@@ -278,7 +276,7 @@ class PubPackageBuilder implements PackageBuilder {
278
276
await driver.discoverAvailableFiles ();
279
277
files.addAll (driver.knownFiles);
280
278
files.addAll (_includeExternalsFrom (driver.knownFiles));
281
- current = _packageMetasForFiles (files);
279
+ current = _packageMetasForFiles (files. difference (knownParts) );
282
280
// To get canonicalization correct for non-locally documented packages
283
281
// (so we can generate the right hyperlinks), it's vital that we
284
282
// add all libraries in dependent packages. So if the analyzer
0 commit comments