Search in sources :

Example 86 with BuildFile

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

the class BuiltInFunctionCompletionContributorTest method testSkylarkNativeCompletion.

@Test
public void testSkylarkNativeCompletion() {
    setRules("java_library", "android_binary");
    BuildFile file = createBuildFile(new WorkspacePath("build_defs.bzl"), "def function():", "  native.java_libra");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 1, "  native.java_libra".length());
    LookupElement[] completionItems = testFixture.completeBasic();
    assertThat(completionItems).isNull();
    assertFileContents(file, "def function():", "  native.java_library()");
    editorTest.assertCaretPosition(editor, 1, "  native.java_library(".length());
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Editor(com.intellij.openapi.editor.Editor) LookupElement(com.intellij.codeInsight.lookup.LookupElement) Test(org.junit.Test)

Example 87 with BuildFile

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

the class BuiltInFunctionCompletionContributorTest method testSimpleTopLevelCompletion.

@Test
public void testSimpleTopLevelCompletion() {
    setRules("java_library", "android_binary");
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 0, 0);
    String[] completionItems = editorTest.getCompletionItemsAsStrings();
    assertThat(completionItems).asList().containsAllOf("android_binary", "java_library");
    assertFileContents(file, "");
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Editor(com.intellij.openapi.editor.Editor) Test(org.junit.Test)

Example 88 with BuildFile

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

the class BuiltInFunctionCompletionContributorTest method testNoCompletionInsideRule.

@Test
public void testNoCompletionInsideRule() {
    ServiceHelper.unregisterLanguageExtensionPoint("com.intellij.completion.contributor", BuiltInSymbolCompletionContributor.class, getTestRootDisposable());
    setRules("java_library", "android_binary");
    String[] contents = { "java_library(", "    name = \"lib\"", "" };
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), contents);
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 2, 0);
    LookupElement[] completionItems = testFixture.completeBasic();
    assertThat(completionItems).isEmpty();
    assertFileContents(file, contents);
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Editor(com.intellij.openapi.editor.Editor) LookupElement(com.intellij.codeInsight.lookup.LookupElement) Test(org.junit.Test)

Example 89 with BuildFile

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

the class BuiltInFunctionCompletionContributorTest method testNoCompletionInComment.

@Test
public void testNoCompletionInComment() {
    setRules("java_library", "android_binary");
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "#java");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 0, "#java".length());
    assertThat(editorTest.getCompletionItemsAsStrings()).isEmpty();
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Editor(com.intellij.openapi.editor.Editor) Test(org.junit.Test)

Example 90 with BuildFile

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

the class BuiltInSymbolCompletionContributorTest method testUniqueTopLevelCompletion.

@Test
public void testUniqueTopLevelCompletion() {
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "PACKAGE_N");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 0, "PACKAGE_N".length());
    LookupElement[] completionItems = testFixture.completeBasic();
    assertThat(completionItems).isNull();
    assertFileContents(file, "PACKAGE_NAME");
    editorTest.assertCaretPosition(editor, 0, "PACKAGE_NAME".length());
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Editor(com.intellij.openapi.editor.Editor) LookupElement(com.intellij.codeInsight.lookup.LookupElement) Test(org.junit.Test)

Aggregations

BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)216 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)197 Test (org.junit.Test)196 Editor (com.intellij.openapi.editor.Editor)46 FuncallExpression (com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression)37 PsiReference (com.intellij.psi.PsiReference)32 PsiElement (com.intellij.psi.PsiElement)27 PsiFile (com.intellij.psi.PsiFile)27 StringLiteral (com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral)18 FunctionStatement (com.google.idea.blaze.base.lang.buildfile.psi.FunctionStatement)17 GlobExpression (com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression)16 LookupElement (com.intellij.codeInsight.lookup.LookupElement)13 Argument (com.google.idea.blaze.base.lang.buildfile.psi.Argument)10 TargetExpression (com.google.idea.blaze.base.lang.buildfile.psi.TargetExpression)8 Nullable (javax.annotation.Nullable)8 ReferenceExpression (com.google.idea.blaze.base.lang.buildfile.psi.ReferenceExpression)7 AssignmentStatement (com.google.idea.blaze.base.lang.buildfile.psi.AssignmentStatement)6 LoadStatement (com.google.idea.blaze.base.lang.buildfile.psi.LoadStatement)6 PsiDirectory (com.intellij.psi.PsiDirectory)6 Label (com.google.idea.blaze.base.model.primitives.Label)5