Search in sources :

Example 6 with ReferenceExpression

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

the class LocalReferenceTest method testReferenceResolves.

@Test
public void testReferenceResolves() {
    BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "a = 1", "c = a");
    AssignmentStatement[] stmts = file.childrenOfClass(AssignmentStatement.class);
    ReferenceExpression ref = (ReferenceExpression) stmts[1].getAssignedValue();
    PsiElement referencedElement = ref.getReferencedElement();
    assertThat(referencedElement).isEqualTo(stmts[0].getLeftHandSideExpression());
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) AssignmentStatement(com.google.idea.blaze.base.lang.buildfile.psi.AssignmentStatement) ReferenceExpression(com.google.idea.blaze.base.lang.buildfile.psi.ReferenceExpression) PsiElement(com.intellij.psi.PsiElement) Test(org.junit.Test)

Example 7 with ReferenceExpression

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

the class LocalReferenceTest method testCreatesReference.

@Test
public void testCreatesReference() {
    BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "a = 1", "c = a");
    AssignmentStatement[] stmts = file.childrenOfClass(AssignmentStatement.class);
    assertThat(stmts).hasLength(2);
    assertThat(stmts[1].getAssignedValue()).isInstanceOf(ReferenceExpression.class);
    ReferenceExpression ref = (ReferenceExpression) stmts[1].getAssignedValue();
    assertThat(ref.getReference()).isInstanceOf(LocalReference.class);
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) AssignmentStatement(com.google.idea.blaze.base.lang.buildfile.psi.AssignmentStatement) ReferenceExpression(com.google.idea.blaze.base.lang.buildfile.psi.ReferenceExpression) Test(org.junit.Test)

Aggregations

BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)7 ReferenceExpression (com.google.idea.blaze.base.lang.buildfile.psi.ReferenceExpression)7 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)7 Test (org.junit.Test)7 AssignmentStatement (com.google.idea.blaze.base.lang.buildfile.psi.AssignmentStatement)4 TargetExpression (com.google.idea.blaze.base.lang.buildfile.psi.TargetExpression)3 FuncallExpression (com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression)2 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)2 LoadedSymbol (com.google.idea.blaze.base.lang.buildfile.psi.LoadedSymbol)1 PsiElement (com.intellij.psi.PsiElement)1