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);
}
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);
}
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");
}
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\"");
}
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\"]");
}
Aggregations