Remove READONLY support from BlazeWorkspace.

It was deprecated in 2019.
https://sites.google.com/a/google.com/git5fordummies/Home

Change-Id: I0b2d4fb0624bc70b7952de5496d280c84172beb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264600
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2022-10-18 16:06:08 +00:00 committed by Commit Queue
parent b6d278be10
commit 8dc77f6fdc
2 changed files with 6 additions and 272 deletions

View file

@ -31,9 +31,8 @@ class BlazeFileUriResolver extends ResourceUriResolver {
for (var genRoot in [
...workspace.binPaths,
workspace.genfiles,
workspace.readonly,
]) {
if (genRoot != null && pathContext.isWithin(genRoot, path)) {
if (pathContext.isWithin(genRoot, path)) {
String relative = pathContext.relative(path, from: genRoot);
var writablePath = pathContext.join(workspace.root, relative);
return pathContext.toUri(writablePath);
@ -74,7 +73,6 @@ class BlazePackageUriResolver extends UriResolver {
for (var root in [
..._workspace.binPaths,
_workspace.genfiles,
_workspace.readonly,
_workspace.root
]) {
var uriParts = _restoreUriParts(root, path);
@ -178,8 +176,6 @@ class BlazePackageUriResolver extends UriResolver {
/// Information about a Blaze workspace.
class BlazeWorkspace extends Workspace
implements WorkspaceWithDefaultAnalysisOptions {
static const String _READONLY = 'READONLY';
/// The name of the file that identifies a set of Blaze Targets.
///
/// For Dart package purposes, a BUILD file identifies a package.
@ -194,10 +190,6 @@ class BlazeWorkspace extends Workspace
@override
final String root;
/// 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 `blaze-bin` folders.
///
/// In practice, there is usually one "bin" path, and sometimes there are two,
@ -224,7 +216,6 @@ class BlazeWorkspace extends Workspace
BlazeWorkspace._(
this.provider,
this.root,
this.readonly,
this.binPaths,
this.genfiles, {
required bool lookForBuildFileSubstitutes,
@ -290,14 +281,6 @@ class BlazeWorkspace extends Workspace
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
@ -420,13 +403,6 @@ class BlazeWorkspace extends Workspace
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);
@ -459,29 +435,14 @@ class BlazeWorkspace extends Workspace
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);
binPaths = binPaths..add(context.join(root, 'blaze-bin'));
return BlazeWorkspace._(provider, root, readonlyRoot, binPaths,
context.join(root, 'blaze-genfiles'),
lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
}
}
final blazeOutFolder = parent.getChildAssumingFolder('blaze-out');
if (blazeOutFolder.exists) {
// Found the "out" folder; must be a Blaze workspace.
String root = parent.path;
var binPaths = _findBinFolderPaths(parent);
binPaths = binPaths..add(context.join(root, 'blaze-bin'));
return BlazeWorkspace._(provider, root, null /* readonly */, binPaths,
context.join(root, 'blaze-genfiles'),
return BlazeWorkspace._(
provider, root, binPaths, context.join(root, 'blaze-genfiles'),
lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
}
@ -490,8 +451,8 @@ class BlazeWorkspace extends Workspace
String root = folder.path;
var binPaths = _findBinFolderPaths(folder);
binPaths = binPaths..add(context.join(root, 'blaze-bin'));
return BlazeWorkspace._(provider, root, null /* readonly */, binPaths,
context.join(root, 'blaze-genfiles'),
return BlazeWorkspace._(
provider, root, binPaths, context.join(root, 'blaze-genfiles'),
lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
}
}

View file

@ -253,17 +253,6 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
_assertNoResolve(toUriStr('/other/my/foo/test/foo1.dart'));
}
void test_resolveAbsolute_file_readonly_to_workspace() {
_addResources([
'/workspace/${file_paths.blazeWorkspaceMarker}',
'/READONLY/workspace/',
'/workspace/my/foo/test/foo1.dart'
]);
_assertResolve(toUriStr('/READONLY/workspace/my/foo/test/foo1.dart'),
'/workspace/my/foo/test/foo1.dart',
restore: false);
}
void test_resolveAbsolute_file_workspace_to_genfiles() {
_addResources([
'/workspace/${file_paths.blazeWorkspaceMarker}',
@ -354,129 +343,6 @@ class BlazePackageUriResolverTest with ResourceProviderMixin {
expect(source, isNull);
}
void test_resolveAbsolute_readonly_bin() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/READONLY/prime/my/foo/lib/foo1.dart',
'/Users/user/test/prime/blaze-genfiles/',
'/Users/user/test/prime/my/module/',
'/Users/user/test/prime/blaze-bin/my/foo/lib/foo1.dart',
], workspacePath: '/Users/user/test/prime/my/module');
_assertResolve('package:my.foo/foo1.dart',
'/Users/user/test/prime/blaze-bin/my/foo/lib/foo1.dart',
exists: true);
}
void test_resolveAbsolute_readonly_bin_notInWorkspace() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/prime/blaze-genfiles/',
'/Users/user/test/prime/my/module/',
'/Users/user/test/prime/blaze-bin/my/foo/lib/foo1.dart',
], workspacePath: '/Users/user/test/prime/my/module');
_assertResolve('package:my.foo/foo1.dart',
'/Users/user/test/prime/blaze-bin/my/foo/lib/foo1.dart',
exists: true);
}
void test_resolveAbsolute_readonly_genfiles() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/READONLY/prime/my/foo/lib/foo1.dart',
'/Users/user/test/prime/blaze-genfiles/',
'/Users/user/test/prime/my/module/',
'/Users/user/test/prime/blaze-genfiles/my/foo/lib/foo1.dart',
], workspacePath: '/Users/user/test/prime/my/module');
_assertResolve('package:my.foo/foo1.dart',
'/Users/user/test/prime/blaze-genfiles/my/foo/lib/foo1.dart',
exists: true);
}
void test_resolveAbsolute_readonly_genfiles_notInWorkspace() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/prime/blaze-genfiles/',
'/Users/user/test/prime/my/module/',
'/Users/user/test/prime/blaze-genfiles/my/foo/lib/foo1.dart',
], workspacePath: '/Users/user/test/prime/my/module');
_assertResolve('package:my.foo/foo1.dart',
'/Users/user/test/prime/blaze-genfiles/my/foo/lib/foo1.dart',
exists: true);
}
void test_resolveAbsolute_readonly_thirdParty_bin() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/READONLY/prime/third_party/dart/foo/lib/foo1.dart',
'/Users/user/test/prime/blaze-genfiles/',
'/Users/user/test/prime/my/module/',
'/Users/user/test/prime/blaze-bin/third_party/dart/foo/lib/foo1.dart',
], workspacePath: '/Users/user/test/prime/my/module');
_assertResolve('package:foo/foo1.dart',
'/Users/user/test/prime/blaze-bin/third_party/dart/foo/lib/foo1.dart',
exists: true);
}
void test_resolveAbsolute_readonly_thirdParty_genfiles() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/READONLY/prime/third_party/dart/foo/lib/foo1.dart',
'/Users/user/test/prime/blaze-genfiles/',
'/Users/user/test/prime/my/module/',
'/Users/user/test/prime/blaze-genfiles/third_party/dart/foo/lib/foo1.dart',
], workspacePath: '/Users/user/test/prime/my/module');
_assertResolve('package:foo/foo1.dart',
'/Users/user/test/prime/blaze-genfiles/third_party/dart/foo/lib/foo1.dart',
exists: true);
}
void test_resolveAbsolute_readonly_thirdParty_workspace_doesNotExist() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/READONLY/prime/third_party/dart/foo/lib/foo1.dart',
'/Users/user/test/prime/blaze-genfiles/',
'/Users/user/test/prime/my/module/',
], workspacePath: '/Users/user/test/prime/my/module');
_assertResolve('package:foo/foo2.dart',
'/Users/user/test/prime/third_party/dart/foo/lib/foo2.dart',
exists: false);
}
void test_resolveAbsolute_readonly_thirdParty_workspace_exists() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/READONLY/prime/third_party/dart/foo/lib/foo1.dart',
'/Users/user/test/prime/blaze-genfiles/',
'/Users/user/test/prime/my/module/',
], workspacePath: '/Users/user/test/prime/my/module');
_assertResolve('package:foo/foo1.dart',
'/Users/user/test/READONLY/prime/third_party/dart/foo/lib/foo1.dart',
exists: true);
}
void test_resolveAbsolute_readonly_workspace_doesNotExist() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/prime/blaze-genfiles/',
'/Users/user/test/prime/my/module/',
], workspacePath: '/Users/user/test/prime/my/module');
_assertResolve('package:my.foo/foo1.dart',
'/Users/user/test/prime/my/foo/lib/foo1.dart',
exists: false);
}
void test_resolveAbsolute_readonly_workspace_exists() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/READONLY/prime/my/foo/lib/foo1.dart',
'/Users/user/test/prime/blaze-genfiles/',
'/Users/user/test/prime/my/module/',
], workspacePath: '/Users/user/test/prime/my/module');
_assertResolve('package:my.foo/foo1.dart',
'/Users/user/test/READONLY/prime/my/foo/lib/foo1.dart',
exists: true);
}
void test_resolveAbsolute_thirdParty_bin() {
_addResources([
'/workspace/${file_paths.blazeWorkspaceMarker}',
@ -985,7 +851,6 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
expect(
workspace.binPaths.first, convertPath('/workspace/blaze-out/host/bin'));
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
@ -1006,7 +871,6 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
}
@ -1020,7 +884,6 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
expect(workspace.binPaths, hasLength(3));
expect(workspace.binPaths,
contains(convertPath('/workspace/blaze-out/host/bin')));
@ -1030,54 +893,6 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
}
void test_find_hasReadonlyFolder() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/prime/',
'/Users/user/test/prime/blaze-genfiles/',
]);
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'));
expect(workspace.binPaths.single,
convertPath('/Users/user/test/prime/blaze-bin'));
expect(workspace.genfiles,
convertPath('/Users/user/test/prime/blaze-genfiles'));
}
void test_find_hasReadonlyFolder_bad_actuallyHasWorkspaceFile() {
_addResources([
'/Users/user/test/READONLY/',
'/Users/user/test/prime/${file_paths.blazeWorkspaceMarker}',
'/Users/user/test/prime/blaze-genfiles/',
]);
var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/Users/user/test/prime/my/module'))!;
expect(workspace.root, convertPath('/Users/user/test/prime'));
expect(workspace.readonly, isNull);
expect(workspace.binPaths.single,
convertPath('/Users/user/test/prime/blaze-bin'));
expect(workspace.genfiles,
convertPath('/Users/user/test/prime/blaze-genfiles'));
}
void test_find_hasReadonlyFolder_blaze() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/prime/',
'/Users/user/test/prime/blaze-genfiles/',
]);
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'));
expect(workspace.binPaths.single,
convertPath('/Users/user/test/prime/blaze-bin'));
expect(workspace.genfiles,
convertPath('/Users/user/test/prime/blaze-genfiles'));
}
void test_find_hasWorkspaceFile() {
_addResources([
'/workspace/${file_paths.blazeWorkspaceMarker}',
@ -1086,7 +901,6 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
}
@ -1099,7 +913,6 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
}
@ -1112,7 +925,6 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
var workspace =
BlazeWorkspace.find(resourceProvider, convertPath('/workspace'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
}
@ -1125,7 +937,6 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
var workspace =
BlazeWorkspace.find(resourceProvider, convertPath('/workspace'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
}
@ -1146,49 +957,11 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
var workspace = BlazeWorkspace.find(
resourceProvider, convertPath('/workspace/my/module'))!;
expect(workspace.root, convertPath('/workspace'));
expect(workspace.readonly, isNull);
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
}
void test_findFile_hasReadonlyFolder() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/prime/',
'/Users/user/test/prime/my/module/test1.dart',
'/Users/user/test/prime/my/module/test2.dart',
'/Users/user/test/prime/my/module/test3.dart',
'/Users/user/test/prime/blaze-bin/my/module/test2.dart',
'/Users/user/test/prime/blaze-genfiles/my/module/test3.dart',
'/Users/user/test/READONLY/prime/other/module/test4.dart',
]);
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');
_expectFindFile('/Users/user/test/prime/my/module/test2.dart',
equals: '/Users/user/test/prime/blaze-bin/my/module/test2.dart');
_expectFindFile('/Users/user/test/prime/my/module/test3.dart',
equals: '/Users/user/test/prime/blaze-genfiles/my/module/test3.dart');
_expectFindFile('/Users/user/test/prime/other/module/test4.dart',
equals: '/Users/user/test/READONLY/prime/other/module/test4.dart');
}
void test_findFile_main_overrides_readonly() {
_addResources([
'/Users/user/test/READONLY/prime/',
'/Users/user/test/prime/',
'/Users/user/test/prime/blaze-genfiles/',
'/Users/user/test/prime/my/module/test.dart',
'/Users/user/test/READONLY/prime/my/module/test.dart',
]);
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');
}
void test_findFile_noReadOnly() {
void test_findFile() {
_addResources([
'/workspace/${file_paths.blazeWorkspaceMarker}',
'/workspace/my/module/test1.dart',