Search in sources :

Example 61 with BuildFile

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

the class BuildQuoteHandlerTest method testAdditionalTripleQuotesNotInsertedWhenClosingQuotes.

@Test
public void testAdditionalTripleQuotesNotInsertedWhenClosingQuotes() {
    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 62 with BuildFile

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

the class EnterInLineCommentTest method testInternalNewlineCommented.

@Test
public void testInternalNewlineCommented() {
    BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "# first line comment", "# second line comment");
    Editor editor = editorTest.openFileInEditor(file.getVirtualFile());
    editorTest.setCaretPosition(editor, 1, "# second ".length());
    editorTest.performTypingAction(editor, '\n');
    assertFileContents(file, "# first line comment", "# second ", "# line comment");
    editorTest.assertCaretPosition(editor, 2, 2);
}
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 63 with BuildFile

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

the class BlazePackageFindUsagesTest method testLabelFragmentReferenceFound.

@Test
public void testLabelFragmentReferenceFound() {
    BuildFile foo = createBuildFile(new WorkspacePath("java/com/google/foo/BUILD"), "java_library(name = \"lib\")");
    BuildFile bar = createBuildFile(new WorkspacePath("java/com/google/bar/BUILD"), "java_library(name = \"lib2\", exports = [\"//java/com/google/foo:lib\"])");
    PsiReference[] references = FindUsages.findAllReferences(foo);
    assertThat(references).hasLength(1);
    PsiElement ref = references[0].getElement();
    assertThat(ref).isInstanceOf(StringLiteral.class);
    assertThat(ref.getContainingFile()).isEqualTo(bar);
}
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) PsiElement(com.intellij.psi.PsiElement) Test(org.junit.Test)

Example 64 with BuildFile

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

the class ExternalFileUsagesTest method testSkylarkExtensionReferencedFromSubpackage.

@Test
public void testSkylarkExtensionReferencedFromSubpackage() {
    createBuildFile(new WorkspacePath("com/google/foo/BUILD"));
    BuildFile ext1 = createBuildFile(new WorkspacePath("com/google/foo/subdir/testing.bzl"), "def fn(): return");
    createBuildFile(new WorkspacePath("com/google/foo/subdir/other.bzl"), "load(':subdir/testing.bzl', 'fn')");
    PsiReference[] references = FindUsages.findAllReferences(ext1);
    assertThat(references).hasLength(1);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) PsiReference(com.intellij.psi.PsiReference) Test(org.junit.Test)

Example 65 with BuildFile

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

the class FindParameterUsagesTest method testLocalReferences.

@Test
public void testLocalReferences() {
    BuildFile buildFile = createBuildFile(new WorkspacePath("java/com/google/build_defs.bzl"), "def function(arg1, arg2)", "function(arg1 = 1, arg2 = \"name\")");
    FunctionStatement fn = buildFile.findChildByClass(FunctionStatement.class);
    ParameterList params = fn.getParameterList();
    PsiReference[] references = FindUsages.findAllReferences(params.findParameterByName("arg1"));
    assertThat(references).hasLength(1);
    references = FindUsages.findAllReferences(params.findParameterByName("arg2"));
    assertThat(references).hasLength(1);
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) FunctionStatement(com.google.idea.blaze.base.lang.buildfile.psi.FunctionStatement) ParameterList(com.google.idea.blaze.base.lang.buildfile.psi.ParameterList) PsiReference(com.intellij.psi.PsiReference) 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