mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'python-fixes'
This commit is contained in:
@@ -100,20 +100,29 @@ public class ScopeUtil {
|
||||
if (decoratorAncestor != null && !isAncestor(decoratorAncestor, firstOwner, true)) {
|
||||
return nextOwner;
|
||||
}
|
||||
// References in default values of parameters are resolved outside of the function (if the lambda is not inside the default value)
|
||||
final PyParameter parameterAncestor = getParentOfType(element, PyParameter.class);
|
||||
// References in default values or in annotations of parameters are resolved outside of the function (if the lambda is not inside the
|
||||
// default value)
|
||||
final PyNamedParameter parameterAncestor = getParentOfType(element, PyNamedParameter.class);
|
||||
if (parameterAncestor != null && !isAncestor(parameterAncestor, firstOwner, true)) {
|
||||
final PyExpression defaultValue = parameterAncestor.getDefaultValue();
|
||||
if (element != null && isAncestor(defaultValue, element, false)) {
|
||||
final PyAnnotation annotation = parameterAncestor.getAnnotation();
|
||||
if (isAncestor(defaultValue, element, false) || isAncestor(annotation, element, false)) {
|
||||
return nextOwner;
|
||||
}
|
||||
}
|
||||
// Superclasses are resolved outside of the class
|
||||
final PyClass containingClass = getParentOfType(element, PyClass.class);
|
||||
if (containingClass != null && element != null &&
|
||||
isAncestor(containingClass.getSuperClassExpressionList(), element, false)) {
|
||||
if (containingClass != null && isAncestor(containingClass.getSuperClassExpressionList(), element, false)) {
|
||||
return nextOwner;
|
||||
}
|
||||
// Function return annotations are resolved outside of the function
|
||||
if (firstOwner instanceof PyFunction) {
|
||||
final PyFunction function = (PyFunction)firstOwner;
|
||||
final PyAnnotation annotation = function.getAnnotation();
|
||||
if (isAncestor(annotation, element, false)) {
|
||||
return nextOwner;
|
||||
}
|
||||
}
|
||||
return firstOwner;
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class B:
|
||||
class C:
|
||||
pass
|
||||
|
||||
class Return:
|
||||
pass
|
||||
|
||||
value = 10
|
||||
|
||||
def foo(self, x: C, y: value) -> Return:
|
||||
pass
|
||||
+5
@@ -116,4 +116,9 @@ public class Py3UnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
public void testNotImportedSubmodulesOfNamespacePackage() {
|
||||
doMultiFileTest("main.py");
|
||||
}
|
||||
|
||||
// PY-15017
|
||||
public void testClassLevelReferenceInMethodAnnotation() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user