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