mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-CR-49176: inline function: optimize imports at declaration site after removing function definition (PY-36721)
GitOrigin-RevId: 2bf0ffdeff5a2b5cd084b53b5e1ed76d547d07f2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d672b03510
commit
e867306f59
@@ -295,16 +295,17 @@ class PyInlineFunctionProcessor(project: Project,
|
||||
.forEach { PyClassRefactoringUtil.optimizeImports(it) }
|
||||
|
||||
if (myRemoveDeclaration) {
|
||||
val file = myFunction.containingFile
|
||||
val stubFunction = PyiUtil.getPythonStub(myFunction)
|
||||
if (stubFunction != null && stubFunction.isWritable) {
|
||||
stubFunction.delete()
|
||||
}
|
||||
val typingOverloads = PyiUtil.getOverloads(myFunction, TypeEvalContext.userInitiated(myProject, myFunction.containingFile))
|
||||
val typingOverloads = PyiUtil.getOverloads(myFunction, TypeEvalContext.userInitiated(myProject, file))
|
||||
if (typingOverloads.isNotEmpty()) {
|
||||
typingOverloads.forEach { it.delete() }
|
||||
PyClassRefactoringUtil.optimizeImports(myFunction.containingFile)
|
||||
}
|
||||
myFunction.delete()
|
||||
PyClassRefactoringUtil.optimizeImports(file)
|
||||
dunderAll.forEach { it.element?.delete() }
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
from datetime import datetime
|
||||
|
||||
print(datetime.now())
|
||||
@@ -0,0 +1,3 @@
|
||||
from src import foo
|
||||
|
||||
f<caret>oo()
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
from datetime import datetime
|
||||
|
||||
def foo():
|
||||
print(datetime.now())
|
||||
@@ -87,6 +87,11 @@ class PyInlineFunctionTest : PyTestCase() {
|
||||
fun testImportedLocally() = doTest(inlineThis = false, remove = true)
|
||||
//fun testInlineImportedAs() = doTest(inlineThis = false)
|
||||
fun testSelfUsageDetection() = doTest(inlineThis = false, remove = true)
|
||||
fun testOptimizeImportsAtDeclarationSite() {
|
||||
doTest(inlineThis = false, remove = true)
|
||||
val testName = getTestName(true)
|
||||
myFixture.checkResultByFile("src.py", "$testName/src.after.py",true)
|
||||
}
|
||||
fun testRemoveFunctionWithStub() {
|
||||
doTest(inlineThis = false, remove = true)
|
||||
val testName = getTestName(true)
|
||||
|
||||
Reference in New Issue
Block a user