From 43b930673ec059ed21c53cd2deef7916ea41fdcc Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Fri, 20 Mar 2026 13:52:02 -0700 Subject: [PATCH] analyzer: Use Workspace.partialSourceFactory in more places For better caching. Change-Id: Ia5c9df85169731ae256dfe68cfe54115a9b402f3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489540 Reviewed-by: Konstantin Shcheglov Commit-Queue: Konstantin Shcheglov Auto-Submit: Samuel Rawlins --- pkg/analyzer/lib/src/dart/analysis/context_builder.dart | 3 +-- pkg/analyzer/lib/src/dart/analysis/context_locator.dart | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart index 6bda1ac70c5..ba3dd42f461 100644 --- a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart +++ b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart @@ -247,8 +247,7 @@ class ContextBuilderImpl { ); { - // TODO(scheglov): We already had partial SourceFactory in ContextLocatorImpl. - var partialSourceFactory = workspace.createSourceFactory(null, null); + var partialSourceFactory = workspace.partialSourceFactory; var embedderYamlSource = partialSourceFactory.forUri( 'package:sky_engine/_embedder.yaml', ); diff --git a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart index d0ceea0d09f..d19089a3a59 100644 --- a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart +++ b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart @@ -242,7 +242,9 @@ class _ContextLocator { required _RootLocation location, }) { if (location.workspace is WorkspaceWithDefaultAnalysisOptions) { - optionsFile ??= _findDefaultOptionsFile(location.sourceFactory); + optionsFile ??= _findDefaultOptionsFile( + location.workspace.partialSourceFactory, + ); } var root = ContextRootImpl( @@ -257,7 +259,7 @@ class _ContextLocator { } root.excludedGlobs.addAll( - _getExcludedGlobs(optionsFile, location.sourceFactory), + _getExcludedGlobs(optionsFile, location.workspace.partialSourceFactory), ); roots.add(root); return root; @@ -918,9 +920,6 @@ class _RootLocation { final File? optionsFile; final File? packageConfigFile; - /// A single source factory for [workspace]. - late final sourceFactory = workspace.createSourceFactory(null, null); - _RootLocation({ required this.rootFolder, required this.workspace,