mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-63371 PY-63372 PY-63373 Recognize type alias names in their definitions as targets for actions
In particular, for Rename and Go to Declaration or Usages. GitOrigin-RevId: 760a28b3a2a2b22022e938d7b4b96729cd7f7dc2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8a5536359d
commit
2e8e817447
@@ -102,4 +102,10 @@ public class PyTypeAliasStatementImpl extends PyBaseElementImpl<PyTypeAliasState
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextOffset() {
|
||||
@Nullable PsiElement name = getNameIdentifier();
|
||||
return name != null ? name.getTextOffset() : super.getTextOffset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
type Al<caret>ias[T] = dict[str, T]
|
||||
|
||||
|
||||
def f[T](x: Alias[T]) -> T:
|
||||
...
|
||||
@@ -0,0 +1,5 @@
|
||||
type Renamed[T] = dict[str, T]
|
||||
|
||||
|
||||
def f[T](x: Renamed[T]) -> T:
|
||||
...
|
||||
@@ -0,0 +1,5 @@
|
||||
type Alias[T] = dict[str, T]
|
||||
|
||||
|
||||
def f[T](x: Al<caret>ias[T]) -> T:
|
||||
...
|
||||
@@ -0,0 +1,5 @@
|
||||
type Renamed[T] = dict[str, T]
|
||||
|
||||
|
||||
def f[T](x: Renamed[T]) -> T:
|
||||
...
|
||||
@@ -268,6 +268,15 @@ class PyNavigationTest : PyTestCase() {
|
||||
doTestGotoDeclarationNavigatesToPyNotPyi()
|
||||
}
|
||||
|
||||
// PY-63372
|
||||
fun testGotoDeclarationOrUsagesOnNewStyleTypeAliasDefinitionShowsUsages() {
|
||||
doTestGotoDeclarationOrUsagesOutcome(GTDUOutcome.SU,
|
||||
"""
|
||||
type Al<caret>ias[T] = dict[str, T]
|
||||
x: Alias
|
||||
""")
|
||||
}
|
||||
|
||||
private fun doTestGotoDeclarationNavigatesToPyNotPyi() {
|
||||
myFixture.copyDirectoryToProject(getTestName(true), "")
|
||||
myFixture.configureByFile("test.py")
|
||||
@@ -287,7 +296,8 @@ class PyNavigationTest : PyTestCase() {
|
||||
|
||||
private fun doTestGotoDeclarationOrUsagesOutcome(expectedOutcome: GTDUOutcome, text: String) {
|
||||
myFixture.configureByText("a.py", text)
|
||||
val actualOutcome = GotoDeclarationOrUsageHandler2.testGTDUOutcomeInNonBlockingReadAction(myFixture.editor, myFixture.file, myFixture.caretOffset)
|
||||
val actualOutcome = GotoDeclarationOrUsageHandler2.testGTDUOutcomeInNonBlockingReadAction(myFixture.editor, myFixture.file,
|
||||
myFixture.caretOffset)
|
||||
assertEquals(expectedOutcome, actualOutcome)
|
||||
}
|
||||
|
||||
|
||||
@@ -398,6 +398,16 @@ public class PyRenameTest extends PyTestCase {
|
||||
doTest("taram");
|
||||
}
|
||||
|
||||
// PY-63373
|
||||
public void testRenameTypeAliasFromItsDefinition() {
|
||||
doTest("Renamed");
|
||||
}
|
||||
|
||||
// PY-63373
|
||||
public void testRenameTypeAliasFromItsUsage() {
|
||||
doTest("Renamed");
|
||||
}
|
||||
|
||||
private void renameWithDocStringFormat(DocStringFormat format, final String newName) {
|
||||
runWithDocStringFormat(format, () -> doTest(newName));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user