Search in sources :

Example 16 with GlobExpression

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

the class GlobReferenceTest method testFindsSubDirectories.

@Test
public void testFindsSubDirectories() {
    PsiFile ref1 = workspace.createPsiFile(new WorkspacePath("java/com/google/test/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);
}
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 17 with GlobExpression

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

the class GlobReferenceTest method testGlobWithExcludes.

@Test
public void testGlobWithExcludes() {
    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);
    List<PsiElement> references = multiResolve(glob);
    assertThat(references).hasSize(1);
    assertThat(references).containsExactly(foo);
}
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