mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
resolve works correctly in nested comprehensions (temp fix until parser is rewritten) (PY-3068)
This commit is contained in:
@@ -147,8 +147,12 @@ public class PyResolveUtil {
|
||||
if ((roof != null) && (seeker != null) && !PsiTreeUtil.isAncestor(roof, seeker, false)) return null;
|
||||
// maybe we're capped by a class? param lists are not capped though syntactically inside the function.
|
||||
if (is_outside_param_list && refersFromMethodToClass(capFunction, seeker)) continue;
|
||||
// names defined in a comprehension element are only visible inside it
|
||||
if (seeker instanceof PyComprehensionElement && !PsiTreeUtil.isAncestor(seeker, elt, false)) continue;
|
||||
// names defined in a comprehension element are only visible inside it or the list comp expressions directly above it
|
||||
if (seeker instanceof PyComprehensionElement &&
|
||||
!(seeker.getParent() instanceof PyComprehensionElement) &&
|
||||
!PsiTreeUtil.isAncestor(seeker, elt, false)) {
|
||||
continue;
|
||||
}
|
||||
// check what we got
|
||||
if (seeker != null) {
|
||||
if (!processor.execute(seeker, ResolveState.initial())) {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
lst1 = [[1,2,3],[4,5,6],[7,8,9]]
|
||||
lst2 = [xx for yy in lst1 for xx in yy]
|
||||
# <ref>
|
||||
@@ -405,4 +405,8 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
public void testResolveInGenerator() {
|
||||
assertResolvesTo(PyTargetExpression.class, "foo");
|
||||
}
|
||||
|
||||
public void testNestedListComp() { // PY-3068
|
||||
assertResolvesTo(PyTargetExpression.class, "yy");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user