diff --git a/python/src/com/jetbrains/python/documentation/docstrings/DocStringParameterReference.java b/python/src/com/jetbrains/python/documentation/docstrings/DocStringParameterReference.java index d0f8ce7897fd..d84cf5cf47fb 100644 --- a/python/src/com/jetbrains/python/documentation/docstrings/DocStringParameterReference.java +++ b/python/src/com/jetbrains/python/documentation/docstrings/DocStringParameterReference.java @@ -60,21 +60,23 @@ public class DocStringParameterReference extends PsiReferenceBase attributes = owner.getInstanceAttributes(); for (PyTargetExpression element : attributes) { - if (getCanonicalText().equals(element.getName())) + if (getCanonicalText().equals(element.getName())) { return element; + } } return null; } @@ -107,8 +110,9 @@ public class DocStringParameterReference extends PsiReferenceBase attributes = owner.getClassAttributes(); for (PyTargetExpression element : attributes) { - if (getCanonicalText().equals(element.getName())) + if (getCanonicalText().equals(element.getName())) { return element; + } } return null; } @@ -149,13 +153,15 @@ public class DocStringParameterReference extends PsiReferenceBase + """ + + def m(self): + self.attr = 'foo' diff --git a/python/testSrc/com/jetbrains/python/PyResolveTest.java b/python/testSrc/com/jetbrains/python/PyResolveTest.java index 5c04c0767613..aff31f6a0b70 100644 --- a/python/testSrc/com/jetbrains/python/PyResolveTest.java +++ b/python/testSrc/com/jetbrains/python/PyResolveTest.java @@ -532,6 +532,10 @@ public class PyResolveTest extends PyResolveTestCase { runWithDocStringFormat(DocStringFormat.GOOGLE, () -> assertResolvesTo(PyTargetExpression.class, "module_level_variable1")); } + public void testEpyDocTypeReferenceForInstanceAttributeInClassLevelDocstring() { + runWithDocStringFormat(DocStringFormat.EPYTEXT, () -> assertResolvesTo(PyTargetExpression.class, "attr")); + } + // PY-7541 public void testLoopToUpperReassignment() { final PsiReference ref = findReferenceByMarker();