use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class GlobReferenceTest method testSimpleGlobReferencingSingleFile3.
@Test
public void testSimpleGlobReferencingSingleFile3() {
PsiFile ref = workspace.createPsiFile(new WorkspacePath("java/com/google/Test.java"));
BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "glob(['T*t.java'])");
GlobExpression glob = PsiUtils.findFirstChildOfClassRecursive(file, GlobExpression.class);
List<PsiElement> references = multiResolve(glob);
assertThat(references).hasSize(1);
assertThat(references).containsExactly(ref);
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class KeywordReferenceTest method testKwargsReference.
@Test
public void testKwargsReference() {
BuildFile file = createBuildFile(new WorkspacePath("java/com/google/build_defs.bzl"), "def function(name, **kwargs)", "function(name = \"name\", deps = [])");
ArgumentList args = file.firstChildOfClass(FuncallExpression.class).getArgList();
assertThat(args.getKeywordArgument("deps").getReferencedElement()).isInstanceOf(Parameter.StarStar.class);
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class LabelReferenceTest method testRuleNameDoesntCrossPackageBoundaries.
@Test
public void testRuleNameDoesntCrossPackageBoundaries() {
BuildFile targetFile = createBuildFile(new WorkspacePath("java/com/google/pkg/subpkg/BUILD"), "rule(name = \"target\")");
BuildFile referencingFile = createBuildFile(new WorkspacePath("java/com/google/pkg/BUILD"), "rule(name = \"other\", dep = \":subpkg/target\")");
Argument.Keyword depArgument = referencingFile.findRule("other").getKeywordArgument("dep");
LabelReference ref = (LabelReference) depArgument.getValue().getReference();
assertThat(ref.resolve()).isNull();
editorTest.replaceStringContents(ref.getElement(), "//java/com/google/pkg/subpkg:target");
assertThat(ref.resolve()).isNotNull();
assertThat(ref.resolve()).isEqualTo(targetFile.findRule("target"));
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class LabelReferenceTest method testRulePreferredOverFile.
@Test
public void testRulePreferredOverFile() {
BuildFile targetFile = createBuildFile(new WorkspacePath("java/com/foo/BUILD"), "java_library(name = 'lib')");
workspace.createDirectory(new WorkspacePath("java/com/foo/lib"));
BuildFile referencingFile = createBuildFile(new WorkspacePath("java/com/google/bar/BUILD"), "java_library(", " name = 'bar',", " src = glob(['**/*.java'])," + " deps = ['//java/com/foo:lib'],", ")");
FuncallExpression target = targetFile.findRule("lib");
assertThat(target).isNotNull();
PsiReference[] references = FindUsages.findAllReferences(target);
assertThat(references).hasLength(1);
PsiElement element = references[0].getElement();
FuncallExpression rule = PsiUtils.getParentOfType(element, FuncallExpression.class, true);
assertThat(rule.getName()).isEqualTo("bar");
assertThat(rule.getContainingFile()).isEqualTo(referencingFile);
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class BuildQuoteHandlerTest method testClosingSingleQuoteInserted.
@Test
public void testClosingSingleQuoteInserted() {
BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "");
editorTest.performTypingAction(file, '\'');
assertFileContents(file, "''");
}
Aggregations