Search in sources :

Example 1 with AssignmentStatement

use of com.google.idea.blaze.base.lang.buildfile.psi.AssignmentStatement 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 2 with AssignmentStatement

use of com.google.idea.blaze.base.lang.buildfile.psi.AssignmentStatement 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

AssignmentStatement (com.google.idea.blaze.base.lang.buildfile.psi.AssignmentStatement)2 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)2 ReferenceExpression (com.google.idea.blaze.base.lang.buildfile.psi.ReferenceExpression)2 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)2 Test (org.junit.Test)2 PsiElement (com.intellij.psi.PsiElement)1