From 6b8fec0abd4e28a0c66b8d52a3167022edede0b8 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 6 Mar 2008 18:16:09 +0300 Subject: [PATCH] fix resolve on file level --- python/src/com/jetbrains/python/psi/impl/PyFileImpl.java | 3 ++- python/testData/resolve/LookAhead.py | 5 +++++ python/testSrc/com/jetbrains/python/PyResolveTest.java | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 python/testData/resolve/LookAhead.py diff --git a/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java b/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java index 9784dc7dff58..4bb24ae1c761 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java @@ -68,7 +68,8 @@ public class PyFileImpl extends PsiFileBase implements PyFile { @NotNull PsiElement place) { final PsiElement[] children = getChildren(); for (PsiElement child : children) { - if (!child.processDeclarations(processor, substitutor, lastParent, place)) { + if (child == lastParent) continue; + if (!child.processDeclarations(processor, substitutor, null, place)) { return false; } } diff --git a/python/testData/resolve/LookAhead.py b/python/testData/resolve/LookAhead.py new file mode 100644 index 000000000000..42b460ea43fd --- /dev/null +++ b/python/testData/resolve/LookAhead.py @@ -0,0 +1,5 @@ +ggg("q") + +def f(q): pass + +ggg = f diff --git a/python/testSrc/com/jetbrains/python/PyResolveTest.java b/python/testSrc/com/jetbrains/python/PyResolveTest.java index 327a649e75a6..40e498f3ed06 100644 --- a/python/testSrc/com/jetbrains/python/PyResolveTest.java +++ b/python/testSrc/com/jetbrains/python/PyResolveTest.java @@ -53,6 +53,11 @@ public class PyResolveTest extends ResolveTestCase { assertTrue(targetElement instanceof PyTargetExpression); } + public void testLookAhead() throws Exception { + PsiElement targetElement = resolve(); + assertTrue(targetElement instanceof PyTargetExpression); + } + @Override protected String getTestDataPath() { return PathManager.getHomePath() + "/plugins/python/testData/resolve/";