RefactoringRope/Refactoring.py

changeset 55
d501156be247
parent 48
de33dc93a3ac
child 62
1077db8d0589
equal deleted inserted replaced
54:e795cb8240aa 55:d501156be247
50 self.__helpDialog = None 50 self.__helpDialog = None
51 51
52 # Rope objects 52 # Rope objects
53 self.__project = None 53 self.__project = None
54 54
55 from FileSystemCommands import e5FileSystemCommands 55 from FileSystemCommands import E5FileSystemCommands
56 self.__fsCommands = e5FileSystemCommands(self.__e5project) 56 self.__fsCommands = E5FileSystemCommands(self.__e5project)
57 57
58 def initActions(self): 58 def initActions(self):
59 """ 59 """
60 Public method to define the refactoring actions. 60 Public method to define the refactoring actions.
61 """ 61 """
63 63
64 ##################################################### 64 #####################################################
65 ## Rename refactoring actions 65 ## Rename refactoring actions
66 ##################################################### 66 #####################################################
67 67
68 self.refactoringRenameAct = E5Action(self.trUtf8('Rename'), 68 self.refactoringRenameAct = E5Action(
69 self.trUtf8('&Rename'), 69 self.trUtf8('Rename'),
70 0, 0, 70 self.trUtf8('&Rename'),
71 self, 'refactoring_rename') 71 0, 0,
72 self, 'refactoring_rename')
72 self.refactoringRenameAct.setStatusTip(self.trUtf8( 73 self.refactoringRenameAct.setStatusTip(self.trUtf8(
73 'Rename the highlighted object')) 74 'Rename the highlighted object'))
74 self.refactoringRenameAct.setWhatsThis(self.trUtf8( 75 self.refactoringRenameAct.setWhatsThis(self.trUtf8(
75 """<b>Rename</b>""" 76 """<b>Rename</b>"""
76 """<p>Rename the highlighted Python object.</p>""" 77 """<p>Rename the highlighted Python object.</p>"""
77 )) 78 ))
78 self.refactoringRenameAct.triggered[()].connect( 79 self.refactoringRenameAct.triggered[()].connect(
79 self.__rename) 80 self.__rename)
80 self.actions.append(self.refactoringRenameAct) 81 self.actions.append(self.refactoringRenameAct)
81 82
82 self.refactoringRenameLocalAct = E5Action(self.trUtf8('Local Rename'), 83 self.refactoringRenameLocalAct = E5Action(
83 self.trUtf8('&Local Rename'), 84 self.trUtf8('Local Rename'),
84 0, 0, 85 self.trUtf8('&Local Rename'),
85 self, 'refactoring_rename_local') 86 0, 0,
87 self, 'refactoring_rename_local')
86 self.refactoringRenameLocalAct.setStatusTip(self.trUtf8( 88 self.refactoringRenameLocalAct.setStatusTip(self.trUtf8(
87 'Rename the highlighted object in the current module only')) 89 'Rename the highlighted object in the current module only'))
88 self.refactoringRenameLocalAct.setWhatsThis(self.trUtf8( 90 self.refactoringRenameLocalAct.setWhatsThis(self.trUtf8(
89 """<b>Local Rename</b>""" 91 """<b>Local Rename</b>"""
90 """<p>Rename the highlighted Python object in the current""" 92 """<p>Rename the highlighted Python object in the current"""
93 self.refactoringRenameLocalAct.triggered[()].connect( 95 self.refactoringRenameLocalAct.triggered[()].connect(
94 self.__renameLocal) 96 self.__renameLocal)
95 self.actions.append(self.refactoringRenameLocalAct) 97 self.actions.append(self.refactoringRenameLocalAct)
96 98
97 self.refactoringRenameModuleAct = E5Action( 99 self.refactoringRenameModuleAct = E5Action(
98 self.trUtf8('Rename Current Module'), 100 self.trUtf8('Rename Current Module'),
99 self.trUtf8('Rename Current Module'), 101 self.trUtf8('Rename Current Module'),
100 0, 0, 102 0, 0,
101 self, 'refactoring_rename_module') 103 self, 'refactoring_rename_module')
102 self.refactoringRenameModuleAct.setStatusTip(self.trUtf8( 104 self.refactoringRenameModuleAct.setStatusTip(self.trUtf8(
103 'Rename the current module')) 105 'Rename the current module'))
104 self.refactoringRenameModuleAct.setWhatsThis(self.trUtf8( 106 self.refactoringRenameModuleAct.setWhatsThis(self.trUtf8(
105 """<b>Rename Current Module</b>""" 107 """<b>Rename Current Module</b>"""
106 """<p>Rename the current module.</p>""" 108 """<p>Rename the current module.</p>"""
108 self.refactoringRenameModuleAct.triggered[()].connect( 110 self.refactoringRenameModuleAct.triggered[()].connect(
109 self.__renameModule) 111 self.__renameModule)
110 self.actions.append(self.refactoringRenameModuleAct) 112 self.actions.append(self.refactoringRenameModuleAct)
111 113
112 self.refactoringChangeOccurrencesAct = E5Action( 114 self.refactoringChangeOccurrencesAct = E5Action(
113 self.trUtf8('Change Occurrences'), 115 self.trUtf8('Change Occurrences'),
114 self.trUtf8('Change &Occurrences'), 116 self.trUtf8('Change &Occurrences'),
115 0, 0, 117 0, 0,
116 self, 'refactoring_change_occurrences') 118 self, 'refactoring_change_occurrences')
117 self.refactoringChangeOccurrencesAct.setStatusTip(self.trUtf8( 119 self.refactoringChangeOccurrencesAct.setStatusTip(self.trUtf8(
118 'Change all occurrences in the local scope')) 120 'Change all occurrences in the local scope'))
119 self.refactoringChangeOccurrencesAct.setWhatsThis(self.trUtf8( 121 self.refactoringChangeOccurrencesAct.setWhatsThis(self.trUtf8(
120 """<b>Change Occurrences</b>""" 122 """<b>Change Occurrences</b>"""
121 """<p>Change all occurrences in the local scope.</p>""" 123 """<p>Change all occurrences in the local scope.</p>"""
127 ##################################################### 129 #####################################################
128 ## Extract refactoring actions 130 ## Extract refactoring actions
129 ##################################################### 131 #####################################################
130 132
131 self.refactoringExtractMethodAct = E5Action( 133 self.refactoringExtractMethodAct = E5Action(
132 self.trUtf8('Extract method'), 134 self.trUtf8('Extract method'),
133 self.trUtf8('Extract &Method'), 135 self.trUtf8('Extract &Method'),
134 0, 0, 136 0, 0,
135 self, 'refactoring_extract_method') 137 self, 'refactoring_extract_method')
136 self.refactoringExtractMethodAct.setStatusTip(self.trUtf8( 138 self.refactoringExtractMethodAct.setStatusTip(self.trUtf8(
137 'Extract the highlighted area as a method')) 139 'Extract the highlighted area as a method'))
138 self.refactoringExtractMethodAct.setWhatsThis(self.trUtf8( 140 self.refactoringExtractMethodAct.setWhatsThis(self.trUtf8(
139 """<b>Extract method</b>""" 141 """<b>Extract method</b>"""
140 """<p>Extract the highlighted area as a method or function.</p>""" 142 """<p>Extract the highlighted area as a method or function.</p>"""
142 self.refactoringExtractMethodAct.triggered[()].connect( 144 self.refactoringExtractMethodAct.triggered[()].connect(
143 self.__extractMethod) 145 self.__extractMethod)
144 self.actions.append(self.refactoringExtractMethodAct) 146 self.actions.append(self.refactoringExtractMethodAct)
145 147
146 self.refactoringExtractLocalVariableAct = E5Action( 148 self.refactoringExtractLocalVariableAct = E5Action(
147 self.trUtf8('Extract local variable'), 149 self.trUtf8('Extract local variable'),
148 self.trUtf8('&Extract Local Variable'), 150 self.trUtf8('&Extract Local Variable'),
149 0, 0, 151 0, 0,
150 self, 'refactoring_extract_variable') 152 self, 'refactoring_extract_variable')
151 self.refactoringExtractLocalVariableAct.setStatusTip(self.trUtf8( 153 self.refactoringExtractLocalVariableAct.setStatusTip(self.trUtf8(
152 'Extract the highlighted area as a local variable')) 154 'Extract the highlighted area as a local variable'))
153 self.refactoringExtractLocalVariableAct.setWhatsThis(self.trUtf8( 155 self.refactoringExtractLocalVariableAct.setWhatsThis(self.trUtf8(
154 """<b>Extract local variable</b>""" 156 """<b>Extract local variable</b>"""
155 """<p>Extract the highlighted area as a local variable.</p>""" 157 """<p>Extract the highlighted area as a local variable.</p>"""
161 ##################################################### 163 #####################################################
162 ## Inline refactoring actions 164 ## Inline refactoring actions
163 ##################################################### 165 #####################################################
164 166
165 self.refactoringInlineAct = E5Action( 167 self.refactoringInlineAct = E5Action(
166 self.trUtf8('Inline'), 168 self.trUtf8('Inline'),
167 self.trUtf8('&Inline'), 169 self.trUtf8('&Inline'),
168 0, 0, 170 0, 0,
169 self, 'refactoring_inline') 171 self, 'refactoring_inline')
170 self.refactoringInlineAct.setStatusTip(self.trUtf8( 172 self.refactoringInlineAct.setStatusTip(self.trUtf8(
171 'Inlines the selected local variable or method')) 173 'Inlines the selected local variable or method'))
172 self.refactoringInlineAct.setWhatsThis(self.trUtf8( 174 self.refactoringInlineAct.setWhatsThis(self.trUtf8(
173 """<b>Inline</b>""" 175 """<b>Inline</b>"""
174 """<p>Inlines the selected local variable or method.</p>""" 176 """<p>Inlines the selected local variable or method.</p>"""
180 ##################################################### 182 #####################################################
181 ## Move refactoring actions 183 ## Move refactoring actions
182 ##################################################### 184 #####################################################
183 185
184 self.refactoringMoveMethodAct = E5Action( 186 self.refactoringMoveMethodAct = E5Action(
185 self.trUtf8('Move method'), 187 self.trUtf8('Move method'),
186 self.trUtf8('Mo&ve Method'), 188 self.trUtf8('Mo&ve Method'),
187 0, 0, 189 0, 0,
188 self, 'refactoring_move_method') 190 self, 'refactoring_move_method')
189 self.refactoringMoveMethodAct.setStatusTip(self.trUtf8( 191 self.refactoringMoveMethodAct.setStatusTip(self.trUtf8(
190 'Move the highlighted method to another class')) 192 'Move the highlighted method to another class'))
191 self.refactoringMoveMethodAct.setWhatsThis(self.trUtf8( 193 self.refactoringMoveMethodAct.setWhatsThis(self.trUtf8(
192 """<b>Move method</b>""" 194 """<b>Move method</b>"""
193 """<p>Move the highlighted method to another class.</p>""" 195 """<p>Move the highlighted method to another class.</p>"""
195 self.refactoringMoveMethodAct.triggered[()].connect( 197 self.refactoringMoveMethodAct.triggered[()].connect(
196 self.__moveMethod) 198 self.__moveMethod)
197 self.actions.append(self.refactoringMoveMethodAct) 199 self.actions.append(self.refactoringMoveMethodAct)
198 200
199 self.refactoringMoveModuleAct = E5Action( 201 self.refactoringMoveModuleAct = E5Action(
200 self.trUtf8('Move current module'), 202 self.trUtf8('Move current module'),
201 self.trUtf8('Move Current Module'), 203 self.trUtf8('Move Current Module'),
202 0, 0, 204 0, 0,
203 self, 'refactoring_move_module') 205 self, 'refactoring_move_module')
204 self.refactoringMoveModuleAct.setStatusTip(self.trUtf8( 206 self.refactoringMoveModuleAct.setStatusTip(self.trUtf8(
205 'Move the current module to another package')) 207 'Move the current module to another package'))
206 self.refactoringMoveModuleAct.setWhatsThis(self.trUtf8( 208 self.refactoringMoveModuleAct.setWhatsThis(self.trUtf8(
207 """<b>Move current module</b>""" 209 """<b>Move current module</b>"""
208 """<p>Move the current module to another package.</p>""" 210 """<p>Move the current module to another package.</p>"""
214 ##################################################### 216 #####################################################
215 ## Use function refactoring action 217 ## Use function refactoring action
216 ##################################################### 218 #####################################################
217 219
218 self.refactoringUseFunctionAct = E5Action( 220 self.refactoringUseFunctionAct = E5Action(
219 self.trUtf8('Use Function'), 221 self.trUtf8('Use Function'),
220 self.trUtf8('Use Function'), 222 self.trUtf8('Use Function'),
221 0, 0, 223 0, 0,
222 self, 'refactoring_use_function') 224 self, 'refactoring_use_function')
223 self.refactoringUseFunctionAct.setStatusTip(self.trUtf8( 225 self.refactoringUseFunctionAct.setStatusTip(self.trUtf8(
224 'Use a function wherever possible.')) 226 'Use a function wherever possible.'))
225 self.refactoringUseFunctionAct.setWhatsThis(self.trUtf8( 227 self.refactoringUseFunctionAct.setWhatsThis(self.trUtf8(
226 """<b>Use function</b>""" 228 """<b>Use function</b>"""
227 """<p>Tries to use a function wherever possible.</p>""" 229 """<p>Tries to use a function wherever possible.</p>"""
233 ##################################################### 235 #####################################################
234 ## Introduce refactorings actions 236 ## Introduce refactorings actions
235 ##################################################### 237 #####################################################
236 238
237 self.refactoringIntroduceFactoryAct = E5Action( 239 self.refactoringIntroduceFactoryAct = E5Action(
238 self.trUtf8('Introduce Factory Method'), 240 self.trUtf8('Introduce Factory Method'),
239 self.trUtf8('Introduce &Factory Method'), 241 self.trUtf8('Introduce &Factory Method'),
240 0, 0, 242 0, 0,
241 self, 'refactoring_introduce_factory_method') 243 self, 'refactoring_introduce_factory_method')
242 self.refactoringIntroduceFactoryAct.setStatusTip(self.trUtf8( 244 self.refactoringIntroduceFactoryAct.setStatusTip(self.trUtf8(
243 'Introduce a factory method or function')) 245 'Introduce a factory method or function'))
244 self.refactoringIntroduceFactoryAct.setWhatsThis(self.trUtf8( 246 self.refactoringIntroduceFactoryAct.setWhatsThis(self.trUtf8(
245 """<b>Introduce Factory Method</b>""" 247 """<b>Introduce Factory Method</b>"""
246 """<p>Introduce a factory method or function.</p>""" 248 """<p>Introduce a factory method or function.</p>"""
248 self.refactoringIntroduceFactoryAct.triggered[()].connect( 250 self.refactoringIntroduceFactoryAct.triggered[()].connect(
249 self.__introduceFactoryMethod) 251 self.__introduceFactoryMethod)
250 self.actions.append(self.refactoringIntroduceFactoryAct) 252 self.actions.append(self.refactoringIntroduceFactoryAct)
251 253
252 self.refactoringIntroduceParameterAct = E5Action( 254 self.refactoringIntroduceParameterAct = E5Action(
253 self.trUtf8('Introduce Parameter'), 255 self.trUtf8('Introduce Parameter'),
254 self.trUtf8('Introduce &Parameter'), 256 self.trUtf8('Introduce &Parameter'),
255 0, 0, 257 0, 0,
256 self, 'refactoring_introduce_parameter_method') 258 self, 'refactoring_introduce_parameter_method')
257 self.refactoringIntroduceParameterAct.setStatusTip(self.trUtf8( 259 self.refactoringIntroduceParameterAct.setStatusTip(self.trUtf8(
258 'Introduce a parameter in a function')) 260 'Introduce a parameter in a function'))
259 self.refactoringIntroduceParameterAct.setWhatsThis(self.trUtf8( 261 self.refactoringIntroduceParameterAct.setWhatsThis(self.trUtf8(
260 """<b>Introduce Parameter</b>""" 262 """<b>Introduce Parameter</b>"""
261 """<p>Introduce a parameter in a function.</p>""" 263 """<p>Introduce a parameter in a function.</p>"""
267 ##################################################### 269 #####################################################
268 ## Import refactorings actions 270 ## Import refactorings actions
269 ##################################################### 271 #####################################################
270 272
271 self.refactoringImportsOrganizeAct = E5Action( 273 self.refactoringImportsOrganizeAct = E5Action(
272 self.trUtf8('Organize Imports'), 274 self.trUtf8('Organize Imports'),
273 self.trUtf8('&Organize Imports'), 275 self.trUtf8('&Organize Imports'),
274 0, 0, 276 0, 0,
275 self, 'refactoring_organize_imports') 277 self, 'refactoring_organize_imports')
276 self.refactoringImportsOrganizeAct.setStatusTip(self.trUtf8( 278 self.refactoringImportsOrganizeAct.setStatusTip(self.trUtf8(
277 'Sort imports according to PEP-8')) 279 'Sort imports according to PEP-8'))
278 self.refactoringImportsOrganizeAct.setWhatsThis(self.trUtf8( 280 self.refactoringImportsOrganizeAct.setWhatsThis(self.trUtf8(
279 """<b>Organize Imports</b>""" 281 """<b>Organize Imports</b>"""
280 """<p>Sort imports according to PEP-8.</p>""" 282 """<p>Sort imports according to PEP-8.</p>"""
282 self.refactoringImportsOrganizeAct.triggered[()].connect( 284 self.refactoringImportsOrganizeAct.triggered[()].connect(
283 self.__importsOrganize) 285 self.__importsOrganize)
284 self.actions.append(self.refactoringImportsOrganizeAct) 286 self.actions.append(self.refactoringImportsOrganizeAct)
285 287
286 self.refactoringImportsStarExpandAct = E5Action( 288 self.refactoringImportsStarExpandAct = E5Action(
287 self.trUtf8('Expand Star Imports'), 289 self.trUtf8('Expand Star Imports'),
288 self.trUtf8('E&xpand Star Imports'), 290 self.trUtf8('E&xpand Star Imports'),
289 0, 0, 291 0, 0,
290 self, 'refactoring_expand_star_imports') 292 self, 'refactoring_expand_star_imports')
291 self.refactoringImportsStarExpandAct.setStatusTip(self.trUtf8( 293 self.refactoringImportsStarExpandAct.setStatusTip(self.trUtf8(
292 'Expand imports like "from xxx import *"')) 294 'Expand imports like "from xxx import *"'))
293 self.refactoringImportsStarExpandAct.setWhatsThis(self.trUtf8( 295 self.refactoringImportsStarExpandAct.setWhatsThis(self.trUtf8(
294 """<b>Expand Star Imports</b>""" 296 """<b>Expand Star Imports</b>"""
295 """<p>Expand imports like "from xxx import *".</p>""" 297 """<p>Expand imports like "from xxx import *".</p>"""
299 self.refactoringImportsStarExpandAct.triggered[()].connect( 301 self.refactoringImportsStarExpandAct.triggered[()].connect(
300 self.__importsExpandStar) 302 self.__importsExpandStar)
301 self.actions.append(self.refactoringImportsStarExpandAct) 303 self.actions.append(self.refactoringImportsStarExpandAct)
302 304
303 self.refactoringImportsRelativeToAbsoluteAct = E5Action( 305 self.refactoringImportsRelativeToAbsoluteAct = E5Action(
304 self.trUtf8('Relative to Absolute'), 306 self.trUtf8('Relative to Absolute'),
305 self.trUtf8('Relative to &Absolute'), 307 self.trUtf8('Relative to &Absolute'),
306 0, 0, 308 0, 0,
307 self, 'refactoring_relative_to_absolute_imports') 309 self, 'refactoring_relative_to_absolute_imports')
308 self.refactoringImportsRelativeToAbsoluteAct.setStatusTip(self.trUtf8( 310 self.refactoringImportsRelativeToAbsoluteAct.setStatusTip(self.trUtf8(
309 'Transform relative imports to absolute ones')) 311 'Transform relative imports to absolute ones'))
310 self.refactoringImportsRelativeToAbsoluteAct.setWhatsThis(self.trUtf8( 312 self.refactoringImportsRelativeToAbsoluteAct.setWhatsThis(self.trUtf8(
311 """<b>Relative to Absolute</b>""" 313 """<b>Relative to Absolute</b>"""
312 """<p>Transform relative imports to absolute ones.</p>""" 314 """<p>Transform relative imports to absolute ones.</p>"""
316 self.refactoringImportsRelativeToAbsoluteAct.triggered[()].connect( 318 self.refactoringImportsRelativeToAbsoluteAct.triggered[()].connect(
317 self.__importsRelativeToAbsolute) 319 self.__importsRelativeToAbsolute)
318 self.actions.append(self.refactoringImportsRelativeToAbsoluteAct) 320 self.actions.append(self.refactoringImportsRelativeToAbsoluteAct)
319 321
320 self.refactoringImportsFromsToImportsAct = E5Action( 322 self.refactoringImportsFromsToImportsAct = E5Action(
321 self.trUtf8('Froms to Imports'), 323 self.trUtf8('Froms to Imports'),
322 self.trUtf8('Froms to &Imports'), 324 self.trUtf8('Froms to &Imports'),
323 0, 0, 325 0, 0,
324 self, 'refactoring_froms_to_imports') 326 self, 'refactoring_froms_to_imports')
325 self.refactoringImportsFromsToImportsAct.setStatusTip(self.trUtf8( 327 self.refactoringImportsFromsToImportsAct.setStatusTip(self.trUtf8(
326 'Transform From imports to plain imports')) 328 'Transform From imports to plain imports'))
327 self.refactoringImportsFromsToImportsAct.setWhatsThis(self.trUtf8( 329 self.refactoringImportsFromsToImportsAct.setWhatsThis(self.trUtf8(
328 """<b>Froms to Imports</b>""" 330 """<b>Froms to Imports</b>"""
329 """<p>Transform From imports to plain imports.</p>""" 331 """<p>Transform From imports to plain imports.</p>"""
333 self.refactoringImportsFromsToImportsAct.triggered[()].connect( 335 self.refactoringImportsFromsToImportsAct.triggered[()].connect(
334 self.__importsFromToImport) 336 self.__importsFromToImport)
335 self.actions.append(self.refactoringImportsFromsToImportsAct) 337 self.actions.append(self.refactoringImportsFromsToImportsAct)
336 338
337 self.refactoringImportsHandleLongAct = E5Action( 339 self.refactoringImportsHandleLongAct = E5Action(
338 self.trUtf8('Handle Long Imports'), 340 self.trUtf8('Handle Long Imports'),
339 self.trUtf8('Handle &Long Imports'), 341 self.trUtf8('Handle &Long Imports'),
340 0, 0, 342 0, 0,
341 self, 'refactoring_organize_imports') 343 self, 'refactoring_organize_imports')
342 self.refactoringImportsHandleLongAct.setStatusTip(self.trUtf8( 344 self.refactoringImportsHandleLongAct.setStatusTip(self.trUtf8(
343 'Transform long import statements to look better')) 345 'Transform long import statements to look better'))
344 self.refactoringImportsHandleLongAct.setWhatsThis(self.trUtf8( 346 self.refactoringImportsHandleLongAct.setWhatsThis(self.trUtf8(
345 """<b>Handle Long Imports</b>""" 347 """<b>Handle Long Imports</b>"""
346 """<p>Transform long import statements to look better.</p>""" 348 """<p>Transform long import statements to look better.</p>"""
354 ##################################################### 356 #####################################################
355 ## Various refactorings actions 357 ## Various refactorings actions
356 ##################################################### 358 #####################################################
357 359
358 self.refactoringRestructureAct = E5Action( 360 self.refactoringRestructureAct = E5Action(
359 self.trUtf8('Restructure'), 361 self.trUtf8('Restructure'),
360 self.trUtf8('Res&tructure'), 362 self.trUtf8('Res&tructure'),
361 0, 0, 363 0, 0,
362 self, 'refactoring_restructure') 364 self, 'refactoring_restructure')
363 self.refactoringRestructureAct.setStatusTip(self.trUtf8( 365 self.refactoringRestructureAct.setStatusTip(self.trUtf8(
364 'Restructure code')) 366 'Restructure code'))
365 self.refactoringRestructureAct.setWhatsThis(self.trUtf8( 367 self.refactoringRestructureAct.setWhatsThis(self.trUtf8(
366 """<b>Restructure</b>""" 368 """<b>Restructure</b>"""
367 """<p>Restructure code. See "Rope Help" for examples.</p>""" 369 """<p>Restructure code. See "Rope Help" for examples.</p>"""
369 self.refactoringRestructureAct.triggered[()].connect( 371 self.refactoringRestructureAct.triggered[()].connect(
370 self.__restructure) 372 self.__restructure)
371 self.actions.append(self.refactoringRestructureAct) 373 self.actions.append(self.refactoringRestructureAct)
372 374
373 self.refactoringChangeSignatureAct = E5Action( 375 self.refactoringChangeSignatureAct = E5Action(
374 self.trUtf8('Change Method Signature'), 376 self.trUtf8('Change Method Signature'),
375 self.trUtf8('&Change Method Signature'), 377 self.trUtf8('&Change Method Signature'),
376 0, 0, 378 0, 0,
377 self, 'refactoring_change_method_signature') 379 self, 'refactoring_change_method_signature')
378 self.refactoringChangeSignatureAct.setStatusTip(self.trUtf8( 380 self.refactoringChangeSignatureAct.setStatusTip(self.trUtf8(
379 'Change the signature of the selected method or function')) 381 'Change the signature of the selected method or function'))
380 self.refactoringChangeSignatureAct.setWhatsThis(self.trUtf8( 382 self.refactoringChangeSignatureAct.setWhatsThis(self.trUtf8(
381 """<b>Change Method Signature</b>""" 383 """<b>Change Method Signature</b>"""
382 """<p>Change the signature of the selected method""" 384 """<p>Change the signature of the selected method"""
385 self.refactoringChangeSignatureAct.triggered[()].connect( 387 self.refactoringChangeSignatureAct.triggered[()].connect(
386 self.__changeSignature) 388 self.__changeSignature)
387 self.actions.append(self.refactoringChangeSignatureAct) 389 self.actions.append(self.refactoringChangeSignatureAct)
388 390
389 self.refactoringInlineArgumentDefaultAct = E5Action( 391 self.refactoringInlineArgumentDefaultAct = E5Action(
390 self.trUtf8('Inline Argument Default'), 392 self.trUtf8('Inline Argument Default'),
391 self.trUtf8('Inline &Argument Default'), 393 self.trUtf8('Inline &Argument Default'),
392 0, 0, 394 0, 0,
393 self, 'refactoring_inline_argument_default') 395 self, 'refactoring_inline_argument_default')
394 self.refactoringInlineArgumentDefaultAct.setStatusTip(self.trUtf8( 396 self.refactoringInlineArgumentDefaultAct.setStatusTip(self.trUtf8(
395 'Inline a parameters default value')) 397 'Inline a parameters default value'))
396 self.refactoringInlineArgumentDefaultAct.setWhatsThis(self.trUtf8( 398 self.refactoringInlineArgumentDefaultAct.setWhatsThis(self.trUtf8(
397 """<b>Inline Argument Default</b>""" 399 """<b>Inline Argument Default</b>"""
398 """<p>Inline a parameters default value.</p>""" 400 """<p>Inline a parameters default value.</p>"""
400 self.refactoringInlineArgumentDefaultAct.triggered[()].connect( 402 self.refactoringInlineArgumentDefaultAct.triggered[()].connect(
401 self.__inlineArgumentDefault) 403 self.__inlineArgumentDefault)
402 self.actions.append(self.refactoringInlineArgumentDefaultAct) 404 self.actions.append(self.refactoringInlineArgumentDefaultAct)
403 405
404 self.refactoringTransformModuleAct = E5Action( 406 self.refactoringTransformModuleAct = E5Action(
405 self.trUtf8('Transform Module to Package'), 407 self.trUtf8('Transform Module to Package'),
406 self.trUtf8('Transform Module to Package'), 408 self.trUtf8('Transform Module to Package'),
407 0, 0, 409 0, 0,
408 self, 'refactoring_transform_module_to_package') 410 self, 'refactoring_transform_module_to_package')
409 self.refactoringTransformModuleAct.setStatusTip(self.trUtf8( 411 self.refactoringTransformModuleAct.setStatusTip(self.trUtf8(
410 'Transform the current module to a package')) 412 'Transform the current module to a package'))
411 self.refactoringTransformModuleAct.setWhatsThis(self.trUtf8( 413 self.refactoringTransformModuleAct.setWhatsThis(self.trUtf8(
412 """<b>Transform Module to Package</b>""" 414 """<b>Transform Module to Package</b>"""
413 """<p>Transform the current module to a package.</p>""" 415 """<p>Transform the current module to a package.</p>"""
415 self.refactoringTransformModuleAct.triggered[()].connect( 417 self.refactoringTransformModuleAct.triggered[()].connect(
416 self.__transformModuleToPackage) 418 self.__transformModuleToPackage)
417 self.actions.append(self.refactoringTransformModuleAct) 419 self.actions.append(self.refactoringTransformModuleAct)
418 420
419 self.refactoringEncapsulateAttributeAct = E5Action( 421 self.refactoringEncapsulateAttributeAct = E5Action(
420 self.trUtf8('Encapsulate Attribute'), 422 self.trUtf8('Encapsulate Attribute'),
421 self.trUtf8('Encap&sulate Attribute'), 423 self.trUtf8('Encap&sulate Attribute'),
422 0, 0, 424 0, 0,
423 self, 'refactoring_encapsulate_attribute') 425 self, 'refactoring_encapsulate_attribute')
424 self.refactoringEncapsulateAttributeAct.setStatusTip(self.trUtf8( 426 self.refactoringEncapsulateAttributeAct.setStatusTip(self.trUtf8(
425 'Generate a getter/setter for an attribute')) 427 'Generate a getter/setter for an attribute'))
426 self.refactoringEncapsulateAttributeAct.setWhatsThis(self.trUtf8( 428 self.refactoringEncapsulateAttributeAct.setWhatsThis(self.trUtf8(
427 """<b>Encapsulate Attribute</b>""" 429 """<b>Encapsulate Attribute</b>"""
428 """<p>Generate a getter/setter for an attribute and changes""" 430 """<p>Generate a getter/setter for an attribute and changes"""
431 self.refactoringEncapsulateAttributeAct.triggered[()].connect( 433 self.refactoringEncapsulateAttributeAct.triggered[()].connect(
432 self.__encapsulateAttribute) 434 self.__encapsulateAttribute)
433 self.actions.append(self.refactoringEncapsulateAttributeAct) 435 self.actions.append(self.refactoringEncapsulateAttributeAct)
434 436
435 self.refactoringLocalVariableToAttributeAct = E5Action( 437 self.refactoringLocalVariableToAttributeAct = E5Action(
436 self.trUtf8('Local Variable to Attribute'), 438 self.trUtf8('Local Variable to Attribute'),
437 self.trUtf8('Local Varia&ble to Attribute'), 439 self.trUtf8('Local Varia&ble to Attribute'),
438 0, 0, 440 0, 0,
439 self, 'refactoring_local_variable_to_attribute') 441 self, 'refactoring_local_variable_to_attribute')
440 self.refactoringLocalVariableToAttributeAct.setStatusTip(self.trUtf8( 442 self.refactoringLocalVariableToAttributeAct.setStatusTip(self.trUtf8(
441 'Change a local variable to an attribute')) 443 'Change a local variable to an attribute'))
442 self.refactoringLocalVariableToAttributeAct.setWhatsThis(self.trUtf8( 444 self.refactoringLocalVariableToAttributeAct.setWhatsThis(self.trUtf8(
443 """<b>Local Variable to Attribute</b>""" 445 """<b>Local Variable to Attribute</b>"""
444 """<p>Change a local variable to an attribute.</p>""" 446 """<p>Change a local variable to an attribute.</p>"""
446 self.refactoringLocalVariableToAttributeAct.triggered[()].connect( 448 self.refactoringLocalVariableToAttributeAct.triggered[()].connect(
447 self.__convertLocalToAttribute) 449 self.__convertLocalToAttribute)
448 self.actions.append(self.refactoringLocalVariableToAttributeAct) 450 self.actions.append(self.refactoringLocalVariableToAttributeAct)
449 451
450 self.refactoringMethodToMethodObjectAct = E5Action( 452 self.refactoringMethodToMethodObjectAct = E5Action(
451 self.trUtf8('Method To Method Object'), 453 self.trUtf8('Method To Method Object'),
452 self.trUtf8('Method To Method Ob&ject'), 454 self.trUtf8('Method To Method Ob&ject'),
453 0, 0, 455 0, 0,
454 self, 'refactoring_method_to_methodobject') 456 self, 'refactoring_method_to_methodobject')
455 self.refactoringMethodToMethodObjectAct.setStatusTip(self.trUtf8( 457 self.refactoringMethodToMethodObjectAct.setStatusTip(self.trUtf8(
456 'Transform a function or a method to a method object')) 458 'Transform a function or a method to a method object'))
457 self.refactoringMethodToMethodObjectAct.setWhatsThis(self.trUtf8( 459 self.refactoringMethodToMethodObjectAct.setWhatsThis(self.trUtf8(
458 """<b>Method To Method Object</b>""" 460 """<b>Method To Method Object</b>"""
459 """<p>Transform a function or a method to a method object.</p>""" 461 """<p>Transform a function or a method to a method object.</p>"""
464 466
465 ##################################################### 467 #####################################################
466 ## Undo/Redo actions 468 ## Undo/Redo actions
467 ##################################################### 469 #####################################################
468 470
469 self.refactoringUndoAct = E5Action(self.trUtf8('Undo'), 471 self.refactoringUndoAct = E5Action(
470 self.trUtf8('&Undo'), 472 self.trUtf8('Undo'),
471 0, 0, 473 self.trUtf8('&Undo'),
472 self, 'refactoring_undo') 474 0, 0,
475 self, 'refactoring_undo')
473 self.refactoringUndoAct.setStatusTip(self.trUtf8( 476 self.refactoringUndoAct.setStatusTip(self.trUtf8(
474 'Undo the last refactoring')) 477 'Undo the last refactoring'))
475 self.refactoringUndoAct.setWhatsThis(self.trUtf8( 478 self.refactoringUndoAct.setWhatsThis(self.trUtf8(
476 """<b>Undo</b>""" 479 """<b>Undo</b>"""
477 """<p>Undo the last refactoring.</p>""" 480 """<p>Undo the last refactoring.</p>"""
478 )) 481 ))
479 self.refactoringUndoAct.triggered[()].connect( 482 self.refactoringUndoAct.triggered[()].connect(
480 self.__undo) 483 self.__undo)
481 self.actions.append(self.refactoringUndoAct) 484 self.actions.append(self.refactoringUndoAct)
482 485
483 self.refactoringRedoAct = E5Action(self.trUtf8('Redo'), 486 self.refactoringRedoAct = E5Action(
484 self.trUtf8('Re&do'), 487 self.trUtf8('Redo'),
485 0, 0, 488 self.trUtf8('Re&do'),
486 self, 'refactoring_redo') 489 0, 0,
490 self, 'refactoring_redo')
487 self.refactoringRedoAct.setStatusTip(self.trUtf8( 491 self.refactoringRedoAct.setStatusTip(self.trUtf8(
488 'Redo the last refactoring')) 492 'Redo the last refactoring'))
489 self.refactoringRedoAct.setWhatsThis(self.trUtf8( 493 self.refactoringRedoAct.setWhatsThis(self.trUtf8(
490 """<b>Redo</b>""" 494 """<b>Redo</b>"""
491 """<p>Redo the last refactoring.</p>""" 495 """<p>Redo the last refactoring.</p>"""
492 )) 496 ))
493 self.refactoringRedoAct.triggered[()].connect( 497 self.refactoringRedoAct.triggered[()].connect(
494 self.__redo) 498 self.__redo)
495 self.actions.append(self.refactoringRedoAct) 499 self.actions.append(self.refactoringRedoAct)
496 500
497 self.refactoringUndoHistoryAct = \ 501 self.refactoringUndoHistoryAct = E5Action(
498 E5Action(self.trUtf8('Show Project Undo History'), 502 self.trUtf8('Show Project Undo History'),
499 self.trUtf8('Show Project Undo History'), 503 self.trUtf8('Show Project Undo History'),
500 0, 0, 504 0, 0,
501 self, 'refactoring_show_project_undo_history') 505 self, 'refactoring_show_project_undo_history')
502 self.refactoringUndoHistoryAct.setStatusTip(self.trUtf8( 506 self.refactoringUndoHistoryAct.setStatusTip(self.trUtf8(
503 'Show the undo history of the project')) 507 'Show the undo history of the project'))
504 self.refactoringUndoHistoryAct.setWhatsThis(self.trUtf8( 508 self.refactoringUndoHistoryAct.setWhatsThis(self.trUtf8(
505 """<b>Show Project Undo History</b>""" 509 """<b>Show Project Undo History</b>"""
506 """<p>Opens a dialog to show the undo history list of""" 510 """<p>Opens a dialog to show the undo history list of"""
508 )) 512 ))
509 self.refactoringUndoHistoryAct.triggered[()].connect( 513 self.refactoringUndoHistoryAct.triggered[()].connect(
510 self.__showProjectUndoHistory) 514 self.__showProjectUndoHistory)
511 self.actions.append(self.refactoringUndoHistoryAct) 515 self.actions.append(self.refactoringUndoHistoryAct)
512 516
513 self.refactoringRedoHistoryAct = \ 517 self.refactoringRedoHistoryAct = E5Action(
514 E5Action(self.trUtf8('Show Project Redo History'), 518 self.trUtf8('Show Project Redo History'),
515 self.trUtf8('Show Project Redo History'), 519 self.trUtf8('Show Project Redo History'),
516 0, 0, 520 0, 0,
517 self, 'refactoring_show_project_redo_history') 521 self, 'refactoring_show_project_redo_history')
518 self.refactoringRedoHistoryAct.setStatusTip(self.trUtf8( 522 self.refactoringRedoHistoryAct.setStatusTip(self.trUtf8(
519 'Show the redo history of the project')) 523 'Show the redo history of the project'))
520 self.refactoringRedoHistoryAct.setWhatsThis(self.trUtf8( 524 self.refactoringRedoHistoryAct.setWhatsThis(self.trUtf8(
521 """<b>Show Project Redo History</b>""" 525 """<b>Show Project Redo History</b>"""
522 """<p>Opens a dialog to show the redo history list of""" 526 """<p>Opens a dialog to show the redo history list of"""
524 )) 528 ))
525 self.refactoringRedoHistoryAct.triggered[()].connect( 529 self.refactoringRedoHistoryAct.triggered[()].connect(
526 self.__showProjectRedoHistory) 530 self.__showProjectRedoHistory)
527 self.actions.append(self.refactoringRedoHistoryAct) 531 self.actions.append(self.refactoringRedoHistoryAct)
528 532
529 self.refactoringUndoFileHistoryAct = \ 533 self.refactoringUndoFileHistoryAct = E5Action(
530 E5Action(self.trUtf8('Show Current File Undo History'), 534 self.trUtf8('Show Current File Undo History'),
531 self.trUtf8('Show Current File Undo History'), 535 self.trUtf8('Show Current File Undo History'),
532 0, 0, 536 0, 0,
533 self, 'refactoring_show_file_undo_history') 537 self, 'refactoring_show_file_undo_history')
534 self.refactoringUndoFileHistoryAct.setStatusTip(self.trUtf8( 538 self.refactoringUndoFileHistoryAct.setStatusTip(self.trUtf8(
535 'Show the undo history of the current file')) 539 'Show the undo history of the current file'))
536 self.refactoringUndoFileHistoryAct.setWhatsThis(self.trUtf8( 540 self.refactoringUndoFileHistoryAct.setWhatsThis(self.trUtf8(
537 """<b>Show Current File Undo History</b>""" 541 """<b>Show Current File Undo History</b>"""
538 """<p>Opens a dialog to show the undo history list of""" 542 """<p>Opens a dialog to show the undo history list of"""
540 )) 544 ))
541 self.refactoringUndoFileHistoryAct.triggered[()].connect( 545 self.refactoringUndoFileHistoryAct.triggered[()].connect(
542 self.__showFileUndoHistory) 546 self.__showFileUndoHistory)
543 self.actions.append(self.refactoringUndoFileHistoryAct) 547 self.actions.append(self.refactoringUndoFileHistoryAct)
544 548
545 self.refactoringRedoFileHistoryAct = \ 549 self.refactoringRedoFileHistoryAct = E5Action(
546 E5Action(self.trUtf8('Show Current File Redo History'), 550 self.trUtf8('Show Current File Redo History'),
547 self.trUtf8('Show Current File Redo History'), 551 self.trUtf8('Show Current File Redo History'),
548 0, 0, 552 0, 0,
549 self, 'refactoring_show_file_redo_history') 553 self, 'refactoring_show_file_redo_history')
550 self.refactoringRedoFileHistoryAct.setStatusTip(self.trUtf8( 554 self.refactoringRedoFileHistoryAct.setStatusTip(self.trUtf8(
551 'Show the redo history of the current file')) 555 'Show the redo history of the current file'))
552 self.refactoringRedoFileHistoryAct.setWhatsThis(self.trUtf8( 556 self.refactoringRedoFileHistoryAct.setWhatsThis(self.trUtf8(
553 """<b>Show Current File Redo History</b>""" 557 """<b>Show Current File Redo History</b>"""
554 """<p>Opens a dialog to show the redo history list of""" 558 """<p>Opens a dialog to show the redo history list of"""
556 )) 560 ))
557 self.refactoringRedoFileHistoryAct.triggered[()].connect( 561 self.refactoringRedoFileHistoryAct.triggered[()].connect(
558 self.__showFileRedoHistory) 562 self.__showFileRedoHistory)
559 self.actions.append(self.refactoringRedoFileHistoryAct) 563 self.actions.append(self.refactoringRedoFileHistoryAct)
560 564
561 self.refactoringClearHistoryAct = \ 565 self.refactoringClearHistoryAct = E5Action(
562 E5Action(self.trUtf8('Clear History'), 566 self.trUtf8('Clear History'),
563 self.trUtf8('Clear History'), 567 self.trUtf8('Clear History'),
564 0, 0, 568 0, 0,
565 self, 'refactoring_clear_history') 569 self, 'refactoring_clear_history')
566 self.refactoringClearHistoryAct.setStatusTip(self.trUtf8( 570 self.refactoringClearHistoryAct.setStatusTip(self.trUtf8(
567 'Clear the refactoring history')) 571 'Clear the refactoring history'))
568 self.refactoringClearHistoryAct.setWhatsThis(self.trUtf8( 572 self.refactoringClearHistoryAct.setWhatsThis(self.trUtf8(
569 """<b>Clear History</b>""" 573 """<b>Clear History</b>"""
570 """<p>Clears the refactoring history.</p>""" 574 """<p>Clears the refactoring history.</p>"""
575 579
576 ##################################################### 580 #####################################################
577 ## Query actions 581 ## Query actions
578 ##################################################### 582 #####################################################
579 583
580 self.queryReferencesAct = E5Action(self.trUtf8('Find occurrences'), 584 self.queryReferencesAct = E5Action(
581 self.trUtf8('Find &Occurrences'), 585 self.trUtf8('Find occurrences'),
582 0, 0, 586 self.trUtf8('Find &Occurrences'),
583 self, 'refactoring_find_occurrences') 587 0, 0,
588 self, 'refactoring_find_occurrences')
584 self.queryReferencesAct.setStatusTip(self.trUtf8( 589 self.queryReferencesAct.setStatusTip(self.trUtf8(
585 'Find occurrences of the highlighted object')) 590 'Find occurrences of the highlighted object'))
586 self.queryReferencesAct.setWhatsThis(self.trUtf8( 591 self.queryReferencesAct.setWhatsThis(self.trUtf8(
587 """<b>Find occurrences</b>""" 592 """<b>Find occurrences</b>"""
588 """<p>Find occurrences of the highlighted class, method,""" 593 """<p>Find occurrences of the highlighted class, method,"""
590 )) 595 ))
591 self.queryReferencesAct.triggered[()].connect( 596 self.queryReferencesAct.triggered[()].connect(
592 self.__queryReferences) 597 self.__queryReferences)
593 self.actions.append(self.queryReferencesAct) 598 self.actions.append(self.queryReferencesAct)
594 599
595 self.queryDefinitionAct = E5Action(self.trUtf8('Find definition'), 600 self.queryDefinitionAct = E5Action(
596 self.trUtf8('Find &Definition'), 601 self.trUtf8('Find definition'),
597 0, 0, 602 self.trUtf8('Find &Definition'),
598 self, 'refactoring_find_definition') 603 0, 0,
604 self, 'refactoring_find_definition')
599 self.queryDefinitionAct.setStatusTip(self.trUtf8( 605 self.queryDefinitionAct.setStatusTip(self.trUtf8(
600 'Find definition of the highlighted item')) 606 'Find definition of the highlighted item'))
601 self.queryDefinitionAct.setWhatsThis(self.trUtf8( 607 self.queryDefinitionAct.setWhatsThis(self.trUtf8(
602 """<b>Find definition</b>""" 608 """<b>Find definition</b>"""
603 """<p>Find the definition of the highlighted class, method,""" 609 """<p>Find the definition of the highlighted class, method,"""
606 self.queryDefinitionAct.triggered[()].connect( 612 self.queryDefinitionAct.triggered[()].connect(
607 self.__queryDefinition) 613 self.__queryDefinition)
608 self.actions.append(self.queryDefinitionAct) 614 self.actions.append(self.queryDefinitionAct)
609 615
610 self.queryImplementationsAct = E5Action( 616 self.queryImplementationsAct = E5Action(
611 self.trUtf8('Find implementations'), 617 self.trUtf8('Find implementations'),
612 self.trUtf8('Find &Implementations'), 618 self.trUtf8('Find &Implementations'),
613 0, 0, 619 0, 0,
614 self, 'refactoring_find_implementations') 620 self, 'refactoring_find_implementations')
615 self.queryImplementationsAct.setStatusTip(self.trUtf8( 621 self.queryImplementationsAct.setStatusTip(self.trUtf8(
616 'Find places where the selected method is overridden')) 622 'Find places where the selected method is overridden'))
617 self.queryImplementationsAct.setWhatsThis(self.trUtf8( 623 self.queryImplementationsAct.setWhatsThis(self.trUtf8(
618 """<b>Find implementations</b>""" 624 """<b>Find implementations</b>"""
619 """<p>Find places where the selected method is overridden.</p>""" 625 """<p>Find places where the selected method is overridden.</p>"""
624 630
625 ##################################################### 631 #####################################################
626 ## Various actions 632 ## Various actions
627 ##################################################### 633 #####################################################
628 634
629 self.refactoringEditConfigAct = E5Action(self.trUtf8('Configure Rope'), 635 self.refactoringEditConfigAct = E5Action(
630 self.trUtf8('&Configure Rope'), 636 self.trUtf8('Configure Rope'),
631 0, 0, 637 self.trUtf8('&Configure Rope'),
632 self, 'refactoring_edit_config') 638 0, 0,
639 self, 'refactoring_edit_config')
633 self.refactoringEditConfigAct.setStatusTip(self.trUtf8( 640 self.refactoringEditConfigAct.setStatusTip(self.trUtf8(
634 'Open the rope configuration file')) 641 'Open the rope configuration file'))
635 self.refactoringEditConfigAct.setWhatsThis(self.trUtf8( 642 self.refactoringEditConfigAct.setWhatsThis(self.trUtf8(
636 """<b>Configure Rope</b>""" 643 """<b>Configure Rope</b>"""
637 """<p>Opens the rope configuration file in an editor.</p>""" 644 """<p>Opens the rope configuration file in an editor.</p>"""
639 self.refactoringEditConfigAct.triggered[()].connect( 646 self.refactoringEditConfigAct.triggered[()].connect(
640 self.__editConfig) 647 self.__editConfig)
641 self.refactoringEditConfigAct.setMenuRole(QAction.NoRole) 648 self.refactoringEditConfigAct.setMenuRole(QAction.NoRole)
642 self.actions.append(self.refactoringEditConfigAct) 649 self.actions.append(self.refactoringEditConfigAct)
643 650
644 self.refactoringHelpAct = E5Action(self.trUtf8('Rope help'), 651 self.refactoringHelpAct = E5Action(
645 self.trUtf8('Rope &Help'), 652 self.trUtf8('Rope help'),
646 0, 0, 653 self.trUtf8('Rope &Help'),
647 self, 'refactoring_help') 654 0, 0,
655 self, 'refactoring_help')
648 self.refactoringHelpAct.setStatusTip(self.trUtf8( 656 self.refactoringHelpAct.setStatusTip(self.trUtf8(
649 'Show help about the rope refactorings')) 657 'Show help about the rope refactorings'))
650 self.refactoringHelpAct.setWhatsThis(self.trUtf8( 658 self.refactoringHelpAct.setWhatsThis(self.trUtf8(
651 """<b>Rope help</b>""" 659 """<b>Rope help</b>"""
652 """<p>Show some help text about the rope refactorings.</p>""" 660 """<p>Show some help text about the rope refactorings.</p>"""
654 self.refactoringHelpAct.triggered[()].connect( 662 self.refactoringHelpAct.triggered[()].connect(
655 self.__showRopeHelp) 663 self.__showRopeHelp)
656 self.actions.append(self.refactoringHelpAct) 664 self.actions.append(self.refactoringHelpAct)
657 665
658 self.refactoringAllSoaAct = E5Action( 666 self.refactoringAllSoaAct = E5Action(
659 self.trUtf8('Analyse all modules'), 667 self.trUtf8('Analyse all modules'),
660 self.trUtf8('&Analyse all modules'), 668 self.trUtf8('&Analyse all modules'),
661 0, 0, 669 0, 0,
662 self, 'refactoring_analyze_all') 670 self, 'refactoring_analyze_all')
663 self.refactoringAllSoaAct.setStatusTip(self.trUtf8( 671 self.refactoringAllSoaAct.setStatusTip(self.trUtf8(
664 'Perform static object analysis on all modules')) 672 'Perform static object analysis on all modules'))
665 self.refactoringAllSoaAct.setWhatsThis(self.trUtf8( 673 self.refactoringAllSoaAct.setWhatsThis(self.trUtf8(
666 """<b>Analyse all modules</b>""" 674 """<b>Analyse all modules</b>"""
667 """<p>Perform static object analysis (SOA) on all modules. """ 675 """<p>Perform static object analysis (SOA) on all modules. """
672 self.refactoringAllSoaAct.triggered[()].connect( 680 self.refactoringAllSoaAct.triggered[()].connect(
673 self.__performSOA) 681 self.__performSOA)
674 self.actions.append(self.refactoringAllSoaAct) 682 self.actions.append(self.refactoringAllSoaAct)
675 683
676 self.updateConfigAct = E5Action( 684 self.updateConfigAct = E5Action(
677 self.trUtf8('Update Configuration'), 685 self.trUtf8('Update Configuration'),
678 self.trUtf8('&Update Configuration'), 686 self.trUtf8('&Update Configuration'),
679 0, 0, 687 0, 0,
680 self, 'refactoring_update_configuration') 688 self, 'refactoring_update_configuration')
681 self.updateConfigAct.setStatusTip(self.trUtf8( 689 self.updateConfigAct.setStatusTip(self.trUtf8(
682 'Generates a new configuration file overwriting the current one.')) 690 'Generates a new configuration file overwriting the current one.'))
683 self.updateConfigAct.setWhatsThis(self.trUtf8( 691 self.updateConfigAct.setWhatsThis(self.trUtf8(
684 """<b>Update Configuration</b>""" 692 """<b>Update Configuration</b>"""
685 """<p>Generates a new configuration file overwriting""" 693 """<p>Generates a new configuration file overwriting"""
784 792
785 def __ropeInfo(self): 793 def __ropeInfo(self):
786 """ 794 """
787 Private slot to show some info about rope. 795 Private slot to show some info about rope.
788 """ 796 """
789 E5MessageBox.about(self.__ui, 797 E5MessageBox.about(
798 self.__ui,
790 self.trUtf8("About rope"), 799 self.trUtf8("About rope"),
791 self.trUtf8("{0}\nVersion {1}\n\n{2}".format( 800 self.trUtf8("{0}\nVersion {1}\n\n{2}".format(
792 rope.INFO, rope.VERSION, rope.COPYRIGHT))) 801 rope.INFO, rope.VERSION, rope.COPYRIGHT)))
793 802
794 def __canUndo(self): 803 def __canUndo(self):
796 Private slot to check, if there are changes to be undone. 805 Private slot to check, if there are changes to be undone.
797 806
798 @return flag indicating, that undoable changes are available (boolean) 807 @return flag indicating, that undoable changes are available (boolean)
799 """ 808 """
800 return self.__project is not None and \ 809 return self.__project is not None and \
801 len(self.__project.history.undo_list) > 0 810 len(self.__project.history.undo_list) > 0
802 811
803 def __canRedo(self): 812 def __canRedo(self):
804 """ 813 """
805 Private slot to check, if there are changes to be redone. 814 Private slot to check, if there are changes to be redone.
806 815
807 @return flag indicating, that redoable changes are available (boolean) 816 @return flag indicating, that redoable changes are available (boolean)
808 """ 817 """
809 return self.__project is not None and \ 818 return self.__project is not None and \
810 len(self.__project.history.redo_list) > 0 819 len(self.__project.history.redo_list) > 0
811 820
812 def __getFileUndoList(self, resource): 821 def __getFileUndoList(self, resource):
813 """ 822 """
814 Private slot to get a list of undoable changes. 823 Private slot to get a list of undoable changes.
815 824
891 @param handle reference to a taskhandle (ProgressHandle) 900 @param handle reference to a taskhandle (ProgressHandle)
892 """ 901 """
893 if handle is not None: 902 if handle is not None:
894 handle.reset() 903 handle.reset()
895 if str(type(err)).split()[-1][1:-2].split('.')[-1] == \ 904 if str(type(err)).split()[-1][1:-2].split('.')[-1] == \
896 'ModuleSyntaxError': 905 'ModuleSyntaxError':
897 res = E5MessageBox.warning(self.__ui, title, 906 res = E5MessageBox.warning(
907 self.__ui, title,
898 self.trUtf8("Rope error: {0}").format(str(err)), 908 self.trUtf8("Rope error: {0}").format(str(err)),
899 E5MessageBox.Ok | E5MessageBox.Open) 909 E5MessageBox.Ok | E5MessageBox.Open)
900 if res == E5MessageBox.Open: 910 if res == E5MessageBox.Open:
901 e5App().getObject("ViewManager").openSourceFile( 911 e5App().getObject("ViewManager").openSourceFile(
902 os.path.join(self.__e5project.getProjectPath(), 912 os.path.join(self.__e5project.getProjectPath(),
903 err.filename), 913 err.filename),
904 err.lineno) 914 err.lineno)
905 else: 915 else:
906 E5MessageBox.warning(self.__ui, title, 916 E5MessageBox.warning(
917 self.__ui, title,
907 self.trUtf8("Rope error: {0}").format(str(err))) 918 self.trUtf8("Rope error: {0}").format(str(err)))
908 919
909 def __getOffset(self, editor, line, index): 920 def __getOffset(self, editor, line, index):
910 """ 921 r"""
911 Private method to get the offset into the text treating CRLF as ONE character. 922 Private method to get the offset into the text treating CRLF as ONE
923 character.
912 924
913 Note: rope seems to convert all EOL styles to just \n. 925 Note: rope seems to convert all EOL styles to just \n.
914 926
915 @param editor reference to the editor (Editor) 927 @param editor reference to the editor (Editor)
916 @param line line for the offset (integer) 928 @param line line for the offset (integer)
945 def __renameModule(self): 957 def __renameModule(self):
946 """ 958 """
947 Private slot to handle the Rename Current Module action. 959 Private slot to handle the Rename Current Module action.
948 """ 960 """
949 self.__doRename(self.trUtf8('Rename Current Module'), 961 self.__doRename(self.trUtf8('Rename Current Module'),
950 renameModule=True) 962 renameModule=True)
951 963
952 def __doRename(self, title, isLocal=False, renameModule=False): 964 def __doRename(self, title, isLocal=False, renameModule=False):
953 """ 965 """
954 Private method to perform the various renaming refactorings. 966 Private method to perform the various renaming refactorings.
955 967
964 if aw is None: 976 if aw is None:
965 return 977 return
966 978
967 if not renameModule and not aw.hasSelectedText(): 979 if not renameModule and not aw.hasSelectedText():
968 # no selection available 980 # no selection available
969 E5MessageBox.warning(self.__ui, title, 981 E5MessageBox.warning(
982 self.__ui, title,
970 self.trUtf8("Highlight the declaration you want to rename" 983 self.trUtf8("Highlight the declaration you want to rename"
971 " and try again.")) 984 " and try again."))
972 return 985 return
973 986
974 if isLocal: 987 if isLocal:
975 if not self.confirmBufferIsSaved(aw): 988 if not self.confirmBufferIsSaved(aw):
976 return 989 return
983 offset = None 996 offset = None
984 else: 997 else:
985 line, index, line1, index1 = aw.getSelection() 998 line, index, line1, index1 = aw.getSelection()
986 if line != line1: 999 if line != line1:
987 # selection span more than one line 1000 # selection span more than one line
988 E5MessageBox.warning(self.__ui, title, 1001 E5MessageBox.warning(
1002 self.__ui, title,
989 self.trUtf8("The selection must not extend beyond" 1003 self.trUtf8("The selection must not extend beyond"
990 " one line.")) 1004 " one line."))
991 return 1005 return
992 index = int(index + (index1 - index) / 2) 1006 index = int(index + (index1 - index) / 2)
993 # keep it inside the object 1007 # keep it inside the object
1022 return 1036 return
1023 1037
1024 title = self.trUtf8("Change Occurrences") 1038 title = self.trUtf8("Change Occurrences")
1025 if not aw.hasSelectedText(): 1039 if not aw.hasSelectedText():
1026 # no selection available 1040 # no selection available
1027 E5MessageBox.warning(self.__ui, title, 1041 E5MessageBox.warning(
1042 self.__ui, title,
1028 self.trUtf8("Highlight an occurrence to be changed" 1043 self.trUtf8("Highlight an occurrence to be changed"
1029 " and try again.")) 1044 " and try again."))
1030 return 1045 return
1031 1046
1032 if not self.confirmBufferIsSaved(aw): 1047 if not self.confirmBufferIsSaved(aw):
1033 return 1048 return
1034 1049
1039 import rope.refactor.rename 1054 import rope.refactor.rename
1040 resource = rope.base.libutils.path_to_resource( 1055 resource = rope.base.libutils.path_to_resource(
1041 self.__project, filename) 1056 self.__project, filename)
1042 try: 1057 try:
1043 renamer = rope.refactor.rename.ChangeOccurrences( 1058 renamer = rope.refactor.rename.ChangeOccurrences(
1044 self.__project, resource, offset) 1059 self.__project, resource, offset)
1045 except Exception as err: 1060 except Exception as err:
1046 self.handleRopeError(err, title) 1061 self.handleRopeError(err, title)
1047 return 1062 return
1048 1063
1049 from ChangeOccurrencesDialog import ChangeOccurrencesDialog 1064 from ChangeOccurrencesDialog import ChangeOccurrencesDialog
1072 Private method to perform the extract refactoring. 1087 Private method to perform the extract refactoring.
1073 1088
1074 @param title title of the refactoring (string) 1089 @param title title of the refactoring (string)
1075 @param kind kind of extraction to be done (string, 1090 @param kind kind of extraction to be done (string,
1076 "method" or "variable") 1091 "method" or "variable")
1092 @exception Exception raised to indicate a wrong extraction method
1077 """ 1093 """
1078 aw = e5App().getObject("ViewManager").activeWindow() 1094 aw = e5App().getObject("ViewManager").activeWindow()
1079 1095
1080 if aw is None: 1096 if aw is None:
1081 return 1097 return
1082 1098
1083 if not aw.hasSelectedText(): 1099 if not aw.hasSelectedText():
1084 # no selection available 1100 # no selection available
1085 E5MessageBox.warning(self.__ui, title, 1101 E5MessageBox.warning(
1102 self.__ui, title,
1086 self.trUtf8("Highlight the region of code you want to extract" 1103 self.trUtf8("Highlight the region of code you want to extract"
1087 " and try again.")) 1104 " and try again."))
1088 return 1105 return
1089 1106
1090 if not self.confirmBufferIsSaved(aw): 1107 if not self.confirmBufferIsSaved(aw):
1091 return 1108 return
1092 1109
1129 return 1146 return
1130 1147
1131 title = self.trUtf8("Inline") 1148 title = self.trUtf8("Inline")
1132 if not aw.hasSelectedText(): 1149 if not aw.hasSelectedText():
1133 # no selection available 1150 # no selection available
1134 E5MessageBox.warning(self.__ui, title, 1151 E5MessageBox.warning(
1152 self.__ui, title,
1135 self.trUtf8("Highlight the local variable, method or parameter" 1153 self.trUtf8("Highlight the local variable, method or parameter"
1136 " you want to inline and try again.")) 1154 " you want to inline and try again."))
1137 return 1155 return
1138 1156
1139 if not self.confirmAllBuffersSaved(): 1157 if not self.confirmAllBuffersSaved():
1140 return 1158 return
1141 1159
1171 return 1189 return
1172 1190
1173 title = self.trUtf8("Move Method") 1191 title = self.trUtf8("Move Method")
1174 if not aw.hasSelectedText(): 1192 if not aw.hasSelectedText():
1175 # no selection available 1193 # no selection available
1176 E5MessageBox.warning(self.__ui, title, 1194 E5MessageBox.warning(
1195 self.__ui, title,
1177 self.trUtf8("Highlight the method to move" 1196 self.trUtf8("Highlight the method to move"
1178 " and try again.")) 1197 " and try again."))
1179 return 1198 return
1180 1199
1181 if not self.confirmAllBuffersSaved(): 1200 if not self.confirmAllBuffersSaved():
1182 return 1201 return
1183 1202
1195 self.handleRopeError(err, title) 1214 self.handleRopeError(err, title)
1196 return 1215 return
1197 1216
1198 if isinstance(mover, rope.refactor.move.MoveGlobal): 1217 if isinstance(mover, rope.refactor.move.MoveGlobal):
1199 from MoveGlobalMethodDialog import MoveGlobalMethodDialog 1218 from MoveGlobalMethodDialog import MoveGlobalMethodDialog
1200 self.dlg = MoveGlobalMethodDialog(self, title, mover, 1219 self.dlg = MoveGlobalMethodDialog(
1201 self.__project, parent=self.__ui) 1220 self, title, mover, self.__project, parent=self.__ui)
1202 else: 1221 else:
1203 from MoveMethodDialog import MoveMethodDialog 1222 from MoveMethodDialog import MoveMethodDialog
1204 self.dlg = MoveMethodDialog(self, title, mover, parent=self.__ui) 1223 self.dlg = MoveMethodDialog(self, title, mover, parent=self.__ui)
1205 self.dlg.show() 1224 self.dlg.show()
1206 1225
1249 return 1268 return
1250 1269
1251 title = self.trUtf8("Use Function") 1270 title = self.trUtf8("Use Function")
1252 if not aw.hasSelectedText(): 1271 if not aw.hasSelectedText():
1253 # no selection available 1272 # no selection available
1254 E5MessageBox.warning(self.__ui, title, 1273 E5MessageBox.warning(
1274 self.__ui, title,
1255 self.trUtf8("Highlight a global function and try again.")) 1275 self.trUtf8("Highlight a global function and try again."))
1256 return 1276 return
1257 1277
1258 if not self.confirmAllBuffersSaved(): 1278 if not self.confirmAllBuffersSaved():
1259 return 1279 return
1290 return 1310 return
1291 1311
1292 title = self.trUtf8("Introduce Factory Method") 1312 title = self.trUtf8("Introduce Factory Method")
1293 if not aw.hasSelectedText(): 1313 if not aw.hasSelectedText():
1294 # no selection available 1314 # no selection available
1295 E5MessageBox.warning(self.__ui, title, 1315 E5MessageBox.warning(
1316 self.__ui, title,
1296 self.trUtf8("Highlight the class to introduce a factory" 1317 self.trUtf8("Highlight the class to introduce a factory"
1297 " method for and try again.")) 1318 " method for and try again."))
1298 return 1319 return
1299 1320
1300 if not self.confirmAllBuffersSaved(): 1321 if not self.confirmAllBuffersSaved():
1301 return 1322 return
1302 1323
1308 resource = rope.base.libutils.path_to_resource( 1329 resource = rope.base.libutils.path_to_resource(
1309 self.__project, filename) 1330 self.__project, filename)
1310 try: 1331 try:
1311 introducer = \ 1332 introducer = \
1312 rope.refactor.introduce_factory.IntroduceFactoryRefactoring( 1333 rope.refactor.introduce_factory.IntroduceFactoryRefactoring(
1313 self.__project, resource, offset) 1334 self.__project, resource, offset)
1314 except Exception as err: 1335 except Exception as err:
1315 self.handleRopeError(err, title) 1336 self.handleRopeError(err, title)
1316 return 1337 return
1317 1338
1318 from IntroduceFactoryDialog import IntroduceFactoryDialog 1339 from IntroduceFactoryDialog import IntroduceFactoryDialog
1330 return 1351 return
1331 1352
1332 title = self.trUtf8("Introduce Parameter") 1353 title = self.trUtf8("Introduce Parameter")
1333 if not aw.hasSelectedText(): 1354 if not aw.hasSelectedText():
1334 # no selection available 1355 # no selection available
1335 E5MessageBox.warning(self.__ui, title, 1356 E5MessageBox.warning(
1357 self.__ui, title,
1336 self.trUtf8("Highlight the code for the new parameter" 1358 self.trUtf8("Highlight the code for the new parameter"
1337 " and try again.")) 1359 " and try again."))
1338 return 1360 return
1339 1361
1340 if not self.confirmAllBuffersSaved(): 1362 if not self.confirmAllBuffersSaved():
1341 return 1363 return
1342 1364
1347 import rope.refactor.introduce_parameter 1369 import rope.refactor.introduce_parameter
1348 resource = rope.base.libutils.path_to_resource( 1370 resource = rope.base.libutils.path_to_resource(
1349 self.__project, filename) 1371 self.__project, filename)
1350 try: 1372 try:
1351 introducer = rope.refactor.introduce_parameter.IntroduceParameter( 1373 introducer = rope.refactor.introduce_parameter.IntroduceParameter(
1352 self.__project, resource, offset) 1374 self.__project, resource, offset)
1353 except Exception as err: 1375 except Exception as err:
1354 self.handleRopeError(err, title) 1376 self.handleRopeError(err, title)
1355 return 1377 return
1356 1378
1357 from IntroduceParameterDialog import IntroduceParameterDialog 1379 from IntroduceParameterDialog import IntroduceParameterDialog
1366 def __importsOrganize(self): 1388 def __importsOrganize(self):
1367 """ 1389 """
1368 Private slot to organize imports. 1390 Private slot to organize imports.
1369 """ 1391 """
1370 from rope.refactor.importutils import ImportOrganizer 1392 from rope.refactor.importutils import ImportOrganizer
1371 self.__doImports(self.trUtf8("Organize Imports"), 1393 self.__doImports(
1394 self.trUtf8("Organize Imports"),
1372 ImportOrganizer.organize_imports) 1395 ImportOrganizer.organize_imports)
1373 1396
1374 def __importsExpandStar(self): 1397 def __importsExpandStar(self):
1375 """ 1398 """
1376 Private slot to expand star imports. 1399 Private slot to expand star imports.
1377 """ 1400 """
1378 from rope.refactor.importutils import ImportOrganizer 1401 from rope.refactor.importutils import ImportOrganizer
1379 self.__doImports(self.trUtf8("Expand Star Imports"), 1402 self.__doImports(
1403 self.trUtf8("Expand Star Imports"),
1380 ImportOrganizer.expand_star_imports) 1404 ImportOrganizer.expand_star_imports)
1381 1405
1382 def __importsRelativeToAbsolute(self): 1406 def __importsRelativeToAbsolute(self):
1383 """ 1407 """
1384 Private slot to transform relative to absolute imports. 1408 Private slot to transform relative to absolute imports.
1385 """ 1409 """
1386 from rope.refactor.importutils import ImportOrganizer 1410 from rope.refactor.importutils import ImportOrganizer
1387 self.__doImports(self.trUtf8("Relative to Absolute"), 1411 self.__doImports(
1412 self.trUtf8("Relative to Absolute"),
1388 ImportOrganizer.relatives_to_absolutes) 1413 ImportOrganizer.relatives_to_absolutes)
1389 1414
1390 def __importsFromToImport(self): 1415 def __importsFromToImport(self):
1391 """ 1416 """
1392 Private slot to transform from imports to plain imports. 1417 Private slot to transform from imports to plain imports.
1393 """ 1418 """
1394 from rope.refactor.importutils import ImportOrganizer 1419 from rope.refactor.importutils import ImportOrganizer
1395 self.__doImports(self.trUtf8("Froms to Imports"), 1420 self.__doImports(
1421 self.trUtf8("Froms to Imports"),
1396 ImportOrganizer.froms_to_imports) 1422 ImportOrganizer.froms_to_imports)
1397 1423
1398 def __importsHandleLong(self): 1424 def __importsHandleLong(self):
1399 """ 1425 """
1400 Private slot to handle long imports. 1426 Private slot to handle long imports.
1401 """ 1427 """
1402 from rope.refactor.importutils import ImportOrganizer 1428 from rope.refactor.importutils import ImportOrganizer
1403 self.__doImports(self.trUtf8("Handle Long Imports"), 1429 self.__doImports(
1430 self.trUtf8("Handle Long Imports"),
1404 ImportOrganizer.handle_long_imports) 1431 ImportOrganizer.handle_long_imports)
1405 1432
1406 def __doImports(self, title, method): 1433 def __doImports(self, title, method):
1407 """ 1434 """
1408 Private method to perform the various imports refactorings. 1435 Private method to perform the various imports refactorings.
1436
1437 @param title title to be used for the import refactoring (string)
1438 @param method method performing the import refactoring
1409 """ 1439 """
1410 aw = e5App().getObject("ViewManager").activeWindow() 1440 aw = e5App().getObject("ViewManager").activeWindow()
1411 1441
1412 if aw is None: 1442 if aw is None:
1413 return 1443 return
1435 self.__project.do(changes) 1465 self.__project.do(changes)
1436 self.refreshEditors(changes) 1466 self.refreshEditors(changes)
1437 if self.__e5project.isDirty(): 1467 if self.__e5project.isDirty():
1438 self.__e5project.saveProject() 1468 self.__e5project.saveProject()
1439 else: 1469 else:
1440 E5MessageBox.information(self.__ui, title, 1470 E5MessageBox.information(
1471 self.__ui, title,
1441 self.trUtf8("The selected refactoring did not produce" 1472 self.trUtf8("The selected refactoring did not produce"
1442 " any change.")) 1473 " any change."))
1443 except Exception as err: 1474 except Exception as err:
1444 self.handleRopeError(err, title) 1475 self.handleRopeError(err, title)
1445 1476
1466 return 1497 return
1467 1498
1468 title = self.trUtf8("Change Method Signature") 1499 title = self.trUtf8("Change Method Signature")
1469 if not aw.hasSelectedText(): 1500 if not aw.hasSelectedText():
1470 # no selection available 1501 # no selection available
1471 E5MessageBox.warning(self.__ui, title, 1502 E5MessageBox.warning(
1503 self.__ui, title,
1472 self.trUtf8("Highlight the method or function to change" 1504 self.trUtf8("Highlight the method or function to change"
1473 " and try again.")) 1505 " and try again."))
1474 return 1506 return
1475 1507
1476 if not self.confirmAllBuffersSaved(): 1508 if not self.confirmAllBuffersSaved():
1477 return 1509 return
1478 1510
1506 return 1538 return
1507 1539
1508 title = self.trUtf8("Inline Argument Default") 1540 title = self.trUtf8("Inline Argument Default")
1509 if not aw.hasSelectedText(): 1541 if not aw.hasSelectedText():
1510 # no selection available 1542 # no selection available
1511 E5MessageBox.warning(self.__ui, title, 1543 E5MessageBox.warning(
1544 self.__ui, title,
1512 self.trUtf8("Highlight the method or function to inline" 1545 self.trUtf8("Highlight the method or function to inline"
1513 " a parameter's default and try again.")) 1546 " a parameter's default and try again."))
1514 return 1547 return
1515 1548
1516 if not self.confirmAllBuffersSaved(): 1549 if not self.confirmAllBuffersSaved():
1517 return 1550 return
1518 1551
1574 return 1607 return
1575 1608
1576 title = self.trUtf8("Encapsulate Attribute") 1609 title = self.trUtf8("Encapsulate Attribute")
1577 if not aw.hasSelectedText(): 1610 if not aw.hasSelectedText():
1578 # no selection available 1611 # no selection available
1579 E5MessageBox.warning(self.__ui, title, 1612 E5MessageBox.warning(
1613 self.__ui, title,
1580 self.trUtf8("Highlight the attribute to encapsulate" 1614 self.trUtf8("Highlight the attribute to encapsulate"
1581 " and try again.")) 1615 " and try again."))
1582 return 1616 return
1583 1617
1584 if not self.confirmAllBuffersSaved(): 1618 if not self.confirmAllBuffersSaved():
1585 return 1619 return
1586 1620
1631 return 1665 return
1632 1666
1633 title = self.trUtf8("Local Variable to Attribute") 1667 title = self.trUtf8("Local Variable to Attribute")
1634 if not aw.hasSelectedText(): 1668 if not aw.hasSelectedText():
1635 # no selection available 1669 # no selection available
1636 E5MessageBox.warning(self.__ui, title, 1670 E5MessageBox.warning(
1671 self.__ui, title,
1637 self.trUtf8("Highlight the local variable to make an attribute" 1672 self.trUtf8("Highlight the local variable to make an attribute"
1638 " and try again.")) 1673 " and try again."))
1639 return 1674 return
1640 1675
1641 if not self.confirmAllBuffersSaved(): 1676 if not self.confirmAllBuffersSaved():
1642 return 1677 return
1643 1678
1671 return 1706 return
1672 1707
1673 title = self.trUtf8("Replace Method With Method Object") 1708 title = self.trUtf8("Replace Method With Method Object")
1674 if not aw.hasSelectedText(): 1709 if not aw.hasSelectedText():
1675 # no selection available 1710 # no selection available
1676 E5MessageBox.warning(self.__ui, title, 1711 E5MessageBox.warning(
1712 self.__ui, title,
1677 self.trUtf8("Highlight the method or function to convert" 1713 self.trUtf8("Highlight the method or function to convert"
1678 " and try again.")) 1714 " and try again."))
1679 return 1715 return
1680 1716
1681 if not self.confirmAllBuffersSaved(): 1717 if not self.confirmAllBuffersSaved():
1682 return 1718 return
1683 1719
1708 """ 1744 """
1709 Private slot to undo the last refactoring. 1745 Private slot to undo the last refactoring.
1710 """ 1746 """
1711 title = self.trUtf8("Undo refactoring") 1747 title = self.trUtf8("Undo refactoring")
1712 history = self.__project.history 1748 history = self.__project.history
1713 res = E5MessageBox.yesNo(None, 1749 res = E5MessageBox.yesNo(
1750 None,
1714 title, 1751 title,
1715 self.trUtf8("""Shall the refactoring <b>{0}</b> be undone?""")\ 1752 self.trUtf8("""Shall the refactoring <b>{0}</b> be undone?""")
1716 .format(Utilities.html_encode( 1753 .format(Utilities.html_encode(
1717 history.undo_list[-1].description))) 1754 history.undo_list[-1].description)))
1718 if res: 1755 if res:
1719 if not self.confirmAllBuffersSaved(): 1756 if not self.confirmAllBuffersSaved():
1720 return 1757 return
1721 1758
1722 from ProgressHandle import ProgressHandle 1759 from ProgressHandle import ProgressHandle
1737 """ 1774 """
1738 Private slot to redo the last refactoring. 1775 Private slot to redo the last refactoring.
1739 """ 1776 """
1740 title = self.trUtf8("Redo refactoring") 1777 title = self.trUtf8("Redo refactoring")
1741 history = self.__project.history 1778 history = self.__project.history
1742 res = E5MessageBox.yesNo(None, 1779 res = E5MessageBox.yesNo(
1780 None,
1743 title, 1781 title,
1744 self.trUtf8("""Shall the refactoring <b>{0}</b> be redone?""")\ 1782 self.trUtf8("""Shall the refactoring <b>{0}</b> be redone?""")
1745 .format(Utilities.html_encode( 1783 .format(Utilities.html_encode(
1746 history.redo_list[-1].description))) 1784 history.redo_list[-1].description)))
1747 if res: 1785 if res:
1748 if not self.confirmAllBuffersSaved(): 1786 if not self.confirmAllBuffersSaved():
1749 return 1787 return
1750 1788
1751 from ProgressHandle import ProgressHandle 1789 from ProgressHandle import ProgressHandle
1818 1856
1819 def __clearHistory(self): 1857 def __clearHistory(self):
1820 """ 1858 """
1821 Private slot to clear the redo and undo lists. 1859 Private slot to clear the redo and undo lists.
1822 """ 1860 """
1823 res = E5MessageBox.yesNo(None, 1861 res = E5MessageBox.yesNo(
1862 None,
1824 self.trUtf8("Clear History"), 1863 self.trUtf8("Clear History"),
1825 self.trUtf8("""Do you really want to clear the undo""" 1864 self.trUtf8("""Do you really want to clear the undo"""
1826 """ and redo history?""")) 1865 """ and redo history?"""))
1827 if res: 1866 if res:
1828 self.__project.history.clear() 1867 self.__project.history.clear()
1841 return 1880 return
1842 1881
1843 title = self.trUtf8("Find Occurrences") 1882 title = self.trUtf8("Find Occurrences")
1844 if not aw.hasSelectedText(): 1883 if not aw.hasSelectedText():
1845 # no selection available 1884 # no selection available
1846 E5MessageBox.warning(self.__ui, title, 1885 E5MessageBox.warning(
1886 self.__ui, title,
1847 self.trUtf8("Highlight the class, method, function or variable" 1887 self.trUtf8("Highlight the class, method, function or variable"
1848 " to search for and try again.")) 1888 " to search for and try again."))
1849 return 1889 return
1850 1890
1851 if not self.confirmAllBuffersSaved(): 1891 if not self.confirmAllBuffersSaved():
1852 return 1892 return
1853 1893
1874 if occurrences: 1914 if occurrences:
1875 from MatchesDialog import MatchesDialog 1915 from MatchesDialog import MatchesDialog
1876 self.dlg = MatchesDialog(self.__ui, True) 1916 self.dlg = MatchesDialog(self.__ui, True)
1877 self.dlg.show() 1917 self.dlg.show()
1878 for occurrence in occurrences: 1918 for occurrence in occurrences:
1879 self.dlg.addEntry(occurrence.resource, 1919 self.dlg.addEntry(
1880 occurrence.lineno, occurrence.unsure) 1920 occurrence.resource, occurrence.lineno, occurrence.unsure)
1881 else: 1921 else:
1882 E5MessageBox.warning(self.__ui, title, 1922 E5MessageBox.warning(
1923 self.__ui, title,
1883 self.trUtf8("No occurrences found.")) 1924 self.trUtf8("No occurrences found."))
1884 1925
1885 def __queryDefinition(self): 1926 def __queryDefinition(self):
1886 """ 1927 """
1887 Private slot to handle the Find Definition action 1928 Private slot to handle the Find Definition action.
1888 """ 1929 """
1889 aw = e5App().getObject("ViewManager").activeWindow() 1930 aw = e5App().getObject("ViewManager").activeWindow()
1890 1931
1891 if aw is None: 1932 if aw is None:
1892 return 1933 return
1893 1934
1894 title = self.trUtf8("Find &Definition") 1935 title = self.trUtf8("Find &Definition")
1895 if not aw.hasSelectedText(): 1936 if not aw.hasSelectedText():
1896 # no selection available 1937 # no selection available
1897 E5MessageBox.warning(self.__ui, title, 1938 E5MessageBox.warning(
1939 self.__ui, title,
1898 self.trUtf8("Highlight the class, method, function or" 1940 self.trUtf8("Highlight the class, method, function or"
1899 " variable reference to search definition for and" 1941 " variable reference to search definition for and"
1900 " try again.")) 1942 " try again."))
1901 return 1943 return
1902 1944
1903 if not self.confirmAllBuffersSaved(): 1945 if not self.confirmAllBuffersSaved():
1904 return 1946 return
1905 1947
1921 from MatchesDialog import MatchesDialog 1963 from MatchesDialog import MatchesDialog
1922 self.dlg = MatchesDialog(self.__ui, False) 1964 self.dlg = MatchesDialog(self.__ui, False)
1923 self.dlg.show() 1965 self.dlg.show()
1924 self.dlg.addEntry(location.resource, location.lineno) 1966 self.dlg.addEntry(location.resource, location.lineno)
1925 else: 1967 else:
1926 E5MessageBox.warning(self.__ui, title, 1968 E5MessageBox.warning(
1969 self.__ui, title,
1927 self.trUtf8("No matching definition found.")) 1970 self.trUtf8("No matching definition found."))
1928 1971
1929 def __queryImplementations(self): 1972 def __queryImplementations(self):
1930 """ 1973 """
1931 Private slot to handle the Find Implementations action. 1974 Private slot to handle the Find Implementations action.
1936 return 1979 return
1937 1980
1938 title = self.trUtf8("Find Implementations") 1981 title = self.trUtf8("Find Implementations")
1939 if not aw.hasSelectedText(): 1982 if not aw.hasSelectedText():
1940 # no selection available 1983 # no selection available
1941 E5MessageBox.warning(self.__ui, title, 1984 E5MessageBox.warning(
1985 self.__ui, title,
1942 self.trUtf8("Highlight the method to search for" 1986 self.trUtf8("Highlight the method to search for"
1943 " and try again.")) 1987 " and try again."))
1944 return 1988 return
1945 1989
1946 if not self.confirmAllBuffersSaved(): 1990 if not self.confirmAllBuffersSaved():
1950 line, index, line1, index1 = aw.getSelection() 1994 line, index, line1, index1 = aw.getSelection()
1951 offset = self.__getOffset(aw, line, index) 1995 offset = self.__getOffset(aw, line, index)
1952 1996
1953 import rope.contrib.findit 1997 import rope.contrib.findit
1954 from ProgressHandle import ProgressHandle 1998 from ProgressHandle import ProgressHandle
1955 resource = rope.base.libutils.path_to_resource(self.__project, 1999 resource = rope.base.libutils.path_to_resource(
1956 filename) 2000 self.__project, filename)
1957 handle = ProgressHandle(title, True, self.__ui) 2001 handle = ProgressHandle(title, True, self.__ui)
1958 handle.show() 2002 handle.show()
1959 QApplication.processEvents() 2003 QApplication.processEvents()
1960 try: 2004 try:
1961 occurrences = rope.contrib.findit.find_implementations( 2005 occurrences = rope.contrib.findit.find_implementations(
1968 if occurrences: 2012 if occurrences:
1969 from MatchesDialog import MatchesDialog 2013 from MatchesDialog import MatchesDialog
1970 self.dlg = MatchesDialog(self.__ui, True) 2014 self.dlg = MatchesDialog(self.__ui, True)
1971 self.dlg.show() 2015 self.dlg.show()
1972 for occurrence in occurrences: 2016 for occurrence in occurrences:
1973 self.dlg.addEntry(occurrence.resource, 2017 self.dlg.addEntry(
1974 occurrence.lineno, occurrence.unsure) 2018 occurrence.resource, occurrence.lineno, occurrence.unsure)
1975 else: 2019 else:
1976 E5MessageBox.warning(self.__ui, title, 2020 E5MessageBox.warning(
1977 self.trUtf8("No occurrences found.")) 2021 self.__ui, title, self.trUtf8("No occurrences found."))
1978 2022
1979 ##################################################### 2023 #####################################################
1980 ## Various actions 2024 ## Various actions
1981 ##################################################### 2025 #####################################################
1982 2026
1992 from QScintilla.MiniEditor import MiniEditor 2036 from QScintilla.MiniEditor import MiniEditor
1993 self.__editor = MiniEditor(configfile) 2037 self.__editor = MiniEditor(configfile)
1994 self.__editor.show() 2038 self.__editor.show()
1995 self.__editor.editorSaved.connect(self.__configChanged) 2039 self.__editor.editorSaved.connect(self.__configChanged)
1996 else: 2040 else:
1997 E5MessageBox.critical(self.__ui, 2041 E5MessageBox.critical(
2042 self.__ui,
1998 self.trUtf8("Configure Rope"), 2043 self.trUtf8("Configure Rope"),
1999 self.trUtf8("""The Rope configuration file '{0}' does""" 2044 self.trUtf8("""The Rope configuration file '{0}' does"""
2000 """ not exist.""").format(configfile)) 2045 """ not exist.""").format(configfile))
2001 else: 2046 else:
2002 E5MessageBox.critical(self.__ui, 2047 E5MessageBox.critical(
2048 self.__ui,
2003 self.trUtf8("Configure Rope"), 2049 self.trUtf8("Configure Rope"),
2004 self.trUtf8("""The Rope admin directory does not exist.""")) 2050 self.trUtf8("""The Rope admin directory does not exist."""))
2005 2051
2006 def __updateConfig(self): 2052 def __updateConfig(self):
2007 """ 2053 """
2008 Private slot to update the configuration file. 2054 Private slot to update the configuration file.
2009 """ 2055 """
2010 res = E5MessageBox.yesNo(self.__ui, 2056 res = E5MessageBox.yesNo(
2057 self.__ui,
2011 self.trUtf8("Update Configuration"), 2058 self.trUtf8("Update Configuration"),
2012 self.trUtf8("""Shall rope's current configuration be replaced """ 2059 self.trUtf8("""Shall rope's current configuration be replaced """
2013 """by a new default configuration?""")) 2060 """by a new default configuration?"""))
2014 if res: 2061 if res:
2015 src = self.__defaultConfig() 2062 src = self.__defaultConfig()
2020 f.write(src) 2067 f.write(src)
2021 f.close() 2068 f.close()
2022 self.__configChanged() 2069 self.__configChanged()
2023 self.__editConfig() 2070 self.__editConfig()
2024 except IOError as err: 2071 except IOError as err:
2025 E5MessageBox.critical(None, 2072 E5MessageBox.critical(
2073 None,
2026 self.trUtf8("Update Configuration"), 2074 self.trUtf8("Update Configuration"),
2027 self.trUtf8("""<p>The configuration could not be""" 2075 self.trUtf8("""<p>The configuration could not be"""
2028 """ updated.</p><p>Reason: {0}</p>""")\ 2076 """ updated.</p><p>Reason: {0}</p>""")
2029 .format(str(err))) 2077 .format(str(err)))
2030 2078
2031 def __showRopeHelp(self): 2079 def __showRopeHelp(self):
2032 """ 2080 """
2033 Private slot to show help about the refactorings offered by Rope. 2081 Private slot to show help about the refactorings offered by Rope.
2034 """ 2082 """
2044 def __performSOA(self): 2092 def __performSOA(self):
2045 """ 2093 """
2046 Private slot to perform SOA on all modules. 2094 Private slot to perform SOA on all modules.
2047 """ 2095 """
2048 title = self.trUtf8("Analyse all modules") 2096 title = self.trUtf8("Analyse all modules")
2049 res = E5MessageBox.yesNo(self.__ui, 2097 res = E5MessageBox.yesNo(
2098 self.__ui,
2050 title, 2099 title,
2051 self.trUtf8("""This action might take some time. """ 2100 self.trUtf8("""This action might take some time. """
2052 """Do you really want to perform SOA?""")) 2101 """Do you really want to perform SOA?"""))
2053 if res: 2102 if res:
2054 from ProgressHandle import ProgressHandle 2103 from ProgressHandle import ProgressHandle
2055 handle = ProgressHandle(title, True, self.__ui) 2104 handle = ProgressHandle(title, True, self.__ui)
2056 handle.show() 2105 handle.show()
2057 QApplication.processEvents() 2106 QApplication.processEvents()
2058 try: 2107 try:
2059 rope.base.libutils.analyze_modules(self.__project, 2108 rope.base.libutils.analyze_modules(
2060 task_handle=handle) 2109 self.__project, task_handle=handle)
2061 handle.reset() 2110 handle.reset()
2062 E5MessageBox.information(self.__ui, 2111 E5MessageBox.information(
2112 self.__ui,
2063 title, 2113 title,
2064 self.trUtf8("""Static object analysis (SOA) done. """ 2114 self.trUtf8("""Static object analysis (SOA) done. """
2065 """SOA database updated.""")) 2115 """SOA database updated."""))
2066 except Exception as err: 2116 except Exception as err:
2067 self.handleRopeError(err, title, handle) 2117 self.handleRopeError(err, title, handle)
2089 """ 2139 """
2090 Private slot called, when the rope config file has changed. 2140 Private slot called, when the rope config file has changed.
2091 """ 2141 """
2092 import rope.base.project 2142 import rope.base.project
2093 self.__project.close() 2143 self.__project.close()
2094 self.__project = rope.base.project.Project(self.__projectpath, 2144 self.__project = rope.base.project.Project(
2095 fscommands=self.__fsCommands) 2145 self.__projectpath, fscommands=self.__fsCommands)
2096 2146
2097 def __defaultConfig(self): 2147 def __defaultConfig(self):
2098 """ 2148 """
2099 Private slot to return the contents of rope's default configuration. 2149 Private slot to return the contents of rope's default configuration.
2100 2150
2129 self.__projectpath = self.__e5project.getProjectPath() 2179 self.__projectpath = self.__e5project.getProjectPath()
2130 self.__projectLanguage = self.__e5project.getProjectLanguage() 2180 self.__projectLanguage = self.__e5project.getProjectLanguage()
2131 2181
2132 if self.__projectLanguage in ["Python3"]: 2182 if self.__projectLanguage in ["Python3"]:
2133 import rope.base.project 2183 import rope.base.project
2134 self.__project = rope.base.project.Project(self.__projectpath, 2184 self.__project = rope.base.project.Project(
2135 fscommands=self.__fsCommands) 2185 self.__projectpath, fscommands=self.__fsCommands)
2136 for act in self.actions: 2186 for act in self.actions:
2137 act.setEnabled(True) 2187 act.setEnabled(True)
2138 2188
2139 def projectClosed(self): 2189 def projectClosed(self):
2140 """ 2190 """
2184 2234
2185 def refreshEditors(self, changes): 2235 def refreshEditors(self, changes):
2186 """ 2236 """
2187 Public method to refresh modified editors. 2237 Public method to refresh modified editors.
2188 2238
2189 @param reference to the Changes object (rope.base.change.ChangeSet) 2239 @param changes reference to the ChangeSet object
2240 (rope.base.change.ChangeSet)
2190 """ 2241 """
2191 vm = e5App().getObject("ViewManager") 2242 vm = e5App().getObject("ViewManager")
2192 2243
2193 changedFiles = [] 2244 changedFiles = []
2194 for resource in changes.get_changed_resources(): 2245 for resource in changes.get_changed_resources():

eric ide

mercurial