From 3f30ddebff34356cbfa125f34d9a9ef64e9d269b Mon Sep 17 00:00:00 2001 From: Anton Lobov Date: Thu, 14 Dec 2023 12:28:27 +0100 Subject: [PATCH] [fleet] inline refactoring for python GitOrigin-RevId: 8b17bfd232e7daaa7203b156724ec402252000d7 --- .../refactoring/inline/PyInlineFunctionHandler.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/python/python-psi-impl/src/com/jetbrains/python/refactoring/inline/PyInlineFunctionHandler.kt b/python/python-psi-impl/src/com/jetbrains/python/refactoring/inline/PyInlineFunctionHandler.kt index c85b2bd8607e..6d4443751043 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/refactoring/inline/PyInlineFunctionHandler.kt +++ b/python/python-psi-impl/src/com/jetbrains/python/refactoring/inline/PyInlineFunctionHandler.kt @@ -44,6 +44,11 @@ class PyInlineFunctionHandler : InlineActionHandler() { } override fun inlineElement(project: Project?, editor: Editor?, element: PsiElement?) { + invoke(project, editor, element) + } + + fun invoke(project: Project?, editor: Editor?, element: PsiElement?, showDialog: Boolean = true, + inlineThisOnly: Boolean = false) { if (project == null || editor == null || element !is PyFunction) return val functionScope = ControlFlowCache.getScope(element) val error = when { @@ -68,10 +73,11 @@ class PyInlineFunctionHandler : InlineActionHandler() { CommonRefactoringUtil.showErrorHint(project, editor, error, PyPsiBundle.message("refactoring.inline.function.title"), REFACTORING_ID) return } - if (!ApplicationManager.getApplication().isUnitTestMode){ + if (showDialog && !ApplicationManager.getApplication().isUnitTestMode) { PyRefactoringUiService.getInstance().showPyInlineFunctionDialog(project, editor, element, findReference(editor)) - } else { - val processor = PyInlineFunctionProcessor(project, editor, element, findReference(editor), false, true) + } + else { + val processor = PyInlineFunctionProcessor(project, editor, element, findReference(editor), inlineThisOnly, true) processor.setPreviewUsages(false) processor.run() }