593 "Source": source, |
593 "Source": source, |
594 "Line": line + 1, |
594 "Line": line + 1, |
595 "Index": index, |
595 "Index": index, |
596 "Uuid": euuid, |
596 "Uuid": euuid, |
597 }, idString=idString) |
597 }, idString=idString) |
|
598 |
|
599 @pyqtSlot() |
|
600 def refactoringExtractFunction(self): |
|
601 """ |
|
602 Public slot to extract an expression to a function. |
|
603 """ |
|
604 editor = self.__vm.activeWindow() |
|
605 if editor: |
|
606 idString = self.__idString(editor) |
|
607 if not idString: |
|
608 return |
|
609 |
|
610 newName, ok = QInputDialog.getText( |
|
611 None, |
|
612 self.tr("Extract Function"), |
|
613 self.tr("Enter the name for the function:"), |
|
614 QLineEdit.EchoMode.Normal |
|
615 ) |
|
616 |
|
617 if ok and newName: |
|
618 filename = editor.getFileName() |
|
619 sLine, sIndex, eLine, eIndex = editor.getSelection() |
|
620 source = editor.text() |
|
621 |
|
622 self.__ensureActive(idString) |
|
623 |
|
624 euuid = str(uuid.uuid4()) |
|
625 self.__editors[euuid] = editor |
|
626 |
|
627 self.sendJson("extractFunction", { |
|
628 "FileName": filename, |
|
629 "Source": source, |
|
630 "Line": sLine + 1, |
|
631 "Index": sIndex, |
|
632 "EndLine": eLine + 1, |
|
633 "EndIndex": eIndex, |
|
634 "Uuid": euuid, |
|
635 "NewName": newName, |
|
636 }, idString=idString) |
598 |
637 |
599 def __showRefactoringDiff(self, result): |
638 def __showRefactoringDiff(self, result): |
600 """ |
639 """ |
601 Private method to show the diff of a refactoring. |
640 Private method to show the diff of a refactoring. |
602 |
641 |