mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-18 12:31:26 +07:00
PY-50788: Correct resolve for inherited docstring attribute names
Now during resolve if there is no class/instance attribute with appropriate name explicitly in the class, we will try to find it in the parent classes and resolve there. GitOrigin-RevId: 52ab5f0ad63cba187457ba3db6107997ede33dee
This commit is contained in:
committed by
intellij-monorepo-bot
parent
50a0dbc592
commit
181edc5caa
@@ -37,8 +37,7 @@ public class DocStringParameterReference extends PsiReferenceBase<PyStringLitera
|
||||
if (owner instanceof PyFunction) {
|
||||
return resolveParameter((PyFunction)owner);
|
||||
}
|
||||
if (owner instanceof PyClass) {
|
||||
PyClass pyClass = (PyClass)owner;
|
||||
if (owner instanceof PyClass pyClass) {
|
||||
final PyFunction init = pyClass.findMethodByName(PyNames.INIT, false, null);
|
||||
if (myType == ReferenceType.PARAMETER) {
|
||||
return init != null ? resolveParameter(init) : resolveClassVariable(pyClass);
|
||||
@@ -50,7 +49,7 @@ public class DocStringParameterReference extends PsiReferenceBase<PyStringLitera
|
||||
return parameter;
|
||||
}
|
||||
}
|
||||
PyElement instanceAttr = resolveInstanceVariable(pyClass);
|
||||
final PyElement instanceAttr = resolveInstanceVariable(pyClass);
|
||||
return instanceAttr != null ? instanceAttr : resolveClassVariable(pyClass);
|
||||
}
|
||||
if (myType == ReferenceType.CLASS_VARIABLE) {
|
||||
@@ -74,25 +73,13 @@ public class DocStringParameterReference extends PsiReferenceBase<PyStringLitera
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PyTargetExpression resolveInstanceVariable(final PyClass owner) {
|
||||
final List<PyTargetExpression> attributes = owner.getInstanceAttributes();
|
||||
for (PyTargetExpression element : attributes) {
|
||||
if (getCanonicalText().equals(element.getName())) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
private PyTargetExpression resolveInstanceVariable(@NotNull PyClass owner) {
|
||||
return owner.findInstanceAttribute(getCanonicalText(), true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PyTargetExpression resolveClassVariable(@NotNull final PyClass owner) {
|
||||
final List<PyTargetExpression> attributes = owner.getClassAttributes();
|
||||
for (PyTargetExpression element : attributes) {
|
||||
if (getCanonicalText().equals(element.getName())) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
private PyTargetExpression resolveClassVariable(@NotNull PyClass owner) {
|
||||
return owner.findClassAttribute(getCanonicalText(), true, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user