use of com.jetbrains.python.psi.PyRecursiveElementVisitor in project intellij-community by JetBrains.
the class PyDependentModuleMembersCollector method collect.
@Override
public void collect(final PsiNamedElement member) {
if (member.getContainingFile() == myModule) {
final PyResolveContext resolveContext = PyResolveContext.defaultContext();
final PsiElement memberBody = PyMoveModuleMembersHelper.expandNamedElementBody(member);
assert memberBody != null;
memberBody.accept(new PyRecursiveElementVisitor() {
@Override
public void visitElement(PsiElement element) {
for (PsiElement result : PyUtil.multiResolveTopPriority(element, resolveContext)) {
if (result != null && isValidSameModuleDependency(result) && result != member) {
myCollection.add((PsiNamedElement) result);
}
}
super.visitElement(element);
}
});
}
}
use of com.jetbrains.python.psi.PyRecursiveElementVisitor in project intellij-community by JetBrains.
the class PyRenameUnresolvedRefQuickFix method collectExpressionsToRename.
private static List<PyReferenceExpression> collectExpressionsToRename(@NotNull final PyReferenceExpression expression, @NotNull final ScopeOwner parentScope) {
final List<PyReferenceExpression> result = new ArrayList<>();
PyRecursiveElementVisitor visitor = new PyRecursiveElementVisitor() {
@Override
public void visitPyReferenceExpression(PyReferenceExpression node) {
if (node.textMatches(expression) && !isValidReference(node.getReference())) {
result.add(node);
}
super.visitPyReferenceExpression(node);
}
};
parentScope.accept(visitor);
return result;
}
Aggregations