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