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");
}
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");
}
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'");
}
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']");
}
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'");
}
Aggregations