From e93d62cfbfd49db734fb6e3ead651dc4c1e31f85 Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Mon, 30 May 2022 16:16:02 +0000 Subject: [PATCH] Store InSummarySource in ExternalLibrary instead of Uri. Change-Id: I83ee145f816acde2588d28053053d7ea0b31a523 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246421 Reviewed-by: Brian Wilkerson Commit-Queue: Konstantin Shcheglov --- .../lib/src/dart/analysis/driver.dart | 5 ++-- .../lib/src/dart/analysis/file_state.dart | 26 +++++-------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart index 2cf4ffde5e3..17a79a5a822 100644 --- a/pkg/analyzer/lib/src/dart/analysis/driver.dart +++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart @@ -761,7 +761,9 @@ class AnalysisDriver implements AnalysisDriverGeneric { return UnspecifiedInvalidResult(); }, (externalLibrary) async { - var element = libraryContext.getLibraryElement(externalLibrary.uri); + final uri = externalLibrary.source.uri; + // TODO(scheglov) Check if the source is not for library. + var element = libraryContext.getLibraryElement(uri); return LibraryElementResultImpl(element); }, ); @@ -1528,7 +1530,6 @@ class AnalysisDriver implements AnalysisDriverGeneric { _saltForUnlinked, _saltForElements, featureSetProvider, - externalSummaries: _externalSummaries, fileContentCache: _fileContentCache, ); _fileTracker = FileTracker(_logger, _fsState); diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart index a14226d6afe..a6763f82876 100644 --- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart +++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart @@ -87,9 +87,9 @@ class AugmentationUnknownFileStateKind extends AugmentationFileStateKind { /// A library from [SummaryDataStore]. class ExternalLibrary { - final Uri uri; + final InSummarySource source; - ExternalLibrary._(this.uri); + ExternalLibrary._(this.source); } /// [FileContentOverlay] is used to temporary override content of files. @@ -902,15 +902,6 @@ class FileSystemState { final FeatureSetProvider featureSetProvider; - /// The optional store with externally provided unlinked and corresponding - /// linked summaries. These summaries are always added to the store for any - /// file analysis. - /// - /// While walking the file graph, when we reach a file that exists in the - /// external store, we add a stub [FileState], but don't attempt to read its - /// content, or its unlinked unit, or imported libraries, etc. - final SummaryDataStore? externalSummaries; - /// Mapping from a URI to the corresponding [FileState]. final Map _uriToFile = {}; @@ -954,7 +945,6 @@ class FileSystemState { this._saltForUnlinked, this._saltForElements, this.featureSetProvider, { - this.externalSummaries, required FileContentCache fileContentCache, }) : _fileContentCache = fileContentCache { _testView = FileSystemStateTestView(this); @@ -1041,20 +1031,16 @@ class FileSystemState { /// without a package name), or we don't know this package. The returned /// file has the last known state since if was last refreshed. Either2 getFileForUri(Uri uri) { + final uriSource = _sourceFactory.forUri2(uri); + // If the external store has this URI, create a stub file for it. // We are given all required unlinked and linked summaries for it. - final externalSummaries = this.externalSummaries; - if (externalSummaries != null) { - String uriStr = uri.toString(); - if (externalSummaries.uriToSummaryPath.containsKey(uriStr)) { - return Either2.t2(ExternalLibrary._(uri)); - } + if (uriSource is InSummarySource) { + return Either2.t2(ExternalLibrary._(uriSource)); } FileState? file = _uriToFile[uri]; if (file == null) { - Source? uriSource = _sourceFactory.forUri2(uri); - // If the URI cannot be resolved, for example because the factory // does not understand the scheme, return the unresolved file instance. if (uriSource == null) {