use of com.jetbrains.python.psi.PyForStatement in project intellij-community by JetBrains.
the class PyForStatementNavigator method getPyForStatementByIterable.
@Nullable
public static PyForStatement getPyForStatementByIterable(final PsiElement element) {
final PyForStatement forStatement = PsiTreeUtil.getParentOfType(element, PyForStatement.class, false);
if (forStatement == null) {
return null;
}
final PyExpression target = forStatement.getForPart().getTarget();
if (target != null && PsiTreeUtil.isAncestor(target, element, false)) {
return forStatement;
}
return null;
}
use of com.jetbrains.python.psi.PyForStatement 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;
}
Aggregations