From 52cd3a0f5e84f35bfd555cf2338af85412ea234b Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Sat, 6 Jul 2024 20:48:24 -0700 Subject: [PATCH] Use the existing AnalysisContext in PackageBuilder --- lib/src/model/package_builder.dart | 3 +-- lib/src/model/package_graph.dart | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/src/model/package_builder.dart b/lib/src/model/package_builder.dart index 23921debae..75d34e52f1 100644 --- a/lib/src/model/package_builder.dart +++ b/lib/src/model/package_builder.dart @@ -190,10 +190,9 @@ class PubPackageBuilder implements PackageBuilder { Future _resolveLibrary(String filePath) async { logDebug('Resolving $filePath...'); - var analysisContext = _contextCollection.contextFor(_config.inputDir); // Allow dart source files with inappropriate suffixes (#1897). final library = - await analysisContext.currentSession.getResolvedLibrary(filePath); + await _analysisContext.currentSession.getResolvedLibrary(filePath); if (library is ResolvedLibraryResult) { return DartDocResolvedLibrary(library); } diff --git a/lib/src/model/package_graph.dart b/lib/src/model/package_graph.dart index 0ea5d982bc..2107255d19 100644 --- a/lib/src/model/package_graph.dart +++ b/lib/src/model/package_graph.dart @@ -43,7 +43,7 @@ class PackageGraph with CommentReferable, Nameable { final InheritanceManager3 inheritanceManager = InheritanceManager3(); - final AnalysisContext analysisContext; + final AnalysisContext _analysisContext; /// PackageMeta for the default package. final PackageMeta packageMeta; @@ -55,7 +55,7 @@ class PackageGraph with CommentReferable, Nameable { DartSdk sdk, this.hasEmbedderSdk, this.packageMetaProvider, - this.analysisContext, + this._analysisContext, ) : packageMeta = config.topLevelPackageMeta, sdkLibrarySources = { for (var lib in sdk.sdkLibraries) sdk.mapDartUri(lib.shortName): lib @@ -244,7 +244,7 @@ class PackageGraph with CommentReferable, Nameable { () => ModelNode( directive, resolvedLibrary.element, - analysisContext, + _analysisContext, commentData: commentData, )); } @@ -299,7 +299,7 @@ class PackageGraph with CommentReferable, Nameable { () => ModelNode( declaration, element, - analysisContext, + _analysisContext, commentData: commentData, ), );