Search in sources :

Example 76 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.

the class DeprecatedLoadQuickFixTest method testRelativeLoadStatementUntouched.

@Test
public void testRelativeLoadStatementUntouched() {
    workspace.createPsiFile(new WorkspacePath("foo/bar/build_defs.bzl"));
    BuildFile file = createBuildFile(new WorkspacePath("foo/bar/BUILD"), "load(':build_defs.bzl', 'symbol')");
    StringLiteral string = PsiUtils.findFirstChildOfClassRecursive(file, StringLiteral.class);
    String prevString = string.getStringContents();
    applyQuickFix(string);
    assertThat(string.getStringContents()).isEqualTo(prevString);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) StringLiteral(com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral) Test(org.junit.Test)

Example 77 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.

the class DeprecatedLoadQuickFixTest method testNormalLoadStatementUntouched.

@Test
public void testNormalLoadStatementUntouched() {
    workspace.createPsiFile(new WorkspacePath("foo/bar/BUILD"));
    workspace.createPsiFile(new WorkspacePath("foo/bar/build_defs.bzl"));
    BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "load('//foo/bar:build_defs.bzl', 'symbol')");
    StringLiteral string = PsiUtils.findFirstChildOfClassRecursive(file, StringLiteral.class);
    String prevString = string.getStringContents();
    applyQuickFix(string);
    assertThat(string.getStringContents()).isEqualTo(prevString);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) StringLiteral(com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral) Test(org.junit.Test)

Example 78 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.

the class RenameRefactoringTest method testRenameSuggestionForBuildFile.

@Test
public void testRenameSuggestionForBuildFile() {
    BuildFile buildFile = createBuildFile(new WorkspacePath("java/com/google/BUILD"));
    RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(buildFile);
    RenameDialog dialog = processor.createRenameDialog(getProject(), buildFile, buildFile, null);
    String[] suggestions = dialog.getSuggestedNames();
    assertThat(suggestions[0]).isEqualTo("BUILD");
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) RenamePsiElementProcessor(com.intellij.refactoring.rename.RenamePsiElementProcessor) RenameDialog(com.intellij.refactoring.rename.RenameDialog) Test(org.junit.Test)

Example 79 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.

the class RenameRefactoringTest method testRenameRule.

@Test
public void testRenameRule() {
    BuildFile fooPackage = createBuildFile(new WorkspacePath("com/google/foo/BUILD"), "rule_type(name = \"target\")", "java_library(name = \"local_ref\", srcs = [\":target\"])");
    BuildFile barPackage = createBuildFile(new WorkspacePath("com/google/test/bar/BUILD"), "rule_type(name = \"ref\", arg = \"//com/google/foo:target\")", "top_level_ref = \"//com/google/foo:target\"");
    FuncallExpression targetRule = PsiUtils.findFirstChildOfClassRecursive(fooPackage, FuncallExpression.class);
    testFixture.renameElement(targetRule, "newTargetName");
    assertFileContents(fooPackage, "rule_type(name = \"newTargetName\")", "java_library(name = \"local_ref\", srcs = [\":newTargetName\"])");
    assertFileContents(barPackage, "rule_type(name = \"ref\", arg = \"//com/google/foo:newTargetName\")", "top_level_ref = \"//com/google/foo:newTargetName\"");
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) FuncallExpression(com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression) Test(org.junit.Test)

Example 80 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.

the class RenameRefactoringTest method testRenameDirectory.

// all references, including path fragments in labels, should be renamed.
@Test
public void testRenameDirectory() {
    createBuildFile(new WorkspacePath("java/com/baz/BUILD"));
    createBuildFile(new WorkspacePath("java/com/google/tools/BUILD"));
    BuildFile buildFile = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "load(", "\"//java/com/google/tools:build_defs.bzl\",", "\"function\"", ")", "function(name = \"name\", deps = [\"//java/com/baz:target\"]");
    renameDirectory(new WorkspacePath("java/com"), new WorkspacePath("java/alt"));
    assertFileContents(buildFile, "load(", "\"//java/alt/google/tools:build_defs.bzl\",", "\"function\"", ")", "function(name = \"name\", deps = [\"//java/alt/baz:target\"]");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) Test(org.junit.Test)

Aggregations

WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)509 Test (org.junit.Test)454 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)197 PsiFile (com.intellij.psi.PsiFile)84 File (java.io.File)75 ProjectView (com.google.idea.blaze.base.projectview.ProjectView)53 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)48 Editor (com.intellij.openapi.editor.Editor)46 VirtualFile (com.intellij.openapi.vfs.VirtualFile)41 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)40 FuncallExpression (com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression)37 PsiReference (com.intellij.psi.PsiReference)37 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)34 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)34 BlazeContentEntry (com.google.idea.blaze.java.sync.model.BlazeContentEntry)33 BlazeCommandRunConfiguration (com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)29 MockBlazeProjectDataBuilder (com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder)26 ImportRoots (com.google.idea.blaze.base.sync.projectview.ImportRoots)26 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)25 PsiElement (com.intellij.psi.PsiElement)25