use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class ExternalWorkspaceReferenceTest method testFileReferenceWithinExternalWorkspaceResolves.
@Test
public void testFileReferenceWithinExternalWorkspaceResolves() {
BuildFile externalFile = (BuildFile) createFileInExternalWorkspace("junit", new WorkspacePath("BUILD"), "java_import(", " name = 'target',", " jars = ['junit-4.11.jar'],", ")");
PsiFile jarFile = createFileInExternalWorkspace("junit", new WorkspacePath("junit-4.11.jar"));
FuncallExpression target = externalFile.findRule("target");
StringLiteral label = PsiUtils.findFirstChildOfClassRecursive(target.getKeywordArgument("jars"), StringLiteral.class);
assertThat(label.getReferencedElement()).isEqualTo(jarFile);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class ExternalWorkspaceReferenceTest method testExternalWorkspaceTargetReference.
@Test
public void testExternalWorkspaceTargetReference() {
BuildFile workspaceBuildFile = createBuildFile(new WorkspacePath("BUILD"), "java_library(", " name = 'lib',", " exports = ['@junit//:jar'],", ")");
BuildFile externalBuildFile = (BuildFile) createFileInExternalWorkspace("junit", new WorkspacePath("BUILD"), "java_import(", " name = 'jar',", " jars = ['junit-4.11.jar'],", ")");
FuncallExpression target = externalBuildFile.findRule("jar");
assertThat(target).isNotNull();
Argument.Keyword arg = workspaceBuildFile.findRule("lib").getKeywordArgument("exports");
StringLiteral label = PsiUtils.findFirstChildOfClassRecursive(arg, StringLiteral.class);
assertThat(label.getReferencedElement()).isEqualTo(target);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class GlobReferenceTest method testExcludeDirectories2.
@Test
public void testExcludeDirectories2() {
workspace.createDirectory(new WorkspacePath("java/com/google/tests"));
workspace.createPsiFile(new WorkspacePath("java/com/google/tests/Test.java"));
workspace.createPsiFile(new WorkspacePath("java/com/google/Foo.java"));
BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "glob(['**/*'], exclude = ['**/*'])");
GlobExpression glob = PsiUtils.findFirstChildOfClassRecursive(file, 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 testIncludeDirectories.
@Test
public void testIncludeDirectories() {
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']," + " exclude_directories = 0)");
GlobExpression glob = PsiUtils.findFirstChildOfClassRecursive(file, GlobExpression.class);
List<PsiElement> references = multiResolve(glob);
assertThat(references).hasSize(3);
assertThat(references).containsExactly(foo, test, test.getParent());
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class GlobReferenceTest method testGlobReferencingMultipleFiles.
@Test
public void testGlobReferencingMultipleFiles() {
PsiFile ref1 = workspace.createPsiFile(new WorkspacePath("java/com/google/Test.java"));
PsiFile ref2 = workspace.createPsiFile(new WorkspacePath("java/com/google/Foo.java"));
BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "glob(['*.java'])");
GlobExpression glob = PsiUtils.findFirstChildOfClassRecursive(file, GlobExpression.class);
List<PsiElement> references = multiResolve(glob);
assertThat(references).hasSize(2);
assertThat(references).containsExactly(ref1, ref2);
}
Aggregations