void (@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { final PyFunction function = getFunction(); final PyMethodDescriptor descriptor = createMethodDescriptor(function); final PyChangeSignatureDialog dialog = new PyChangeSignatureDialog(project, descriptor) { // Similar to JavaChangeSignatureDialog.createAndPreselectNew() @Override protected int getSelectedIdx() { return (int)StreamEx.of(getParameters()).indexOf(info -> info.getOldIndex() < 0).orElse(super.getSelectedIdx()); } }; final PyCallSiteExpression originalCallSite = myOriginalCallSiteExpression != null ? myOriginalCallSiteExpression.getElement() : null; try { if (originalCallSite != null) { originalCallSite.putUserData(CHANGE_SIGNATURE_ORIGINAL_CALL, true); } if (ApplicationManager.getApplication().isUnitTestMode()) { BaseRefactoringProcessor processor = dialog.createRefactoringProcessor(); dialog.close(DialogWrapper.OK_EXIT_CODE); processor.run(); } else { dialog.show(); } } finally { if (originalCallSite != null) { originalCallSite.putUserData(CHANGE_SIGNATURE_ORIGINAL_CALL, null); } } }