diff -r 04583cac110f -r 72a1d9030d67 RefactoringRope/ExtractDialog.py --- a/RefactoringRope/ExtractDialog.py Tue Sep 19 19:40:18 2017 +0200 +++ b/RefactoringRope/ExtractDialog.py Wed Sep 20 19:49:26 2017 +0200 @@ -20,22 +20,33 @@ """ Class implementing the Extract dialog. """ - def __init__(self, refactoring, title, extractor, parent=None): + def __init__(self, refactoring, title, filename, startOffset, endOffset, + extractionType, parent=None): """ Constructor @param refactoring reference to the main refactoring object - (Refactoring) - @param title title of the dialog (string) - @param extractor reference to the extractor object - (rope.refactor.extract.ExtractMethod or - rope.refactor.extract.ExtractVariable) - @param parent reference to the parent widget (QWidget) + @type Refactoring + @param title title of the dialog + @str str + @param filename file name to be worked on + @type str + @param startOffset offset within file to start extraction + @type int + @param endOffset offset within file to end extraction + @type int + @param parent reference to the parent widget + @type QWidget """ RefactoringDialogBase.__init__(self, refactoring, title, parent) self.setupUi(self) - self.__extractor = extractor + self._changeGroupName = "Extract" + + self.__filename = filename + self.__startOffset = startOffset + self.__endOffset = endOffset + self.__extractionType = extractionType self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) self.__okButton.setEnabled(False) @@ -51,7 +62,8 @@ """ Private slot to react to changes of the new name. - @param text text entered into the edit (string) + @param text text entered into the edit + @type str """ self.__okButton.setEnabled(text != "") @@ -60,27 +72,26 @@ """ Private slot to act on the button pressed. - @param button reference to the button pressed (QAbstractButton) + @param button reference to the button pressed + @type QAbstractButton """ if button == self.__previewButton: - self.previewChanges() + self.requestPreview() elif button == self.__okButton: self.applyChanges() - def _calculateChanges(self, handle): + def _calculateChanges(self): """ Protected method to calculate the changes. - - @param handle reference to the task handle - (rope.base.taskhandle.TaskHandle) - @return reference to the Changes object (rope.base.change.ChangeSet) """ - try: - changes = self.__extractor.get_changes( - self.newNameEdit.text(), - similar=self.similarCheckBox.isChecked(), - global_=self.globalCheckBox.isChecked()) - return changes - except Exception as err: - self._refactoring.handleRopeError(err, self._title, handle) - return None + self._refactoring.sendJson("CalculateExtractChanges", { + "ChangeGroup": self._changeGroupName, + "Title": self._title, + "FileName": self.__filename, + "StartOffset": self.__startOffset, + "EndOffset": self.__endOffset, + "Kind": self.__extractionType, + "NewName": self.newNameEdit.text(), + "Similar": self.similarCheckBox.isChecked(), + "Global": self.globalCheckBox.isChecked(), + })