use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class BuiltInSymbolCompletionContributorTest method testNoCompletionAfterInteger.
@Test
public void testNoCompletionAfterInteger() {
BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "123");
Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
editorTest.setCaretPosition(editor, 0, "123".length());
assertThat(editorTest.getCompletionItemsAsStrings()).isEmpty();
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class BuiltInSymbolCompletionContributorTest method testNoCompletionInComment.
@Test
public void testNoCompletionInComment() {
BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "#PACK");
Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
editorTest.setCaretPosition(editor, 0, "#PACK".length());
assertThat(editorTest.getCompletionItemsAsStrings()).isEmpty();
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class FilePathCompletionTest method testInsertPairQuoteOptionRespected.
@Test
public void testInsertPairQuoteOptionRespected() {
boolean old = CodeInsightSettings.getInstance().AUTOINSERT_PAIR_QUOTE;
try {
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_QUOTE = false;
BuildFile file = createBuildFile(new WorkspacePath("java/BUILD"), "'//");
Editor editor = editorTest.openFileInEditor(file);
editorTest.setCaretPosition(editor, 0, "'//".length());
assertThat(editorTest.completeIfUnique()).isTrue();
assertFileContents(file, "'//java");
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_QUOTE = true;
file = createBuildFile(new WorkspacePath("foo/BUILD"), "'//j");
editor = editorTest.openFileInEditor(file);
editorTest.setCaretPosition(editor, 0, "'//j".length());
assertThat(editorTest.completeIfUnique()).isTrue();
assertFileContents(file, "'//java'");
} finally {
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_QUOTE = old;
}
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class FilePathCompletionTest method testUniqueDirectoryCompleted.
@Test
public void testUniqueDirectoryCompleted() {
BuildFile file = createBuildFile(new WorkspacePath("java/BUILD"), "'//'");
Editor editor = editorTest.openFileInEditor(file);
editorTest.setCaretPosition(editor, 0, "'//".length());
assertThat(editorTest.completeIfUnique()).isTrue();
assertFileContents(file, "'//java'");
// check caret remains inside closing quote
editorTest.assertCaretPosition(editor, 0, "'//java".length());
}
use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.
the class FilePathCompletionTest method testMultiStageCompletion.
// expected to be a typical workflow -- complete a segment,
// get the possibilities, then start typing
// next segment and complete again
@Test
public void testMultiStageCompletion() {
workspace.createDirectory(new WorkspacePath("foo"));
workspace.createDirectory(new WorkspacePath("bar"));
workspace.createDirectory(new WorkspacePath("other"));
workspace.createDirectory(new WorkspacePath("other/foo"));
workspace.createDirectory(new WorkspacePath("other/bar"));
BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "'//'");
Editor editor = editorTest.openFileInEditor(file);
editorTest.setCaretPosition(editor, 0, "'//".length());
String[] completionItems = editorTest.getCompletionItemsAsStrings();
assertThat(completionItems).hasLength(3);
editorTest.performTypingAction(editor, 'o');
assertThat(editorTest.completeIfUnique()).isTrue();
assertFileContents(file, "'//other'");
editorTest.assertCaretPosition(editor, 0, "'//other".length());
editorTest.performTypingAction(editor, '/');
editorTest.performTypingAction(editor, 'f');
assertThat(editorTest.completeIfUnique()).isTrue();
assertFileContents(file, "'//other/foo'");
editorTest.assertCaretPosition(editor, 0, "'//other/foo".length());
}
Aggregations