use of com.jetbrains.python.psi.stubs.PyFunctionStub in project intellij-community by JetBrains.
the class PyClassImpl method getTargetExpressions.
@NotNull
private static List<PyTargetExpression> getTargetExpressions(@NotNull PyFunction function) {
final PyFunctionStub stub = function.getStub();
if (stub != null) {
return Arrays.asList(stub.getChildrenByType(PyElementTypes.TARGET_EXPRESSION, PyTargetExpression.EMPTY_ARRAY));
} else {
final PyStatementList statementList = function.getStatementList();
final List<PyTargetExpression> result = new ArrayList<>();
statementList.accept(new PyRecursiveElementVisitor() {
@Override
public void visitPyClass(PyClass node) {
}
public void visitPyAssignmentStatement(final PyAssignmentStatement node) {
for (PyExpression expression : node.getTargets()) {
if (expression instanceof PyTargetExpression) {
result.add((PyTargetExpression) expression);
}
}
}
@Override
public void visitPyWithStatement(PyWithStatement node) {
StreamEx.of(node.getWithItems()).map(PyWithItem::getTarget).select(PyTargetExpression.class).forEach(result::add);
}
});
return result;
}
}
Aggregations