-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…6700) * [#6664] Resolve a workspace label across external repositories - 4/n * Fix tests execution * Minor simplification * Small cleanups * Set the `bazel.read.external.workspace.data` registry key to true * Improve fixtures and simplify tests * Fix compilation * Address some comments * Replace the length based caret setting with the `configureByText`
- Loading branch information
Showing
13 changed files
with
258 additions
and
69 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...ogle/idea/blaze/base/lang/buildfile/references/ExternalWorkspaceReferenceBzlModeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<caret>'] | ||
)""", 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<caret>'] | ||
)""", targetLabel)); | ||
Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); | ||
|
||
PsiElement target = | ||
GotoDeclarationAction.findTargetElement( | ||
getProject(), editor, editor.getCaretModel().getOffset()); | ||
|
||
assertThat(target).isNotNull(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.