945 # keep it inside the object |
945 # keep it inside the object |
946 offset = self.__getOffset(aw, line, index) |
946 offset = self.__getOffset(aw, line, index) |
947 selectedText = aw.selectedText() |
947 selectedText = aw.selectedText() |
948 |
948 |
949 from RenameDialog import RenameDialog |
949 from RenameDialog import RenameDialog |
950 dlg = RenameDialog( |
950 dlg = RenameDialog(self, title, filename, offset, isLocal, |
951 self, title, filename, offset, isLocal, |
951 selectedText=selectedText, parent=self.__ui) |
952 selectedText=selectedText, parent=self.__ui) |
|
953 changeGroup = dlg.getChangeGroupName() |
952 changeGroup = dlg.getChangeGroupName() |
954 self.__refactoringDialogs[changeGroup] = dlg |
953 self.__refactoringDialogs[changeGroup] = dlg |
955 dlg.finished.connect( |
954 dlg.finished.connect( |
956 lambda: self.__refactoringDialogClosed(changeGroup)) |
955 lambda: self.__refactoringDialogClosed(changeGroup)) |
957 dlg.show() |
956 dlg.show() |
958 |
957 |
959 # TODO: continue from here |
|
960 def __changeOccurrences(self): |
958 def __changeOccurrences(self): |
961 """ |
959 """ |
962 Private slot to perform the Change Occurrences refactoring. |
960 Private slot to perform the Change Occurrences refactoring. |
963 """ |
961 """ |
964 aw = e5App().getObject("ViewManager").activeWindow() |
962 aw = e5App().getObject("ViewManager").activeWindow() |
980 |
978 |
981 filename = aw.getFileName() |
979 filename = aw.getFileName() |
982 line, index, line1, index1 = aw.getSelection() |
980 line, index, line1, index1 = aw.getSelection() |
983 offset = self.__getOffset(aw, line, index) |
981 offset = self.__getOffset(aw, line, index) |
984 |
982 |
985 import rope.refactor.rename |
|
986 resource = rope.base.libutils.path_to_resource( |
|
987 self.__project, filename) |
|
988 try: |
|
989 renamer = rope.refactor.rename.ChangeOccurrences( |
|
990 self.__project, resource, offset) |
|
991 except Exception as err: |
|
992 self.handleRopeError(err, title) |
|
993 return |
|
994 |
|
995 from ChangeOccurrencesDialog import ChangeOccurrencesDialog |
983 from ChangeOccurrencesDialog import ChangeOccurrencesDialog |
996 self.dlg = ChangeOccurrencesDialog(self, title, renamer, |
984 dlg = ChangeOccurrencesDialog(self, title, filename, offset, |
997 parent=self.__ui) |
985 parent=self.__ui) |
998 self.dlg.show() |
986 changeGroup = dlg.getChangeGroupName() |
|
987 self.__refactoringDialogs[changeGroup] = dlg |
|
988 dlg.finished.connect( |
|
989 lambda: self.__refactoringDialogClosed(changeGroup)) |
|
990 dlg.show() |
999 |
991 |
1000 ##################################################### |
992 ##################################################### |
1001 ## Extract refactorings |
993 ## Extract refactorings |
1002 ##################################################### |
994 ##################################################### |
1003 |
995 |
1011 """ |
1003 """ |
1012 Private slot to handle the Extract Local Variable action. |
1004 Private slot to handle the Extract Local Variable action. |
1013 """ |
1005 """ |
1014 self.__doExtract(self.tr("Extract Local Variable"), "variable") |
1006 self.__doExtract(self.tr("Extract Local Variable"), "variable") |
1015 |
1007 |
|
1008 # TODO: continue from here |
1016 def __doExtract(self, title, kind): |
1009 def __doExtract(self, title, kind): |
1017 """ |
1010 """ |
1018 Private method to perform the extract refactoring. |
1011 Private method to perform the extract refactoring. |
1019 |
1012 |
1020 @param title title of the refactoring (string) |
1013 @param title title of the refactoring (string) |