use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class GlobReferenceTest method testExcludeDirectories.
@Test
public void testExcludeDirectories() {
workspace.createDirectory(new WorkspacePath("java/com/google/tests"));
PsiFile test = workspace.createPsiFile(new WorkspacePath("java/com/google/tests/Test.java"));
PsiFile foo = workspace.createPsiFile(new WorkspacePath("java/com/google/Foo.java"));
BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "glob(['**/*'], exclude = ['BUILD'])");
GlobExpression glob = PsiUtils.findFirstChildOfClassRecursive(file, GlobExpression.class);
List<PsiElement> references = multiResolve(glob);
assertThat(references).hasSize(2);
assertThat(references).containsExactly(foo, test);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class GlobReferenceTest method testFilesInSubpackagesExcluded.
@Test
public void testFilesInSubpackagesExcluded() {
BuildFile pkg = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "glob(['**/*.java'])");
createBuildFile(new WorkspacePath("java/com/google/other/BUILD"));
workspace.createFile(new WorkspacePath("java/com/google/other/Other.java"));
GlobExpression glob = PsiUtils.findFirstChildOfClassRecursive(pkg, GlobExpression.class);
List<PsiElement> references = multiResolve(glob);
assertThat(references).isEmpty();
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile 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.lang.buildfile.psi.BuildFile 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.lang.buildfile.psi.BuildFile 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"));
}
Aggregations