diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock
index ed4f1241a45..27bae869b77 100644
--- a/MODULE.bazel.lock
+++ b/MODULE.bazel.lock
@@ -67,12 +67,12 @@
"https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74",
"https://bcr.bazel.build/modules/rules_java/6.0.0/MODULE.bazel": "8a43b7df601a7ec1af61d79345c17b31ea1fedc6711fd4abfd013ea612978e39",
"https://bcr.bazel.build/modules/rules_java/7.1.0/MODULE.bazel": "30d9135a2b6561c761bd67bd4990da591e6bdc128790ce3e7afd6a3558b2fb64",
+ "https://bcr.bazel.build/modules/rules_java/7.10.0/MODULE.bazel": "530c3beb3067e870561739f1144329a21c851ff771cd752a49e06e3dc9c2e71a",
+ "https://bcr.bazel.build/modules/rules_java/7.10.0/source.json": "01e9e64c170c3698ea82539f406ef04a1583b5b1a2458a91f3f7ea9f2bf8b553",
"https://bcr.bazel.build/modules/rules_java/7.2.0/MODULE.bazel": "06c0334c9be61e6cef2c8c84a7800cef502063269a5af25ceb100b192453d4ab",
"https://bcr.bazel.build/modules/rules_java/7.4.0/MODULE.bazel": "a592852f8a3dd539e82ee6542013bf2cadfc4c6946be8941e189d224500a8934",
"https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe",
"https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1",
- "https://bcr.bazel.build/modules/rules_java/7.9.0/MODULE.bazel": "aa1ebea5c5e2a4b31fbabe07bf3e9951ccc0f4e92499c42d325580f86c456020",
- "https://bcr.bazel.build/modules/rules_java/7.9.0/source.json": "41ba541cffadec937a872c9cdfe67e2936afcb560b6957d60c2bf313a868e4b2",
"https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7",
"https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909",
"https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036",
diff --git a/base/src/META-INF/blaze-base.xml b/base/src/META-INF/blaze-base.xml
index ba8931a0b07..4c93d7ed3ac 100644
--- a/base/src/META-INF/blaze-base.xml
+++ b/base/src/META-INF/blaze-base.xml
@@ -411,7 +411,7 @@
-
diff --git a/base/src/com/google/idea/blaze/base/lang/buildfile/references/LabelReference.java b/base/src/com/google/idea/blaze/base/lang/buildfile/references/LabelReference.java
index a3457bb56ea..514747a98db 100644
--- a/base/src/com/google/idea/blaze/base/lang/buildfile/references/LabelReference.java
+++ b/base/src/com/google/idea/blaze/base/lang/buildfile/references/LabelReference.java
@@ -32,9 +32,12 @@
import com.intellij.openapi.vfs.VirtualFileFilter;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceBase;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+
import javax.annotation.Nullable;
/** Converts a blaze label into an absolute path, then resolves that path to a PsiElements */
diff --git a/base/src/com/google/idea/blaze/base/model/ExternalWorkspaceData.java b/base/src/com/google/idea/blaze/base/model/ExternalWorkspaceData.java
index 888b22c99f6..9d5424a259b 100644
--- a/base/src/com/google/idea/blaze/base/model/ExternalWorkspaceData.java
+++ b/base/src/com/google/idea/blaze/base/model/ExternalWorkspaceData.java
@@ -7,6 +7,9 @@
import com.google.idea.blaze.base.ideinfo.ProtoWrapper;
import com.google.idea.blaze.base.model.primitives.ExternalWorkspace;
+import javax.annotation.Nullable;
+
+
public final class ExternalWorkspaceData implements ProtoWrapper {
public ImmutableMap workspaces;
@@ -22,25 +25,32 @@ public static ExternalWorkspaceData create(ImmutableList work
.stream()
.collect(
ImmutableMap.toImmutableMap(
- ExternalWorkspace::name,
+ ExternalWorkspace::repositoryName,
Functions.identity()))
);
}
@Override
public ProjectData.ExternalWorkspaceData toProto() {
- ImmutableList protoWorkspaces = workspaces
- .values()
- .stream()
- .map(ExternalWorkspace::toProto)
- .collect(ImmutableList.toImmutableList());
-
- return ProjectData.ExternalWorkspaceData.newBuilder()
- .addAllWorkspaces(protoWorkspaces)
- .build();
+ ProjectData.ExternalWorkspaceData.Builder builder = ProjectData.ExternalWorkspaceData.newBuilder();
+
+ for (ExternalWorkspace externalWorkspace : workspaces.values()) {
+ builder = builder.addWorkspaces(externalWorkspace.toProto());
+ }
+
+ return builder.build();
}
public static ExternalWorkspaceData fromProto(ProjectData.ExternalWorkspaceData proto) {
- return new ExternalWorkspaceData(proto.getWorkspacesList().stream().map(ExternalWorkspace::fromProto).collect(ImmutableList.toImmutableList()));
+ return new ExternalWorkspaceData(
+ proto.getWorkspacesList()
+ .stream()
+ .map(ExternalWorkspace::fromProto)
+ .collect(ImmutableList.toImmutableList()));
+ }
+
+ @Nullable
+ public ExternalWorkspace getByRepoName(String name) {
+ return workspaces.get(name);
}
}
diff --git a/base/src/com/google/idea/blaze/base/model/primitives/ExternalWorkspace.java b/base/src/com/google/idea/blaze/base/model/primitives/ExternalWorkspace.java
index 2fec441c34b..ce4b1fe9308 100644
--- a/base/src/com/google/idea/blaze/base/model/primitives/ExternalWorkspace.java
+++ b/base/src/com/google/idea/blaze/base/model/primitives/ExternalWorkspace.java
@@ -13,7 +13,11 @@ public abstract class ExternalWorkspace implements ProtoWrapper workspaceRootCache = SyncCache.getInstance(project)
- .get(WorkspaceHelper.class, (p, data) -> new ConcurrentHashMap());
+ Map workspaceRootCache =
+ SyncCache.getInstance(project)
+ .get(WorkspaceHelper.class, (p, data) -> new ConcurrentHashMap<>());
//the null cache value case could happen when the blazeProjectData is null.
- if(workspaceRootCache == null) {
+ if (workspaceRootCache == null) {
return null;
}
- WorkspaceRoot root = null;
if (workspaceRootCache.containsKey(workspaceName)) {
- root = workspaceRootCache.get(workspaceName);
- } else if (getBlazeProjectData(project) != null) {
- File externalDir = new File(getBlazeProjectData(project).getBlazeInfo().getOutputBase(),
- "external/" + workspaceName);
+ return workspaceRootCache.get(workspaceName);
+ }
+
+ BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
+ if (blazeProjectData != null) {
+ File externalBase = new File(blazeProjectData.getBlazeInfo().getOutputBase(), "external");
- if (externalDir.exists() || isInTestMode()) {
- root = new WorkspaceRoot(externalDir);
+ File workspaceDir = new File(externalBase, workspaceName);
+ ExternalWorkspace workspace = blazeProjectData.getExternalWorkspaceData().getByRepoName(workspaceName);
+ if (workspace != null) {
+ workspaceDir = new File(externalBase, workspace.name());
+ }
+
+ if (workspaceDir.exists() || isInTestMode()) {
+ WorkspaceRoot root = new WorkspaceRoot(workspaceDir);
workspaceRootCache.put(workspaceName, root);
+ return root;
}
}
- return root;
+ return null;
}
//The unit test use the TempFileSystem to create VirtualFile which does not exist on disk.
diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/RuleTargetCompletionTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/RuleTargetCompletionTest.java
index 5ada9f4a3e3..20328d2a493 100644
--- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/RuleTargetCompletionTest.java
+++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/RuleTargetCompletionTest.java
@@ -24,6 +24,7 @@
import com.google.idea.blaze.base.lang.buildfile.language.semantics.RuleDefinition;
import com.google.idea.blaze.base.lang.buildfile.psi.BuildFile;
import com.google.idea.blaze.base.model.primitives.WorkspacePath;
+import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.openapi.editor.Editor;
import javax.annotation.Nullable;
@@ -188,6 +189,11 @@ public void testLocalPathIgnoredForNonLocalLabels() throws Throwable {
assertThat(completionItems).asList().doesNotContain("'//java/com/google:other_rule'");
}
+ @Test
+ public void testExternalRepoCompletion() throws Throwable {
+
+ }
+
private static void setBuildLanguageSpecRules(
MockBuildLanguageSpecProvider specProvider, String... ruleNames) {
ImmutableMap.Builder rules = ImmutableMap.builder();
diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/findusages/ExternalWorkspaceFindUsagesTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/findusages/ExternalWorkspaceFindUsagesTest.java
index 7291eb3cb48..74d41032f4d 100644
--- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/findusages/ExternalWorkspaceFindUsagesTest.java
+++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/findusages/ExternalWorkspaceFindUsagesTest.java
@@ -24,6 +24,7 @@
import com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral;
import com.google.idea.blaze.base.lang.buildfile.psi.util.PsiUtils;
import com.google.idea.blaze.base.lang.buildfile.search.FindUsages;
+import com.google.idea.blaze.base.model.BlazeProjectData;
import com.google.idea.blaze.base.model.primitives.WorkspacePath;
import com.google.idea.blaze.base.settings.BuildSystemName;
import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
@@ -140,16 +141,4 @@ public void testFindUsagesFromExternalWorkspaceFileShortFormLabel() {
assertThat(references).hasLength(1);
assertThat(references[0].getElement()).isEqualTo(label);
}
-
- private PsiFile createFileInExternalWorkspace(
- String workspaceName, WorkspacePath path, String... contents) {
- String filePath =
- Paths.get(getExternalSourceRoot().getPath(), workspaceName, path.relativePath()).toString();
- return fileSystem.createPsiFile(filePath, contents);
- }
-
- private File getExternalSourceRoot() {
- return WorkspaceHelper.getExternalSourceRoot(
- BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData());
- }
}
diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/references/ExternalWorkspaceReferenceBzlModeTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/references/ExternalWorkspaceReferenceBzlModeTest.java
new file mode 100644
index 00000000000..8c870e7f54c
--- /dev/null
+++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/references/ExternalWorkspaceReferenceBzlModeTest.java
@@ -0,0 +1,92 @@
+package com.google.idea.blaze.base.lang.buildfile.references;
+
+import com.google.common.collect.ImmutableList;
+import com.google.idea.blaze.base.ExternalWorkspaceFixture;
+import com.google.idea.blaze.base.lang.buildfile.BuildFileIntegrationTestCase;
+import com.google.idea.blaze.base.lang.buildfile.psi.BuildFile;
+import com.google.idea.blaze.base.model.ExternalWorkspaceData;
+import com.google.idea.blaze.base.model.primitives.ExternalWorkspace;
+import com.google.idea.blaze.base.model.primitives.Label;
+import com.google.idea.blaze.base.model.primitives.TargetName;
+import com.google.idea.blaze.base.model.primitives.WorkspacePath;
+import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(JUnit4.class)
+public class ExternalWorkspaceReferenceBzlModeTest extends BuildFileIntegrationTestCase {
+
+ protected ExternalWorkspaceFixture workspaceOne;
+ protected ExternalWorkspaceFixture workspaceTwoMapped;
+
+ @Override
+ protected ExternalWorkspaceData mockExternalWorkspaceData() {
+ workspaceOne = new ExternalWorkspaceFixture(
+ ExternalWorkspace.create("workspace_one", "workspace_one"), fileSystem);
+
+ workspaceTwoMapped = new ExternalWorkspaceFixture(
+ ExternalWorkspace.create("workspace_two", "com_workspace_two"), fileSystem);
+
+ return ExternalWorkspaceData.create(
+ ImmutableList.of(workspaceOne.w, workspaceTwoMapped.w));
+ }
+
+ @Before
+ public void doSetupExternalWorkspaces() {
+ workspaceOne.createBuildFile(
+ new WorkspacePath("p1/p2/BUILD"),
+ "java_library(name = 'rule1')");
+
+ workspaceTwoMapped.createBuildFile(
+ new WorkspacePath("p1/p2/BUILD"),
+ "java_library(name = 'rule1')");
+ }
+
+ @Test
+ public void testUnmappedExternalWorkspace() throws Throwable {
+ Label targetLabel = workspaceOne.createLabel(
+ new WorkspacePath("p1/p2"), TargetName.create("rule1"));
+
+ PsiFile file = testFixture.configureByText("BUILD",
+ String.format("""
+ java_library(
+ name = 'lib',
+ deps = ['%s']
+ )""", targetLabel));
+ Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
+
+ PsiElement target =
+ GotoDeclarationAction.findTargetElement(
+ getProject(), editor, editor.getCaretModel().getOffset());
+
+ assertThat(target).isNotNull();
+ }
+
+ @Test
+ public void testRemappedExternalWorkspace() throws Throwable {
+ Label targetLabel = workspaceTwoMapped.createLabel(
+ new WorkspacePath("p1/p2"), TargetName.create("rule1"));
+
+ PsiFile file = testFixture.configureByText("BUILD",
+ String.format("""
+ java_library(
+ name = 'lib',
+ deps = ['%s']
+ )""", targetLabel));
+ Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
+
+ PsiElement target =
+ GotoDeclarationAction.findTargetElement(
+ getProject(), editor, editor.getCaretModel().getOffset());
+
+ assertThat(target).isNotNull();
+ }
+}
diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/references/ExternalWorkspaceReferenceTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/references/ExternalWorkspaceReferenceTest.java
index d1f48af45e5..1c3d0b85a06 100644
--- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/references/ExternalWorkspaceReferenceTest.java
+++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/references/ExternalWorkspaceReferenceTest.java
@@ -25,13 +25,10 @@
import com.google.idea.blaze.base.lang.buildfile.psi.LoadStatement;
import com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral;
import com.google.idea.blaze.base.lang.buildfile.psi.util.PsiUtils;
+import com.google.idea.blaze.base.model.ExternalWorkspaceData;
import com.google.idea.blaze.base.model.primitives.WorkspacePath;
import com.google.idea.blaze.base.settings.BuildSystemName;
-import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
-import com.google.idea.blaze.base.sync.workspace.WorkspaceHelper;
import com.intellij.psi.PsiFile;
-import java.io.File;
-import java.nio.file.Paths;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -223,15 +220,8 @@ public void testRelativeLoadInExternalWorkspace() {
assertThat(load.getImportedSymbolElements()[0].getLoadedElement()).isEqualTo(function);
}
- private PsiFile createFileInExternalWorkspace(
- String workspaceName, WorkspacePath path, String... contents) {
- String filePath =
- Paths.get(getExternalSourceRoot().getPath(), workspaceName, path.relativePath()).toString();
- return fileSystem.createPsiFile(filePath, contents);
- }
-
- private File getExternalSourceRoot() {
- return WorkspaceHelper.getExternalSourceRoot(
- BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData());
+ @Override
+ protected ExternalWorkspaceData mockExternalWorkspaceData() {
+ return super.mockExternalWorkspaceData();
}
}
diff --git a/base/tests/utils/integration/com/google/idea/blaze/base/ExternalWorkspaceFixture.java b/base/tests/utils/integration/com/google/idea/blaze/base/ExternalWorkspaceFixture.java
new file mode 100644
index 00000000000..b95abc23e33
--- /dev/null
+++ b/base/tests/utils/integration/com/google/idea/blaze/base/ExternalWorkspaceFixture.java
@@ -0,0 +1,60 @@
+package com.google.idea.blaze.base;
+
+import com.google.idea.blaze.base.lang.buildfile.psi.BuildFile;
+import com.google.idea.blaze.base.model.BlazeProjectData;
+import com.google.idea.blaze.base.model.primitives.ExternalWorkspace;
+import com.google.idea.blaze.base.model.primitives.Label;
+import com.google.idea.blaze.base.model.primitives.TargetName;
+import com.google.idea.blaze.base.model.primitives.WorkspacePath;
+import com.google.idea.blaze.base.model.primitives.WorkspaceRoot;
+import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
+import com.intellij.psi.PsiFile;
+
+import java.io.File;
+import java.nio.file.Paths;
+
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.idea.blaze.base.settings.ui.ProjectViewUi.getProject;
+import static org.junit.Assert.assertNotNull;
+
+public class ExternalWorkspaceFixture {
+ public final ExternalWorkspace w;
+
+ final TestFileSystem fileSystem;
+ WorkspaceFileSystem workspaceFileSystem;
+
+ public ExternalWorkspaceFixture(ExternalWorkspace w, TestFileSystem fileSystem) {
+ this.w = w;
+ this.fileSystem = fileSystem;
+ }
+
+ public BuildFile createBuildFile(WorkspacePath workspacePath, String... contentLines) {
+ PsiFile file = getWorkspaceFileSystem().createPsiFile(workspacePath, contentLines);
+ assertThat(file).isInstanceOf(BuildFile.class);
+ return (BuildFile) file;
+ }
+
+ WorkspaceFileSystem getWorkspaceFileSystem() {
+ if (workspaceFileSystem == null) {
+ BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData();
+ assertNotNull(blazeProjectData);
+
+ File outputBase = blazeProjectData.getBlazeInfo().getOutputBase();
+
+
+ WorkspaceRoot workspaceRoot = new WorkspaceRoot(Paths.get(
+ blazeProjectData.getBlazeInfo().getOutputBase().getAbsolutePath(),
+ "external", w.name()).normalize().toFile());
+
+ File workspaceRootFile = workspaceRoot.directory();
+ assertThat(workspaceRootFile).isNotNull();
+ workspaceFileSystem = new WorkspaceFileSystem(workspaceRoot, fileSystem);
+ }
+
+ return workspaceFileSystem;
+ }
+
+ public Label createLabel(WorkspacePath packagePath, TargetName targetName) {
+ return Label.create(w.repositoryName(), packagePath, targetName);
+ }
+}
\ No newline at end of file
diff --git a/base/tests/utils/integration/com/google/idea/blaze/base/lang/buildfile/BuildFileIntegrationTestCase.java b/base/tests/utils/integration/com/google/idea/blaze/base/lang/buildfile/BuildFileIntegrationTestCase.java
index d7bca78144a..a2f8ce53d7f 100644
--- a/base/tests/utils/integration/com/google/idea/blaze/base/lang/buildfile/BuildFileIntegrationTestCase.java
+++ b/base/tests/utils/integration/com/google/idea/blaze/base/lang/buildfile/BuildFileIntegrationTestCase.java
@@ -15,21 +15,27 @@
*/
package com.google.idea.blaze.base.lang.buildfile;
-import static com.google.common.truth.Truth.assertThat;
-
import com.google.common.base.Joiner;
import com.google.idea.blaze.base.BlazeIntegrationTestCase;
import com.google.idea.blaze.base.EditorTestHelper;
import com.google.idea.blaze.base.lang.buildfile.psi.BuildFile;
+import com.google.idea.blaze.base.model.BlazeProjectData;
+import com.google.idea.blaze.base.model.ExternalWorkspaceData;
import com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder;
import com.google.idea.blaze.base.model.MockBlazeProjectDataManager;
import com.google.idea.blaze.base.model.primitives.WorkspacePath;
import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
+import com.google.idea.blaze.base.sync.workspace.WorkspaceHelper;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
-import java.util.List;
import org.junit.Before;
+import java.io.File;
+import java.nio.file.Paths;
+import java.util.List;
+
+import static com.google.common.truth.Truth.assertThat;
+
/** BUILD file specific integration test base */
public abstract class BuildFileIntegrationTestCase extends BlazeIntegrationTestCase {
protected EditorTestHelper editorTest;
@@ -40,11 +46,16 @@ public final void doSetup() {
new MockBlazeProjectDataManager(
MockBlazeProjectDataBuilder.builder(workspaceRoot)
.setOutputBase(fileSystem.getRootDir() + "/output_base")
+ .setExternalWorkspaceData(mockExternalWorkspaceData())
.build());
registerProjectService(BlazeProjectDataManager.class, mockProjectDataManager);
editorTest = new EditorTestHelper(getProject(), testFixture);
}
+ protected ExternalWorkspaceData mockExternalWorkspaceData() {
+ return ExternalWorkspaceData.EMPTY;
+ }
+
/**
* Creates a file with the specified contents and file path in the test project, and asserts that
* it's parsed as a BuildFile
@@ -68,4 +79,18 @@ protected void assertFileContents(PsiFile file, List contentLines) {
String contents = Joiner.on('\n').join(contentLines);
assertThat(file.getText()).isEqualTo(contents);
}
+
+ protected PsiFile createFileInExternalWorkspace(
+ String workspaceName, WorkspacePath path, String... contents) {
+ String filePath =
+ Paths.get(getExternalSourceRoot().getPath(), workspaceName, path.relativePath()).toString();
+ return fileSystem.createPsiFile(filePath, contents);
+ }
+
+ protected File getExternalSourceRoot() {
+ BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData();
+ assertThat(blazeProjectData).isNotNull();
+
+ return WorkspaceHelper.getExternalSourceRoot(blazeProjectData);
+ }
}
diff --git a/base/tests/utils/unit/com/google/idea/blaze/base/model/MockBlazeProjectDataBuilder.java b/base/tests/utils/unit/com/google/idea/blaze/base/model/MockBlazeProjectDataBuilder.java
index 1d226a61060..08718043b1f 100644
--- a/base/tests/utils/unit/com/google/idea/blaze/base/model/MockBlazeProjectDataBuilder.java
+++ b/base/tests/utils/unit/com/google/idea/blaze/base/model/MockBlazeProjectDataBuilder.java
@@ -107,7 +107,8 @@ public MockBlazeProjectDataBuilder setWorkspaceLanguageSettings(
}
@CanIgnoreReturnValue
- public MockBlazeProjectDataBuilder setExternalWorkspaceData(ExternalWorkspaceData externalWorkspaceData) {
+ public MockBlazeProjectDataBuilder setExternalWorkspaceData(
+ ExternalWorkspaceData externalWorkspaceData) {
this.externalWorkspaceData = externalWorkspaceData;
return this;
}