From abee4410a93b7e48850d36818b535d72d2522479 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 30 Dec 2024 14:00:04 -0800 Subject: [PATCH] More cleanup from removal of SpecialClasses --- lib/src/model/package_builder.dart | 69 +++++++++++++----------------- lib/src/model/package_graph.dart | 1 - 2 files changed, 29 insertions(+), 41 deletions(-) diff --git a/lib/src/model/package_builder.dart b/lib/src/model/package_builder.dart index 6cdf05fbea..a536c8ce26 100644 --- a/lib/src/model/package_builder.dart +++ b/lib/src/model/package_builder.dart @@ -226,11 +226,9 @@ class PubPackageBuilder implements PackageBuilder { /// [addingSpecials] indicates that only [SpecialClass]es are being resolved /// in this round. Future _discoverLibraries( - void Function(DartDocResolvedLibrary) addLibrary, - Set processedLibraries, - Set files, { - bool addingSpecials = false, - }) async { + void Function(DartDocResolvedLibrary) addLibrary, + Set processedLibraries, + Set files) async { files = {...files}; // Discover Dart libraries in a loop. In each iteration of the loop, we take // a set of files (starting with the ones passed into the function), resolve @@ -251,17 +249,15 @@ class PubPackageBuilder implements PackageBuilder { // find all documentable files in that package, for the universal reference // scope. This variable tracks which packages we've seen so far. var knownPackages = {}; - if (!addingSpecials) { - progressBarStart(files.length); - } + progressBarStart(files.length); + // The set of files that are discovered while iterating in the below // do-while loop, which are then added to `files`, as they are found. var newFiles = {}; do { filesInLastPass = filesInCurrentPass; - if (!addingSpecials) { - progressBarUpdateTickCount(files.length); - } + progressBarUpdateTickCount(files.length); + // Be careful here, not to accidentally stack up multiple // [DartDocResolvedLibrary]s, as those eat our heap. var libraryFiles = files.difference(_knownParts); @@ -271,9 +267,8 @@ class PubPackageBuilder implements PackageBuilder { continue; } processedFiles.add(file); - if (!addingSpecials) { - progressBarTick(); - } + progressBarTick(); + var resolvedLibrary = await _resolveLibrary(file); if (resolvedLibrary == null) { // `file` did not resolve to a _library_; could be a part, an @@ -292,41 +287,35 @@ class PubPackageBuilder implements PackageBuilder { processedLibraries.add(resolvedLibrary.element); } files.addAll(newFiles); - if (!addingSpecials) { - var externals = _includedExternalsFrom(newFiles); - if (externals.isNotEmpty) { - includeExternalsWasSpecified = true; - } - files.addAll(externals); + var externals = _includedExternalsFrom(newFiles); + if (externals.isNotEmpty) { + includeExternalsWasSpecified = true; } + files.addAll(externals); var packages = _packageMetasForFiles(files.difference(_knownParts)); filesInCurrentPass = {...files.difference(_knownParts)}; - if (!addingSpecials) { - // To get canonicalization correct for non-locally documented packages - // (so we can generate the right hyperlinks), it's vital that we add all - // libraries in dependent packages. So if the analyzer discovers some - // files in a package we haven't seen yet, add files for that package. - for (var meta in packages.difference(knownPackages)) { - if (meta.isSdk) { - if (!_skipUnreachableSdkLibraries) { - files.addAll(_sdkFilesToDocument); - } - } else { - files.addAll(await _findFilesToDocumentInPackage( - meta.dir.path, - includeDependencies: false, - filterExcludes: false, - ).toList()); + // To get canonicalization correct for non-locally documented packages + // (so we can generate the right hyperlinks), it's vital that we add all + // libraries in dependent packages. So if the analyzer discovers some + // files in a package we haven't seen yet, add files for that package. + for (var meta in packages.difference(knownPackages)) { + if (meta.isSdk) { + if (!_skipUnreachableSdkLibraries) { + files.addAll(_sdkFilesToDocument); } + } else { + files.addAll(await _findFilesToDocumentInPackage( + meta.dir.path, + includeDependencies: false, + filterExcludes: false, + ).toList()); } - knownPackages.addAll(packages); } + knownPackages.addAll(packages); } while (!filesInLastPass.containsAll(filesInCurrentPass)); - if (!addingSpecials) { - progressBarComplete(); - } + progressBarComplete(); } /// Returns all top level library files in the 'lib/' directory of the given diff --git a/lib/src/model/package_graph.dart b/lib/src/model/package_graph.dart index 63a50dd3de..f86ce3f155 100644 --- a/lib/src/model/package_graph.dart +++ b/lib/src/model/package_graph.dart @@ -204,7 +204,6 @@ class PackageGraph with CommentReferable, Nameable { final Map _modelNodes = {}; /// The Object class declared in the Dart SDK's 'dart:core' library. - // TODO(srawlins): I think nothing depends on this any longer; remove. late InheritingContainer objectClass; /// Populate's [_modelNodes] with elements in [resolvedLibrary].