@@ -193,7 +193,7 @@ class PubPackageBuilder implements PackageBuilder {
193193 /// If [filePath] is not a library, returns null.
194194 Future <DartDocResolvedLibrary > processLibrary (String filePath) async {
195195 var name = filePath;
196- var directoryCurrentPath = config. resourceProvider.pathContext.current;
196+ var directoryCurrentPath = resourceProvider.pathContext.current;
197197
198198 if (name.startsWith (directoryCurrentPath)) {
199199 name = name.substring (directoryCurrentPath.length);
@@ -235,20 +235,15 @@ class PubPackageBuilder implements PackageBuilder {
235235 return null ;
236236 }
237237
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+ };
245241
246- /// Parse libraries with the analyzer and invoke a callback with the
242+ /// Parses libraries with the analyzer and invokes [libraryAdder] with each
247243 /// result.
248244 ///
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] .
252247 Future <void > _parseLibraries (
253248 void Function (DartDocResolvedLibrary ) libraryAdder,
254249 Set <LibraryElement > libraries,
@@ -257,17 +252,20 @@ class PubPackageBuilder implements PackageBuilder {
257252 isLibraryIncluded ?? = (_) => true ;
258253 var lastPass = < PackageMeta > {};
259254 Set <PackageMeta > current;
255+ var knownParts = < String > {};
260256 do {
261257 lastPass = _packageMetasForFiles (files);
262258
263259 // 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) ) {
266262 logProgress (f);
267263 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)) {
271269 logDebug ('parsing ${f }...' );
272270 libraryAdder (r);
273271 libraries.add (r.element);
@@ -278,7 +276,7 @@ class PubPackageBuilder implements PackageBuilder {
278276 await driver.discoverAvailableFiles ();
279277 files.addAll (driver.knownFiles);
280278 files.addAll (_includeExternalsFrom (driver.knownFiles));
281- current = _packageMetasForFiles (files);
279+ current = _packageMetasForFiles (files. difference (knownParts) );
282280 // To get canonicalization correct for non-locally documented packages
283281 // (so we can generate the right hyperlinks), it's vital that we
284282 // add all libraries in dependent packages. So if the analyzer
0 commit comments