use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile 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.BuildFile in project intellij by bazelbuild.
the class GlobFindUsagesTest method testFilesInSubpackagesExcluded.
@Test
public void testFilesInSubpackagesExcluded() {
BuildFile pkg = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "glob(['**/*.java'])");
BuildFile subPkg = createBuildFile(new WorkspacePath("java/com/google/other/BUILD"));
workspace.createFile(new WorkspacePath("java/com/google/other/Other.java"));
PsiUtils.findFirstChildOfClassRecursive(pkg, GlobExpression.class);
PsiReference[] references = FindUsages.findAllReferences(subPkg);
assertThat(references).isEmpty();
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile 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.BuildFile in project intellij by bazelbuild.
the class GlobFindUsagesTest method testExcludeDirectories.
@Test
public void testExcludeDirectories() {
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'])");
PsiUtils.findFirstChildOfClassRecursive(file, GlobExpression.class);
PsiReference[] references = FindUsages.findAllReferences(dir);
assertThat(references).isEmpty();
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile 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