Search in sources :

Example 91 with BuildFile

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();
}
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 92 with BuildFile

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();
}
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 93 with BuildFile

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;
    }
}
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 94 with BuildFile

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());
}
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 95 with BuildFile

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());
}
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