Don't resolve target expression to latest defs syntactically below it in the PSI (PY-7541)

Resolving to such elements may become a source of resolve loops.
This commit is contained in:
Andrey Vlasovskikh
2012-09-10 23:15:11 +04:00
parent 31cffdd99f
commit 76357c81c9
5 changed files with 48 additions and 0 deletions
@@ -373,6 +373,11 @@ public class PyPsiUtils {
return expression instanceof PyStringLiteralExpression ? ((PyStringLiteralExpression)expression).getStringValue() : null;
}
public static boolean isBefore(@NotNull final PsiElement element, @NotNull final PsiElement element2) {
// TODO: From RubyPsiUtil, should be moved to PsiTreeUtil
return element.getTextOffset() <= element2.getTextOffset();
}
private static abstract class TopLevelVisitor extends PyRecursiveElementVisitor {
public void visitPyElement(final PyElement node) {
super.visitPyElement(node);