Search in sources :

Example 81 with BuildFile

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

the class BuiltInFunctionAttributeCompletionContributorTest method testNoCompletionInComment.

@Test
public void testNoCompletionInComment() {
    setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data");
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "sh_binary(#");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 0, "sh_binary(#".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 82 with BuildFile

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

the class BuiltInFunctionAttributeCompletionContributorTest method testNoCompletionAfterInteger.

@Test
public void testNoCompletionAfterInteger() {
    setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data");
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "sh_binary(testonly = 1,");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 0, "sh_binary(testonly = 1".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 83 with BuildFile

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

the class BuiltInFunctionAttributeCompletionContributorTest method testNoCompletionInUnknownRule.

@Test
public void testNoCompletionInUnknownRule() {
    ServiceHelper.unregisterLanguageExtensionPoint("com.intellij.completion.contributor", BuiltInSymbolCompletionContributor.class, getTestRootDisposable());
    ServiceHelper.unregisterLanguageExtensionPoint("com.intellij.completion.contributor", BuiltInFunctionCompletionContributor.class, getTestRootDisposable());
    setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data");
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "java_binary(");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 0, "java_binary(".length());
    LookupElement[] completionItems = testFixture.completeBasic();
    assertThat(completionItems).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) LookupElement(com.intellij.codeInsight.lookup.LookupElement) Test(org.junit.Test)

Example 84 with BuildFile

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

the class BuiltInFunctionAttributeCompletionContributorTest method testDoNotShowExistingAttributesInAutocompleteSuggestions.

@Test
public void testDoNotShowExistingAttributesInAutocompleteSuggestions() {
    setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data");
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "sh_binary(name = 'bin', )");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 0, "sh_binary(name = 'bin', ".length());
    String[] completionItems = editorTest.getCompletionItemsAsStrings();
    assertThat(completionItems).asList().containsAllOf("deps", "srcs", "data");
    assertThat(completionItems).asList().doesNotContain("name");
}
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 85 with BuildFile

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

the class BuiltInFunctionAttributeCompletionContributorTest method testSimpleCompletion.

@Test
public void testSimpleCompletion() {
    setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data");
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "sh_binary(");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 0, "sh_binary(".length());
    String[] completionItems = editorTest.getCompletionItemsAsStrings();
    assertThat(completionItems).asList().containsAllOf("name", "deps", "srcs", "data");
}
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)

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