1131 |
1131 |
1132 ##################################################### |
1132 ##################################################### |
1133 ## Use function refactoring |
1133 ## Use function refactoring |
1134 ##################################################### |
1134 ##################################################### |
1135 |
1135 |
1136 # TODO: continue from here |
|
1137 def __useFunction(self): |
1136 def __useFunction(self): |
1138 """ |
1137 """ |
1139 Private slot to use a function wherever possible. |
1138 Private slot to use a function wherever possible. |
1140 """ |
1139 """ |
1141 aw = e5App().getObject("ViewManager").activeWindow() |
1140 aw = e5App().getObject("ViewManager").activeWindow() |
1156 |
1155 |
1157 filename = aw.getFileName() |
1156 filename = aw.getFileName() |
1158 line, index, line1, index1 = aw.getSelection() |
1157 line, index, line1, index1 = aw.getSelection() |
1159 offset = self.__getOffset(aw, line, index) |
1158 offset = self.__getOffset(aw, line, index) |
1160 |
1159 |
1161 import rope.refactor.usefunction |
|
1162 resource = rope.base.libutils.path_to_resource( |
|
1163 self.__project, filename) |
|
1164 try: |
|
1165 user = rope.refactor.usefunction.UseFunction( |
|
1166 self.__project, resource, offset) |
|
1167 except Exception as err: |
|
1168 self.handleRopeError(err, title) |
|
1169 return |
|
1170 |
|
1171 from UseFunctionDialog import UseFunctionDialog |
1160 from UseFunctionDialog import UseFunctionDialog |
1172 self.dlg = UseFunctionDialog(self, title, user, parent=self.__ui) |
1161 dlg = UseFunctionDialog(self, title, filename, offset, |
1173 self.dlg.show() |
1162 parent=self.__ui) |
|
1163 changeGroup = dlg.getChangeGroupName() |
|
1164 self.__refactoringDialogs[changeGroup] = dlg |
|
1165 dlg.finished.connect( |
|
1166 lambda: self.__refactoringDialogClosed(changeGroup)) |
|
1167 dlg.show() |
1174 |
1168 |
1175 ##################################################### |
1169 ##################################################### |
1176 ## Introduce refactorings |
1170 ## Introduce refactorings |
1177 ##################################################### |
1171 ##################################################### |
1178 |
1172 |
|
1173 # TODO: continue from here |
1179 def __introduceFactoryMethod(self): |
1174 def __introduceFactoryMethod(self): |
1180 """ |
1175 """ |
1181 Private slot to introduce a factory method or global function. |
1176 Private slot to introduce a factory method or global function. |
1182 """ |
1177 """ |
1183 aw = e5App().getObject("ViewManager").activeWindow() |
1178 aw = e5App().getObject("ViewManager").activeWindow() |