Search in sources :

Example 6 with GlobExpression

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();
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) GlobExpression(com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression) PsiElement(com.intellij.psi.PsiElement) Test(org.junit.Test)

Example 7 with GlobExpression

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);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) PsiFile(com.intellij.psi.PsiFile) GlobExpression(com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression) PsiElement(com.intellij.psi.PsiElement) Test(org.junit.Test)

Example 8 with GlobExpression

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);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) PsiReference(com.intellij.psi.PsiReference) PsiFile(com.intellij.psi.PsiFile) GlobExpression(com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression) Test(org.junit.Test)

Example 9 with GlobExpression

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);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) PsiReference(com.intellij.psi.PsiReference) PsiFile(com.intellij.psi.PsiFile) GlobExpression(com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression) Test(org.junit.Test)

Example 10 with GlobExpression

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);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) PsiDirectory(com.intellij.psi.PsiDirectory) PsiReference(com.intellij.psi.PsiReference) GlobExpression(com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression) Test(org.junit.Test)

Aggregations

GlobExpression (com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression)17 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)16 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)16 Test (org.junit.Test)16 PsiFile (com.intellij.psi.PsiFile)13 PsiElement (com.intellij.psi.PsiElement)10 PsiReference (com.intellij.psi.PsiReference)6 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)1