Commit b4d8e4ab authored by Andrey Vokin's avatar Andrey Vokin Committed by intellij-monorepo-bot
Browse files

PY-71972 "Go to declaration or Usages" doesn't work for instance fields from the constructor.

TextOffset is used to retrieve target element here: TargetElementUtilBase#getNamedElement.

(cherry picked from commit 5c9d721e6870079e4bf86ab7e5c8efb0be5810b0)

IJ-CR-132893

GitOrigin-RevId: 3d6c231d22e4493ce853f8c66e89c584a0834e56
parent 4dd2fc56
Branches unavailable Tags unavailable
No related merge requests found
Showing with 18 additions and 0 deletions
+18 -0
......@@ -71,6 +71,11 @@ public class PyTargetExpressionImpl extends PyBaseElementImpl<PyTargetExpression
pyVisitor.visitPyTargetExpression(this);
}
@Override
public int getTextOffset() {
return PyTargetExpression.super.getTextOffset();
}
@Nullable
@Override
public String getName() {
......
......@@ -80,6 +80,19 @@ class PyNavigationTest : PyTestCase() {
"print(va<caret>r)")
}
// PY-71972
fun testGotToDeclarationOrUsagesOnInstanceAttributeDefinitionShowsUsages() {
doTestGotoDeclarationOrUsagesOutcome(GTDUOutcome.SU, """
class C:
def __init__(self, val):
self.va<caret>l = val
def __str__(self):
return f"{self.val} {self.val}"
""".trimIndent()
)
}
fun testGotoDeclarationOnInitialization() {
myFixture.configureByText(
"a.py",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment