Search in sources :

Example 96 with BuildFile

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

the class ParameterCompletionContributorTest method testKwargsCompletion.

@Test
public void testKwargsCompletion() {
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "def function(arg1, **");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 0, "def function(arg1, **".length());
    LookupElement[] completionItems = testFixture.completeBasic();
    assertThat(completionItems).isNull();
    assertFileContents(file, "def function(arg1, **kwargs");
}
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 97 with BuildFile

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

the class ParameterCompletionContributorTest method testArgsCompletion.

@Test
public void testArgsCompletion() {
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "def function(arg1, *");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 0, "def function(arg1, *".length());
    LookupElement[] completionItems = testFixture.completeBasic();
    assertThat(completionItems).isNull();
    assertFileContents(file, "def function(arg1, *args");
}
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 98 with BuildFile

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

the class RuleTargetCompletionTest method testCustomRuleCompletion.

@Test
public void testCustomRuleCompletion() {
    MockBuildLanguageSpecProvider specProvider = new MockBuildLanguageSpecProvider();
    setBuildLanguageSpecRules(specProvider, "java_library");
    registerApplicationService(BuildLanguageSpecProvider.class, specProvider);
    BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "custom_rule(name = 'lib')", "java_library(", "    name = 'test',", "    deps = [':']");
    Editor editor = editorTest.openFileInEditor(file);
    editorTest.setCaretPosition(editor, 3, "    deps = [':".length());
    LookupElement[] completionItems = testFixture.completeBasic();
    assertThat(completionItems).hasLength(1);
    assertThat(completionItems[0].toString()).isEqualTo("':lib'");
}
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 99 with BuildFile

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

the class RuleTargetCompletionTest method testPackageLocalRulesCompletedWithoutColon.

@Test
public void testPackageLocalRulesCompletedWithoutColon() {
    BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "java_library(name = 'lib')", "java_library(", "    name = 'test',", "    deps = ['']");
    Editor editor = editorTest.openFileInEditor(file);
    editorTest.setCaretPosition(editor, 3, "    deps = ['".length());
    assertThat(editorTest.completeIfUnique()).isTrue();
    assertFileContents(file, "java_library(name = 'lib')", "java_library(", "    name = 'test',", "    deps = ['lib']");
}
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 100 with BuildFile

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

the class RuleTargetCompletionTest method testNonLocalTarget.

@Test
public void testNonLocalTarget() {
    createBuildFile(new WorkspacePath("java/com/google/foo/BUILD"), "java_library(name = 'foo_lib')");
    BuildFile bar = createBuildFile(new WorkspacePath("java/com/google/bar/BUILD"), "java_library(", "    name = 'bar_lib',", "    deps = '//java/com/google/foo:')");
    Editor editor = editorTest.openFileInEditor(bar);
    editorTest.setCaretPosition(editor, 2, "    deps = '//java/com/google/foo:".length());
    String[] completionItems = editorTest.getCompletionItemsAsStrings();
    assertThat(completionItems).asList().containsExactly("'//java/com/google/foo:foo_lib'");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) 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