Search in sources :

Example 56 with BuildFile

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

the class LabelReferenceTest method testRulePreferredOverFile.

@Test
public void testRulePreferredOverFile() {
    BuildFile targetFile = createBuildFile(new WorkspacePath("java/com/foo/BUILD"), "java_library(name = 'lib')");
    workspace.createDirectory(new WorkspacePath("java/com/foo/lib"));
    BuildFile referencingFile = createBuildFile(new WorkspacePath("java/com/google/bar/BUILD"), "java_library(", "    name = 'bar',", "    src = glob(['**/*.java'])," + "    deps = ['//java/com/foo:lib'],", ")");
    FuncallExpression target = targetFile.findRule("lib");
    assertThat(target).isNotNull();
    PsiReference[] references = FindUsages.findAllReferences(target);
    assertThat(references).hasLength(1);
    PsiElement element = references[0].getElement();
    FuncallExpression rule = PsiUtils.getParentOfType(element, FuncallExpression.class, true);
    assertThat(rule.getName()).isEqualTo("bar");
    assertThat(rule.getContainingFile()).isEqualTo(referencingFile);
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) PsiReference(com.intellij.psi.PsiReference) FuncallExpression(com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression) PsiElement(com.intellij.psi.PsiElement) Test(org.junit.Test)

Example 57 with BuildFile

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

the class BuildQuoteHandlerTest method testClosingSingleQuoteInserted.

@Test
public void testClosingSingleQuoteInserted() {
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "");
    editorTest.performTypingAction(file, '\'');
    assertFileContents(file, "''");
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Test(org.junit.Test)

Example 58 with BuildFile

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

the class BuildQuoteHandlerTest method testClosingTripleSingleQuoteInserted.

@Test
public void testClosingTripleSingleQuoteInserted() {
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "");
    editorTest.performTypingAction(file, '\'');
    editorTest.performTypingAction(file, '\'');
    editorTest.performTypingAction(file, '\'');
    assertFileContents(file, "''''''");
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Test(org.junit.Test)

Example 59 with BuildFile

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

the class BuildQuoteHandlerTest method testAdditionalQuoteNotInsertedWhenClosingQuotes.

@Test
public void testAdditionalQuoteNotInsertedWhenClosingQuotes() {
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "'text<caret>", "laterContents");
    testFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    editorTest.performTypingAction(file, '\'');
    testFixture.checkResult(Joiner.on("\n").join("'text'<caret>", "laterContents"));
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Test(org.junit.Test)

Example 60 with BuildFile

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

the class BuildQuoteHandlerTest method testOnlyCaretMovedWhenCompletingExistingClosingQuotes.

@Test
public void testOnlyCaretMovedWhenCompletingExistingClosingQuotes() {
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "'text<caret>'", "laterContents");
    testFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    editorTest.performTypingAction(file, '\'');
    testFixture.checkResult(Joiner.on("\n").join("'text'<caret>", "laterContents"));
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) 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