mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Disable suggested refactorings for everything inside stubs or having such stubs (PY-42285)
Since we can't correctly apply refactorings to stubs and implementations. GitOrigin-RevId: a4ac64f93d9c894908eb0d72fd1e9c9624d7094b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
abe238bc27
commit
1f258240d0
+11
-2
@@ -9,6 +9,7 @@ import com.intellij.psi.util.hasErrorElementInRange
|
||||
import com.intellij.refactoring.suggested.*
|
||||
import com.jetbrains.python.PyNames
|
||||
import com.jetbrains.python.PyTokenTypes
|
||||
import com.jetbrains.python.psi.PyElement
|
||||
import com.jetbrains.python.psi.PyFunction
|
||||
import com.jetbrains.python.psi.PyParameter
|
||||
import com.jetbrains.python.psi.PyParameterList
|
||||
@@ -22,7 +23,7 @@ class PySuggestedRefactoringSupport : SuggestedRefactoringSupport {
|
||||
return element is PyFunction &&
|
||||
element.name.let { it != null && PyNames.isIdentifier(it) } &&
|
||||
element.property == null &&
|
||||
!PyiUtil.isOverload(element, TypeEvalContext.codeAnalysis(element.project, element.containingFile))
|
||||
!shouldBeSuppressed(element)
|
||||
}
|
||||
|
||||
internal fun defaultValue(parameter: SuggestedRefactoringSupport.Parameter): String? {
|
||||
@@ -33,7 +34,15 @@ class PySuggestedRefactoringSupport : SuggestedRefactoringSupport {
|
||||
return element is PsiNameIdentifierOwner &&
|
||||
element.name.let { it != null && PyNames.isIdentifier(it) } &&
|
||||
(element !is PyParameter || containingFunction(element).let { it != null && !isAvailableForChangeSignature(it) }) &&
|
||||
!PyiUtil.isOverload(element, TypeEvalContext.codeAnalysis(element.project, element.containingFile))
|
||||
!shouldBeSuppressed(element)
|
||||
}
|
||||
|
||||
private fun shouldBeSuppressed(element: PsiElement): Boolean {
|
||||
if (PyiUtil.isInsideStub(element)) return true
|
||||
if (element is PyElement && PyiUtil.getPythonStub(element) != null) return true
|
||||
if (PyiUtil.isOverload(element, TypeEvalContext.codeAnalysis(element.project, element.containingFile))) return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
private fun containingFunction(parameter: PyParameter): PyFunction? {
|
||||
|
||||
+3
-6
@@ -766,16 +766,13 @@ class PySuggestedRefactoringTest : PyTestCase() {
|
||||
|
||||
myFixture.copyFileToProject("$testDataPathPrefix/$source", source)
|
||||
|
||||
doChangeSignatureTest(
|
||||
doNoIntentionTest(
|
||||
"""
|
||||
def foo(p1<caret>):
|
||||
print(p1)
|
||||
""".trimIndent(),
|
||||
"""
|
||||
def foo(p12):
|
||||
print(p12)
|
||||
""".trimIndent(),
|
||||
{ myFixture.type("2") }
|
||||
{ myFixture.type("2") },
|
||||
intention = changeSignatureIntention()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user