use of com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression 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.GlobExpression 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.GlobExpression in project intellij by bazelbuild.
the class GlobFindUsagesTest method testFindsSubDirectories.
@Test
public void testFindsSubDirectories() {
PsiFile ref1 = workspace.createPsiFile(new WorkspacePath("java/com/google/test/Test.java"));
BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "glob(['**/*.java'])");
GlobExpression glob = PsiUtils.findFirstChildOfClassRecursive(file, GlobExpression.class);
PsiReference[] references = FindUsages.findAllReferences(ref1);
assertThat(references).hasLength(1);
assertThat(references[0].getElement()).isEqualTo(glob);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression in project intellij by bazelbuild.
the class GlobFindUsagesTest 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);
PsiReference[] references = FindUsages.findAllReferences(ref1);
assertThat(references).hasLength(1);
assertThat(references[0].getElement()).isEqualTo(glob);
references = FindUsages.findAllReferences(ref2);
assertThat(references).hasLength(1);
assertThat(references[0].getElement()).isEqualTo(glob);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression in project intellij by bazelbuild.
the class GlobFindUsagesTest method testIncludeDirectories.
@Test
public void testIncludeDirectories() {
PsiDirectory dir = workspace.createPsiDirectory(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 = ['BUILD']," + " exclude_directories = 0)");
GlobExpression glob = PsiUtils.findFirstChildOfClassRecursive(file, GlobExpression.class);
PsiReference[] references = FindUsages.findAllReferences(dir);
assertThat(references).hasLength(1);
assertThat(references[0].getElement()).isEqualTo(glob);
}
Aggregations