use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile 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();
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile 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);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class BuildFileFoldingBuilderTest method testEndOfFileFunctionDelcaration.
@Test
public void testEndOfFileFunctionDelcaration() {
// bug 28618935: test no NPE in the case where there's no
// statement list following the func-def colon
BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "def function():");
getFoldingRegions(file);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class ArgumentCompletionContributorTest method testExistingKeywordArg.
@Test
public void testExistingKeywordArg() {
completionTester.runWithAutoPopupEnabled(() -> {
BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "def function(name, deps, srcs):", " # empty function", "function(name = \"lib\")");
Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
editorTest.setCaretPosition(editor, 2, "function(".length());
String[] completionItems = editorTest.getCompletionItemsAsStrings();
assertThat(completionItems).asList().containsAllOf("name", "deps", "srcs", "function");
});
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class BuildLabelAutoCompletionTest method testPopupAutocompleteAfterColon.
@Test
public void testPopupAutocompleteAfterColon() {
completionTester.runWithAutoPopupEnabled(() -> {
createBuildFile(new WorkspacePath("java/com/foo/BUILD"), "java_library(name = 'target')");
BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "java_library(", " name = 'lib',", " srcs = ['//java/com/foo'],");
Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
editorTest.setCaretPosition(editor, 2, " srcs = ['//java/com/foo".length());
completionTester.typeWithPauses(":");
assertThat(currentLookupStrings()).containsExactly("'//java/com/foo:target'");
});
}
Aggregations