mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Try to resolve a class-level name in the outer context if it exists, but it is not found in the latest defs (PY-6540)
This commit is contained in:
@@ -998,7 +998,7 @@ public class PyClassImpl extends PyPresentableElementImpl<PyClassStub> implement
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyResolveUtil.scopeCrawlUp(processor, this, this);
|
||||
PyResolveUtil.scopeCrawlUp(processor, this, null, this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,15 @@ public class PyReferenceImpl implements PsiReferenceEx, PsiPolyVariantReference
|
||||
if (!latest.isEmpty()) {
|
||||
return latest;
|
||||
}
|
||||
if (!isCythonLevel(myElement)) {
|
||||
if (owner instanceof PyClass) {
|
||||
final ScopeOwner classOwner = ScopeUtil.getScopeOwner(owner);
|
||||
if (classOwner != null) {
|
||||
final ResolveProcessor outerProcessor = new ResolveProcessor(referencedName);
|
||||
PyResolveUtil.scopeCrawlUp(outerProcessor, classOwner, referencedName, roof);
|
||||
uexpr = outerProcessor.getResult();
|
||||
}
|
||||
}
|
||||
else if (!isCythonLevel(myElement)) {
|
||||
uexpr = null;
|
||||
}
|
||||
}
|
||||
@@ -511,7 +519,7 @@ public class PyReferenceImpl implements PsiReferenceEx, PsiPolyVariantReference
|
||||
final CompletionVariantsProcessor processor = new CompletionVariantsProcessor(element);
|
||||
final ScopeOwner owner = realContext instanceof ScopeOwner ? (ScopeOwner)realContext : ScopeUtil.getScopeOwner(realContext);
|
||||
if (owner != null) {
|
||||
PyResolveUtil.scopeCrawlUp(processor, owner, null);
|
||||
PyResolveUtil.scopeCrawlUp(processor, owner, null, null);
|
||||
}
|
||||
|
||||
// in a call, include function's arg names
|
||||
@@ -520,7 +528,7 @@ public class PyReferenceImpl implements PsiReferenceEx, PsiPolyVariantReference
|
||||
// include builtin names
|
||||
final PyFile builtinsFile = PyBuiltinCache.getInstance(element).getBuiltinsFile();
|
||||
if (builtinsFile != null) {
|
||||
PyResolveUtil.scopeCrawlUp(processor, builtinsFile, null);
|
||||
PyResolveUtil.scopeCrawlUp(processor, builtinsFile, null, null);
|
||||
}
|
||||
|
||||
if (underscores >= 2) {
|
||||
|
||||
@@ -103,8 +103,9 @@ public class PyResolveUtil {
|
||||
scopeCrawlUp(processor, owner, originalOwner, name, roof);
|
||||
}
|
||||
|
||||
public static void scopeCrawlUp(@NotNull PsiScopeProcessor processor, @NotNull ScopeOwner scopeOwner, @Nullable PsiElement roof) {
|
||||
scopeCrawlUp(processor, scopeOwner, scopeOwner, null, roof);
|
||||
public static void scopeCrawlUp(@NotNull PsiScopeProcessor processor, @NotNull ScopeOwner scopeOwner, @Nullable String name,
|
||||
@Nullable PsiElement roof) {
|
||||
scopeCrawlUp(processor, scopeOwner, scopeOwner, name, roof);
|
||||
}
|
||||
|
||||
private static void scopeCrawlUp(@NotNull PsiScopeProcessor processor, @Nullable ScopeOwner scopeOwner,
|
||||
|
||||
@@ -186,7 +186,7 @@ public class PyModuleType implements PyType { // Modules don't descend from obje
|
||||
@Override
|
||||
public void handleEvent(Event event, @Nullable Object associated) {
|
||||
}
|
||||
}, owner, null);
|
||||
}, owner, null, null);
|
||||
return visibleImports;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo(object):
|
||||
pass
|
||||
|
||||
class Bar(object):
|
||||
Foo = Foo
|
||||
# <ref>
|
||||
|
||||
@@ -467,4 +467,9 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
public void testLambdaParameterInDefaultValue() {
|
||||
assertResolvesTo(PyNamedParameter.class, "xx");
|
||||
}
|
||||
|
||||
// PY-6540
|
||||
public void testClassRedefinedField() {
|
||||
assertResolvesTo(PyClass.class, "Foo");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user