Rename Bazel to Blaze - files, classes, methods.
No changes to implementation yet, we still look for both Blaze and Bazel.
Bug: https://github.com/dart-lang/sdk/issues/49629
Change-Id: Iaf1b1cc2c9a8cf28d8bbfb5541819a1f5c8a3de6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254343
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index 4225e8c..00746d6 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -27,8 +27,8 @@
import 'package:analyzer/src/pubspec/pubspec_validator.dart';
import 'package:analyzer/src/task/options.dart';
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
-import 'package:analyzer/src/workspace/bazel.dart';
-import 'package:analyzer/src/workspace/bazel_watcher.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
+import 'package:analyzer/src/workspace/blaze_watcher.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart' as protocol;
import 'package:analyzer_plugin/utilities/analyzer_converter.dart';
import 'package:path/path.dart' as path;
@@ -43,7 +43,7 @@
/// Not private to enable testing.
/// NB: If you set this to `false` remember to disable the
/// `test/integration/serve/bazel_changes_test.dart`.
-var experimentalEnableBazelWatching = true;
+var experimentalEnableBlazeWatching = true;
/// Class that maintains a mapping from included/excluded paths to a set of
/// folders that should correspond to analysis contexts.
@@ -195,23 +195,23 @@
/// For each folder, stores the subscription to the Bazel workspace so that we
/// can establish watches for the generated files.
- final bazelSearchSubscriptions =
- <Folder, StreamSubscription<BazelSearchInfo>>{};
+ final blazeSearchSubscriptions =
+ <Folder, StreamSubscription<BlazeSearchInfo>>{};
/// The watcher service running in a separate isolate to watch for changes
/// to files generated by Bazel.
///
/// Might be `null` if watching Bazel files is not enabled.
- BazelFileWatcherService? bazelWatcherService;
+ BlazeFileWatcherService? blazeWatcherService;
- /// The subscription to changes in the files watched by [bazelWatcherService].
+ /// The subscription to changes in the files watched by [blazeWatcherService].
///
/// Might be `null` if watching Bazel files is not enabled.
- StreamSubscription<List<WatchEvent>>? bazelWatcherSubscription;
+ StreamSubscription<List<WatchEvent>>? blazeWatcherSubscription;
/// For each [Folder] store which files are being watched. This allows us to
/// clean up when we destroy a context.
- final bazelWatchedPathsPerFolder = <Folder, _BazelWatchedFiles>{};
+ final blazeWatchedPathsPerFolder = <Folder, _BlazeWatchedFiles>{};
/// Experiments which have been enabled (or disabled) via the
/// `--enable-experiment` command-line option.
@@ -236,9 +236,9 @@
{required bool enableBazelWatcher})
: pathContext = resourceProvider.pathContext {
if (enableBazelWatcher) {
- bazelWatcherService = BazelFileWatcherService(_instrumentationService);
- bazelWatcherSubscription = bazelWatcherService!.events
- .listen((events) => _handleBazelWatchEvents(events));
+ blazeWatcherService = BlazeFileWatcherService(_instrumentationService);
+ blazeWatcherSubscription = blazeWatcherService!.events
+ .listen((events) => _handleBlazeWatchEvents(events));
}
}
@@ -505,7 +505,7 @@
);
}
- _watchBazelFilesIfNeeded(rootFolder, driver);
+ _watchBlazeFilesIfNeeded(rootFolder, driver);
for (var file in analysisContext.contextRoot.analyzedFiles()) {
if (file_paths.isAndroidManifestXml(pathContext, file)) {
@@ -625,14 +625,14 @@
/// Clean up and destroy the context associated with the given folder.
void _destroyAnalysisContext(DriverBasedAnalysisContext context) {
var rootFolder = context.contextRoot.root;
- var watched = bazelWatchedPathsPerFolder.remove(rootFolder);
+ var watched = blazeWatchedPathsPerFolder.remove(rootFolder);
if (watched != null) {
for (var path in watched.paths) {
- bazelWatcherService!.stopWatching(watched.workspace, path);
+ blazeWatcherService!.stopWatching(watched.workspace, path);
}
- _stopWatchingBazelBinPaths(watched);
+ _stopWatchingBlazeBinPaths(watched);
}
- bazelSearchSubscriptions.remove(rootFolder)?.cancel();
+ blazeSearchSubscriptions.remove(rootFolder)?.cancel();
driverMap.remove(rootFolder);
}
@@ -650,7 +650,7 @@
}
}
- List<String> _getPossibleBazelBinPaths(_BazelWatchedFiles watched) => [
+ List<String> _getPossibleBlazeBinPaths(_BlazeWatchedFiles watched) => [
pathContext.join(watched.workspace, 'bazel-bin'),
pathContext.join(watched.workspace, 'blaze-bin'),
];
@@ -660,26 +660,26 @@
///
/// Whenever the files change, we trigger re-analysis. This allows us to react
/// to creation/modification of files that were generated by Bazel.
- void _handleBazelSearchInfo(
- Folder folder, String workspace, BazelSearchInfo info) {
- final bazelWatcherService = this.bazelWatcherService;
- if (bazelWatcherService == null) {
+ void _handleBlazeSearchInfo(
+ Folder folder, String workspace, BlazeSearchInfo info) {
+ final blazeWatcherService = this.blazeWatcherService;
+ if (blazeWatcherService == null) {
return;
}
- var watched = bazelWatchedPathsPerFolder.putIfAbsent(
- folder, () => _BazelWatchedFiles(workspace));
+ var watched = blazeWatchedPathsPerFolder.putIfAbsent(
+ folder, () => _BlazeWatchedFiles(workspace));
var added = watched.paths.add(info.requestedPath);
- if (added) bazelWatcherService.startWatching(workspace, info);
+ if (added) blazeWatcherService.startWatching(workspace, info);
}
/// Notifies the drivers that a generated Bazel file has changed.
- void _handleBazelWatchEvents(List<WatchEvent> events) {
+ void _handleBlazeWatchEvents(List<WatchEvent> events) {
// First check if we have any changes to the bazel-*/blaze-* paths. If
// we do, we'll simply recreate all contexts to make sure that we follow the
// correct paths.
- var bazelSymlinkPaths = bazelWatchedPathsPerFolder.values
- .expand((watched) => _getPossibleBazelBinPaths(watched))
+ var bazelSymlinkPaths = blazeWatchedPathsPerFolder.values
+ .expand((watched) => _getPossibleBlazeBinPaths(watched))
.toSet();
if (events.any((event) => bazelSymlinkPaths.contains(event.path))) {
refresh();
@@ -722,7 +722,7 @@
final isPubspec = file_paths.isPubspecYaml(pathContext, path);
if (file_paths.isAnalysisOptionsYaml(pathContext, path) ||
- file_paths.isBazelBuild(pathContext, path) ||
+ file_paths.isBlazeBuild(pathContext, path) ||
file_paths.isPackageConfigJson(pathContext, path) ||
isPubspec ||
false) {
@@ -813,19 +813,19 @@
/// server starts up, in which case `BazelWorkspace` assumes by default the
/// Bazel ones. So we want to detect if the symlinks get created to reset
/// everything and repeat the search for the folders.
- void _startWatchingBazelBinPaths(_BazelWatchedFiles watched) {
- var watcherService = bazelWatcherService;
+ void _startWatchingBlazeBinPaths(_BlazeWatchedFiles watched) {
+ var watcherService = blazeWatcherService;
if (watcherService == null) return;
- var paths = _getPossibleBazelBinPaths(watched);
+ var paths = _getPossibleBlazeBinPaths(watched);
watcherService.startWatching(
- watched.workspace, BazelSearchInfo(paths[0], paths));
+ watched.workspace, BlazeSearchInfo(paths[0], paths));
}
/// Stops watching for the `bazel-bin` and `blaze-bin` symlinks.
- void _stopWatchingBazelBinPaths(_BazelWatchedFiles watched) {
- var watcherService = bazelWatcherService;
+ void _stopWatchingBlazeBinPaths(_BlazeWatchedFiles watched) {
+ var watcherService = blazeWatcherService;
if (watcherService == null) return;
- var paths = _getPossibleBazelBinPaths(watched);
+ var paths = _getPossibleBlazeBinPaths(watched);
watcherService.stopWatching(watched.workspace, paths[0]);
}
@@ -835,21 +835,21 @@
/// folder, but we still want to watch for changes to them.
///
/// Does nothing if the [driver] is not in a Bazel workspace.
- void _watchBazelFilesIfNeeded(Folder folder, AnalysisDriver analysisDriver) {
- if (!experimentalEnableBazelWatching) return;
- var watcherService = bazelWatcherService;
+ void _watchBlazeFilesIfNeeded(Folder folder, AnalysisDriver analysisDriver) {
+ if (!experimentalEnableBlazeWatching) return;
+ var watcherService = blazeWatcherService;
if (watcherService == null) return;
var workspace = analysisDriver.analysisContext?.contextRoot.workspace;
- if (workspace is BazelWorkspace &&
- !bazelSearchSubscriptions.containsKey(folder)) {
- bazelSearchSubscriptions[folder] = workspace.bazelCandidateFiles.listen(
+ if (workspace is BlazeWorkspace &&
+ !blazeSearchSubscriptions.containsKey(folder)) {
+ blazeSearchSubscriptions[folder] = workspace.blazeCandidateFiles.listen(
(notification) =>
- _handleBazelSearchInfo(folder, workspace.root, notification));
+ _handleBlazeSearchInfo(folder, workspace.root, notification));
- var watched = _BazelWatchedFiles(workspace.root);
- bazelWatchedPathsPerFolder[folder] = watched;
- _startWatchingBazelBinPaths(watched);
+ var watched = _BlazeWatchedFiles(workspace.root);
+ blazeWatchedPathsPerFolder[folder] = watched;
+ _startWatchingBlazeBinPaths(watched);
}
}
}
@@ -883,10 +883,10 @@
void recordAnalysisErrors(String path, List<protocol.AnalysisError> errors) {}
}
-class _BazelWatchedFiles {
+class _BlazeWatchedFiles {
final String workspace;
final paths = <String>{};
- _BazelWatchedFiles(this.workspace);
+ _BlazeWatchedFiles(this.workspace);
}
/// Handles a task queue of tasks that cannot run concurrently.
diff --git a/pkg/analysis_server/lib/src/plugin/plugin_manager.dart b/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
index df45853..d16b8e9 100644
--- a/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
+++ b/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
@@ -18,7 +18,7 @@
import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:analyzer/src/util/glob.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
import 'package:analyzer/src/workspace/gn.dart';
import 'package:analyzer/src/workspace/workspace.dart';
import 'package:analyzer_plugin/channel/channel.dart';
@@ -438,7 +438,7 @@
// because we won't be running pub.
return _computeFiles(pluginFolder);
}
- var workspace = BazelWorkspace.find(resourceProvider, pluginFolder.path) ??
+ var workspace = BlazeWorkspace.find(resourceProvider, pluginFolder.path) ??
GnWorkspace.find(resourceProvider, pluginFolder.path);
if (workspace != null) {
// Similarly, we won't be running pub if we're in a workspace because
diff --git a/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart b/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
index 26c3a06..3e84510 100644
--- a/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
+++ b/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
@@ -14,7 +14,7 @@
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
import 'package:analyzer/src/workspace/gn.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart'
show KytheEntry, KytheVName;
@@ -85,7 +85,7 @@
}
var path = source.fullName;
- var bazelWorkspace = BazelWorkspace.find(provider, path);
+ var bazelWorkspace = BlazeWorkspace.find(provider, path);
if (bazelWorkspace != null) {
return provider.pathContext.relative(path, from: bazelWorkspace.root);
}
diff --git a/pkg/analysis_server/test/analysis/get_hover_test.dart b/pkg/analysis_server/test/analysis/get_hover_test.dart
index 5c4b1fd..359613a 100644
--- a/pkg/analysis_server/test/analysis/get_hover_test.dart
+++ b/pkg/analysis_server/test/analysis/get_hover_test.dart
@@ -11,14 +11,14 @@
void main() {
defineReflectiveSuite(() {
- defineReflectiveTests(AnalysisHoverBazelTest);
+ defineReflectiveTests(AnalysisHoverBlazeTest);
defineReflectiveTests(AnalysisHoverTest);
});
}
@reflectiveTest
-class AnalysisHoverBazelTest extends BazelWorkspaceAnalysisServerTest {
- Future<void> test_bazel_notOwnedUri() async {
+class AnalysisHoverBlazeTest extends BlazeWorkspaceAnalysisServerTest {
+ Future<void> test_blaze_notOwnedUri() async {
newFile(
'$workspaceRootPath/bazel-genfiles/dart/my/lib/test.dart',
'// generated',
diff --git a/pkg/analysis_server/test/analysis_server_base.dart b/pkg/analysis_server/test/analysis_server_base.dart
index 2d9482a..cebb54f 100644
--- a/pkg/analysis_server/test/analysis_server_base.dart
+++ b/pkg/analysis_server/test/analysis_server_base.dart
@@ -71,7 +71,7 @@
}
}
-class BazelWorkspaceAnalysisServerTest extends ContextResolutionTest {
+class BlazeWorkspaceAnalysisServerTest extends ContextResolutionTest {
String get myPackageLibPath => '$myPackageRootPath/lib';
String get myPackageRootPath => '$workspaceRootPath/dart/my';
diff --git a/pkg/analysis_server/test/domain_analysis_test.dart b/pkg/analysis_server/test/domain_analysis_test.dart
index 473113c..a4bc41d 100644
--- a/pkg/analysis_server/test/domain_analysis_test.dart
+++ b/pkg/analysis_server/test/domain_analysis_test.dart
@@ -19,14 +19,14 @@
void main() {
defineReflectiveSuite(() {
- defineReflectiveTests(AnalysisDomainBazelTest);
+ defineReflectiveTests(AnalysisDomainBlazeTest);
defineReflectiveTests(AnalysisDomainPubTest);
defineReflectiveTests(SetSubscriptionsTest);
});
}
@reflectiveTest
-class AnalysisDomainBazelTest extends _AnalysisDomainTest {
+class AnalysisDomainBlazeTest extends _AnalysisDomainTest {
String get myPackageLibPath => '$myPackageRootPath/lib';
String get myPackageRootPath => '$workspaceRootPath/dart/my';
@@ -41,7 +41,7 @@
Future<void> test_fileSystem_changeFile_buildFile() async {
// This BUILD file does not enable null safety.
- newBazelBuildFile(myPackageRootPath, '');
+ newBlazeBuildFile(myPackageRootPath, '');
newFile(myPackageTestFilePath, '''
void f(int? a) {}
@@ -54,7 +54,7 @@
assertHasErrors(myPackageTestFilePath);
// Enable null safety.
- newBazelBuildFile(myPackageRootPath, '''
+ newBlazeBuildFile(myPackageRootPath, '''
dart_package(null_safety = True)
''');
diff --git a/pkg/analysis_server/test/integration/server/bazel_changes_test.dart b/pkg/analysis_server/test/integration/server/blaze_changes_test.dart
similarity index 77%
rename from pkg/analysis_server/test/integration/server/bazel_changes_test.dart
rename to pkg/analysis_server/test/integration/server/blaze_changes_test.dart
index 9767c8f..f74207a 100644
--- a/pkg/analysis_server/test/integration/server/bazel_changes_test.dart
+++ b/pkg/analysis_server/test/integration/server/blaze_changes_test.dart
@@ -19,12 +19,12 @@
}
defineReflectiveSuite(() {
- defineReflectiveTests(BazelChangesTest);
+ defineReflectiveTests(BlazeChangesTest);
});
}
@reflectiveTest
-class BazelChangesTest extends AbstractAnalysisServerIntegrationTest {
+class BlazeChangesTest extends AbstractAnalysisServerIntegrationTest {
var processedNotification = Completer<void>();
/// Path to the `command.log` file.
@@ -32,12 +32,12 @@
/// Writing to it should trigger our change detection to run.
late String commandLogPath;
- late String bazelRoot;
+ late String blazeRoot;
late String tmpPath;
late String workspacePath;
- late String bazelOrBlazeOutPath;
- late String bazelOrBlazeBinPath;
- late String bazelOrBlazeGenfilesPath;
+ late String blazeOutPath;
+ late String blazeBinPath;
+ late String blazeGenfilesPath;
late Directory oldSourceDirectory;
String inTmpDir(String relative) =>
@@ -61,21 +61,21 @@
sourceDirectory = Directory(inWorkspace('third_party/dart/project'));
sourceDirectory.createSync(recursive: true);
- bazelRoot = inTmpDir('bazel_or_blaze_root');
- Directory(bazelRoot).createSync(recursive: true);
+ blazeRoot = inTmpDir('bazel_or_blaze_root');
+ Directory(blazeRoot).createSync(recursive: true);
- bazelOrBlazeOutPath =
- '$bazelRoot/execroot/bazel_or_blaze_workspace/bazel_or_blaze-out';
- bazelOrBlazeBinPath =
- '$bazelRoot/execroot/bazel_or_blaze_workspace/bazel_or_blaze-out/bin';
- bazelOrBlazeGenfilesPath =
- '$bazelRoot/execroot/bazel_or_blaze_workspace/bazel_or_blaze-out/genfiles';
+ blazeOutPath =
+ '$blazeRoot/execroot/bazel_or_blaze_workspace/bazel_or_blaze-out';
+ blazeBinPath =
+ '$blazeRoot/execroot/bazel_or_blaze_workspace/bazel_or_blaze-out/bin';
+ blazeGenfilesPath =
+ '$blazeRoot/execroot/bazel_or_blaze_workspace/bazel_or_blaze-out/genfiles';
- Directory(inTmpDir(bazelOrBlazeOutPath)).createSync(recursive: true);
- Directory(inTmpDir(bazelOrBlazeBinPath)).createSync(recursive: true);
- Directory(inTmpDir(bazelOrBlazeGenfilesPath)).createSync(recursive: true);
+ Directory(inTmpDir(blazeOutPath)).createSync(recursive: true);
+ Directory(inTmpDir(blazeBinPath)).createSync(recursive: true);
+ Directory(inTmpDir(blazeGenfilesPath)).createSync(recursive: true);
- commandLogPath = inTmpDir('$bazelRoot/command.log');
+ commandLogPath = inTmpDir('$blazeRoot/command.log');
}
@override
@@ -88,13 +88,6 @@
// Add a bit more time -- the isolate take a while to start when the test is
// not run from a snapshot.
@TestTimeout(Timeout.factor(2))
- Future<void> test_bazelChanges() async {
- await testChangesImpl('bazel');
- }
-
- // Add a bit more time -- the isolate take a while to start when the test is
- // not run from a snapshot.
- @TestTimeout(Timeout.factor(2))
Future<void> test_blazeChanges() async {
await testChangesImpl('blaze');
}
@@ -137,7 +130,7 @@
await resetCompleterAndErrors();
var generatedFilePath = inWorkspace(
- '$bazelOrBlazeGenfilesPath/third_party/dart/project/lib/generated.dart');
+ '$blazeGenfilesPath/third_party/dart/project/lib/generated.dart');
writeFile(generatedFilePath, 'my_fun() {}');
_createSymlinks(prefix);
writeFile(commandLogPath, 'Build completed successfully');
@@ -174,9 +167,9 @@
}
void _createSymlinks(String prefix) {
- Link(inWorkspace('$prefix-out')).createSync(bazelOrBlazeOutPath);
- Link(inWorkspace('$prefix-bin')).createSync(bazelOrBlazeBinPath);
- Link(inWorkspace('$prefix-genfiles')).createSync(bazelOrBlazeGenfilesPath);
+ Link(inWorkspace('$prefix-out')).createSync(blazeOutPath);
+ Link(inWorkspace('$prefix-bin')).createSync(blazeBinPath);
+ Link(inWorkspace('$prefix-genfiles')).createSync(blazeGenfilesPath);
}
void _deleteSymlinks(String prefix) {
diff --git a/pkg/analysis_server/test/integration/server/test_all.dart b/pkg/analysis_server/test/integration/server/test_all.dart
index 1239990..d96283a 100644
--- a/pkg/analysis_server/test/integration/server/test_all.dart
+++ b/pkg/analysis_server/test/integration/server/test_all.dart
@@ -4,7 +4,7 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bazel_changes_test.dart' as bazel_changes_test;
+import 'blaze_changes_test.dart' as blaze_changes_test;
import 'command_line_options_test.dart' as command_line_options_test;
import 'get_version_test.dart' as get_version_test;
import 'set_subscriptions_invalid_service_test.dart'
@@ -15,7 +15,7 @@
void main() {
defineReflectiveSuite(() {
- bazel_changes_test.main();
+ blaze_changes_test.main();
command_line_options_test.main();
get_version_test.main();
set_subscriptions_test.main();
diff --git a/pkg/analysis_server/test/lsp/initialization_test.dart b/pkg/analysis_server/test/lsp/initialization_test.dart
index 28bd71b..04947cf 100644
--- a/pkg/analysis_server/test/lsp/initialization_test.dart
+++ b/pkg/analysis_server/test/lsp/initialization_test.dart
@@ -43,7 +43,7 @@
as Map<String, Object?>);
}
- Future<void> test_bazelWorkspace() async {
+ Future<void> test_blazeWorkspace() async {
var workspacePath = '/home/user/ws';
// Make it a Bazel workspace.
newFile(convertPath('$workspacePath/WORKSPACE'), '');
@@ -811,7 +811,7 @@
expect(server.contextManager.includedPaths, equals([file1]));
}
- Future<void> test_nonProjectFiles_bazelWorkspace() async {
+ Future<void> test_nonProjectFiles_blazeWorkspace() async {
final file1 = convertPath('/home/nonProject/file1.dart');
newFile(file1, '');
diff --git a/pkg/analysis_server/test/src/cider/assists_test.dart b/pkg/analysis_server/test/src/cider/assists_test.dart
index af5dc8e..fd0f6c2 100644
--- a/pkg/analysis_server/test/src/cider/assists_test.dart
+++ b/pkg/analysis_server/test/src/cider/assists_test.dart
@@ -41,7 +41,7 @@
@override
void setUp() {
super.setUp();
- BazelMockPackages.instance.addFlutter(resourceProvider);
+ BlazeMockPackages.instance.addFlutter(resourceProvider);
}
Future<void> test_addReturnType() async {
diff --git a/pkg/analysis_server/test/src/cider/cider_service.dart b/pkg/analysis_server/test/src/cider/cider_service.dart
index 6ebf3aa..0415123 100644
--- a/pkg/analysis_server/test/src/cider/cider_service.dart
+++ b/pkg/analysis_server/test/src/cider/cider_service.dart
@@ -10,7 +10,7 @@
import 'package:analyzer/src/dart/sdk/sdk.dart';
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
import 'package:crypto/crypto.dart';
import 'package:linter/src/rules.dart';
@@ -33,7 +33,7 @@
);
var sdk = FolderBasedDartSdk(resourceProvider, sdkRoot);
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider,
convertPath(testPath),
)!;
diff --git a/pkg/analysis_server/test/src/cider/document_symbols_test.dart b/pkg/analysis_server/test/src/cider/document_symbols_test.dart
index 7d25c9e..f1ebc40 100644
--- a/pkg/analysis_server/test/src/cider/document_symbols_test.dart
+++ b/pkg/analysis_server/test/src/cider/document_symbols_test.dart
@@ -146,7 +146,7 @@
}
void test_isTest_isTestGroup() async {
- BazelMockPackages.instance.addMeta(resourceProvider);
+ BlazeMockPackages.instance.addMeta(resourceProvider);
var outline = await _compute('''
import 'package:meta/meta.dart';
diff --git a/pkg/analysis_server/test/src/cider/rename_test.dart b/pkg/analysis_server/test/src/cider/rename_test.dart
index 270b014..eb90fe3 100644
--- a/pkg/analysis_server/test/src/cider/rename_test.dart
+++ b/pkg/analysis_server/test/src/cider/rename_test.dart
@@ -26,7 +26,7 @@
@override
void setUp() {
super.setUp();
- BazelMockPackages.instance.addFlutter(resourceProvider);
+ BlazeMockPackages.instance.addFlutter(resourceProvider);
}
void test_cannotRename_inSdk() async {
diff --git a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
index 3ee9a6a..47bd6f6 100644
--- a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
+++ b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
@@ -491,7 +491,7 @@
expect(files.packages, packageConfigFile);
}
- void test_pathsFor_withPubspec_inBazelWorkspace() {
+ void test_pathsFor_withPubspec_inBlazeWorkspace() {
//
// Build a Bazel workspace containing four packages, including the plugin.
//
diff --git a/pkg/analysis_server/test/src/utilities/mock_packages.dart b/pkg/analysis_server/test/src/utilities/mock_packages.dart
index 884b687..cb6c5d2 100644
--- a/pkg/analysis_server/test/src/utilities/mock_packages.dart
+++ b/pkg/analysis_server/test/src/utilities/mock_packages.dart
@@ -39,13 +39,13 @@
/// Helper for copying files from "tests/mock_packages" to memory file system
/// for Bazel.
-class BazelMockPackages {
- static final BazelMockPackages instance = BazelMockPackages._();
+class BlazeMockPackages {
+ static final BlazeMockPackages instance = BlazeMockPackages._();
/// The mapping from relative Posix paths of files to the file contents.
final Map<String, String> _cachedFiles = {};
- BazelMockPackages._() {
+ BlazeMockPackages._() {
_cacheFiles(_cachedFiles);
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
index 4aa5964c..e79d448 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
@@ -17,7 +17,7 @@
import 'package:analyzer/src/util/yaml.dart';
import 'package:analyzer/src/utilities/extensions/file_system.dart';
import 'package:analyzer/src/workspace/basic.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
import 'package:analyzer/src/workspace/gn.dart';
import 'package:analyzer/src/workspace/package_build.dart';
import 'package:analyzer/src/workspace/pub.dart';
@@ -376,7 +376,7 @@
var rootPath = folder.path;
Workspace? workspace;
- workspace = BazelWorkspace.find(resourceProvider, rootPath,
+ workspace = BlazeWorkspace.find(resourceProvider, rootPath,
lookForBuildFileSubstitutes: false);
workspace = _mostSpecificWorkspace(
workspace, GnWorkspace.find(resourceProvider, rootPath));
diff --git a/pkg/analyzer/lib/src/services/available_declarations.dart b/pkg/analyzer/lib/src/services/available_declarations.dart
index 8256f71..f0a990f 100644
--- a/pkg/analyzer/lib/src/services/available_declarations.dart
+++ b/pkg/analyzer/lib/src/services/available_declarations.dart
@@ -211,7 +211,7 @@
}
var contextPathList = <String>[];
- if (!_analysisContext.contextRoot.workspace.isBazel) {
+ if (!_analysisContext.contextRoot.workspace.isBlaze) {
_Package? package;
for (var candidatePackage in _packages) {
if (candidatePackage.contains(path)) {
@@ -341,7 +341,7 @@
var pubPathPrefixToPathList = <String, List<String>>{};
for (var path in _analysisContext.contextRoot.analyzedFiles()) {
- if (file_paths.isBazelBuild(pathContext, path)) {
+ if (file_paths.isBlazeBuild(pathContext, path)) {
var file = _tracker._resourceProvider.getFile(path);
var packageFolder = file.parent;
_packages.add(_Package(packageFolder));
diff --git a/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart b/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart
index 72d0042..55cff30 100644
--- a/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart
+++ b/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart
@@ -74,8 +74,8 @@
return newAnalysisOptionsYamlFile(directoryPath, content);
}
- File newBazelBuildFile(String directoryPath, String content) {
- String path = join(directoryPath, file_paths.bazelBuild);
+ File newBlazeBuildFile(String directoryPath, String content) {
+ String path = join(directoryPath, file_paths.blazeBuild);
return newFile(path, content);
}
diff --git a/pkg/analyzer/lib/src/util/file_paths.dart b/pkg/analyzer/lib/src/util/file_paths.dart
index 85d865f..57e8b22 100644
--- a/pkg/analyzer/lib/src/util/file_paths.dart
+++ b/pkg/analyzer/lib/src/util/file_paths.dart
@@ -14,7 +14,7 @@
const String androidManifestXml = 'AndroidManifest.xml';
/// File name of Bazel `BUILD` files.
-const String bazelBuild = 'BUILD';
+const String blazeBuild = 'BUILD';
/// The name of the `.dart_tool` directory.
const String dotDartTool = '.dart_tool';
@@ -47,8 +47,8 @@
}
/// Return `true` if [path] is a Bazel `BUILD` file.
-bool isBazelBuild(p.Context pathContext, String path) {
- return pathContext.basename(path) == bazelBuild;
+bool isBlazeBuild(p.Context pathContext, String path) {
+ return pathContext.basename(path) == blazeBuild;
}
/// Return `true` if [path] is a Dart file.
diff --git a/pkg/analyzer/lib/src/workspace/bazel.dart b/pkg/analyzer/lib/src/workspace/bazel.dart
index 201b8c9..54bd91d 100644
--- a/pkg/analyzer/lib/src/workspace/bazel.dart
+++ b/pkg/analyzer/lib/src/workspace/bazel.dart
@@ -2,733 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:async';
-import 'dart:collection';
+import 'package:analyzer/src/workspace/blaze.dart';
-import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/src/context/packages.dart';
-import 'package:analyzer/src/generated/sdk.dart';
-import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/summary/package_bundle_reader.dart';
-import 'package:analyzer/src/util/uri.dart';
-import 'package:analyzer/src/workspace/bazel_watcher.dart';
-import 'package:analyzer/src/workspace/workspace.dart';
-import 'package:collection/collection.dart';
-import 'package:path/path.dart' as path;
-import 'package:pub_semver/pub_semver.dart';
-
-/// Instances of the class `BazelFileUriResolver` resolve `file` URI's by first
-/// resolving file uri's in the expected way, and then by looking in the
-/// corresponding generated directories.
-class BazelFileUriResolver extends ResourceUriResolver {
- final BazelWorkspace workspace;
-
- BazelFileUriResolver(this.workspace) : super(workspace.provider);
-
- @override
- Uri pathToUri(String path) {
- var pathContext = workspace.provider.pathContext;
- for (var genRoot in [
- ...workspace.binPaths,
- workspace.genfiles,
- workspace.readonly,
- ]) {
- if (genRoot != null && pathContext.isWithin(genRoot, path)) {
- String relative = pathContext.relative(path, from: genRoot);
- var writablePath = pathContext.join(workspace.root, relative);
- return pathContext.toUri(writablePath);
- }
- }
- return workspace.provider.pathContext.toUri(path);
- }
-
- @override
- Source? resolveAbsolute(Uri uri) {
- if (!ResourceUriResolver.isFileUri(uri)) {
- return null;
- }
- String filePath = fileUriToNormalizedPath(provider.pathContext, uri);
- var file = workspace.findFile(filePath);
- if (file != null) {
- return file.createSource(uri);
- }
- return null;
- }
-}
-
-/// The [UriResolver] that can resolve `package` URIs in [BazelWorkspace].
-class BazelPackageUriResolver extends UriResolver {
- final BazelWorkspace _workspace;
- final path.Context _context;
-
- /// The cache of absolute [Uri]s to [Source]s mappings.
- final Map<Uri, Source> _sourceCache = HashMap<Uri, Source>();
-
- BazelPackageUriResolver(BazelWorkspace workspace)
- : _workspace = workspace,
- _context = workspace.provider.pathContext;
-
- @override
- Uri? pathToUri(String path) {
- // Search in each root.
- for (var root in [
- ..._workspace.binPaths,
- _workspace.genfiles,
- _workspace.readonly,
- _workspace.root
- ]) {
- var uriParts = _restoreUriParts(root, path);
- if (uriParts != null) {
- return Uri.parse('package:${uriParts[0]}/${uriParts[1]}');
- }
- }
-
- return null;
- }
-
- @override
- Source? resolveAbsolute(Uri uri) {
- var source = _sourceCache[uri];
- if (source == null) {
- source = _resolveAbsolute(uri);
- if (source != null) {
- _sourceCache[uri] = source;
- }
- }
- return source;
- }
-
- Source? _resolveAbsolute(Uri uri) {
- if (uri.isScheme('file')) {
- var path = fileUriToNormalizedPath(_context, uri);
- var pathRelativeToRoot = _workspace._relativeToRoot(path);
- if (pathRelativeToRoot == null) return null;
- var fullFilePath = _context.join(_workspace.root, pathRelativeToRoot);
- var file = _workspace.findFile(fullFilePath);
- return file?.createSource(uri);
- }
- if (!uri.isScheme('package')) {
- return null;
- }
- String uriPath = Uri.decodeComponent(uri.path);
- int slash = uriPath.indexOf('/');
-
- // If the path either starts with a slash or has no slash, it is invalid.
- if (slash < 1) {
- return null;
- }
-
- if (uriPath.contains('//') || uriPath.contains('..')) {
- return null;
- }
-
- String packageName = uriPath.substring(0, slash);
-
- String fileUriPart = uriPath.substring(slash + 1);
- if (fileUriPart.isEmpty) {
- return null;
- }
-
- String filePath = fileUriPart.replaceAll('/', _context.separator);
-
- if (!packageName.contains('.')) {
- String fullFilePath = _context.join(
- _workspace.root, 'third_party', 'dart', packageName, 'lib', filePath);
- var file = _workspace.findFile(fullFilePath);
- return file?.createSource(uri);
- } else {
- String packagePath = packageName.replaceAll('.', _context.separator);
- String fullFilePath =
- _context.join(_workspace.root, packagePath, 'lib', filePath);
- var file = _workspace.findFile(fullFilePath);
- return file?.createSource(uri);
- }
- }
-
- /// Restore [filePath] to its 'package:' URI parts.
- ///
- /// Returns `null` if [root] is null or if [filePath] is not within [root].
- List<String>? _restoreUriParts(String? root, String filePath) {
- path.Context context = _workspace.provider.pathContext;
- if (root != null && context.isWithin(root, filePath)) {
- String relative = context.relative(filePath, from: root);
- List<String> components = context.split(relative);
- if (components.length > 4 &&
- components[0] == 'third_party' &&
- components[1] == 'dart' &&
- components[3] == 'lib') {
- String packageName = components[2];
- String pathInLib = components.skip(4).join('/');
- return [packageName, pathInLib];
- } else {
- for (int i = components.length - 2; i >= 2; i--) {
- String component = components[i];
- if (component == 'lib') {
- String packageName = components.getRange(0, i).join('.');
- String pathInLib = components.skip(i + 1).join('/');
- return [packageName, pathInLib];
- }
- }
- }
- }
- return null;
- }
-}
-
-/// Information about a Bazel workspace.
-class BazelWorkspace extends Workspace
- implements WorkspaceWithDefaultAnalysisOptions {
- static const String _WORKSPACE = 'WORKSPACE';
- static const String _READONLY = 'READONLY';
-
- /// The name of the file that identifies a set of Bazel Targets.
- ///
- /// For Dart package purposes, a BUILD file identifies a package.
- static const String _buildFileName = 'BUILD';
-
- /// Default prefix for "-genfiles" and "-bin" that will be assumed if no build
- /// output symlinks are found.
- static const defaultSymlinkPrefix = 'bazel';
-
- final ResourceProvider provider;
-
- /// The absolute workspace root path.
- ///
- /// It contains the `WORKSPACE` file or its parent contains the `READONLY`
- /// folder.
- @override
- final String root;
-
- /// Either `blaze` or `bazel`.
- final String symlinkPrefix;
-
- /// The absolute path to the optional read only workspace root, in the
- /// `READONLY` folder if a git-based workspace, or `null`.
- final String? readonly;
-
- /// The absolute paths to all `bazel-bin` folders.
- ///
- /// In practice, there is usually one "bin" path, and sometimes there are two,
- /// on distributed build systems. It is very rare to have more than two.
- final List<String> binPaths;
-
- /// The absolute path to the `bazel-genfiles` folder.
- final String genfiles;
-
- /// Sometimes `BUILD` files are not preserved, and `xyz.packages` files
- /// are created instead. But looking for them is expensive, so we want
- /// to avoid this in cases when `BUILD` files are always available.
- final bool _lookForBuildFileSubstitutes;
-
- /// The language version for this workspace, `null` if cannot be read.
- final Version? _languageVersion;
-
- /// The cache of packages. The key is the directory path, the value is
- /// the corresponding package.
- final Map<String, BazelWorkspacePackage> _directoryToPackage = {};
-
- final _bazelCandidateFiles = StreamController<BazelSearchInfo>.broadcast();
-
- BazelWorkspace._(
- this.provider,
- this.root,
- this.symlinkPrefix,
- this.readonly,
- this.binPaths,
- this.genfiles, {
- required bool lookForBuildFileSubstitutes,
- }) : _lookForBuildFileSubstitutes = lookForBuildFileSubstitutes,
- _languageVersion = _readLanguageVersion(provider, root);
-
- /// Stream of files that we tried to find along with their potential or actual
- /// paths.
- Stream<BazelSearchInfo> get bazelCandidateFiles =>
- _bazelCandidateFiles.stream;
-
- @override
- bool get isBazel => true;
-
- @override
- UriResolver get packageUriResolver => BazelPackageUriResolver(this);
-
- @override
- SourceFactory createSourceFactory(
- DartSdk? sdk,
- SummaryDataStore? summaryData,
- ) {
- List<UriResolver> resolvers = <UriResolver>[];
- if (sdk != null) {
- resolvers.add(DartUriResolver(sdk));
- }
- resolvers.add(packageUriResolver);
- resolvers.add(BazelFileUriResolver(this));
- if (summaryData != null) {
- resolvers.add(InSummaryUriResolver(summaryData));
- }
- return SourceFactory(resolvers);
- }
-
- /// Return the file with the given [absolutePath], looking first into
- /// directories for generated files: `bazel-bin` and `bazel-genfiles`, and
- /// then into the workspace root. The file in the workspace root is returned
- /// even if it does not exist. Return `null` if the given [absolutePath] is
- /// not in the workspace [root].
- File? findFile(String absolutePath) {
- path.Context context = provider.pathContext;
- try {
- String relative = context.relative(absolutePath, from: root);
- if (relative == '.') {
- return null;
- }
- // First check genfiles and bin directories. Note that we always use the
- // symlinks and not the [binPaths] or [genfiles] to make sure we use the
- // files corresponding to the most recent build configuration and get
- // consistent view of all the generated files.
- var generatedCandidates = [
- '$symlinkPrefix-genfiles',
- '$symlinkPrefix-bin'
- ].map((prefix) => context.join(root, context.join(prefix, relative)));
- for (var path in generatedCandidates) {
- File file = provider.getFile(path);
- if (file.exists) {
- _bazelCandidateFiles
- .add(BazelSearchInfo(relative, generatedCandidates.toList()));
- return file;
- }
- }
- // Writable
- File writableFile = provider.getFile(absolutePath);
- if (writableFile.exists) {
- return writableFile;
- }
- // READONLY
- final readonly = this.readonly;
- if (readonly != null) {
- File file = provider.getFile(context.join(readonly, relative));
- if (file.exists) {
- return file;
- }
- }
- // If we couldn't find the file, assume that it has not yet been
- // generated, so send an event with all the paths that we tried.
- _bazelCandidateFiles
- .add(BazelSearchInfo(relative, generatedCandidates.toList()));
- // Not generated, return the default one.
- return writableFile;
- } catch (_) {
- return null;
- }
- }
-
- @override
- BazelWorkspacePackage? findPackageFor(String filePath) {
- path.Context context = provider.pathContext;
- var directoryPath = context.dirname(filePath);
-
- var cachedPackage = _directoryToPackage[directoryPath];
- if (cachedPackage != null) {
- return cachedPackage;
- }
-
- if (!context.isWithin(root, directoryPath)) {
- return null;
- }
-
- // Handle files which are given with their location in "bazel-bin", etc.
- // This does not typically happen during usual analysis, but it still could,
- // and it can come up in tests.
- for (var binPath in [genfiles, ...binPaths]) {
- if (context.isWithin(binPath, directoryPath)) {
- return findPackageFor(
- context.join(root, context.relative(filePath, from: binPath)));
- }
- }
-
- /// Return the package rooted at [folder].
- BazelWorkspacePackage? packageRootedAt(Folder folder) {
- var uriParts = (packageUriResolver as BazelPackageUriResolver)
- ._restoreUriParts(root, '${folder.path}/lib/__fake__.dart');
- String? packageName;
- if (uriParts != null && uriParts.isNotEmpty) {
- packageName = uriParts[0];
- }
- // TODO(srawlins): If [packageName] could not be derived from [uriParts],
- // I imagine this should throw.
- if (packageName == null) {
- return null;
- }
- var package = BazelWorkspacePackage(packageName, folder.path, this);
- _directoryToPackage[directoryPath] = package;
- return package;
- }
-
- var startFolder = provider.getFolder(directoryPath);
- for (var folder in startFolder.withAncestors) {
- if (folder.path.length < root.length) {
- // We've walked up outside of [root], so [path] is definitely not
- // defined in any package in this workspace.
- return null;
- }
-
- if (folder.getChildAssumingFile(_buildFileName).exists) {
- // Found the BUILD file, denoting a Dart package.
- return packageRootedAt(folder);
- }
-
- if (_hasBuildFileSubstitute(folder)) {
- return packageRootedAt(folder);
- }
- }
-
- return null;
- }
-
- /// In some distributed build environments, BUILD files are not preserved.
- /// We can still look for a ".packages" file in order to determine a
- /// package's root. A ".packages" file found in [folder]'s sister path
- /// under a "bin" path among [binPaths] denotes a Dart package.
- ///
- /// For example, if the [root] of this BazelWorkspace is
- /// "/build/work/abc123/workspace" with two "bin" folders,
- /// "/build/work/abc123/workspace/blaze-out/host/bin/" and
- /// "/build/work/abc123/workspace/blaze-out/k8-opt/bin/", and [folder]
- /// is at "/build/work/abc123/workspace/foo/bar", then we must look for a
- /// file ending in ".packages" in the folders
- /// "/build/work/abc123/workspace/blaze-out/host/bin/foo/bar" and
- /// "/build/work/abc123/workspace/blaze-out/k8-opt/bin/foo/bar".
- bool _hasBuildFileSubstitute(Folder folder) {
- if (!_lookForBuildFileSubstitutes) {
- return false;
- }
-
- path.Context context = provider.pathContext;
-
- // [folder]'s path, relative to [root]. For example, "foo/bar".
- String relative = context.relative(folder.path, from: root);
-
- for (String bin in binPaths) {
- Folder binChild =
- provider.getFolder(context.normalize(context.join(bin, relative)));
- if (binChild.exists &&
- binChild.getChildren().any((c) => c.path.endsWith('.packages'))) {
- // [folder]'s sister folder within [bin] contains a ".packages" file.
- return true;
- }
- }
-
- return false;
- }
-
- String? _relativeToRoot(String p) {
- path.Context context = provider.pathContext;
- // genfiles
- if (context.isWithin(genfiles, p)) {
- return context.relative(p, from: genfiles);
- }
- // bin
- for (String bin in binPaths) {
- if (context.isWithin(bin, p)) {
- return context.relative(p, from: bin);
- }
- }
- // READONLY
- final readonly = this.readonly;
- if (readonly != null) {
- if (context.isWithin(readonly, p)) {
- return context.relative(p, from: readonly);
- }
- }
- // Not generated
- if (context.isWithin(root, p)) {
- return context.relative(p, from: root);
- }
- // Failed reverse lookup
- return null;
- }
-
- /// Find the Bazel workspace that contains the given [filePath].
- ///
- /// This method walks up the file system from [filePath], looking for various
- /// "marker" files which indicate a Bazel workspace.
- ///
- /// At each folder _f_ with parent _p_, starting with [filePath]:
- ///
- /// * If _f_ has a sibling folder named "READONLY", and that folder has a
- /// child folder with the same name as _f_, then a BazelWorkspace rooted at
- /// _f_ is returned.
- /// * If _f_ has a child folder named "blaze-out" or "bazel-out", then a
- /// BazelWorkspace rooted at _f_ is returned.
- /// * If _f_ has a child file named "WORKSPACE", then a BazelWorkspace rooted
- /// at _f_ is returned.
- static BazelWorkspace? find(
- ResourceProvider provider,
- String filePath, {
- bool lookForBuildFileSubstitutes = true,
- }) {
- var context = provider.pathContext;
- var startFolder = provider.getFolder(filePath);
- for (var folder in startFolder.withAncestors) {
- var parent = folder.parent;
-
- // Found the READONLY folder, might be a git-based workspace.
- Folder readonlyFolder = parent.getChildAssumingFolder(_READONLY);
- if (readonlyFolder.exists) {
- String root = folder.path;
- String readonlyRoot =
- context.join(readonlyFolder.path, folder.shortName);
- if (provider.getFolder(readonlyRoot).exists) {
- var binPaths = _findBinFolderPaths(folder);
- String symlinkPrefix =
- _findSymlinkPrefix(provider, root, binPaths: binPaths);
- binPaths = binPaths..add(context.join(root, '$symlinkPrefix-bin'));
- return BazelWorkspace._(provider, root, symlinkPrefix, readonlyRoot,
- binPaths, context.join(root, '$symlinkPrefix-genfiles'),
- lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
- }
- }
-
- if (_firstExistingFolder(parent, ['blaze-out', 'bazel-out']) != null) {
- // Found the "out" folder; must be a bazel workspace.
- String root = parent.path;
- var binPaths = _findBinFolderPaths(parent);
- String symlinkPrefix =
- _findSymlinkPrefix(provider, root, binPaths: binPaths);
- binPaths = binPaths..add(context.join(root, '$symlinkPrefix-bin'));
- return BazelWorkspace._(
- provider,
- root,
- symlinkPrefix,
- null /* readonly */,
- binPaths,
- context.join(root, '$symlinkPrefix-genfiles'),
- lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
- }
-
- // Found the WORKSPACE file, must be a non-git workspace.
- if (folder.getChildAssumingFile(_WORKSPACE).exists) {
- String root = folder.path;
- var binPaths = _findBinFolderPaths(folder);
- String symlinkPrefix =
- _findSymlinkPrefix(provider, root, binPaths: binPaths);
- binPaths = binPaths..add(context.join(root, '$symlinkPrefix-bin'));
- return BazelWorkspace._(
- provider,
- root,
- symlinkPrefix,
- null /* readonly */,
- binPaths,
- context.join(root, '$symlinkPrefix-genfiles'),
- lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
- }
- }
-
- return null;
- }
-
- /// Find the "bin" folder path, by searching for it.
- ///
- /// Depending on the environment we're working in (source code tree, build
- /// environment subtree of sources, local workspace, blaze, bazel), the "bin"
- /// folder may be available at a symlink found at `$root/blaze-bin/` or
- /// `$root/bazel-bin/`. If that symlink is not available, then we must search
- /// the immediate folders found in `$root/blaze-out/` and `$root/bazel-out/`
- /// for folders named "bin".
- ///
- /// If no "bin" folder is found in any of those locations, empty list is
- /// returned.
- static List<String> _findBinFolderPaths(Folder root) {
- var out = _firstExistingFolder(root, ['blaze-out', 'bazel-out']);
- if (out == null) {
- return [];
- }
-
- List<String> binPaths = [];
- for (var child in out.getChildren().whereType<Folder>()) {
- // Children are folders denoting architectures and build flags, like
- // 'k8-opt', 'k8-fastbuild', perhaps 'host'.
- Folder possibleBin = child.getChildAssumingFolder('bin');
- if (possibleBin.exists) {
- binPaths.add(possibleBin.path);
- }
- }
- return binPaths;
- }
-
- /// Return the symlink prefix, _X_, for folders `X-bin` or `X-genfiles`.
- ///
- /// If the workspace's "bin" folders were already found, the symlink prefix is
- /// determined from one of the [binPaths]. Otherwise it is determined by
- /// probing the internal `blaze-genfiles` and `bazel-genfiles`. Make a default
- /// assumption according to [defaultSymlinkPrefix] if neither of the folders
- /// exists.
- static String _findSymlinkPrefix(ResourceProvider provider, String root,
- {List<String>? binPaths}) {
- path.Context context = provider.pathContext;
- if (binPaths != null && binPaths.isNotEmpty) {
- return context.basename(binPaths.first).startsWith('bazel')
- ? 'bazel'
- : 'blaze';
- }
- if (provider.getFolder(context.join(root, 'blaze-genfiles')).exists) {
- return 'blaze';
- }
- if (provider.getFolder(context.join(root, 'bazel-genfiles')).exists) {
- return 'bazel';
- }
- // Couldn't find it. Make a default assumption.
- return defaultSymlinkPrefix;
- }
-
- /// Return the first folder within [root], chosen from [names], which exists.
- static Folder? _firstExistingFolder(Folder root, List<String> names) => names
- .map((name) => root.getChildAssumingFolder(name))
- .firstWhereOrNull((folder) => folder.exists);
-
- /// Return the default language version of the workspace.
- ///
- /// Return `null` if cannot be read, for example because the file does not
- /// exist, or is not available in this build configuration (batch analysis).
- static Version? _readLanguageVersion(
- ResourceProvider resourceProvider,
- String rootPath,
- ) {
- var file = resourceProvider.getFile(
- resourceProvider.pathContext.joinAll(
- [rootPath, 'dart', 'build_defs', 'bzl', 'language.bzl'],
- ),
- );
-
- String content;
- try {
- content = file.readAsStringSync();
- } on FileSystemException {
- return null;
- }
-
- final pattern = RegExp(r'_version_null_safety\s*=\s*"(\d+\.\d+)"');
- for (var match in pattern.allMatches(content)) {
- return Version.parse('${match.group(1)}.0');
- }
-
- return null;
- }
-}
-
-/// Information about a package defined in a BazelWorkspace.
-///
-/// Separate from [Packages] or package maps, this class is designed to simply
-/// understand whether arbitrary file paths represent libraries declared within
-/// a given package in a BazelWorkspace.
-class BazelWorkspacePackage extends WorkspacePackage {
- /// A prefix for any URI of a path in this package.
- final String _uriPrefix;
-
- @override
- final String root;
-
- @override
- final BazelWorkspace workspace;
-
- bool _buildFileReady = false;
- List<String>? _enabledExperiments;
- Version? _languageVersion;
-
- BazelWorkspacePackage(String packageName, this.root, this.workspace)
- : _uriPrefix = 'package:$packageName/';
-
- @override
- List<String>? get enabledExperiments {
- _readBuildFile();
- return _enabledExperiments;
- }
-
- @override
- Version? get languageVersion {
- _readBuildFile();
- return _languageVersion ?? workspace._languageVersion;
- }
-
- @override
- bool contains(Source source) {
- var uri = source.uri;
- if (uri.isScheme('package')) {
- return uri.toString().startsWith(_uriPrefix);
- }
-
- var path = source.fullName;
- return workspace.findPackageFor(path)?.root == root;
- }
-
- @override
- // TODO(brianwilkerson) Implement this by looking in the BUILD file for 'deps'
- // lists.
- Packages packagesAvailableTo(String libraryPath) => Packages.empty;
-
- @override
- bool sourceIsInPublicApi(Source source) {
- var filePath = filePathFromSource(source);
- if (filePath == null) return false;
-
- var libFolder = workspace.provider.pathContext.join(root, 'lib');
- if (workspace.provider.pathContext.isWithin(libFolder, filePath)) {
- // A file in "$root/lib" is public iff it is not in "$root/lib/src".
- var libSrcFolder = workspace.provider.pathContext.join(libFolder, 'src');
- return !workspace.provider.pathContext.isWithin(libSrcFolder, filePath);
- }
-
- var relativeRoot =
- workspace.provider.pathContext.relative(root, from: workspace.root);
- for (var binPath in workspace.binPaths) {
- libFolder =
- workspace.provider.pathContext.join(binPath, relativeRoot, 'lib');
- if (workspace.provider.pathContext.isWithin(libFolder, filePath)) {
- // A file in "$bin/lib" is public iff it is not in "$bin/lib/src".
- var libSrcFolder =
- workspace.provider.pathContext.join(libFolder, 'src');
- return !workspace.provider.pathContext.isWithin(libSrcFolder, filePath);
- }
- }
-
- libFolder = workspace.provider.pathContext
- .join(workspace.genfiles, relativeRoot, 'lib');
- if (workspace.provider.pathContext.isWithin(libFolder, filePath)) {
- // A file in "$genfiles/lib" is public iff it is not in
- // "$genfiles/lib/src".
- var libSrcFolder = workspace.provider.pathContext.join(libFolder, 'src');
- return !workspace.provider.pathContext.isWithin(libSrcFolder, filePath);
- }
-
- return false;
- }
-
- void _readBuildFile() {
- if (_buildFileReady) {
- return;
- }
-
- try {
- _buildFileReady = true;
- var buildContent = workspace.provider
- .getFolder(root)
- .getChildAssumingFile('BUILD')
- .readAsStringSync();
- var flattenedBuildContent = buildContent
- .split('\n')
- .map((e) => e.trim())
- .where((e) => !e.startsWith('#'))
- .map((e) => e.replaceAll(' ', ''))
- .join();
- var hasNonNullableFlag = const {
- 'dart_package(null_safety=True',
- 'dart_package(sound_null_safety=True',
- }.any(flattenedBuildContent.contains);
- if (hasNonNullableFlag) {
- // Enabled by default.
- } else {
- _languageVersion = Version.parse('2.9.0');
- }
- } on FileSystemException {
- // ignored
- }
- }
-}
+@Deprecated('Use BlazeWorkspace instead')
+typedef BazelWorkspace = BlazeWorkspace;
diff --git a/pkg/analyzer/lib/src/workspace/blaze.dart b/pkg/analyzer/lib/src/workspace/blaze.dart
new file mode 100644
index 0000000..fbbfa72
--- /dev/null
+++ b/pkg/analyzer/lib/src/workspace/blaze.dart
@@ -0,0 +1,734 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+import 'dart:collection';
+
+import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/src/context/packages.dart';
+import 'package:analyzer/src/generated/sdk.dart';
+import 'package:analyzer/src/generated/source.dart';
+import 'package:analyzer/src/summary/package_bundle_reader.dart';
+import 'package:analyzer/src/util/uri.dart';
+import 'package:analyzer/src/workspace/blaze_watcher.dart';
+import 'package:analyzer/src/workspace/workspace.dart';
+import 'package:collection/collection.dart';
+import 'package:path/path.dart' as path;
+import 'package:pub_semver/pub_semver.dart';
+
+/// Instances of the class `BazelFileUriResolver` resolve `file` URI's by first
+/// resolving file uri's in the expected way, and then by looking in the
+/// corresponding generated directories.
+class BlazeFileUriResolver extends ResourceUriResolver {
+ final BlazeWorkspace workspace;
+
+ BlazeFileUriResolver(this.workspace) : super(workspace.provider);
+
+ @override
+ Uri pathToUri(String path) {
+ var pathContext = workspace.provider.pathContext;
+ for (var genRoot in [
+ ...workspace.binPaths,
+ workspace.genfiles,
+ workspace.readonly,
+ ]) {
+ if (genRoot != null && pathContext.isWithin(genRoot, path)) {
+ String relative = pathContext.relative(path, from: genRoot);
+ var writablePath = pathContext.join(workspace.root, relative);
+ return pathContext.toUri(writablePath);
+ }
+ }
+ return workspace.provider.pathContext.toUri(path);
+ }
+
+ @override
+ Source? resolveAbsolute(Uri uri) {
+ if (!ResourceUriResolver.isFileUri(uri)) {
+ return null;
+ }
+ String filePath = fileUriToNormalizedPath(provider.pathContext, uri);
+ var file = workspace.findFile(filePath);
+ if (file != null) {
+ return file.createSource(uri);
+ }
+ return null;
+ }
+}
+
+/// The [UriResolver] that can resolve `package` URIs in [BlazeWorkspace].
+class BlazePackageUriResolver extends UriResolver {
+ final BlazeWorkspace _workspace;
+ final path.Context _context;
+
+ /// The cache of absolute [Uri]s to [Source]s mappings.
+ final Map<Uri, Source> _sourceCache = HashMap<Uri, Source>();
+
+ BlazePackageUriResolver(BlazeWorkspace workspace)
+ : _workspace = workspace,
+ _context = workspace.provider.pathContext;
+
+ @override
+ Uri? pathToUri(String path) {
+ // Search in each root.
+ for (var root in [
+ ..._workspace.binPaths,
+ _workspace.genfiles,
+ _workspace.readonly,
+ _workspace.root
+ ]) {
+ var uriParts = _restoreUriParts(root, path);
+ if (uriParts != null) {
+ return Uri.parse('package:${uriParts[0]}/${uriParts[1]}');
+ }
+ }
+
+ return null;
+ }
+
+ @override
+ Source? resolveAbsolute(Uri uri) {
+ var source = _sourceCache[uri];
+ if (source == null) {
+ source = _resolveAbsolute(uri);
+ if (source != null) {
+ _sourceCache[uri] = source;
+ }
+ }
+ return source;
+ }
+
+ Source? _resolveAbsolute(Uri uri) {
+ if (uri.isScheme('file')) {
+ var path = fileUriToNormalizedPath(_context, uri);
+ var pathRelativeToRoot = _workspace._relativeToRoot(path);
+ if (pathRelativeToRoot == null) return null;
+ var fullFilePath = _context.join(_workspace.root, pathRelativeToRoot);
+ var file = _workspace.findFile(fullFilePath);
+ return file?.createSource(uri);
+ }
+ if (!uri.isScheme('package')) {
+ return null;
+ }
+ String uriPath = Uri.decodeComponent(uri.path);
+ int slash = uriPath.indexOf('/');
+
+ // If the path either starts with a slash or has no slash, it is invalid.
+ if (slash < 1) {
+ return null;
+ }
+
+ if (uriPath.contains('//') || uriPath.contains('..')) {
+ return null;
+ }
+
+ String packageName = uriPath.substring(0, slash);
+
+ String fileUriPart = uriPath.substring(slash + 1);
+ if (fileUriPart.isEmpty) {
+ return null;
+ }
+
+ String filePath = fileUriPart.replaceAll('/', _context.separator);
+
+ if (!packageName.contains('.')) {
+ String fullFilePath = _context.join(
+ _workspace.root, 'third_party', 'dart', packageName, 'lib', filePath);
+ var file = _workspace.findFile(fullFilePath);
+ return file?.createSource(uri);
+ } else {
+ String packagePath = packageName.replaceAll('.', _context.separator);
+ String fullFilePath =
+ _context.join(_workspace.root, packagePath, 'lib', filePath);
+ var file = _workspace.findFile(fullFilePath);
+ return file?.createSource(uri);
+ }
+ }
+
+ /// Restore [filePath] to its 'package:' URI parts.
+ ///
+ /// Returns `null` if [root] is null or if [filePath] is not within [root].
+ List<String>? _restoreUriParts(String? root, String filePath) {
+ path.Context context = _workspace.provider.pathContext;
+ if (root != null && context.isWithin(root, filePath)) {
+ String relative = context.relative(filePath, from: root);
+ List<String> components = context.split(relative);
+ if (components.length > 4 &&
+ components[0] == 'third_party' &&
+ components[1] == 'dart' &&
+ components[3] == 'lib') {
+ String packageName = components[2];
+ String pathInLib = components.skip(4).join('/');
+ return [packageName, pathInLib];
+ } else {
+ for (int i = components.length - 2; i >= 2; i--) {
+ String component = components[i];
+ if (component == 'lib') {
+ String packageName = components.getRange(0, i).join('.');
+ String pathInLib = components.skip(i + 1).join('/');
+ return [packageName, pathInLib];
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
+
+/// Information about a Bazel workspace.
+class BlazeWorkspace extends Workspace
+ implements WorkspaceWithDefaultAnalysisOptions {
+ static const String _WORKSPACE = 'WORKSPACE';
+ static const String _READONLY = 'READONLY';
+
+ /// The name of the file that identifies a set of Bazel Targets.
+ ///
+ /// For Dart package purposes, a BUILD file identifies a package.
+ static const String _buildFileName = 'BUILD';
+
+ /// Default prefix for "-genfiles" and "-bin" that will be assumed if no build
+ /// output symlinks are found.
+ static const defaultSymlinkPrefix = 'bazel';
+
+ final ResourceProvider provider;
+
+ /// The absolute workspace root path.
+ ///
+ /// It contains the `WORKSPACE` file or its parent contains the `READONLY`
+ /// folder.
+ @override
+ final String root;
+
+ /// Either `blaze` or `bazel`.
+ final String symlinkPrefix;
+
+ /// The absolute path to the optional read only workspace root, in the
+ /// `READONLY` folder if a git-based workspace, or `null`.
+ final String? readonly;
+
+ /// The absolute paths to all `bazel-bin` folders.
+ ///
+ /// In practice, there is usually one "bin" path, and sometimes there are two,
+ /// on distributed build systems. It is very rare to have more than two.
+ final List<String> binPaths;
+
+ /// The absolute path to the `bazel-genfiles` folder.
+ final String genfiles;
+
+ /// Sometimes `BUILD` files are not preserved, and `xyz.packages` files
+ /// are created instead. But looking for them is expensive, so we want
+ /// to avoid this in cases when `BUILD` files are always available.
+ final bool _lookForBuildFileSubstitutes;
+
+ /// The language version for this workspace, `null` if cannot be read.
+ final Version? _languageVersion;
+
+ /// The cache of packages. The key is the directory path, the value is
+ /// the corresponding package.
+ final Map<String, BlazeWorkspacePackage> _directoryToPackage = {};
+
+ final _blazeCandidateFiles = StreamController<BlazeSearchInfo>.broadcast();
+
+ BlazeWorkspace._(
+ this.provider,
+ this.root,
+ this.symlinkPrefix,
+ this.readonly,
+ this.binPaths,
+ this.genfiles, {
+ required bool lookForBuildFileSubstitutes,
+ }) : _lookForBuildFileSubstitutes = lookForBuildFileSubstitutes,
+ _languageVersion = _readLanguageVersion(provider, root);
+
+ /// Stream of files that we tried to find along with their potential or actual
+ /// paths.
+ Stream<BlazeSearchInfo> get blazeCandidateFiles =>
+ _blazeCandidateFiles.stream;
+
+ @override
+ bool get isBlaze => true;
+
+ @override
+ UriResolver get packageUriResolver => BlazePackageUriResolver(this);
+
+ @override
+ SourceFactory createSourceFactory(
+ DartSdk? sdk,
+ SummaryDataStore? summaryData,
+ ) {
+ List<UriResolver> resolvers = <UriResolver>[];
+ if (sdk != null) {
+ resolvers.add(DartUriResolver(sdk));
+ }
+ resolvers.add(packageUriResolver);
+ resolvers.add(BlazeFileUriResolver(this));
+ if (summaryData != null) {
+ resolvers.add(InSummaryUriResolver(summaryData));
+ }
+ return SourceFactory(resolvers);
+ }
+
+ /// Return the file with the given [absolutePath], looking first into
+ /// directories for generated files: `bazel-bin` and `bazel-genfiles`, and
+ /// then into the workspace root. The file in the workspace root is returned
+ /// even if it does not exist. Return `null` if the given [absolutePath] is
+ /// not in the workspace [root].
+ File? findFile(String absolutePath) {
+ path.Context context = provider.pathContext;
+ try {
+ String relative = context.relative(absolutePath, from: root);
+ if (relative == '.') {
+ return null;
+ }
+ // First check genfiles and bin directories. Note that we always use the
+ // symlinks and not the [binPaths] or [genfiles] to make sure we use the
+ // files corresponding to the most recent build configuration and get
+ // consistent view of all the generated files.
+ var generatedCandidates = [
+ '$symlinkPrefix-genfiles',
+ '$symlinkPrefix-bin'
+ ].map((prefix) => context.join(root, context.join(prefix, relative)));
+ for (var path in generatedCandidates) {
+ File file = provider.getFile(path);
+ if (file.exists) {
+ _blazeCandidateFiles
+ .add(BlazeSearchInfo(relative, generatedCandidates.toList()));
+ return file;
+ }
+ }
+ // Writable
+ File writableFile = provider.getFile(absolutePath);
+ if (writableFile.exists) {
+ return writableFile;
+ }
+ // READONLY
+ final readonly = this.readonly;
+ if (readonly != null) {
+ File file = provider.getFile(context.join(readonly, relative));
+ if (file.exists) {
+ return file;
+ }
+ }
+ // If we couldn't find the file, assume that it has not yet been
+ // generated, so send an event with all the paths that we tried.
+ _blazeCandidateFiles
+ .add(BlazeSearchInfo(relative, generatedCandidates.toList()));
+ // Not generated, return the default one.
+ return writableFile;
+ } catch (_) {
+ return null;
+ }
+ }
+
+ @override
+ BlazeWorkspacePackage? findPackageFor(String filePath) {
+ path.Context context = provider.pathContext;
+ var directoryPath = context.dirname(filePath);
+
+ var cachedPackage = _directoryToPackage[directoryPath];
+ if (cachedPackage != null) {
+ return cachedPackage;
+ }
+
+ if (!context.isWithin(root, directoryPath)) {
+ return null;
+ }
+
+ // Handle files which are given with their location in "bazel-bin", etc.
+ // This does not typically happen during usual analysis, but it still could,
+ // and it can come up in tests.
+ for (var binPath in [genfiles, ...binPaths]) {
+ if (context.isWithin(binPath, directoryPath)) {
+ return findPackageFor(
+ context.join(root, context.relative(filePath, from: binPath)));
+ }
+ }
+
+ /// Return the package rooted at [folder].
+ BlazeWorkspacePackage? packageRootedAt(Folder folder) {
+ var uriParts = (packageUriResolver as BlazePackageUriResolver)
+ ._restoreUriParts(root, '${folder.path}/lib/__fake__.dart');
+ String? packageName;
+ if (uriParts != null && uriParts.isNotEmpty) {
+ packageName = uriParts[0];
+ }
+ // TODO(srawlins): If [packageName] could not be derived from [uriParts],
+ // I imagine this should throw.
+ if (packageName == null) {
+ return null;
+ }
+ var package = BlazeWorkspacePackage(packageName, folder.path, this);
+ _directoryToPackage[directoryPath] = package;
+ return package;
+ }
+
+ var startFolder = provider.getFolder(directoryPath);
+ for (var folder in startFolder.withAncestors) {
+ if (folder.path.length < root.length) {
+ // We've walked up outside of [root], so [path] is definitely not
+ // defined in any package in this workspace.
+ return null;
+ }
+
+ if (folder.getChildAssumingFile(_buildFileName).exists) {
+ // Found the BUILD file, denoting a Dart package.
+ return packageRootedAt(folder);
+ }
+
+ if (_hasBuildFileSubstitute(folder)) {
+ return packageRootedAt(folder);
+ }
+ }
+
+ return null;
+ }
+
+ /// In some distributed build environments, BUILD files are not preserved.
+ /// We can still look for a ".packages" file in order to determine a
+ /// package's root. A ".packages" file found in [folder]'s sister path
+ /// under a "bin" path among [binPaths] denotes a Dart package.
+ ///
+ /// For example, if the [root] of this BazelWorkspace is
+ /// "/build/work/abc123/workspace" with two "bin" folders,
+ /// "/build/work/abc123/workspace/blaze-out/host/bin/" and
+ /// "/build/work/abc123/workspace/blaze-out/k8-opt/bin/", and [folder]
+ /// is at "/build/work/abc123/workspace/foo/bar", then we must look for a
+ /// file ending in ".packages" in the folders
+ /// "/build/work/abc123/workspace/blaze-out/host/bin/foo/bar" and
+ /// "/build/work/abc123/workspace/blaze-out/k8-opt/bin/foo/bar".
+ bool _hasBuildFileSubstitute(Folder folder) {
+ if (!_lookForBuildFileSubstitutes) {
+ return false;
+ }
+
+ path.Context context = provider.pathContext;
+
+ // [folder]'s path, relative to [root]. For example, "foo/bar".
+ String relative = context.relative(folder.path, from: root);
+
+ for (String bin in binPaths) {
+ Folder binChild =
+ provider.getFolder(context.normalize(context.join(bin, relative)));
+ if (binChild.exists &&
+ binChild.getChildren().any((c) => c.path.endsWith('.packages'))) {
+ // [folder]'s sister folder within [bin] contains a ".packages" file.
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ String? _relativeToRoot(String p) {
+ path.Context context = provider.pathContext;
+ // genfiles
+ if (context.isWithin(genfiles, p)) {
+ return context.relative(p, from: genfiles);
+ }
+ // bin
+ for (String bin in binPaths) {
+ if (context.isWithin(bin, p)) {
+ return context.relative(p, from: bin);
+ }
+ }
+ // READONLY
+ final readonly = this.readonly;
+ if (readonly != null) {
+ if (context.isWithin(readonly, p)) {
+ return context.relative(p, from: readonly);
+ }
+ }
+ // Not generated
+ if (context.isWithin(root, p)) {
+ return context.relative(p, from: root);
+ }
+ // Failed reverse lookup
+ return null;
+ }
+
+ /// Find the Bazel workspace that contains the given [filePath].
+ ///
+ /// This method walks up the file system from [filePath], looking for various
+ /// "marker" files which indicate a Bazel workspace.
+ ///
+ /// At each folder _f_ with parent _p_, starting with [filePath]:
+ ///
+ /// * If _f_ has a sibling folder named "READONLY", and that folder has a
+ /// child folder with the same name as _f_, then a BazelWorkspace rooted at
+ /// _f_ is returned.
+ /// * If _f_ has a child folder named "blaze-out" or "bazel-out", then a
+ /// BazelWorkspace rooted at _f_ is returned.
+ /// * If _f_ has a child file named "WORKSPACE", then a BazelWorkspace rooted
+ /// at _f_ is returned.
+ static BlazeWorkspace? find(
+ ResourceProvider provider,
+ String filePath, {
+ bool lookForBuildFileSubstitutes = true,
+ }) {
+ var context = provider.pathContext;
+ var startFolder = provider.getFolder(filePath);
+ for (var folder in startFolder.withAncestors) {
+ var parent = folder.parent;
+
+ // Found the READONLY folder, might be a git-based workspace.
+ Folder readonlyFolder = parent.getChildAssumingFolder(_READONLY);
+ if (readonlyFolder.exists) {
+ String root = folder.path;
+ String readonlyRoot =
+ context.join(readonlyFolder.path, folder.shortName);
+ if (provider.getFolder(readonlyRoot).exists) {
+ var binPaths = _findBinFolderPaths(folder);
+ String symlinkPrefix =
+ _findSymlinkPrefix(provider, root, binPaths: binPaths);
+ binPaths = binPaths..add(context.join(root, '$symlinkPrefix-bin'));
+ return BlazeWorkspace._(provider, root, symlinkPrefix, readonlyRoot,
+ binPaths, context.join(root, '$symlinkPrefix-genfiles'),
+ lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
+ }
+ }
+
+ if (_firstExistingFolder(parent, ['blaze-out', 'bazel-out']) != null) {
+ // Found the "out" folder; must be a bazel workspace.
+ String root = parent.path;
+ var binPaths = _findBinFolderPaths(parent);
+ String symlinkPrefix =
+ _findSymlinkPrefix(provider, root, binPaths: binPaths);
+ binPaths = binPaths..add(context.join(root, '$symlinkPrefix-bin'));
+ return BlazeWorkspace._(
+ provider,
+ root,
+ symlinkPrefix,
+ null /* readonly */,
+ binPaths,
+ context.join(root, '$symlinkPrefix-genfiles'),
+ lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
+ }
+
+ // Found the WORKSPACE file, must be a non-git workspace.
+ if (folder.getChildAssumingFile(_WORKSPACE).exists) {
+ String root = folder.path;
+ var binPaths = _findBinFolderPaths(folder);
+ String symlinkPrefix =
+ _findSymlinkPrefix(provider, root, binPaths: binPaths);
+ binPaths = binPaths..add(context.join(root, '$symlinkPrefix-bin'));
+ return BlazeWorkspace._(
+ provider,
+ root,
+ symlinkPrefix,
+ null /* readonly */,
+ binPaths,
+ context.join(root, '$symlinkPrefix-genfiles'),
+ lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
+ }
+ }
+
+ return null;
+ }
+
+ /// Find the "bin" folder path, by searching for it.
+ ///
+ /// Depending on the environment we're working in (source code tree, build
+ /// environment subtree of sources, local workspace, blaze, bazel), the "bin"
+ /// folder may be available at a symlink found at `$root/blaze-bin/` or
+ /// `$root/bazel-bin/`. If that symlink is not available, then we must search
+ /// the immediate folders found in `$root/blaze-out/` and `$root/bazel-out/`
+ /// for folders named "bin".
+ ///
+ /// If no "bin" folder is found in any of those locations, empty list is
+ /// returned.
+ static List<String> _findBinFolderPaths(Folder root) {
+ var out = _firstExistingFolder(root, ['blaze-out', 'bazel-out']);
+ if (out == null) {
+ return [];
+ }
+
+ List<String> binPaths = [];
+ for (var child in out.getChildren().whereType<Folder>()) {
+ // Children are folders denoting architectures and build flags, like
+ // 'k8-opt', 'k8-fastbuild', perhaps 'host'.
+ Folder possibleBin = child.getChildAssumingFolder('bin');
+ if (possibleBin.exists) {
+ binPaths.add(possibleBin.path);
+ }
+ }
+ return binPaths;
+ }
+
+ /// Return the symlink prefix, _X_, for folders `X-bin` or `X-genfiles`.
+ ///
+ /// If the workspace's "bin" folders were already found, the symlink prefix is
+ /// determined from one of the [binPaths]. Otherwise it is determined by
+ /// probing the internal `blaze-genfiles` and `bazel-genfiles`. Make a default
+ /// assumption according to [defaultSymlinkPrefix] if neither of the folders
+ /// exists.
+ static String _findSymlinkPrefix(ResourceProvider provider, String root,
+ {List<String>? binPaths}) {
+ path.Context context = provider.pathContext;
+ if (binPaths != null && binPaths.isNotEmpty) {
+ return context.basename(binPaths.first).startsWith('bazel')
+ ? 'bazel'
+ : 'blaze';
+ }
+ if (provider.getFolder(context.join(root, 'blaze-genfiles')).exists) {
+ return 'blaze';
+ }
+ if (provider.getFolder(context.join(root, 'bazel-genfiles')).exists) {
+ return 'bazel';
+ }
+ // Couldn't find it. Make a default assumption.
+ return defaultSymlinkPrefix;
+ }
+
+ /// Return the first folder within [root], chosen from [names], which exists.
+ static Folder? _firstExistingFolder(Folder root, List<String> names) => names
+ .map((name) => root.getChildAssumingFolder(name))
+ .firstWhereOrNull((folder) => folder.exists);
+
+ /// Return the default language version of the workspace.
+ ///
+ /// Return `null` if cannot be read, for example because the file does not
+ /// exist, or is not available in this build configuration (batch analysis).
+ static Version? _readLanguageVersion(
+ ResourceProvider resourceProvider,
+ String rootPath,
+ ) {
+ var file = resourceProvider.getFile(
+ resourceProvider.pathContext.joinAll(
+ [rootPath, 'dart', 'build_defs', 'bzl', 'language.bzl'],
+ ),
+ );
+
+ String content;
+ try {
+ content = file.readAsStringSync();
+ } on FileSystemException {
+ return null;
+ }
+
+ final pattern = RegExp(r'_version_null_safety\s*=\s*"(\d+\.\d+)"');
+ for (var match in pattern.allMatches(content)) {
+ return Version.parse('${match.group(1)}.0');
+ }
+
+ return null;
+ }
+}
+
+/// Information about a package defined in a BazelWorkspace.
+///
+/// Separate from [Packages] or package maps, this class is designed to simply
+/// understand whether arbitrary file paths represent libraries declared within
+/// a given package in a BazelWorkspace.
+class BlazeWorkspacePackage extends WorkspacePackage {
+ /// A prefix for any URI of a path in this package.
+ final String _uriPrefix;
+
+ @override
+ final String root;
+
+ @override
+ final BlazeWorkspace workspace;
+
+ bool _buildFileReady = false;
+ List<String>? _enabledExperiments;
+ Version? _languageVersion;
+
+ BlazeWorkspacePackage(String packageName, this.root, this.workspace)
+ : _uriPrefix = 'package:$packageName/';
+
+ @override
+ List<String>? get enabledExperiments {
+ _readBuildFile();
+ return _enabledExperiments;
+ }
+
+ @override
+ Version? get languageVersion {
+ _readBuildFile();
+ return _languageVersion ?? workspace._languageVersion;
+ }
+
+ @override
+ bool contains(Source source) {
+ var uri = source.uri;
+ if (uri.isScheme('package')) {
+ return uri.toString().startsWith(_uriPrefix);
+ }
+
+ var path = source.fullName;
+ return workspace.findPackageFor(path)?.root == root;
+ }
+
+ @override
+ // TODO(brianwilkerson) Implement this by looking in the BUILD file for 'deps'
+ // lists.
+ Packages packagesAvailableTo(String libraryPath) => Packages.empty;
+
+ @override
+ bool sourceIsInPublicApi(Source source) {
+ var filePath = filePathFromSource(source);
+ if (filePath == null) return false;
+
+ var libFolder = workspace.provider.pathContext.join(root, 'lib');
+ if (workspace.provider.pathContext.isWithin(libFolder, filePath)) {
+ // A file in "$root/lib" is public iff it is not in "$root/lib/src".
+ var libSrcFolder = workspace.provider.pathContext.join(libFolder, 'src');
+ return !workspace.provider.pathContext.isWithin(libSrcFolder, filePath);
+ }
+
+ var relativeRoot =
+ workspace.provider.pathContext.relative(root, from: workspace.root);
+ for (var binPath in workspace.binPaths) {
+ libFolder =
+ workspace.provider.pathContext.join(binPath, relativeRoot, 'lib');
+ if (workspace.provider.pathContext.isWithin(libFolder, filePath)) {
+ // A file in "$bin/lib" is public iff it is not in "$bin/lib/src".
+ var libSrcFolder =
+ workspace.provider.pathContext.join(libFolder, 'src');
+ return !workspace.provider.pathContext.isWithin(libSrcFolder, filePath);
+ }
+ }
+
+ libFolder = workspace.provider.pathContext
+ .join(workspace.genfiles, relativeRoot, 'lib');
+ if (workspace.provider.pathContext.isWithin(libFolder, filePath)) {
+ // A file in "$genfiles/lib" is public iff it is not in
+ // "$genfiles/lib/src".
+ var libSrcFolder = workspace.provider.pathContext.join(libFolder, 'src');
+ return !workspace.provider.pathContext.isWithin(libSrcFolder, filePath);
+ }
+
+ return false;
+ }
+
+ void _readBuildFile() {
+ if (_buildFileReady) {
+ return;
+ }
+
+ try {
+ _buildFileReady = true;
+ var buildContent = workspace.provider
+ .getFolder(root)
+ .getChildAssumingFile('BUILD')
+ .readAsStringSync();
+ var flattenedBuildContent = buildContent
+ .split('\n')
+ .map((e) => e.trim())
+ .where((e) => !e.startsWith('#'))
+ .map((e) => e.replaceAll(' ', ''))
+ .join();
+ var hasNonNullableFlag = const {
+ 'dart_package(null_safety=True',
+ 'dart_package(sound_null_safety=True',
+ }.any(flattenedBuildContent.contains);
+ if (hasNonNullableFlag) {
+ // Enabled by default.
+ } else {
+ _languageVersion = Version.parse('2.9.0');
+ }
+ } on FileSystemException {
+ // ignored
+ }
+ }
+}
diff --git a/pkg/analyzer/lib/src/workspace/bazel_watcher.dart b/pkg/analyzer/lib/src/workspace/blaze_watcher.dart
similarity index 83%
rename from pkg/analyzer/lib/src/workspace/bazel_watcher.dart
rename to pkg/analyzer/lib/src/workspace/blaze_watcher.dart
index b53019e..b489112 100644
--- a/pkg/analyzer/lib/src/workspace/bazel_watcher.dart
+++ b/pkg/analyzer/lib/src/workspace/blaze_watcher.dart
@@ -14,10 +14,10 @@
Future<void> _isolateMain(SendPort sendPort) async {
var fromMainIsolate = ReceivePort();
- var bazelIsolate = BazelFileWatcherIsolate(
+ var blazeIsolate = BlazeFileWatcherIsolate(
fromMainIsolate, sendPort, PhysicalResourceProvider.INSTANCE)
..start();
- await bazelIsolate.hasFinished;
+ await blazeIsolate.hasFinished;
}
/// Exposes the ability to poll for changes in generated files.
@@ -26,7 +26,7 @@
/// file might be located, but after the first time we actually find the file,
/// we can only focus on that particular path, since the files should be
/// consistently in the same place after rebuilds.
-class BazelFilePoller {
+class BlazeFilePoller {
/// The possible "candidate" paths that we watch.
final List<String> _candidates;
@@ -40,7 +40,7 @@
/// path.
String? _validPath;
- BazelFilePoller(this._provider, this._candidates);
+ BlazeFilePoller(this._provider, this._candidates);
/// Checks if the file corresponding to the watched path has changed and
/// returns the event or `null` if nothing changed.
@@ -109,7 +109,7 @@
_ModifiedInfo? _pollOne(String path) {
try {
// This might seem a bit convoluted but is necessary to deal with a
- // symlink to a directory (e.g., `bazel-bin`).
+ // symlink to a directory (e.g., `blaze-bin`).
var pathResource = _provider.getResource(path);
var symlinkTarget = pathResource.resolveSymbolicLinksSync().path;
@@ -135,11 +135,11 @@
/// The watcher implementation that runs in a separate isolate.
///
-/// It'll try to detect when Bazel finished running (through [PollTrigger] which
-/// usually will be [_BazelInvocationWatcher]) and then poll all the files to
+/// It'll try to detect when Blaze finished running (through [PollTrigger] which
+/// usually will be [_BlazeInvocationWatcher]) and then poll all the files to
/// find any changes, which will be sent to the main isolate as
-/// [BazelWatcherEvents].
-class BazelFileWatcherIsolate {
+/// [BlazeWatcherEvents].
+class BlazeFileWatcherIsolate {
final ReceivePort _fromMainIsolate;
final SendPort _toMainIsolate;
late final StreamSubscription _fromMainIsolateSubscription;
@@ -154,14 +154,14 @@
/// Resource provider used for polling.
///
- /// NB: The default [PollTrigger] (i.e., [_BazelInvocationWatcher]) uses
+ /// NB: The default [PollTrigger] (i.e., [_BlazeInvocationWatcher]) uses
/// `dart:io` directly. So for testing both [_provider] and
/// [_pollTriggerFactory] should be provided.
final ResourceProvider _provider;
final _hasFinished = Completer<void>();
- BazelFileWatcherIsolate(
+ BlazeFileWatcherIsolate(
this._fromMainIsolate, this._toMainIsolate, this._provider,
{PollTrigger Function(String)? pollTriggerFactory}) {
_pollTriggerFactory = pollTriggerFactory ?? _defaultPollTrigger;
@@ -170,7 +170,7 @@
Future<void> get hasFinished => _hasFinished.future;
void handleRequest(dynamic request) async {
- if (request is BazelWatcherStartWatching) {
+ if (request is BlazeWatcherStartWatching) {
var workspaceData = _perWorkspaceData[request.workspace];
if (workspaceData == null) {
var trigger = _pollTriggerFactory(request.workspace);
@@ -186,8 +186,8 @@
return;
}
workspaceData.pollers[requestedPath] =
- BazelFilePoller(_provider, request.info.candidatePaths)..start();
- } else if (request is BazelWatcherStopWatching) {
+ BlazeFilePoller(_provider, request.info.candidatePaths)..start();
+ } else if (request is BlazeWatcherStopWatching) {
var workspaceData = _perWorkspaceData[request.workspace];
if (workspaceData == null) return;
var count = workspaceData.watched.remove(request.requestedPath);
@@ -199,7 +199,7 @@
_perWorkspaceData.remove(request.workspace);
}
}
- } else if (request is BazelWatcherShutdownIsolate) {
+ } else if (request is BlazeWatcherShutdownIsolate) {
unawaited(_fromMainIsolateSubscription.cancel());
_fromMainIsolate.close();
for (var data in _perWorkspaceData.values) {
@@ -211,8 +211,8 @@
} else {
// We don't have access to the `InstrumentationService` so we send the
// message to the main isolate to log it.
- _toMainIsolate.send(BazelWatcherError(
- 'BazelFileWatcherIsolate got unexpected request: $request'));
+ _toMainIsolate.send(BlazeWatcherError(
+ 'BlazeFileWatcherIsolate got unexpected request: $request'));
}
}
@@ -228,14 +228,14 @@
}
/// Starts listening for messages from the main isolate and sends it
- /// [BazelWatcherIsolateStarted].
+ /// [BlazeWatcherIsolateStarted].
void start() {
_fromMainIsolateSubscription = _fromMainIsolate.listen(handleRequest);
- _toMainIsolate.send(BazelWatcherIsolateStarted(_fromMainIsolate.sendPort));
+ _toMainIsolate.send(BlazeWatcherIsolateStarted(_fromMainIsolate.sendPort));
}
PollTrigger _defaultPollTrigger(String workspacePath) =>
- _BazelInvocationWatcher(_provider, workspacePath);
+ _BlazeInvocationWatcher(_provider, workspacePath);
void _pollAllWatchers(String workspace) {
try {
@@ -245,7 +245,7 @@
if (event != null) events.add(event);
}
if (events.isNotEmpty) {
- _toMainIsolate.send(BazelWatcherEvents(events));
+ _toMainIsolate.send(BlazeWatcherEvents(events));
}
} on Exception catch (_) {
// This shouldn't really happen, but we shouldn't crash when polling
@@ -264,27 +264,27 @@
/// the requests until the isolate has started.
///
/// The isolate is started lazily on the first request to watch a path, so
-/// instantiating [BazelFileWatcherService] is very cheap.
+/// instantiating [BlazeFileWatcherService] is very cheap.
///
/// The protocol when communicating with the isolate:
-/// 1. The watcher isolate sends to the main one a [BazelWatcherIsolateStarted]
-/// and expects a [BazelWatcherInitializeIsolate] to be sent from the main
+/// 1. The watcher isolate sends to the main one a [BlazeWatcherIsolateStarted]
+/// and expects a [BlazeWatcherInitializeIsolate] to be sent from the main
/// isolate as a reply.
/// 2. The main isolate can request to start watching a file by sending
-/// [BazelWatcherStartWatching] request. There is no response expected.
-/// 3. The watcher isolate will send a [BazelWatcherEvents] notification when
+/// [BlazeWatcherStartWatching] request. There is no response expected.
+/// 3. The watcher isolate will send a [BlazeWatcherEvents] notification when
/// changes are detected. Again, no response from the main isolate is
/// expected.
-/// 4. The main isolate will send a [BazelWatcherShutdownIsolate] when the
+/// 4. The main isolate will send a [BlazeWatcherShutdownIsolate] when the
/// isolate is supposed to shut down. No more messages should be exchanged
/// afterwards.
-class BazelFileWatcherService {
+class BlazeFileWatcherService {
final InstrumentationService _instrumetation;
final _events = StreamController<List<WatchEvent>>.broadcast();
/// Buffers files to watch until the isolate is ready.
- final _buffer = <BazelWatcherMessage>[];
+ final _buffer = <BlazeWatcherMessage>[];
late final ReceivePort _fromIsolatePort;
late final SendPort _toIsolatePort;
@@ -296,7 +296,7 @@
/// True if the isolate is ready to watch files.
final _isolateHasStarted = Completer<void>();
- BazelFileWatcherService(this._instrumetation);
+ BlazeFileWatcherService(this._instrumetation);
Stream<List<WatchEvent>> get events => _events.stream;
@@ -305,7 +305,7 @@
/// isolate.
void shutdown() {
if (_isolateHasStarted.isCompleted) {
- _toIsolatePort.send(BazelWatcherShutdownIsolate());
+ _toIsolatePort.send(BlazeWatcherShutdownIsolate());
}
if (_isolateIsStarting) {
_fromIsolateSubscription.cancel();
@@ -314,10 +314,10 @@
_events.close();
}
- void startWatching(String workspace, BazelSearchInfo info) {
+ void startWatching(String workspace, BlazeSearchInfo info) {
assert(!_events.isClosed);
_startIsolateIfNeeded();
- var request = BazelWatcherStartWatching(workspace, info);
+ var request = BlazeWatcherStartWatching(workspace, info);
if (!_isolateHasStarted.isCompleted) {
_buffer.add(request);
} else {
@@ -327,7 +327,7 @@
void stopWatching(String workspace, String requestedPath) {
assert(!_events.isClosed);
- var request = BazelWatcherStopWatching(workspace, requestedPath);
+ var request = BlazeWatcherStopWatching(workspace, requestedPath);
if (!_isolateHasStarted.isCompleted) {
_buffer.add(request);
} else {
@@ -336,16 +336,16 @@
}
void _handleIsolateMessage(dynamic message) {
- if (message is BazelWatcherIsolateStarted) {
+ if (message is BlazeWatcherIsolateStarted) {
_toIsolatePort = message.sendPort;
_isolateHasStarted.complete();
- } else if (message is BazelWatcherEvents) {
+ } else if (message is BlazeWatcherEvents) {
_events.add(message.events);
- } else if (message is BazelWatcherError) {
+ } else if (message is BlazeWatcherError) {
_instrumetation.logError(message.message);
} else {
_instrumetation.logError(
- 'Received unexpected message from BazelFileWatcherIsolate: $message');
+ 'Received unexpected message from BlazeFileWatcherIsolate: $message');
}
}
@@ -367,53 +367,53 @@
}
}
-/// Notification that we issue when searching for generated files in a Bazel
+/// Notification that we issue when searching for generated files in a Blaze
/// workspace.
///
/// This allows clients to watch for changes to the generated files.
-class BazelSearchInfo {
+class BlazeSearchInfo {
/// Candidate paths that we searched.
final List<String> candidatePaths;
/// Absolute path that we tried searching for.
///
/// This is not necessarily the path of the actual file that will be used. See
- /// `BazelWorkspace.findFile` for details.
+ /// `BlazeWorkspace.findFile` for details.
final String requestedPath;
- BazelSearchInfo(this.requestedPath, this.candidatePaths);
+ BlazeSearchInfo(this.requestedPath, this.candidatePaths);
}
-class BazelWatcherError implements BazelWatcherMessage {
+class BlazeWatcherError implements BlazeWatcherMessage {
final String message;
- BazelWatcherError(this.message);
+ BlazeWatcherError(this.message);
}
-class BazelWatcherEvents implements BazelWatcherMessage {
+class BlazeWatcherEvents implements BlazeWatcherMessage {
final List<WatchEvent> events;
- BazelWatcherEvents(this.events);
+ BlazeWatcherEvents(this.events);
}
/// Sent by the watcher isolate to transfer the [SendPort] to the main isolate.
-class BazelWatcherIsolateStarted implements BazelWatcherMessage {
+class BlazeWatcherIsolateStarted implements BlazeWatcherMessage {
final SendPort sendPort;
- BazelWatcherIsolateStarted(this.sendPort);
+ BlazeWatcherIsolateStarted(this.sendPort);
}
-abstract class BazelWatcherMessage {}
+abstract class BlazeWatcherMessage {}
-class BazelWatcherShutdownIsolate implements BazelWatcherMessage {}
+class BlazeWatcherShutdownIsolate implements BlazeWatcherMessage {}
-class BazelWatcherStartWatching implements BazelWatcherMessage {
+class BlazeWatcherStartWatching implements BlazeWatcherMessage {
final String workspace;
- final BazelSearchInfo info;
- BazelWatcherStartWatching(this.workspace, this.info);
+ final BlazeSearchInfo info;
+ BlazeWatcherStartWatching(this.workspace, this.info);
}
-class BazelWatcherStopWatching implements BazelWatcherMessage {
+class BlazeWatcherStopWatching implements BlazeWatcherMessage {
final String workspace;
final String requestedPath;
- BazelWatcherStopWatching(this.workspace, this.requestedPath);
+ BlazeWatcherStopWatching(this.workspace, this.requestedPath);
}
class FileInfo {
@@ -428,15 +428,15 @@
void cancel();
}
-/// Watches for finished Bazel invocations.
+/// Watches for finished Blaze invocations.
///
-/// The idea here is to detect when Bazel finished running and use that to
-/// trigger polling. To detect that we use the `command.log` file that bazel
+/// The idea here is to detect when Blaze finished running and use that to
+/// trigger polling. To detect that we use the `command.log` file that Blaze
/// continuously updates as the build progresses. We find that file based on [1]:
///
-/// - In the workspace directory there should be a `bazel-out` symlink whose
+/// - In the workspace directory there should be a `blaze-out` symlink whose
/// target should be of the form:
-/// `[...]/<hash of workspace>/execroot/<workspace name>/bazel-out`
+/// `[...]/<hash of workspace>/execroot/<workspace name>/blaze-out`
/// - The file should be in `[...]/<hash of workspace>/command.log`.
///
/// In other words, we need to get the target of the symlink and then trim three
@@ -446,7 +446,7 @@
///
/// NB: We're not using a [ResourceProvider] because it doesn't support finding a
/// target of a symlink.
-class _BazelInvocationWatcher implements PollTrigger {
+class _BlazeInvocationWatcher implements PollTrigger {
/// Determines how often do we check for `command.log` changes.
///
/// Note that on some systems the granularity is about 1s, so let's set this
@@ -465,10 +465,10 @@
final ResourceProvider _provider;
final String _workspacePath;
late final Timer _timer;
- BazelFilePoller? _poller;
+ BlazeFilePoller? _poller;
String? _commandLogPath;
- _BazelInvocationWatcher(this._provider, this._workspacePath) {
+ _BlazeInvocationWatcher(this._provider, this._workspacePath) {
_timer = Timer.periodic(_pollInterval, _poll);
}
@@ -509,7 +509,7 @@
_commandLogPath ??= await _getCommandLogPath();
if (_commandLogPath == null) return;
- _poller ??= BazelFilePoller(_provider, [_commandLogPath!]);
+ _poller ??= BlazeFilePoller(_provider, [_commandLogPath!]);
var event = _poller!.poll();
if (event == null) return;
@@ -529,7 +529,7 @@
/// Data used to determines if a file has changed.
///
/// This turns out to be important for tracking files that change a lot, like
-/// the `command.log` that we use to detect the finished build. Bazel writes to
+/// the `command.log` that we use to detect the finished build. Blaze writes to
/// the file continuously and because the resolution of a timestamp is pretty
/// low, it's quite possible to receive the same timestamp even though the file
/// has changed. We use its length to remedy that. It's not perfect (for that
@@ -589,8 +589,8 @@
}
class _PerWorkspaceData {
- /// For each requested file stores the corresponding [BazelFilePoller].
- final pollers = <String, BazelFilePoller>{};
+ /// For each requested file stores the corresponding [BlazeFilePoller].
+ final pollers = <String, BlazeFilePoller>{};
/// Keeps count of the number of requests to watch a file, so that we can stop
/// watching when we reach 0 clients.
diff --git a/pkg/analyzer/lib/src/workspace/workspace.dart b/pkg/analyzer/lib/src/workspace/workspace.dart
index b872e4e..1b47d0c 100644
--- a/pkg/analyzer/lib/src/workspace/workspace.dart
+++ b/pkg/analyzer/lib/src/workspace/workspace.dart
@@ -7,15 +7,15 @@
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/summary/api_signature.dart';
import 'package:analyzer/src/summary/package_bundle_reader.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
import 'package:meta/meta.dart';
import 'package:pub_semver/pub_semver.dart';
/// Abstract superclass of classes that provide information about the workspace
/// in which analysis is being performed.
abstract class Workspace {
- /// Return true iff this [Workspace] is a [BazelWorkspace].
- bool get isBazel => false;
+ /// Return true iff this [Workspace] is a [BlazeWorkspace].
+ bool get isBlaze => false;
/// Return `true` if the read state of configuration files is consistent
/// with their current state on the file system.
diff --git a/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart b/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart
index 419816c..965db20 100644
--- a/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart
@@ -18,7 +18,7 @@
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
import 'package:analyzer/src/workspace/basic.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
import 'package:analyzer/src/workspace/pub.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -167,21 +167,21 @@
expect(context.sdkRoot, sdkRoot);
}
- void test_sourceFactory_bazelWorkspace() {
+ void test_sourceFactory_blazeWorkspace() {
var projectPath = convertPath('/workspace/my/module');
newFile('/workspace/WORKSPACE', '');
newFolder('/workspace/bazel-bin');
newFolder('/workspace/bazel-genfiles');
var analysisContext = _createSingleAnalysisContext(projectPath);
- expect(analysisContext.contextRoot.workspace, isA<BazelWorkspace>());
+ expect(analysisContext.contextRoot.workspace, isA<BlazeWorkspace>());
expect(
analysisContext.uriResolvers,
unorderedEquals([
isA<DartUriResolver>(),
- isA<BazelPackageUriResolver>(),
- isA<BazelFileUriResolver>(),
+ isA<BlazePackageUriResolver>(),
+ isA<BlazeFileUriResolver>(),
]),
);
}
diff --git a/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart b/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart
index 70b8c34..ac31f59 100644
--- a/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart
@@ -8,7 +8,7 @@
import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
import 'package:analyzer/src/workspace/basic.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
import 'package:analyzer/src/workspace/pub.dart';
import 'package:analyzer/src/workspace/workspace.dart';
import 'package:test/test.dart';
@@ -291,10 +291,10 @@
}
void
- test_locateRoots_multiple_dirAndNestedDir_outerIsBazel_innerConfigurationFiles() {
+ test_locateRoots_multiple_dirAndNestedDir_outerIsBlaze_innerConfigurationFiles() {
var outerRootFolder = newFolder('/outer');
newFile('$outerRootFolder/WORKSPACE', '');
- newBazelBuildFile('$outerRootFolder', '');
+ newBlazeBuildFile('$outerRootFolder', '');
var innerRootFolder = newFolder('/outer/examples/inner');
var innerOptionsFile = newAnalysisOptionsYamlFile('$innerRootFolder', '');
var innerPackagesFile = newPackageConfigJsonFile('$innerRootFolder', '');
@@ -475,7 +475,7 @@
expect(outer2Root.packagesFile, isNull);
}
- void test_locateRoots_multiple_dirs_bazel_differentWorkspaces() {
+ void test_locateRoots_multiple_dirs_blaze_differentWorkspaces() {
var workspacePath1 = '/home/workspace1';
var workspacePath2 = '/home/workspace2';
var pkgPath1 = '$workspacePath1/pkg1';
@@ -483,8 +483,8 @@
newFile('$workspacePath1/WORKSPACE', '');
newFile('$workspacePath2/WORKSPACE', '');
- newBazelBuildFile(pkgPath1, '');
- newBazelBuildFile(pkgPath2, '');
+ newBlazeBuildFile(pkgPath1, '');
+ newBlazeBuildFile(pkgPath2, '');
var folder1 = newFolder('$pkgPath1/lib/folder1');
var folder2 = newFolder('$pkgPath2/lib/folder2');
@@ -501,7 +501,7 @@
expect(root1.excludedPaths, isEmpty);
expect(root1.optionsFile, isNull);
expect(root1.packagesFile, isNull);
- _assertBazelWorkspace(root1.workspace, workspacePath1);
+ _assertBlazeWorkspace(root1.workspace, workspacePath1);
_assertAnalyzedFiles2(root1, [file1]);
var root2 = findRoot(roots, getFolder(folder2.path));
@@ -509,7 +509,7 @@
expect(root2.excludedPaths, isEmpty);
expect(root2.optionsFile, isNull);
expect(root2.packagesFile, isNull);
- _assertBazelWorkspace(root2.workspace, workspacePath2);
+ _assertBlazeWorkspace(root2.workspace, workspacePath2);
_assertAnalyzedFiles2(root2, [file2]);
}
@@ -668,7 +668,7 @@
_assertAnalyzedFiles2(root, [testFile1, testFile2]);
}
- void test_locateRoots_multiple_files_bazel_differentWorkspaces() {
+ void test_locateRoots_multiple_files_blaze_differentWorkspaces() {
var workspacePath1 = '/home/workspace1';
var workspacePath2 = '/home/workspace2';
var pkgPath1 = '$workspacePath1/pkg1';
@@ -676,8 +676,8 @@
newFile('$workspacePath1/WORKSPACE', '');
newFile('$workspacePath2/WORKSPACE', '');
- newBazelBuildFile(pkgPath1, '');
- newBazelBuildFile(pkgPath2, '');
+ newBlazeBuildFile(pkgPath1, '');
+ newBlazeBuildFile(pkgPath2, '');
var file1 = newFile('$pkgPath1/lib/file1.dart', '');
var file2 = newFile('$pkgPath2/lib/file2.dart', '');
@@ -692,7 +692,7 @@
expect(root1.excludedPaths, isEmpty);
expect(root1.optionsFile, isNull);
expect(root1.packagesFile, isNull);
- _assertBazelWorkspace(root1.workspace, workspacePath1);
+ _assertBlazeWorkspace(root1.workspace, workspacePath1);
_assertAnalyzedFiles2(root1, [file1]);
var root2 = findRoot(roots, getFolder(workspacePath2));
@@ -700,18 +700,18 @@
expect(root2.excludedPaths, isEmpty);
expect(root2.optionsFile, isNull);
expect(root2.packagesFile, isNull);
- _assertBazelWorkspace(root2.workspace, workspacePath2);
+ _assertBlazeWorkspace(root2.workspace, workspacePath2);
_assertAnalyzedFiles2(root2, [file2]);
}
- void test_locateRoots_multiple_files_bazel_sameWorkspace_differentPackages() {
+ void test_locateRoots_multiple_files_blaze_sameWorkspace_differentPackages() {
var workspacePath = '/home/workspace';
var fooPath = '$workspacePath/foo';
var barPath = '$workspacePath/bar';
newFile('$workspacePath/WORKSPACE', '');
- newBazelBuildFile(fooPath, '');
- newBazelBuildFile(barPath, '');
+ newBlazeBuildFile(fooPath, '');
+ newBlazeBuildFile(barPath, '');
var fooFile = newFile('$fooPath/lib/foo.dart', '');
var barFile = newFile('$barPath/lib/bar.dart', '');
@@ -726,7 +726,7 @@
expect(root.excludedPaths, isEmpty);
expect(root.optionsFile, isNull);
expect(root.packagesFile, isNull);
- _assertBazelWorkspace(root.workspace, workspacePath);
+ _assertBlazeWorkspace(root.workspace, workspacePath);
_assertAnalyzedFiles2(root, [fooFile, barFile]);
}
@@ -1130,7 +1130,7 @@
expect(outerRoot.packagesFile, outerPackagesFile);
}
- void test_locateRoots_options_default_bazel() {
+ void test_locateRoots_options_default_blaze() {
var workspacePath = '/home/workspace';
var workspaceFolder = getFolder(workspacePath);
newFile('$workspacePath/WORKSPACE', '');
@@ -1550,8 +1550,8 @@
expect(workspace.root, root);
}
- void _assertBazelWorkspace(Workspace workspace, String posixRoot) {
- workspace as BazelWorkspace;
+ void _assertBlazeWorkspace(Workspace workspace, String posixRoot) {
+ workspace as BlazeWorkspace;
var root = convertPath(posixRoot);
expect(workspace.root, root);
}
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 471ae13..522fc5d 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -37,7 +37,7 @@
defineReflectiveTests(AnalysisDriverSchedulerTest);
defineReflectiveTests(AnalysisDriverTest);
defineReflectiveTests(AnalysisDriver_PubPackageTest);
- defineReflectiveTests(AnalysisDriver_BazelWorkspaceTest);
+ defineReflectiveTests(AnalysisDriver_BlazeWorkspaceTest);
});
}
@@ -54,7 +54,7 @@
}
@reflectiveTest
-class AnalysisDriver_BazelWorkspaceTest extends BazelWorkspaceResolutionTest {
+class AnalysisDriver_BlazeWorkspaceTest extends BlazeWorkspaceResolutionTest {
void test_nestedLib_notCanonicalUri() async {
var outerLibPath = '$workspaceRootPath/my/outer/lib';
diff --git a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
index e55fc00..2248d58 100644
--- a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
@@ -30,14 +30,14 @@
main() {
defineReflectiveSuite(() {
defineReflectiveTests(FileSystemStateTest);
- defineReflectiveTests(FileSystemState_BazelWorkspaceTest);
+ defineReflectiveTests(FileSystemState_BlazeWorkspaceTest);
defineReflectiveTests(FileSystemState_PubPackageTest);
defineReflectiveTests(UpdateNodeTextExpectations);
});
}
@reflectiveTest
-class FileSystemState_BazelWorkspaceTest extends BazelWorkspaceResolutionTest {
+class FileSystemState_BlazeWorkspaceTest extends BlazeWorkspaceResolutionTest {
void test_getFileForUri_hasGenerated_askGeneratedFirst() async {
var relPath = 'dart/my/test/a.dart';
var writablePath = convertPath('$workspaceRootPath/$relPath');
diff --git a/pkg/analyzer/test/src/dart/analysis/session_test.dart b/pkg/analyzer/test/src/dart/analysis/session_test.dart
index c5a53f2..68f3f4e 100644
--- a/pkg/analyzer/test/src/dart/analysis/session_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/session_test.dart
@@ -14,13 +14,13 @@
main() {
defineReflectiveSuite(() {
defineReflectiveTests(AnalysisSessionImplTest);
- defineReflectiveTests(AnalysisSessionImpl_BazelWorkspaceTest);
+ defineReflectiveTests(AnalysisSessionImpl_BlazeWorkspaceTest);
});
}
@reflectiveTest
-class AnalysisSessionImpl_BazelWorkspaceTest
- extends BazelWorkspaceResolutionTest {
+class AnalysisSessionImpl_BlazeWorkspaceTest
+ extends BlazeWorkspaceResolutionTest {
void test_getErrors_notFileOfUri() async {
var relPath = 'dart/my/lib/a.dart';
newFile('$workspaceRootPath/bazel-bin/$relPath', '');
diff --git a/pkg/analyzer/test/src/dart/micro/file_resolution.dart b/pkg/analyzer/test/src/dart/micro/file_resolution.dart
index f02a94e..0e2170f 100644
--- a/pkg/analyzer/test/src/dart/micro/file_resolution.dart
+++ b/pkg/analyzer/test/src/dart/micro/file_resolution.dart
@@ -17,7 +17,7 @@
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
import 'package:analyzer/src/util/performance/operation_performance.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
import 'package:crypto/crypto.dart';
import 'package:linter/src/rules.dart';
import 'package:test/test.dart';
@@ -88,7 +88,7 @@
///
/// We do this the first time, and to test reusing results from [byteStore].
void createFileResolver() {
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider,
testFile.path,
)!;
diff --git a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
index 28777a2..a324e97 100644
--- a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
@@ -21,7 +21,7 @@
import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
import 'package:analyzer/src/workspace/basic.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
import 'package:analyzer/src/workspace/gn.dart';
import 'package:analyzer/src/workspace/package_build.dart';
import 'package:analyzer/src/workspace/pub.dart';
@@ -89,7 +89,7 @@
}
}
-class BazelWorkspaceResolutionTest extends ContextResolutionTest {
+class BlazeWorkspaceResolutionTest extends ContextResolutionTest {
@override
List<String> get collectionIncludedPaths => [workspaceRootPath];
@@ -116,7 +116,7 @@
@override
void verifyCreatedCollection() {
super.verifyCreatedCollection();
- assertBazelWorkspaceFor(testFile);
+ assertBlazeWorkspaceFor(testFile);
}
}
@@ -163,9 +163,9 @@
expect(workspace, TypeMatcher<BasicWorkspace>());
}
- void assertBazelWorkspaceFor(File file) {
+ void assertBlazeWorkspaceFor(File file) {
var workspace = contextFor(file).contextRoot.workspace;
- expect(workspace, TypeMatcher<BazelWorkspace>());
+ expect(workspace, TypeMatcher<BlazeWorkspace>());
}
void assertDriverStateString(
diff --git a/pkg/analyzer/test/src/dart/resolution/non_nullable_bazel_workspace_test.dart b/pkg/analyzer/test/src/dart/resolution/non_nullable_blaze_workspace_test.dart
similarity index 96%
rename from pkg/analyzer/test/src/dart/resolution/non_nullable_bazel_workspace_test.dart
rename to pkg/analyzer/test/src/dart/resolution/non_nullable_blaze_workspace_test.dart
index ce660c5..1079f3f 100644
--- a/pkg/analyzer/test/src/dart/resolution/non_nullable_bazel_workspace_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/non_nullable_blaze_workspace_test.dart
@@ -11,12 +11,12 @@
main() {
defineReflectiveSuite(() {
- defineReflectiveTests(NonNullableBazelWorkspaceTest);
+ defineReflectiveTests(NonNullableBlazeWorkspaceTest);
});
}
@reflectiveTest
-class NonNullableBazelWorkspaceTest extends BazelWorkspaceResolutionTest {
+class NonNullableBlazeWorkspaceTest extends BlazeWorkspaceResolutionTest {
@override
bool get isNullSafetyEnabled => true;
diff --git a/pkg/analyzer/test/src/dart/resolution/test_all.dart b/pkg/analyzer/test/src/dart/resolution/test_all.dart
index f070c0e..40dceb6 100644
--- a/pkg/analyzer/test/src/dart/resolution/test_all.dart
+++ b/pkg/analyzer/test/src/dart/resolution/test_all.dart
@@ -53,7 +53,7 @@
import 'mixin_test.dart' as mixin_resolution;
import 'namespace_test.dart' as namespace;
import 'node_text_expectations.dart';
-import 'non_nullable_bazel_workspace_test.dart' as non_nullable_bazel_workspace;
+import 'non_nullable_blaze_workspace_test.dart' as non_nullable_blaze_workspace;
import 'non_nullable_test.dart' as non_nullable;
import 'optional_const_test.dart' as optional_const;
import 'part_test.dart' as part_;
@@ -120,7 +120,7 @@
method_invocation.main();
mixin_resolution.main();
namespace.main();
- non_nullable_bazel_workspace.main();
+ non_nullable_blaze_workspace.main();
non_nullable.main();
optional_const.main();
part_.main();
diff --git a/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart b/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
index 61e6d02..ef0cb73 100644
--- a/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
@@ -14,7 +14,7 @@
defineReflectiveTests(
DeprecatedMemberUse_BasicWorkspace_WithoutNullSafetyTest,
);
- defineReflectiveTests(DeprecatedMemberUse_BazelWorkspaceTest);
+ defineReflectiveTests(DeprecatedMemberUse_BlazeWorkspaceTest);
defineReflectiveTests(DeprecatedMemberUse_GnWorkspaceTest);
defineReflectiveTests(DeprecatedMemberUse_PackageBuildWorkspaceTest);
@@ -22,7 +22,7 @@
DeprecatedMemberUseFromSamePackage_BasicWorkspaceTest,
);
defineReflectiveTests(
- DeprecatedMemberUseFromSamePackage_BazelWorkspaceTest,
+ DeprecatedMemberUseFromSamePackage_BlazeWorkspaceTest,
);
defineReflectiveTests(
DeprecatedMemberUseFromSamePackage_PackageBuildWorkspaceTest,
@@ -330,8 +330,8 @@
}
@reflectiveTest
-class DeprecatedMemberUse_BazelWorkspaceTest
- extends BazelWorkspaceResolutionTest {
+class DeprecatedMemberUse_BlazeWorkspaceTest
+ extends BlazeWorkspaceResolutionTest {
test_dart() async {
newFile('$workspaceRootPath/foo/bar/lib/a.dart', r'''
@deprecated
@@ -353,7 +353,7 @@
class A {}
''');
- assertBazelWorkspaceFor(testFile);
+ assertBlazeWorkspaceFor(testFile);
await assertErrorsInCode(r'''
import 'package:aaa/a.dart';
@@ -1557,8 +1557,8 @@
}
@reflectiveTest
-class DeprecatedMemberUseFromSamePackage_BazelWorkspaceTest
- extends BazelWorkspaceResolutionTest {
+class DeprecatedMemberUseFromSamePackage_BlazeWorkspaceTest
+ extends BlazeWorkspaceResolutionTest {
test_it() async {
newFile('$myPackageLibPath/a.dart', r'''
@deprecated
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart
index 1437172..0f0dabb 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart
@@ -10,7 +10,7 @@
main() {
defineReflectiveSuite(() {
- defineReflectiveTests(InvalidExportOfInternalElement_BazelPackageTest);
+ defineReflectiveTests(InvalidExportOfInternalElement_BlazePackageTest);
defineReflectiveTests(
InvalidExportOfInternalElement_PackageBuildPackageTest);
defineReflectiveTests(InvalidExportOfInternalElement_PubPackageTest);
@@ -18,10 +18,10 @@
}
@reflectiveTest
-class InvalidExportOfInternalElement_BazelPackageTest
- extends BazelWorkspaceResolutionTest
+class InvalidExportOfInternalElement_BlazePackageTest
+ extends BlazeWorkspaceResolutionTest
with InvalidExportOfInternalElementTest {
- String get testPackageBazelBinPath => '$workspaceRootPath/bazel-bin/dart/my';
+ String get testPackageBlazeBinPath => '$workspaceRootPath/bazel-bin/dart/my';
String get testPackageGenfilesPath =>
'$workspaceRootPath/bazel-genfiles/dart/my';
@@ -36,17 +36,17 @@
MockPackages.addMetaPackageFiles(
getFolder(metaPath),
);
- newFile('$testPackageBazelBinPath/my.packages', '');
+ newFile('$testPackageBlazeBinPath/my.packages', '');
newFolder('$workspaceRootPath/bazel-out');
}
- void test_exporterIsInBazelBinLib() async {
+ void test_exporterIsInBlazeBinLib() async {
newFile(testPackageImplementationFilePath, r'''
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFileCode('$testPackageBazelBinPath/lib/bar.dart', r'''
+ await resolveFileCode('$testPackageBlazeBinPath/lib/bar.dart', r'''
export 'src/foo.dart';
''');
@@ -55,13 +55,13 @@
]);
}
- void test_exporterIsInBazelBinLibSrc() async {
+ void test_exporterIsInBlazeBinLibSrc() async {
newFile(testPackageImplementationFilePath, r'''
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFileCode('$testPackageBazelBinPath/lib/src/bar.dart', r'''
+ await resolveFileCode('$testPackageBlazeBinPath/lib/src/bar.dart', r'''
export 'foo.dart';
''');
@@ -137,8 +137,8 @@
assertNoErrorsInResult();
}
- void test_internalIsInBazelBin() async {
- newFile('$testPackageBazelBinPath/lib/src/foo.dart', r'''
+ void test_internalIsInBlazeBin() async {
+ newFile('$testPackageBlazeBinPath/lib/src/foo.dart', r'''
import 'package:meta/meta.dart';
@internal class One {}
''');
diff --git a/pkg/analyzer/test/src/workspace/basic_test.dart b/pkg/analyzer/test/src/workspace/basic_test.dart
index 3392a96..b89d35a 100644
--- a/pkg/analyzer/test/src/workspace/basic_test.dart
+++ b/pkg/analyzer/test/src/workspace/basic_test.dart
@@ -41,7 +41,7 @@
}),
convertPath('/workspace'),
);
- expect(workspace.isBazel, isFalse);
+ expect(workspace.isBlaze, isFalse);
}
void test_contains_differentWorkspace() {
@@ -109,7 +109,7 @@
BasicWorkspace workspace = BasicWorkspace.find(
resourceProvider, Packages.empty, convertPath('/workspace'));
expect(workspace.root, convertPath('/workspace'));
- expect(workspace.isBazel, isFalse);
+ expect(workspace.isBlaze, isFalse);
}
void test_find_fail_notAbsolute() {
@@ -123,6 +123,6 @@
BasicWorkspace workspace = BasicWorkspace.find(resourceProvider,
Packages.empty, convertPath('/workspace/project/lib/lib1.dart'));
expect(workspace.root, convertPath('/workspace/project/lib'));
- expect(workspace.isBazel, isFalse);
+ expect(workspace.isBlaze, isFalse);
}
}
diff --git a/pkg/analyzer/test/src/workspace/bazel_test.dart b/pkg/analyzer/test/src/workspace/blaze_test.dart
similarity index 93%
rename from pkg/analyzer/test/src/workspace/bazel_test.dart
rename to pkg/analyzer/test/src/workspace/blaze_test.dart
index 784c9b8..abc3f90 100644
--- a/pkg/analyzer/test/src/workspace/bazel_test.dart
+++ b/pkg/analyzer/test/src/workspace/blaze_test.dart
@@ -6,7 +6,7 @@
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/summary/package_bundle_reader.dart';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
import 'package:async/async.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -15,19 +15,19 @@
main() {
defineReflectiveSuite(() {
- defineReflectiveTests(BazelFileUriResolverTest);
- defineReflectiveTests(BazelPackageUriResolverTest);
- defineReflectiveTests(BazelWorkspaceTest);
- defineReflectiveTests(BazelWorkspacePackageTest);
+ defineReflectiveTests(BlazeFileUriResolverTest);
+ defineReflectiveTests(BlazePackageUriResolverTest);
+ defineReflectiveTests(BlazeWorkspaceTest);
+ defineReflectiveTests(BlazeWorkspacePackageTest);
});
}
@reflectiveTest
-class BazelFileUriResolverTest with ResourceProviderMixin {
- late final BazelWorkspace workspace;
- late final BazelFileUriResolver resolver;
+class BlazeFileUriResolverTest with ResourceProviderMixin {
+ late final BlazeWorkspace workspace;
+ late final BlazeFileUriResolver resolver;
- void test_resolveAbsolute_bazelBin_exists() {
+ void test_resolveAbsolute_blazeBin_exists() {
_addResources([
'/workspace/WORKSPACE',
'/workspace/bazel-bin/my/test/a.dart',
@@ -81,7 +81,7 @@
);
}
- void test_resolveAbsolute_writableUri_bazelBin_hasWritable() {
+ void test_resolveAbsolute_writableUri_blazeBin_hasWritable() {
_addResources([
'/workspace/WORKSPACE',
'/workspace/my/test/a.dart',
@@ -93,7 +93,7 @@
);
}
- void test_resolveAbsolute_writableUri_bazelBin_noWritable() {
+ void test_resolveAbsolute_writableUri_blazeBin_noWritable() {
_addResources([
'/workspace/WORKSPACE',
'/workspace/bazel-bin/my/test/a.dart',
@@ -104,7 +104,7 @@
);
}
- void test_resolveAbsolute_writableUri_bazelGenfiles_hasWritable() {
+ void test_resolveAbsolute_writableUri_blazeGenfiles_hasWritable() {
_addResources([
'/workspace/WORKSPACE',
'/workspace/my/test/a.dart',
@@ -116,7 +116,7 @@
);
}
- void test_resolveAbsolute_writableUri_bazelGenfiles_noWritable() {
+ void test_resolveAbsolute_writableUri_blazeGenfiles_noWritable() {
_addResources([
'/workspace/WORKSPACE',
'/workspace/bazel-genfiles/my/test/a.dart',
@@ -157,11 +157,11 @@
newFile(path, '');
}
}
- workspace = BazelWorkspace.find(
+ workspace = BlazeWorkspace.find(
resourceProvider,
getFolder('/workspace').path,
)!;
- resolver = BazelFileUriResolver(workspace);
+ resolver = BlazeFileUriResolver(workspace);
}
void _assertResolve(
@@ -184,9 +184,9 @@
}
@reflectiveTest
-class BazelPackageUriResolverTest with ResourceProviderMixin {
- late final BazelWorkspace workspace;
- late final BazelPackageUriResolver resolver;
+class BlazePackageUriResolverTest with ResourceProviderMixin {
+ late final BlazeWorkspace workspace;
+ late final BlazePackageUriResolver resolver;
void test_resolveAbsolute_bin() {
_addResources([
@@ -652,8 +652,8 @@
}
}
workspace =
- BazelWorkspace.find(resourceProvider, convertPath(workspacePath))!;
- resolver = BazelPackageUriResolver(workspace);
+ BlazeWorkspace.find(resourceProvider, convertPath(workspacePath))!;
+ resolver = BlazePackageUriResolver(workspace);
}
void _assertNoResolve(String uriStr) {
@@ -683,9 +683,9 @@
}
@reflectiveTest
-class BazelWorkspacePackageTest with ResourceProviderMixin {
- late final BazelWorkspace workspace;
- BazelWorkspacePackage? package;
+class BlazeWorkspacePackageTest with ResourceProviderMixin {
+ late final BlazeWorkspace workspace;
+ BlazeWorkspacePackage? package;
void test_contains_differentPackage_summarySource() {
_setUpPackage();
@@ -767,7 +767,7 @@
'/ws/blaze-out/host/bin/some/code/code.dart',
'/ws/blaze-bin/some/code/code.dart',
]);
- workspace = BazelWorkspace.find(
+ workspace = BlazeWorkspace.find(
resourceProvider,
convertPath('/ws/some/code/testing'),
)!;
@@ -786,7 +786,7 @@
convertPath('/ws/blaze-out/k8-opt/bin/news/lib/news_base.pb.dart');
newFile('/ws/news/BUILD', '');
newFile(path, '');
- workspace = BazelWorkspace.find(resourceProvider, path)!;
+ workspace = BlazeWorkspace.find(resourceProvider, path)!;
var package = workspace.findPackageFor(path);
expect(package, isNull);
@@ -797,7 +797,7 @@
'/ws/WORKSPACE',
'/ws/bazel-genfiles',
]);
- workspace = BazelWorkspace.find(
+ workspace = BlazeWorkspace.find(
resourceProvider,
convertPath('/ws/some/code'),
)!;
@@ -812,7 +812,7 @@
'/ws/blaze-out/host/bin/some/code/code.packages',
'/ws/some/code/lib/code.dart',
]);
- workspace = BazelWorkspace.find(
+ workspace = BlazeWorkspace.find(
resourceProvider,
convertPath('/ws/some/code'),
lookForBuildFileSubstitutes: false,
@@ -830,7 +830,7 @@
'/ws/blaze-out/k8-opt/bin/some/code/',
'/ws/some/code/lib/code.dart',
]);
- workspace = BazelWorkspace.find(
+ workspace = BlazeWorkspace.find(
resourceProvider,
convertPath('/ws/some/code'),
)!;
@@ -848,7 +848,7 @@
'/ws/blaze-out/host/bin/some/code/code.packages',
'/ws/some/code/lib/code.dart',
]);
- workspace = BazelWorkspace.find(
+ workspace = BlazeWorkspace.find(
resourceProvider,
convertPath('/ws/some/code'),
)!;
@@ -868,7 +868,7 @@
'/ws/some/code/lib/code.dart',
'/ws/some/code/testing/lib/testing.dart',
]);
- workspace = BazelWorkspace.find(
+ workspace = BlazeWorkspace.find(
resourceProvider,
convertPath('/ws/some/code/testing'),
)!;
@@ -916,7 +916,7 @@
'/ws/some/code/lib/code.dart',
]);
- workspace = BazelWorkspace.find(
+ workspace = BlazeWorkspace.find(
resourceProvider,
convertPath('/ws/some/code'),
)!;
@@ -932,17 +932,17 @@
}
@reflectiveTest
-class BazelWorkspaceTest with ResourceProviderMixin {
- late final BazelWorkspace workspace;
+class BlazeWorkspaceTest with ResourceProviderMixin {
+ late final BlazeWorkspace workspace;
- void test_bazelNotifications() async {
+ void test_blazeNotifications() async {
_addResources([
'/workspace/WORKSPACE',
'/workspace/bazel-bin/my/module/test1.dart',
]);
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
- var notifications = StreamQueue(workspace.bazelCandidateFiles);
+ var notifications = StreamQueue(workspace.blazeCandidateFiles);
var file1 =
workspace.findFile(convertPath('/workspace/my/module/test1.dart'))!;
@@ -972,7 +972,7 @@
void test_find_fail_notAbsolute() {
expect(
() =>
- BazelWorkspace.find(resourceProvider, convertPath('not_absolute')),
+ BlazeWorkspace.find(resourceProvider, convertPath('not_absolute')),
throwsA(const TypeMatcher<ArgumentError>()));
}
@@ -981,7 +981,7 @@
'/workspace/blaze-out/host/bin/',
'/workspace/my/module/BUILD',
]);
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
@@ -1002,7 +1002,7 @@
'/workspace/blaze-out/',
'/workspace/my/module/',
]);
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
@@ -1016,7 +1016,7 @@
'/workspace/blaze-out/k8-fastbuild/bin/',
'/workspace/my/module/',
]);
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
@@ -1035,7 +1035,7 @@
'/Users/user/test/prime/',
'/Users/user/test/prime/bazel-genfiles/',
]);
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/Users/user/test/prime/my/module'))!;
expect(workspace.root, convertPath('/Users/user/test/prime'));
expect(workspace.readonly, convertPath('/Users/user/test/READONLY/prime'));
@@ -1051,7 +1051,7 @@
'/Users/user/test/prime/WORKSPACE',
'/Users/user/test/prime/bazel-genfiles/',
]);
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/Users/user/test/prime/my/module'))!;
expect(workspace.root, convertPath('/Users/user/test/prime'));
expect(workspace.readonly, isNull);
@@ -1067,7 +1067,7 @@
'/Users/user/test/prime/',
'/Users/user/test/prime/blaze-genfiles/',
]);
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/Users/user/test/prime/my/module'))!;
expect(workspace.root, convertPath('/Users/user/test/prime'));
expect(workspace.readonly, convertPath('/Users/user/test/READONLY/prime'));
@@ -1082,7 +1082,7 @@
'/workspace/WORKSPACE',
'/workspace/bazel-genfiles/',
]);
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
@@ -1095,7 +1095,7 @@
'/workspace/WORKSPACE',
'/workspace/bazel-genfiles/',
]);
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
@@ -1109,7 +1109,7 @@
'/workspace/bazel-genfiles/',
]);
var workspace =
- BazelWorkspace.find(resourceProvider, convertPath('/workspace'))!;
+ BlazeWorkspace.find(resourceProvider, convertPath('/workspace'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
expect(workspace.binPaths.single, convertPath('/workspace/bazel-bin'));
@@ -1122,7 +1122,7 @@
'/workspace/blaze-genfiles/',
]);
var workspace =
- BazelWorkspace.find(resourceProvider, convertPath('/workspace'))!;
+ BlazeWorkspace.find(resourceProvider, convertPath('/workspace'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
@@ -1130,20 +1130,20 @@
}
void test_find_null_noWorkspaceMarkers() {
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'));
expect(workspace, isNull);
}
void test_find_null_noWorkspaceMarkers_inRoot() {
- var workspace = BazelWorkspace.find(resourceProvider, convertPath('/'));
+ var workspace = BlazeWorkspace.find(resourceProvider, convertPath('/'));
expect(workspace, isNull);
}
void test_find_null_symlinkPrefix() {
- String prefix = BazelWorkspace.defaultSymlinkPrefix;
+ String prefix = BlazeWorkspace.defaultSymlinkPrefix;
newFile('/workspace/WORKSPACE', '');
- var workspace = BazelWorkspace.find(
+ var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
@@ -1162,7 +1162,7 @@
'/Users/user/test/prime/bazel-genfiles/my/module/test3.dart',
'/Users/user/test/READONLY/prime/other/module/test4.dart',
]);
- workspace = BazelWorkspace.find(
+ workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/Users/user/test/prime/my/module'))!;
_expectFindFile('/Users/user/test/prime/my/module/test1.dart',
equals: '/Users/user/test/prime/my/module/test1.dart');
@@ -1182,7 +1182,7 @@
'/Users/user/test/prime/my/module/test.dart',
'/Users/user/test/READONLY/prime/my/module/test.dart',
]);
- workspace = BazelWorkspace.find(
+ workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/Users/user/test/prime/my/module'))!;
_expectFindFile('/Users/user/test/prime/my/module/test.dart',
equals: '/Users/user/test/prime/my/module/test.dart');
@@ -1197,7 +1197,7 @@
'/workspace/bazel-bin/my/module/test2.dart',
'/workspace/bazel-genfiles/my/module/test3.dart',
]);
- workspace = BazelWorkspace.find(
+ workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
_expectFindFile('/workspace/my/module/test1.dart',
equals: '/workspace/my/module/test1.dart');
@@ -1218,7 +1218,7 @@
}
}
- /// Expect that [BazelWorkspace.findFile], given [path], returns [equals].
+ /// Expect that [BlazeWorkspace.findFile], given [path], returns [equals].
void _expectFindFile(String path, {required String equals}) =>
expect(workspace.findFile(convertPath(path))!.path, convertPath(equals));
}
diff --git a/pkg/analyzer/test/src/workspace/bazel_watcher_test.dart b/pkg/analyzer/test/src/workspace/blaze_watcher_test.dart
similarity index 82%
rename from pkg/analyzer/test/src/workspace/bazel_watcher_test.dart
rename to pkg/analyzer/test/src/workspace/blaze_watcher_test.dart
index 647a228..af19d2f 100644
--- a/pkg/analyzer/test/src/workspace/bazel_watcher_test.dart
+++ b/pkg/analyzer/test/src/workspace/blaze_watcher_test.dart
@@ -6,8 +6,8 @@
import 'dart:isolate';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
-import 'package:analyzer/src/workspace/bazel_watcher.dart';
+import 'package:analyzer/src/workspace/blaze.dart';
+import 'package:analyzer/src/workspace/blaze_watcher.dart';
import 'package:async/async.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -15,15 +15,15 @@
main() {
defineReflectiveSuite(() {
- defineReflectiveTests(BazelWatcherTest);
+ defineReflectiveTests(BlazeWatcherTest);
});
}
@reflectiveTest
-class BazelWatcherTest with ResourceProviderMixin {
- late final BazelWorkspace workspace;
+class BlazeWatcherTest with ResourceProviderMixin {
+ late final BlazeWorkspace workspace;
- void test_bazelFileWatcher() async {
+ void test_blazeFileWatcher() async {
_addResources([
'/workspace/WORKSPACE',
]);
@@ -31,7 +31,7 @@
convertPath('/workspace/bazel-bin/my/module/test1.dart'),
convertPath('/workspace/bazel-genfiles/my/module/test1.dart'),
];
- var watcher = BazelFilePoller(resourceProvider, candidates);
+ var watcher = BlazeFilePoller(resourceProvider, candidates);
// First do some tests with the first candidate path.
_addResources([candidates[0]]);
@@ -68,7 +68,7 @@
expect(watcher.poll(), isNull);
}
- void test_bazelFileWatcherIsolate() async {
+ void test_blazeFileWatcherIsolate() async {
_addResources([
'/workspace/WORKSPACE',
]);
@@ -86,28 +86,28 @@
// We'll directly call `handleRequest` to avoid any problems with various
// interleavings of async functions.
var dummyRecPort = ReceivePort();
- var watcher = BazelFileWatcherIsolate(
+ var watcher = BlazeFileWatcherIsolate(
dummyRecPort, recPort.sendPort, resourceProvider,
pollTriggerFactory: (_) => trigger)
..start();
var queue = StreamQueue(recPort);
- await queue.next as BazelWatcherIsolateStarted;
+ await queue.next as BlazeWatcherIsolateStarted;
- watcher.handleRequest(BazelWatcherStartWatching(
+ watcher.handleRequest(BlazeWatcherStartWatching(
convertPath('/workspace'),
- BazelSearchInfo(
+ BlazeSearchInfo(
convertPath('/workspace/my/module/test1.dart'), candidates1)));
- watcher.handleRequest(BazelWatcherStartWatching(
+ watcher.handleRequest(BlazeWatcherStartWatching(
convertPath('/workspace'),
- BazelSearchInfo(
+ BlazeSearchInfo(
convertPath('/workspace/my/module/test2.dart'), candidates2)));
// First do some tests with the first candidate path.
_addResources([candidates1[0]]);
trigger.controller.add('');
- var events = (await queue.next as BazelWatcherEvents).events;
+ var events = (await queue.next as BlazeWatcherEvents).events;
expect(events, hasLength(1));
expect(events[0].path, candidates1[0]);
@@ -117,7 +117,7 @@
_addResources([candidates2[1]]);
trigger.controller.add('');
- events = (await queue.next as BazelWatcherEvents).events;
+ events = (await queue.next as BlazeWatcherEvents).events;
expect(events, hasLength(1));
expect(events[0].path, candidates2[1]);
@@ -125,17 +125,17 @@
expect(watcher.numWatchedFiles(), 2);
- watcher.handleRequest(BazelWatcherStopWatching(convertPath('/workspace'),
+ watcher.handleRequest(BlazeWatcherStopWatching(convertPath('/workspace'),
convertPath('/workspace/my/module/test1.dart')));
expect(watcher.numWatchedFiles(), 1);
- watcher.handleRequest(BazelWatcherStopWatching(convertPath('/workspace'),
+ watcher.handleRequest(BlazeWatcherStopWatching(convertPath('/workspace'),
convertPath('/workspace/my/module/test2.dart')));
expect(watcher.numWatchedFiles(), 0);
- watcher.handleRequest(BazelWatcherShutdownIsolate());
+ watcher.handleRequest(BlazeWatcherShutdownIsolate());
await watcher.hasFinished;
// We need to do this manually, since it's the callers responsibility to
@@ -144,7 +144,7 @@
recPort.close();
}
- void test_bazelFileWatcherIsolate_multipleWorkspaces() async {
+ void test_blazeFileWatcherIsolate_multipleWorkspaces() async {
_addResources([
'/workspace1/WORKSPACE',
'/workspace2/WORKSPACE',
@@ -176,28 +176,28 @@
// We'll directly call `handleRequest` to avoid any problems with various
// interleavings of async functions.
var dummyRecPort = ReceivePort();
- var watcher = BazelFileWatcherIsolate(
+ var watcher = BlazeFileWatcherIsolate(
dummyRecPort, recPort.sendPort, resourceProvider,
pollTriggerFactory: triggerFactory)
..start();
var queue = StreamQueue(recPort);
- await queue.next as BazelWatcherIsolateStarted;
+ await queue.next as BlazeWatcherIsolateStarted;
- watcher.handleRequest(BazelWatcherStartWatching(
+ watcher.handleRequest(BlazeWatcherStartWatching(
convertPath('/workspace1'),
- BazelSearchInfo(
+ BlazeSearchInfo(
convertPath('/workspace1/my/module/test1.dart'), candidates1)));
- watcher.handleRequest(BazelWatcherStartWatching(
+ watcher.handleRequest(BlazeWatcherStartWatching(
convertPath('/workspace2'),
- BazelSearchInfo(
+ BlazeSearchInfo(
convertPath('/workspace2/my/module/test2.dart'), candidates2)));
// First do some tests with the first candidate path.
_addResources([candidates1[0]]);
trigger1!.controller.add('');
- var events = (await queue.next as BazelWatcherEvents).events;
+ var events = (await queue.next as BlazeWatcherEvents).events;
expect(events, hasLength(1));
expect(events[0].path, candidates1[0]);
@@ -207,7 +207,7 @@
_addResources([candidates2[1]]);
trigger2!.controller.add('');
- events = (await queue.next as BazelWatcherEvents).events;
+ events = (await queue.next as BlazeWatcherEvents).events;
expect(events, hasLength(1));
expect(events[0].path, candidates2[1]);
@@ -215,17 +215,17 @@
expect(watcher.numWatchedFiles(), 2);
- watcher.handleRequest(BazelWatcherStopWatching(convertPath('/workspace1'),
+ watcher.handleRequest(BlazeWatcherStopWatching(convertPath('/workspace1'),
convertPath('/workspace1/my/module/test1.dart')));
expect(watcher.numWatchedFiles(), 1);
- watcher.handleRequest(BazelWatcherStopWatching(convertPath('/workspace2'),
+ watcher.handleRequest(BlazeWatcherStopWatching(convertPath('/workspace2'),
convertPath('/workspace2/my/module/test2.dart')));
expect(watcher.numWatchedFiles(), 0);
- watcher.handleRequest(BazelWatcherShutdownIsolate());
+ watcher.handleRequest(BlazeWatcherShutdownIsolate());
await watcher.hasFinished;
// We need to do this manually, since it's the callers responsibility to
@@ -234,7 +234,7 @@
recPort.close();
}
- void test_bazelFileWatcherWithFolder() async {
+ void test_blazeFileWatcherWithFolder() async {
_addResources([
'/workspace/WORKSPACE',
]);
@@ -248,7 +248,7 @@
convertPath('/workspace/bazel-out'),
convertPath('/workspace/blaze-out'),
];
- var watcher = BazelFilePoller(resourceProvider, candidates);
+ var watcher = BlazeFilePoller(resourceProvider, candidates);
// First do some tests with the first candidate path.
addFolder(candidates[0]);
diff --git a/pkg/analyzer/test/src/workspace/gn_test.dart b/pkg/analyzer/test/src/workspace/gn_test.dart
index 2de0362..27f6e79 100644
--- a/pkg/analyzer/test/src/workspace/gn_test.dart
+++ b/pkg/analyzer/test/src/workspace/gn_test.dart
@@ -132,7 +132,7 @@
newFolder('/ws/some/code');
var gnWorkspace =
GnWorkspace.find(resourceProvider, convertPath('/ws/some/code'))!;
- expect(gnWorkspace.isBazel, isFalse);
+ expect(gnWorkspace.isBlaze, isFalse);
return gnWorkspace;
}
}
diff --git a/pkg/analyzer/test/src/workspace/package_build_test.dart b/pkg/analyzer/test/src/workspace/package_build_test.dart
index 80e9f53..faf8614 100644
--- a/pkg/analyzer/test/src/workspace/package_build_test.dart
+++ b/pkg/analyzer/test/src/workspace/package_build_test.dart
@@ -66,7 +66,7 @@
resolver = PackageBuildFileUriResolver(workspace);
newFile('/workspace/test.dart', '');
newFile('/workspace/.dart_tool/build/generated/project/gen.dart', '');
- expect(workspace.isBazel, isFalse);
+ expect(workspace.isBlaze, isFalse);
}
void test_pathToUri() {
diff --git a/pkg/analyzer/test/src/workspace/pub_test.dart b/pkg/analyzer/test/src/workspace/pub_test.dart
index 5fbbc9b..a0552561 100644
--- a/pkg/analyzer/test/src/workspace/pub_test.dart
+++ b/pkg/analyzer/test/src/workspace/pub_test.dart
@@ -40,7 +40,7 @@
}),
convertPath('/workspace'),
)!;
- expect(workspace.isBazel, isFalse);
+ expect(workspace.isBlaze, isFalse);
}
void test_contains_differentWorkspace() {
@@ -103,7 +103,7 @@
newPubspecYamlFile('/workspace', 'name: project');
var workspace = PubWorkspace.find(
resourceProvider, Packages.empty, convertPath('/workspace'))!;
- expect(workspace.isBazel, isFalse);
+ expect(workspace.isBlaze, isFalse);
expect(workspace.root, convertPath('/workspace'));
}
diff --git a/pkg/analyzer/test/src/workspace/test_all.dart b/pkg/analyzer/test/src/workspace/test_all.dart
index dc1b496..b4f396e 100644
--- a/pkg/analyzer/test/src/workspace/test_all.dart
+++ b/pkg/analyzer/test/src/workspace/test_all.dart
@@ -5,8 +5,8 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'basic_test.dart' as basic;
-import 'bazel_test.dart' as bazel;
-import 'bazel_watcher_test.dart' as bazel_watcher;
+import 'blaze_test.dart' as blaze;
+import 'blaze_watcher_test.dart' as blaze_watcher;
import 'gn_test.dart' as gn;
import 'package_build_test.dart' as package_build;
import 'pub_test.dart' as pub;
@@ -14,8 +14,8 @@
main() {
defineReflectiveSuite(() {
basic.main();
- bazel.main();
- bazel_watcher.main();
+ blaze.main();
+ blaze_watcher.main();
gn.main();
package_build.main();
pub.main();
diff --git a/pkg/analyzer_cli/test/data/bazel/WORKSPACE b/pkg/analyzer_cli/test/data/blaze/WORKSPACE
similarity index 100%
rename from pkg/analyzer_cli/test/data/bazel/WORKSPACE
rename to pkg/analyzer_cli/test/data/blaze/WORKSPACE
diff --git a/pkg/analyzer_cli/test/data/bazel/proj/lib/file.dart b/pkg/analyzer_cli/test/data/blaze/proj/lib/file.dart
similarity index 100%
rename from pkg/analyzer_cli/test/data/bazel/proj/lib/file.dart
rename to pkg/analyzer_cli/test/data/blaze/proj/lib/file.dart
diff --git a/pkg/analyzer_cli/test/driver_test.dart b/pkg/analyzer_cli/test/driver_test.dart
index 154362b..fc485ca 100644
--- a/pkg/analyzer_cli/test/driver_test.dart
+++ b/pkg/analyzer_cli/test/driver_test.dart
@@ -129,7 +129,7 @@
@reflectiveTest
class ExitCodesTest extends BaseTest {
@SkippedTest(reason: 'Fails on bots, passes locally. Do not know why.')
- Future<void> test_bazelWorkspace_relativePath() async {
+ Future<void> test_blazeWorkspace_relativePath() async {
// Copy to temp dir so that existing analysis options
// in the test directory hierarchy do not interfere
await withTempDirAsync((String tempDirPath) async {