Search in sources :

Example 1 with PyForPart

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

the class PyForStatementNavigator method getPyForStatementByBody.

@Nullable
public static Object getPyForStatementByBody(final PsiElement element) {
    final PyForStatement forStatement = PsiTreeUtil.getParentOfType(element, PyForStatement.class, false);
    if (forStatement == null) {
        return null;
    }
    final PyForPart forPart = forStatement.getForPart();
    return forPart == element || forPart.getStatementList() == element ? forStatement : null;
}
Also used : PyForStatement(com.jetbrains.python.psi.PyForStatement) PyForPart(com.jetbrains.python.psi.PyForPart) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PyForPart (com.jetbrains.python.psi.PyForPart)1 PyForStatement (com.jetbrains.python.psi.PyForStatement)1 Nullable (org.jetbrains.annotations.Nullable)1