Search in sources :

Example 11 with GlobExpression

use of com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression in project intellij by bazelbuild.

the class GlobFindUsagesTest method testGlobWithExcludes.

@Test
public void testGlobWithExcludes() {
    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(" + "  ['**/*.java']," + "  exclude = ['tests/*.java'])");
    GlobExpression glob = PsiUtils.findFirstChildOfClassRecursive(file, GlobExpression.class);
    PsiReference[] references = FindUsages.findAllReferences(foo);
    assertThat(references).hasLength(1);
    assertThat(references[0].getElement()).isEqualTo(glob);
    assertThat(FindUsages.findAllReferences(test)).isEmpty();
}
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 12 with GlobExpression

use of com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression in project intellij by bazelbuild.

the class GlobFindUsagesTest method testSimpleGlobReferencingSingleFile2.

@Test
public void testSimpleGlobReferencingSingleFile2() {
    PsiFile ref = workspace.createPsiFile(new WorkspacePath("java/com/google/Test.java"));
    BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "glob(['*.java'])");
    GlobExpression glob = PsiUtils.findFirstChildOfClassRecursive(file, GlobExpression.class);
    PsiReference[] references = FindUsages.findAllReferences(ref);
    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 13 with GlobExpression

use of com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression in project intellij by bazelbuild.

the class GlobFindUsagesTest 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);
    PsiReference[] references = FindUsages.findAllReferences(ref);
    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 14 with GlobExpression

use of com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression in project intellij by bazelbuild.

the class GlobReferenceTest method testSimpleGlobReferencingSingleFile.

@Test
public void testSimpleGlobReferencingSingleFile() {
    PsiFile ref = workspace.createPsiFile(new WorkspacePath("java/com/google/Test.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(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 15 with GlobExpression

use of com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression in project intellij by bazelbuild.

the class GlobReferenceTest method testSimpleGlobReferencingSingleFile2.

@Test
public void testSimpleGlobReferencingSingleFile2() {
    PsiFile ref = workspace.createPsiFile(new WorkspacePath("java/com/google/Test.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(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)

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