diff -r cb044ec27c24 -r 4f53795beff0 RefactoringRope/RenameDialog.py --- a/RefactoringRope/RenameDialog.py Sat Jun 25 18:06:56 2022 +0200 +++ b/RefactoringRope/RenameDialog.py Wed Sep 21 15:30:34 2022 +0200 @@ -21,11 +21,20 @@ """ Class implementing the Rename dialog. """ - def __init__(self, refactoring, title, filename, offset, isLocal, - selectedText='', parent=None): + + def __init__( + self, + refactoring, + title, + filename, + offset, + isLocal, + selectedText="", + parent=None, + ): """ Constructor - + @param refactoring reference to the main refactoring object @type RefactoringServer @param title title of the dialog @@ -44,43 +53,43 @@ """ RefactoringDialogBase.__init__(self, refactoring, title, parent) self.setupUi(self) - + self._changeGroupName = "Rename" - + self.__filename = filename self.__offset = offset self.__local = isLocal - - self.__okButton = self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok) + + self.__okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) self.__okButton.setEnabled(False) self.__previewButton = self.buttonBox.addButton( - self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole) + self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole + ) self.__previewButton.setDefault(True) self.__previewButton.setEnabled(False) - + self.newNameEdit.setText(selectedText) self.newNameEdit.selectAll() - + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) - + @pyqtSlot(str) def on_newNameEdit_textChanged(self, text): """ Private slot to react to changes of the new name. - + @param text text entered into the edit @type str """ self.__okButton.setEnabled(text != "") self.__previewButton.setEnabled(text != "") - + @pyqtSlot(QAbstractButton) def on_buttonBox_clicked(self, button): """ Private slot to act on the button pressed. - + @param button reference to the button pressed @type QAbstractButton """ @@ -88,11 +97,11 @@ self.requestPreview() elif button == self.__okButton: self.applyChanges() - + def __confirmUnsure(self, data): """ Private method to confirm unsure occurrences. - + @param data dictionary containing the change data @type dict """ @@ -104,9 +113,9 @@ filename = data["FileName"] start = data["StartOffset"] end = data["EndOffset"] - + vm = ericApp().getObject("ViewManager") - + # display the file and select the match vm.openSourceFile(filename) aw = vm.activeWindow() @@ -116,43 +125,50 @@ aw.ensureLineVisible(sline) aw.gotoLine(sline) aw.setSelection(sline, sindex, eline, eindex) - + answer = EricMessageBox.yesNo( self._ui, self.tr("Rename"), self.tr("""<p>Is the highlighted code a match?</p>"""), - yesDefault=True) - + yesDefault=True, + ) + aw.setCursorPosition(cline, cindex) aw.ensureCursorVisible() - - self._refactoring.sendJson("ConfirmUnsure", { - "Answer": answer, - }) - + + self._refactoring.sendJson( + "ConfirmUnsure", + { + "Answer": answer, + }, + ) + def _calculateChanges(self): """ Protected method to initiate the calculation of the changes. """ if self.askButton.isChecked(): self.hide() - - self._refactoring.sendJson("CalculateRenameChanges", { - "ChangeGroup": self._changeGroupName, - "Title": self._title, - "FileName": self.__filename, - "Offset": self.__offset, - "LocalRename": self.__local, - "NewName": self.newNameEdit.text(), - "RenameHierarchy": self.allCheckBox.isChecked(), - "RenameInStrings": self.stringsCheckBox.isChecked(), - }) - + + self._refactoring.sendJson( + "CalculateRenameChanges", + { + "ChangeGroup": self._changeGroupName, + "Title": self._title, + "FileName": self.__filename, + "Offset": self.__offset, + "LocalRename": self.__local, + "NewName": self.newNameEdit.text(), + "RenameHierarchy": self.allCheckBox.isChecked(), + "RenameInStrings": self.stringsCheckBox.isChecked(), + }, + ) + def processChangeData(self, data): """ Public method to process the change data sent by the refactoring client. - + @param data dictionary containing the change data @type dict """