use of com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression in project intellij by bazelbuild.
the class ExternalWorkspaceReferenceTest method testLocalTargetReferenceWithinExternalWorkspaceResolves.
@Test
public void testLocalTargetReferenceWithinExternalWorkspaceResolves() {
BuildFile externalFile = (BuildFile) createFileInExternalWorkspace("junit", new WorkspacePath("BUILD"), "java_import(", " name = 'jar',", " jars = ['junit-4.11.jar'],", ")", "java_library(", " name = 'lib',", " srcs = [':jar'],", ")");
FuncallExpression target = externalFile.findRule("jar");
assertThat(target).isNotNull();
Argument.Keyword arg = externalFile.findRule("lib").getKeywordArgument("srcs");
StringLiteral label = PsiUtils.findFirstChildOfClassRecursive(arg, StringLiteral.class);
assertThat(label.getReferencedElement()).isEqualTo(target);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression in project intellij by bazelbuild.
the class LabelReferenceTest method testTargetInAnotherPackageResolves.
@Test
public void testTargetInAnotherPackageResolves() {
BuildFile targetFile = createBuildFile(new WorkspacePath("java/com/google/foo/BUILD"), "rule(name = \"target\")");
BuildFile referencingFile = createBuildFile(new WorkspacePath("java/com/google/bar/BUILD"), "rule(name = \"other\", dep = \"//java/com/google/foo:target\")");
FuncallExpression target = targetFile.findRule("target");
assertThat(target).isNotNull();
Argument.Keyword depArgument = referencingFile.findRule("other").getKeywordArgument("dep");
assertThat(depArgument.getValue().getReferencedElement()).isEqualTo(target);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression in project intellij by bazelbuild.
the class LabelReferenceTest method testAbsoluteLabelInSkylarkExtension.
@Test
public void testAbsoluteLabelInSkylarkExtension() {
BuildFile targetFile = createBuildFile(new WorkspacePath("java/com/google/foo/BUILD"), "rule(name = \"foo\")");
BuildFile referencingFile = createBuildFile(new WorkspacePath("java/com/google/foo/skylark.bzl"), "LIST = ['//java/com/google/foo:foo']");
FuncallExpression target = targetFile.findRule("foo");
assertThat(target).isNotNull();
StringLiteral label = PsiUtils.findFirstChildOfClassRecursive(referencingFile, StringLiteral.class);
assertThat(label.getReferencedElement()).isEqualTo(target);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression in project intellij by bazelbuild.
the class LabelReferenceTest method testLabelWithImplicitRuleName.
@Test
public void testLabelWithImplicitRuleName() {
BuildFile targetFile = createBuildFile(new WorkspacePath("java/com/google/foo/BUILD"), "rule(name = \"foo\")");
BuildFile referencingFile = createBuildFile(new WorkspacePath("java/com/google/bar/BUILD"), "rule(name = \"other\", dep = \"//java/com/google/foo\")");
FuncallExpression target = targetFile.findRule("foo");
assertThat(target).isNotNull();
Argument.Keyword depArgument = referencingFile.findRule("other").getKeywordArgument("dep");
assertThat(depArgument.getValue().getReferencedElement()).isEqualTo(target);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression in project intellij by bazelbuild.
the class LabelReferenceTest method testLocalRuleReference.
@Test
public void testLocalRuleReference() {
BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "java_library(name = \"lib\")", "java_library(name = \"foo\", deps = [\":lib\"])", "java_library(name = \"bar\", deps = [\"//java/com/google:lib\"])");
FuncallExpression lib = file.findRule("lib");
FuncallExpression foo = file.findRule("foo");
FuncallExpression bar = file.findRule("bar");
assertThat(lib).isNotNull();
StringLiteral label = PsiUtils.findFirstChildOfClassRecursive(foo.getKeywordArgument("deps"), StringLiteral.class);
assertThat(label.getReferencedElement()).isEqualTo(lib);
label = PsiUtils.findFirstChildOfClassRecursive(bar.getKeywordArgument("deps"), StringLiteral.class);
assertThat(label.getReferencedElement()).isEqualTo(lib);
}
Aggregations