Search in sources :

Example 1 with PySubscriptionExpression

use of com.jetbrains.python.psi.PySubscriptionExpression in project intellij-community by JetBrains.

the class PyAssignmentMappingTest method testSubscribedTarget.

public void testSubscribedTarget() throws Exception {
    Map<String, PsiElement> marks = loadTest();
    Assert.assertEquals(2, marks.size());
    // const -> expr;
    PsiElement src = marks.get("<src>").getParent();
    // ident -> target expr
    PsiElement dst = marks.get("<dst>").getParent().getParent();
    Assert.assertTrue(dst instanceof PySubscriptionExpression);
    PyAssignmentStatement stmt = (PyAssignmentStatement) src.getParent();
    List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
    Assert.assertEquals(1, mapping.size());
    Pair<PyExpression, PyExpression> pair = mapping.get(0);
    Assert.assertEquals(dst, pair.getFirst());
    Assert.assertEquals(src, pair.getSecond());
}
Also used : PyExpression(com.jetbrains.python.psi.PyExpression) PySubscriptionExpression(com.jetbrains.python.psi.PySubscriptionExpression) PyAssignmentStatement(com.jetbrains.python.psi.PyAssignmentStatement) PsiElement(com.intellij.psi.PsiElement) Pair(com.intellij.openapi.util.Pair)

Aggregations

Pair (com.intellij.openapi.util.Pair)1 PsiElement (com.intellij.psi.PsiElement)1 PyAssignmentStatement (com.jetbrains.python.psi.PyAssignmentStatement)1 PyExpression (com.jetbrains.python.psi.PyExpression)1 PySubscriptionExpression (com.jetbrains.python.psi.PySubscriptionExpression)1