RefactoringRope/Refactoring.py

changeset 20
83b71483e198
parent 19
32dd7dbf3e8e
child 26
b02d1f37b55e
equal deleted inserted replaced
19:32dd7dbf3e8e 20:83b71483e198
103 ##################################################### 103 #####################################################
104 ## Rename refactoring actions 104 ## Rename refactoring actions
105 ##################################################### 105 #####################################################
106 106
107 self.refactoringRenameAct = E5Action(self.trUtf8('Rename'), 107 self.refactoringRenameAct = E5Action(self.trUtf8('Rename'),
108 self.trUtf8('&Rename'), 108 self.trUtf8('&Rename'),
109 0, 0, 109 0, 0,
110 self,'refactoring_rename') 110 self, 'refactoring_rename')
111 self.refactoringRenameAct.setStatusTip(self.trUtf8( 111 self.refactoringRenameAct.setStatusTip(self.trUtf8(
112 'Rename the highlighted object')) 112 'Rename the highlighted object'))
113 self.refactoringRenameAct.setWhatsThis(self.trUtf8( 113 self.refactoringRenameAct.setWhatsThis(self.trUtf8(
114 """<b>Rename</b>""" 114 """<b>Rename</b>"""
115 """<p>Rename the highlighted Python object.</p>""" 115 """<p>Rename the highlighted Python object.</p>"""
117 self.refactoringRenameAct.triggered[()].connect( 117 self.refactoringRenameAct.triggered[()].connect(
118 self.__rename) 118 self.__rename)
119 self.actions.append(self.refactoringRenameAct) 119 self.actions.append(self.refactoringRenameAct)
120 120
121 self.refactoringRenameLocalAct = E5Action(self.trUtf8('Local Rename'), 121 self.refactoringRenameLocalAct = E5Action(self.trUtf8('Local Rename'),
122 self.trUtf8('&Local Rename'), 122 self.trUtf8('&Local Rename'),
123 0, 0, 123 0, 0,
124 self,'refactoring_rename_local') 124 self, 'refactoring_rename_local')
125 self.refactoringRenameLocalAct.setStatusTip(self.trUtf8( 125 self.refactoringRenameLocalAct.setStatusTip(self.trUtf8(
126 'Rename the highlighted object in the current module only')) 126 'Rename the highlighted object in the current module only'))
127 self.refactoringRenameLocalAct.setWhatsThis(self.trUtf8( 127 self.refactoringRenameLocalAct.setWhatsThis(self.trUtf8(
128 """<b>Local Rename</b>""" 128 """<b>Local Rename</b>"""
129 """<p>Rename the highlighted Python object in the current""" 129 """<p>Rename the highlighted Python object in the current"""
133 self.__renameLocal) 133 self.__renameLocal)
134 self.actions.append(self.refactoringRenameLocalAct) 134 self.actions.append(self.refactoringRenameLocalAct)
135 135
136 self.refactoringRenameModuleAct = E5Action( 136 self.refactoringRenameModuleAct = E5Action(
137 self.trUtf8('Rename Current Module'), 137 self.trUtf8('Rename Current Module'),
138 self.trUtf8('Rename Current Module'), 138 self.trUtf8('Rename Current Module'),
139 0, 0, 139 0, 0,
140 self,'refactoring_rename_module') 140 self, 'refactoring_rename_module')
141 self.refactoringRenameModuleAct.setStatusTip(self.trUtf8( 141 self.refactoringRenameModuleAct.setStatusTip(self.trUtf8(
142 'Rename the current module')) 142 'Rename the current module'))
143 self.refactoringRenameModuleAct.setWhatsThis(self.trUtf8( 143 self.refactoringRenameModuleAct.setWhatsThis(self.trUtf8(
144 """<b>Rename Current Module</b>""" 144 """<b>Rename Current Module</b>"""
145 """<p>Rename the current module.</p>""" 145 """<p>Rename the current module.</p>"""
148 self.__renameModule) 148 self.__renameModule)
149 self.actions.append(self.refactoringRenameModuleAct) 149 self.actions.append(self.refactoringRenameModuleAct)
150 150
151 self.refactoringChangeOccurrencesAct = E5Action( 151 self.refactoringChangeOccurrencesAct = E5Action(
152 self.trUtf8('Change Occurrences'), 152 self.trUtf8('Change Occurrences'),
153 self.trUtf8('Change &Occurrences'), 153 self.trUtf8('Change &Occurrences'),
154 0, 0, 154 0, 0,
155 self,'refactoring_change_occurrences') 155 self, 'refactoring_change_occurrences')
156 self.refactoringChangeOccurrencesAct.setStatusTip(self.trUtf8( 156 self.refactoringChangeOccurrencesAct.setStatusTip(self.trUtf8(
157 'Change all occurrences in the local scope')) 157 'Change all occurrences in the local scope'))
158 self.refactoringChangeOccurrencesAct.setWhatsThis(self.trUtf8( 158 self.refactoringChangeOccurrencesAct.setWhatsThis(self.trUtf8(
159 """<b>Change Occurrences</b>""" 159 """<b>Change Occurrences</b>"""
160 """<p>Change all occurrences in the local scope.</p>""" 160 """<p>Change all occurrences in the local scope.</p>"""
169 169
170 self.refactoringExtractMethodAct = E5Action( 170 self.refactoringExtractMethodAct = E5Action(
171 self.trUtf8('Extract method'), 171 self.trUtf8('Extract method'),
172 self.trUtf8('Extract &Method'), 172 self.trUtf8('Extract &Method'),
173 0, 0, 173 0, 0,
174 self,'refactoring_extract_method') 174 self, 'refactoring_extract_method')
175 self.refactoringExtractMethodAct.setStatusTip(self.trUtf8( 175 self.refactoringExtractMethodAct.setStatusTip(self.trUtf8(
176 'Extract the highlighted area as a method')) 176 'Extract the highlighted area as a method'))
177 self.refactoringExtractMethodAct.setWhatsThis(self.trUtf8( 177 self.refactoringExtractMethodAct.setWhatsThis(self.trUtf8(
178 """<b>Extract method</b>""" 178 """<b>Extract method</b>"""
179 """<p>Extract the highlighted area as a method or function.</p>""" 179 """<p>Extract the highlighted area as a method or function.</p>"""
184 184
185 self.refactoringExtractLocalVariableAct = E5Action( 185 self.refactoringExtractLocalVariableAct = E5Action(
186 self.trUtf8('Extract local variable'), 186 self.trUtf8('Extract local variable'),
187 self.trUtf8('&Extract Local Variable'), 187 self.trUtf8('&Extract Local Variable'),
188 0, 0, 188 0, 0,
189 self,'refactoring_extract_variable') 189 self, 'refactoring_extract_variable')
190 self.refactoringExtractLocalVariableAct.setStatusTip(self.trUtf8( 190 self.refactoringExtractLocalVariableAct.setStatusTip(self.trUtf8(
191 'Extract the highlighted area as a local variable')) 191 'Extract the highlighted area as a local variable'))
192 self.refactoringExtractLocalVariableAct.setWhatsThis(self.trUtf8( 192 self.refactoringExtractLocalVariableAct.setWhatsThis(self.trUtf8(
193 """<b>Extract local variable</b>""" 193 """<b>Extract local variable</b>"""
194 """<p>Extract the highlighted area as a local variable.</p>""" 194 """<p>Extract the highlighted area as a local variable.</p>"""
203 203
204 self.refactoringInlineAct = E5Action( 204 self.refactoringInlineAct = E5Action(
205 self.trUtf8('Inline'), 205 self.trUtf8('Inline'),
206 self.trUtf8('&Inline'), 206 self.trUtf8('&Inline'),
207 0, 0, 207 0, 0,
208 self,'refactoring_inline') 208 self, 'refactoring_inline')
209 self.refactoringInlineAct.setStatusTip(self.trUtf8( 209 self.refactoringInlineAct.setStatusTip(self.trUtf8(
210 'Inlines the selected local variable or method')) 210 'Inlines the selected local variable or method'))
211 self.refactoringInlineAct.setWhatsThis(self.trUtf8( 211 self.refactoringInlineAct.setWhatsThis(self.trUtf8(
212 """<b>Inline</b>""" 212 """<b>Inline</b>"""
213 """<p>Inlines the selected local variable or method.</p>""" 213 """<p>Inlines the selected local variable or method.</p>"""
222 222
223 self.refactoringMoveMethodAct = E5Action( 223 self.refactoringMoveMethodAct = E5Action(
224 self.trUtf8('Move method'), 224 self.trUtf8('Move method'),
225 self.trUtf8('Mo&ve Method'), 225 self.trUtf8('Mo&ve Method'),
226 0, 0, 226 0, 0,
227 self,'refactoring_move_method') 227 self, 'refactoring_move_method')
228 self.refactoringMoveMethodAct.setStatusTip(self.trUtf8( 228 self.refactoringMoveMethodAct.setStatusTip(self.trUtf8(
229 'Move the highlighted method to another class')) 229 'Move the highlighted method to another class'))
230 self.refactoringMoveMethodAct.setWhatsThis(self.trUtf8( 230 self.refactoringMoveMethodAct.setWhatsThis(self.trUtf8(
231 """<b>Move method</b>""" 231 """<b>Move method</b>"""
232 """<p>Move the highlighted method to another class.</p>""" 232 """<p>Move the highlighted method to another class.</p>"""
237 237
238 self.refactoringMoveModuleAct = E5Action( 238 self.refactoringMoveModuleAct = E5Action(
239 self.trUtf8('Move current module'), 239 self.trUtf8('Move current module'),
240 self.trUtf8('Move Current Module'), 240 self.trUtf8('Move Current Module'),
241 0, 0, 241 0, 0,
242 self,'refactoring_move_module') 242 self, 'refactoring_move_module')
243 self.refactoringMoveModuleAct.setStatusTip(self.trUtf8( 243 self.refactoringMoveModuleAct.setStatusTip(self.trUtf8(
244 'Move the current module to another package')) 244 'Move the current module to another package'))
245 self.refactoringMoveModuleAct.setWhatsThis(self.trUtf8( 245 self.refactoringMoveModuleAct.setWhatsThis(self.trUtf8(
246 """<b>Move current module</b>""" 246 """<b>Move current module</b>"""
247 """<p>Move the current module to another package.</p>""" 247 """<p>Move the current module to another package.</p>"""
256 256
257 self.refactoringUseFunctionAct = E5Action( 257 self.refactoringUseFunctionAct = E5Action(
258 self.trUtf8('Use Function'), 258 self.trUtf8('Use Function'),
259 self.trUtf8('Use Function'), 259 self.trUtf8('Use Function'),
260 0, 0, 260 0, 0,
261 self,'refactoring_use_function') 261 self, 'refactoring_use_function')
262 self.refactoringUseFunctionAct.setStatusTip(self.trUtf8( 262 self.refactoringUseFunctionAct.setStatusTip(self.trUtf8(
263 'Use a function wherever possible.')) 263 'Use a function wherever possible.'))
264 self.refactoringUseFunctionAct.setWhatsThis(self.trUtf8( 264 self.refactoringUseFunctionAct.setWhatsThis(self.trUtf8(
265 """<b>Use function</b>""" 265 """<b>Use function</b>"""
266 """<p>Tries to use a function wherever possible.</p>""" 266 """<p>Tries to use a function wherever possible.</p>"""
275 275
276 self.refactoringIntroduceFactoryAct = E5Action( 276 self.refactoringIntroduceFactoryAct = E5Action(
277 self.trUtf8('Introduce Factory Method'), 277 self.trUtf8('Introduce Factory Method'),
278 self.trUtf8('Introduce &Factory Method'), 278 self.trUtf8('Introduce &Factory Method'),
279 0, 0, 279 0, 0,
280 self,'refactoring_introduce_factory_method') 280 self, 'refactoring_introduce_factory_method')
281 self.refactoringIntroduceFactoryAct.setStatusTip(self.trUtf8( 281 self.refactoringIntroduceFactoryAct.setStatusTip(self.trUtf8(
282 'Introduce a factory method or function')) 282 'Introduce a factory method or function'))
283 self.refactoringIntroduceFactoryAct.setWhatsThis(self.trUtf8( 283 self.refactoringIntroduceFactoryAct.setWhatsThis(self.trUtf8(
284 """<b>Introduce Factory Method</b>""" 284 """<b>Introduce Factory Method</b>"""
285 """<p>Introduce a factory method or function.</p>""" 285 """<p>Introduce a factory method or function.</p>"""
290 290
291 self.refactoringIntroduceParameterAct = E5Action( 291 self.refactoringIntroduceParameterAct = E5Action(
292 self.trUtf8('Introduce Parameter'), 292 self.trUtf8('Introduce Parameter'),
293 self.trUtf8('Introduce &Parameter'), 293 self.trUtf8('Introduce &Parameter'),
294 0, 0, 294 0, 0,
295 self,'refactoring_introduce_parameter_method') 295 self, 'refactoring_introduce_parameter_method')
296 self.refactoringIntroduceParameterAct.setStatusTip(self.trUtf8( 296 self.refactoringIntroduceParameterAct.setStatusTip(self.trUtf8(
297 'Introduce a parameter in a function')) 297 'Introduce a parameter in a function'))
298 self.refactoringIntroduceParameterAct.setWhatsThis(self.trUtf8( 298 self.refactoringIntroduceParameterAct.setWhatsThis(self.trUtf8(
299 """<b>Introduce Parameter</b>""" 299 """<b>Introduce Parameter</b>"""
300 """<p>Introduce a parameter in a function.</p>""" 300 """<p>Introduce a parameter in a function.</p>"""
309 309
310 self.refactoringImportsOrganizeAct = E5Action( 310 self.refactoringImportsOrganizeAct = E5Action(
311 self.trUtf8('Organize Imports'), 311 self.trUtf8('Organize Imports'),
312 self.trUtf8('&Organize Imports'), 312 self.trUtf8('&Organize Imports'),
313 0, 0, 313 0, 0,
314 self,'refactoring_organize_imports') 314 self, 'refactoring_organize_imports')
315 self.refactoringImportsOrganizeAct.setStatusTip(self.trUtf8( 315 self.refactoringImportsOrganizeAct.setStatusTip(self.trUtf8(
316 'Sort imports according to PEP-8')) 316 'Sort imports according to PEP-8'))
317 self.refactoringImportsOrganizeAct.setWhatsThis(self.trUtf8( 317 self.refactoringImportsOrganizeAct.setWhatsThis(self.trUtf8(
318 """<b>Organize Imports</b>""" 318 """<b>Organize Imports</b>"""
319 """<p>Sort imports according to PEP-8.</p>""" 319 """<p>Sort imports according to PEP-8.</p>"""
324 324
325 self.refactoringImportsStarExpandAct = E5Action( 325 self.refactoringImportsStarExpandAct = E5Action(
326 self.trUtf8('Expand Star Imports'), 326 self.trUtf8('Expand Star Imports'),
327 self.trUtf8('E&xpand Star Imports'), 327 self.trUtf8('E&xpand Star Imports'),
328 0, 0, 328 0, 0,
329 self,'refactoring_expand_star_imports') 329 self, 'refactoring_expand_star_imports')
330 self.refactoringImportsStarExpandAct.setStatusTip(self.trUtf8( 330 self.refactoringImportsStarExpandAct.setStatusTip(self.trUtf8(
331 'Expand imports like "from xxx import *"')) 331 'Expand imports like "from xxx import *"'))
332 self.refactoringImportsStarExpandAct.setWhatsThis(self.trUtf8( 332 self.refactoringImportsStarExpandAct.setWhatsThis(self.trUtf8(
333 """<b>Expand Star Imports</b>""" 333 """<b>Expand Star Imports</b>"""
334 """<p>Expand imports like "from xxx import *".</p>""" 334 """<p>Expand imports like "from xxx import *".</p>"""
341 341
342 self.refactoringImportsRelativeToAbsoluteAct = E5Action( 342 self.refactoringImportsRelativeToAbsoluteAct = E5Action(
343 self.trUtf8('Relative to Absolute'), 343 self.trUtf8('Relative to Absolute'),
344 self.trUtf8('Relative to &Absolute'), 344 self.trUtf8('Relative to &Absolute'),
345 0, 0, 345 0, 0,
346 self,'refactoring_relative_to_absolute_imports') 346 self, 'refactoring_relative_to_absolute_imports')
347 self.refactoringImportsRelativeToAbsoluteAct.setStatusTip(self.trUtf8( 347 self.refactoringImportsRelativeToAbsoluteAct.setStatusTip(self.trUtf8(
348 'Transform relative imports to absolute ones')) 348 'Transform relative imports to absolute ones'))
349 self.refactoringImportsRelativeToAbsoluteAct.setWhatsThis(self.trUtf8( 349 self.refactoringImportsRelativeToAbsoluteAct.setWhatsThis(self.trUtf8(
350 """<b>Relative to Absolute</b>""" 350 """<b>Relative to Absolute</b>"""
351 """<p>Transform relative imports to absolute ones.</p>""" 351 """<p>Transform relative imports to absolute ones.</p>"""
358 358
359 self.refactoringImportsFromsToImportsAct = E5Action( 359 self.refactoringImportsFromsToImportsAct = E5Action(
360 self.trUtf8('Froms to Imports'), 360 self.trUtf8('Froms to Imports'),
361 self.trUtf8('Froms to &Imports'), 361 self.trUtf8('Froms to &Imports'),
362 0, 0, 362 0, 0,
363 self,'refactoring_froms_to_imports') 363 self, 'refactoring_froms_to_imports')
364 self.refactoringImportsFromsToImportsAct.setStatusTip(self.trUtf8( 364 self.refactoringImportsFromsToImportsAct.setStatusTip(self.trUtf8(
365 'Transform From imports to plain imports')) 365 'Transform From imports to plain imports'))
366 self.refactoringImportsFromsToImportsAct.setWhatsThis(self.trUtf8( 366 self.refactoringImportsFromsToImportsAct.setWhatsThis(self.trUtf8(
367 """<b>Froms to Imports</b>""" 367 """<b>Froms to Imports</b>"""
368 """<p>Transform From imports to plain imports.</p>""" 368 """<p>Transform From imports to plain imports.</p>"""
375 375
376 self.refactoringImportsHandleLongAct = E5Action( 376 self.refactoringImportsHandleLongAct = E5Action(
377 self.trUtf8('Handle Long Imports'), 377 self.trUtf8('Handle Long Imports'),
378 self.trUtf8('Handle &Long Imports'), 378 self.trUtf8('Handle &Long Imports'),
379 0, 0, 379 0, 0,
380 self,'refactoring_organize_imports') 380 self, 'refactoring_organize_imports')
381 self.refactoringImportsHandleLongAct.setStatusTip(self.trUtf8( 381 self.refactoringImportsHandleLongAct.setStatusTip(self.trUtf8(
382 'Transform long import statements to look better')) 382 'Transform long import statements to look better'))
383 self.refactoringImportsHandleLongAct.setWhatsThis(self.trUtf8( 383 self.refactoringImportsHandleLongAct.setWhatsThis(self.trUtf8(
384 """<b>Handle Long Imports</b>""" 384 """<b>Handle Long Imports</b>"""
385 """<p>Transform long import statements to look better.</p>""" 385 """<p>Transform long import statements to look better.</p>"""
396 396
397 self.refactoringRestructureAct = E5Action( 397 self.refactoringRestructureAct = E5Action(
398 self.trUtf8('Restructure'), 398 self.trUtf8('Restructure'),
399 self.trUtf8('Res&tructure'), 399 self.trUtf8('Res&tructure'),
400 0, 0, 400 0, 0,
401 self,'refactoring_restructure') 401 self, 'refactoring_restructure')
402 self.refactoringRestructureAct.setStatusTip(self.trUtf8( 402 self.refactoringRestructureAct.setStatusTip(self.trUtf8(
403 'Restructure code')) 403 'Restructure code'))
404 self.refactoringRestructureAct.setWhatsThis(self.trUtf8( 404 self.refactoringRestructureAct.setWhatsThis(self.trUtf8(
405 """<b>Restructure</b>""" 405 """<b>Restructure</b>"""
406 """<p>Restructure code. See "Rope Help" for examples.</p>""" 406 """<p>Restructure code. See "Rope Help" for examples.</p>"""
411 411
412 self.refactoringChangeSignatureAct = E5Action( 412 self.refactoringChangeSignatureAct = E5Action(
413 self.trUtf8('Change Method Signature'), 413 self.trUtf8('Change Method Signature'),
414 self.trUtf8('&Change Method Signature'), 414 self.trUtf8('&Change Method Signature'),
415 0, 0, 415 0, 0,
416 self,'refactoring_change_method_signature') 416 self, 'refactoring_change_method_signature')
417 self.refactoringChangeSignatureAct.setStatusTip(self.trUtf8( 417 self.refactoringChangeSignatureAct.setStatusTip(self.trUtf8(
418 'Change the signature of the selected method or function')) 418 'Change the signature of the selected method or function'))
419 self.refactoringChangeSignatureAct.setWhatsThis(self.trUtf8( 419 self.refactoringChangeSignatureAct.setWhatsThis(self.trUtf8(
420 """<b>Change Method Signature</b>""" 420 """<b>Change Method Signature</b>"""
421 """<p>Change the signature of the selected method""" 421 """<p>Change the signature of the selected method"""
427 427
428 self.refactoringInlineArgumentDefaultAct = E5Action( 428 self.refactoringInlineArgumentDefaultAct = E5Action(
429 self.trUtf8('Inline Argument Default'), 429 self.trUtf8('Inline Argument Default'),
430 self.trUtf8('Inline &Argument Default'), 430 self.trUtf8('Inline &Argument Default'),
431 0, 0, 431 0, 0,
432 self,'refactoring_inline_argument_default') 432 self, 'refactoring_inline_argument_default')
433 self.refactoringInlineArgumentDefaultAct.setStatusTip(self.trUtf8( 433 self.refactoringInlineArgumentDefaultAct.setStatusTip(self.trUtf8(
434 'Inline a parameters default value')) 434 'Inline a parameters default value'))
435 self.refactoringInlineArgumentDefaultAct.setWhatsThis(self.trUtf8( 435 self.refactoringInlineArgumentDefaultAct.setWhatsThis(self.trUtf8(
436 """<b>Inline Argument Default</b>""" 436 """<b>Inline Argument Default</b>"""
437 """<p>Inline a parameters default value.</p>""" 437 """<p>Inline a parameters default value.</p>"""
442 442
443 self.refactoringTransformModuleAct = E5Action( 443 self.refactoringTransformModuleAct = E5Action(
444 self.trUtf8('Transform Module to Package'), 444 self.trUtf8('Transform Module to Package'),
445 self.trUtf8('Transform Module to Package'), 445 self.trUtf8('Transform Module to Package'),
446 0, 0, 446 0, 0,
447 self,'refactoring_transform_module_to_package') 447 self, 'refactoring_transform_module_to_package')
448 self.refactoringTransformModuleAct.setStatusTip(self.trUtf8( 448 self.refactoringTransformModuleAct.setStatusTip(self.trUtf8(
449 'Transform the current module to a package')) 449 'Transform the current module to a package'))
450 self.refactoringTransformModuleAct.setWhatsThis(self.trUtf8( 450 self.refactoringTransformModuleAct.setWhatsThis(self.trUtf8(
451 """<b>Transform Module to Package</b>""" 451 """<b>Transform Module to Package</b>"""
452 """<p>Transform the current module to a package.</p>""" 452 """<p>Transform the current module to a package.</p>"""
457 457
458 self.refactoringEncapsulateAttributeAct = E5Action( 458 self.refactoringEncapsulateAttributeAct = E5Action(
459 self.trUtf8('Encapsulate Attribute'), 459 self.trUtf8('Encapsulate Attribute'),
460 self.trUtf8('Encap&sulate Attribute'), 460 self.trUtf8('Encap&sulate Attribute'),
461 0, 0, 461 0, 0,
462 self,'refactoring_encapsulate_attribute') 462 self, 'refactoring_encapsulate_attribute')
463 self.refactoringEncapsulateAttributeAct.setStatusTip(self.trUtf8( 463 self.refactoringEncapsulateAttributeAct.setStatusTip(self.trUtf8(
464 'Generate a getter/setter for an attribute')) 464 'Generate a getter/setter for an attribute'))
465 self.refactoringEncapsulateAttributeAct.setWhatsThis(self.trUtf8( 465 self.refactoringEncapsulateAttributeAct.setWhatsThis(self.trUtf8(
466 """<b>Encapsulate Attribute</b>""" 466 """<b>Encapsulate Attribute</b>"""
467 """<p>Generate a getter/setter for an attribute and changes""" 467 """<p>Generate a getter/setter for an attribute and changes"""
473 473
474 self.refactoringLocalVariableToAttributeAct = E5Action( 474 self.refactoringLocalVariableToAttributeAct = E5Action(
475 self.trUtf8('Local Variable to Attribute'), 475 self.trUtf8('Local Variable to Attribute'),
476 self.trUtf8('Local Varia&ble to Attribute'), 476 self.trUtf8('Local Varia&ble to Attribute'),
477 0, 0, 477 0, 0,
478 self,'refactoring_local_variable_to_attribute') 478 self, 'refactoring_local_variable_to_attribute')
479 self.refactoringLocalVariableToAttributeAct.setStatusTip(self.trUtf8( 479 self.refactoringLocalVariableToAttributeAct.setStatusTip(self.trUtf8(
480 'Change a local variable to an attribute')) 480 'Change a local variable to an attribute'))
481 self.refactoringLocalVariableToAttributeAct.setWhatsThis(self.trUtf8( 481 self.refactoringLocalVariableToAttributeAct.setWhatsThis(self.trUtf8(
482 """<b>Local Variable to Attribute</b>""" 482 """<b>Local Variable to Attribute</b>"""
483 """<p>Change a local variable to an attribute.</p>""" 483 """<p>Change a local variable to an attribute.</p>"""
488 488
489 self.refactoringMethodToMethodObjectAct = E5Action( 489 self.refactoringMethodToMethodObjectAct = E5Action(
490 self.trUtf8('Method To Method Object'), 490 self.trUtf8('Method To Method Object'),
491 self.trUtf8('Method To Method Ob&ject'), 491 self.trUtf8('Method To Method Ob&ject'),
492 0, 0, 492 0, 0,
493 self,'refactoring_method_to_methodobject') 493 self, 'refactoring_method_to_methodobject')
494 self.refactoringMethodToMethodObjectAct.setStatusTip(self.trUtf8( 494 self.refactoringMethodToMethodObjectAct.setStatusTip(self.trUtf8(
495 'Transform a function or a method to a method object')) 495 'Transform a function or a method to a method object'))
496 self.refactoringMethodToMethodObjectAct.setWhatsThis(self.trUtf8( 496 self.refactoringMethodToMethodObjectAct.setWhatsThis(self.trUtf8(
497 """<b>Method To Method Object</b>""" 497 """<b>Method To Method Object</b>"""
498 """<p>Transform a function or a method to a method object.</p>""" 498 """<p>Transform a function or a method to a method object.</p>"""
504 ##################################################### 504 #####################################################
505 ## Undo/Redo actions 505 ## Undo/Redo actions
506 ##################################################### 506 #####################################################
507 507
508 self.refactoringUndoAct = E5Action(self.trUtf8('Undo'), 508 self.refactoringUndoAct = E5Action(self.trUtf8('Undo'),
509 self.trUtf8('&Undo'), 509 self.trUtf8('&Undo'),
510 0, 0, 510 0, 0,
511 self,'refactoring_undo') 511 self, 'refactoring_undo')
512 self.refactoringUndoAct.setStatusTip(self.trUtf8( 512 self.refactoringUndoAct.setStatusTip(self.trUtf8(
513 'Undo the last refactoring')) 513 'Undo the last refactoring'))
514 self.refactoringUndoAct.setWhatsThis(self.trUtf8( 514 self.refactoringUndoAct.setWhatsThis(self.trUtf8(
515 """<b>Undo</b>""" 515 """<b>Undo</b>"""
516 """<p>Undo the last refactoring.</p>""" 516 """<p>Undo the last refactoring.</p>"""
518 self.refactoringUndoAct.triggered[()].connect( 518 self.refactoringUndoAct.triggered[()].connect(
519 self.__undo) 519 self.__undo)
520 self.actions.append(self.refactoringUndoAct) 520 self.actions.append(self.refactoringUndoAct)
521 521
522 self.refactoringRedoAct = E5Action(self.trUtf8('Redo'), 522 self.refactoringRedoAct = E5Action(self.trUtf8('Redo'),
523 self.trUtf8('Re&do'), 523 self.trUtf8('Re&do'),
524 0, 0, 524 0, 0,
525 self,'refactoring_redo') 525 self, 'refactoring_redo')
526 self.refactoringRedoAct.setStatusTip(self.trUtf8( 526 self.refactoringRedoAct.setStatusTip(self.trUtf8(
527 'Redo the last refactoring')) 527 'Redo the last refactoring'))
528 self.refactoringRedoAct.setWhatsThis(self.trUtf8( 528 self.refactoringRedoAct.setWhatsThis(self.trUtf8(
529 """<b>Redo</b>""" 529 """<b>Redo</b>"""
530 """<p>Redo the last refactoring.</p>""" 530 """<p>Redo the last refactoring.</p>"""
533 self.__redo) 533 self.__redo)
534 self.actions.append(self.refactoringRedoAct) 534 self.actions.append(self.refactoringRedoAct)
535 535
536 self.refactoringUndoHistoryAct = \ 536 self.refactoringUndoHistoryAct = \
537 E5Action(self.trUtf8('Show Project Undo History'), 537 E5Action(self.trUtf8('Show Project Undo History'),
538 self.trUtf8('Show Project Undo History'), 538 self.trUtf8('Show Project Undo History'),
539 0, 0, 539 0, 0,
540 self,'refactoring_show_project_undo_history') 540 self, 'refactoring_show_project_undo_history')
541 self.refactoringUndoHistoryAct.setStatusTip(self.trUtf8( 541 self.refactoringUndoHistoryAct.setStatusTip(self.trUtf8(
542 'Show the undo history of the project')) 542 'Show the undo history of the project'))
543 self.refactoringUndoHistoryAct.setWhatsThis(self.trUtf8( 543 self.refactoringUndoHistoryAct.setWhatsThis(self.trUtf8(
544 """<b>Show Project Undo History</b>""" 544 """<b>Show Project Undo History</b>"""
545 """<p>Opens a dialog to show the undo history list of""" 545 """<p>Opens a dialog to show the undo history list of"""
549 self.__showProjectUndoHistory) 549 self.__showProjectUndoHistory)
550 self.actions.append(self.refactoringUndoHistoryAct) 550 self.actions.append(self.refactoringUndoHistoryAct)
551 551
552 self.refactoringRedoHistoryAct = \ 552 self.refactoringRedoHistoryAct = \
553 E5Action(self.trUtf8('Show Project Redo History'), 553 E5Action(self.trUtf8('Show Project Redo History'),
554 self.trUtf8('Show Project Redo History'), 554 self.trUtf8('Show Project Redo History'),
555 0, 0, 555 0, 0,
556 self,'refactoring_show_project_redo_history') 556 self, 'refactoring_show_project_redo_history')
557 self.refactoringRedoHistoryAct.setStatusTip(self.trUtf8( 557 self.refactoringRedoHistoryAct.setStatusTip(self.trUtf8(
558 'Show the redo history of the project')) 558 'Show the redo history of the project'))
559 self.refactoringRedoHistoryAct.setWhatsThis(self.trUtf8( 559 self.refactoringRedoHistoryAct.setWhatsThis(self.trUtf8(
560 """<b>Show Project Redo History</b>""" 560 """<b>Show Project Redo History</b>"""
561 """<p>Opens a dialog to show the redo history list of""" 561 """<p>Opens a dialog to show the redo history list of"""
565 self.__showProjectRedoHistory) 565 self.__showProjectRedoHistory)
566 self.actions.append(self.refactoringRedoHistoryAct) 566 self.actions.append(self.refactoringRedoHistoryAct)
567 567
568 self.refactoringUndoFileHistoryAct = \ 568 self.refactoringUndoFileHistoryAct = \
569 E5Action(self.trUtf8('Show Current File Undo History'), 569 E5Action(self.trUtf8('Show Current File Undo History'),
570 self.trUtf8('Show Current File Undo History'), 570 self.trUtf8('Show Current File Undo History'),
571 0, 0, 571 0, 0,
572 self,'refactoring_show_file_undo_history') 572 self, 'refactoring_show_file_undo_history')
573 self.refactoringUndoFileHistoryAct.setStatusTip(self.trUtf8( 573 self.refactoringUndoFileHistoryAct.setStatusTip(self.trUtf8(
574 'Show the undo history of the current file')) 574 'Show the undo history of the current file'))
575 self.refactoringUndoFileHistoryAct.setWhatsThis(self.trUtf8( 575 self.refactoringUndoFileHistoryAct.setWhatsThis(self.trUtf8(
576 """<b>Show Current File Undo History</b>""" 576 """<b>Show Current File Undo History</b>"""
577 """<p>Opens a dialog to show the undo history list of""" 577 """<p>Opens a dialog to show the undo history list of"""
581 self.__showFileUndoHistory) 581 self.__showFileUndoHistory)
582 self.actions.append(self.refactoringUndoFileHistoryAct) 582 self.actions.append(self.refactoringUndoFileHistoryAct)
583 583
584 self.refactoringRedoFileHistoryAct = \ 584 self.refactoringRedoFileHistoryAct = \
585 E5Action(self.trUtf8('Show Current File Redo History'), 585 E5Action(self.trUtf8('Show Current File Redo History'),
586 self.trUtf8('Show Current File Redo History'), 586 self.trUtf8('Show Current File Redo History'),
587 0, 0, 587 0, 0,
588 self,'refactoring_show_file_redo_history') 588 self, 'refactoring_show_file_redo_history')
589 self.refactoringRedoFileHistoryAct.setStatusTip(self.trUtf8( 589 self.refactoringRedoFileHistoryAct.setStatusTip(self.trUtf8(
590 'Show the redo history of the current file')) 590 'Show the redo history of the current file'))
591 self.refactoringRedoFileHistoryAct.setWhatsThis(self.trUtf8( 591 self.refactoringRedoFileHistoryAct.setWhatsThis(self.trUtf8(
592 """<b>Show Current File Redo History</b>""" 592 """<b>Show Current File Redo History</b>"""
593 """<p>Opens a dialog to show the redo history list of""" 593 """<p>Opens a dialog to show the redo history list of"""
597 self.__showFileRedoHistory) 597 self.__showFileRedoHistory)
598 self.actions.append(self.refactoringRedoFileHistoryAct) 598 self.actions.append(self.refactoringRedoFileHistoryAct)
599 599
600 self.refactoringClearHistoryAct = \ 600 self.refactoringClearHistoryAct = \
601 E5Action(self.trUtf8('Clear History'), 601 E5Action(self.trUtf8('Clear History'),
602 self.trUtf8('Clear History'), 602 self.trUtf8('Clear History'),
603 0, 0, 603 0, 0,
604 self,'refactoring_clear_history') 604 self, 'refactoring_clear_history')
605 self.refactoringClearHistoryAct.setStatusTip(self.trUtf8( 605 self.refactoringClearHistoryAct.setStatusTip(self.trUtf8(
606 'Clear the refactoring history')) 606 'Clear the refactoring history'))
607 self.refactoringClearHistoryAct.setWhatsThis(self.trUtf8( 607 self.refactoringClearHistoryAct.setWhatsThis(self.trUtf8(
608 """<b>Clear History</b>""" 608 """<b>Clear History</b>"""
609 """<p>Clears the refactoring history.</p>""" 609 """<p>Clears the refactoring history.</p>"""
617 ##################################################### 617 #####################################################
618 618
619 self.queryReferencesAct = E5Action(self.trUtf8('Find occurrences'), 619 self.queryReferencesAct = E5Action(self.trUtf8('Find occurrences'),
620 self.trUtf8('Find &Occurrences'), 620 self.trUtf8('Find &Occurrences'),
621 0, 0, 621 0, 0,
622 self,'refactoring_find_occurrences') 622 self, 'refactoring_find_occurrences')
623 self.queryReferencesAct.setStatusTip(self.trUtf8( 623 self.queryReferencesAct.setStatusTip(self.trUtf8(
624 'Find occurrences of the highlighted object')) 624 'Find occurrences of the highlighted object'))
625 self.queryReferencesAct.setWhatsThis(self.trUtf8( 625 self.queryReferencesAct.setWhatsThis(self.trUtf8(
626 """<b>Find occurrences</b>""" 626 """<b>Find occurrences</b>"""
627 """<p>Find occurrences of the highlighted class, method,""" 627 """<p>Find occurrences of the highlighted class, method,"""
632 self.actions.append(self.queryReferencesAct) 632 self.actions.append(self.queryReferencesAct)
633 633
634 self.queryDefinitionAct = E5Action(self.trUtf8('Find definition'), 634 self.queryDefinitionAct = E5Action(self.trUtf8('Find definition'),
635 self.trUtf8('Find &Definition'), 635 self.trUtf8('Find &Definition'),
636 0, 0, 636 0, 0,
637 self,'refactoring_find_definition') 637 self, 'refactoring_find_definition')
638 self.queryDefinitionAct.setStatusTip(self.trUtf8( 638 self.queryDefinitionAct.setStatusTip(self.trUtf8(
639 'Find definition of the highlighted item')) 639 'Find definition of the highlighted item'))
640 self.queryDefinitionAct.setWhatsThis(self.trUtf8( 640 self.queryDefinitionAct.setWhatsThis(self.trUtf8(
641 """<b>Find definition</b>""" 641 """<b>Find definition</b>"""
642 """<p>Find the definition of the highlighted class, method,""" 642 """<p>Find the definition of the highlighted class, method,"""
648 648
649 self.queryImplementationsAct = E5Action( 649 self.queryImplementationsAct = E5Action(
650 self.trUtf8('Find implementations'), 650 self.trUtf8('Find implementations'),
651 self.trUtf8('Find &Implementations'), 651 self.trUtf8('Find &Implementations'),
652 0, 0, 652 0, 0,
653 self,'refactoring_find_implementations') 653 self, 'refactoring_find_implementations')
654 self.queryImplementationsAct.setStatusTip(self.trUtf8( 654 self.queryImplementationsAct.setStatusTip(self.trUtf8(
655 'Find places where the selected method is overridden')) 655 'Find places where the selected method is overridden'))
656 self.queryImplementationsAct.setWhatsThis(self.trUtf8( 656 self.queryImplementationsAct.setWhatsThis(self.trUtf8(
657 """<b>Find implementations</b>""" 657 """<b>Find implementations</b>"""
658 """<p>Find places where the selected method is overridden.</p>""" 658 """<p>Find places where the selected method is overridden.</p>"""
666 ##################################################### 666 #####################################################
667 667
668 self.refactoringEditConfigAct = E5Action(self.trUtf8('Configure Rope'), 668 self.refactoringEditConfigAct = E5Action(self.trUtf8('Configure Rope'),
669 self.trUtf8('&Configure Rope'), 669 self.trUtf8('&Configure Rope'),
670 0, 0, 670 0, 0,
671 self,'refactoring_edit_config') 671 self, 'refactoring_edit_config')
672 self.refactoringEditConfigAct.setStatusTip(self.trUtf8( 672 self.refactoringEditConfigAct.setStatusTip(self.trUtf8(
673 'Open the rope configuration file')) 673 'Open the rope configuration file'))
674 self.refactoringEditConfigAct.setWhatsThis(self.trUtf8( 674 self.refactoringEditConfigAct.setWhatsThis(self.trUtf8(
675 """<b>Configure Rope</b>""" 675 """<b>Configure Rope</b>"""
676 """<p>Opens the rope configuration file in an editor.</p>""" 676 """<p>Opens the rope configuration file in an editor.</p>"""
680 self.actions.append(self.refactoringEditConfigAct) 680 self.actions.append(self.refactoringEditConfigAct)
681 681
682 self.refactoringHelpAct = E5Action(self.trUtf8('Rope help'), 682 self.refactoringHelpAct = E5Action(self.trUtf8('Rope help'),
683 self.trUtf8('Rope &Help'), 683 self.trUtf8('Rope &Help'),
684 0, 0, 684 0, 0,
685 self,'refactoring_help') 685 self, 'refactoring_help')
686 self.refactoringHelpAct.setStatusTip(self.trUtf8( 686 self.refactoringHelpAct.setStatusTip(self.trUtf8(
687 'Show help about the rope refactorings')) 687 'Show help about the rope refactorings'))
688 self.refactoringHelpAct.setWhatsThis(self.trUtf8( 688 self.refactoringHelpAct.setWhatsThis(self.trUtf8(
689 """<b>Rope help</b>""" 689 """<b>Rope help</b>"""
690 """<p>Show some help text about the rope refactorings.</p>""" 690 """<p>Show some help text about the rope refactorings.</p>"""
695 695
696 self.refactoringAllSoaAct = E5Action( 696 self.refactoringAllSoaAct = E5Action(
697 self.trUtf8('Analyse all modules'), 697 self.trUtf8('Analyse all modules'),
698 self.trUtf8('&Analyse all modules'), 698 self.trUtf8('&Analyse all modules'),
699 0, 0, 699 0, 0,
700 self,'refactoring_analyze_all') 700 self, 'refactoring_analyze_all')
701 self.refactoringAllSoaAct.setStatusTip(self.trUtf8( 701 self.refactoringAllSoaAct.setStatusTip(self.trUtf8(
702 'Perform static object analysis on all modules')) 702 'Perform static object analysis on all modules'))
703 self.refactoringAllSoaAct.setWhatsThis(self.trUtf8( 703 self.refactoringAllSoaAct.setWhatsThis(self.trUtf8(
704 """<b>Analyse all modules</b>""" 704 """<b>Analyse all modules</b>"""
705 """<p>Perform static object analysis (SOA) on all modules. """ 705 """<p>Perform static object analysis (SOA) on all modules. """
713 713
714 self.updateConfigAct = E5Action( 714 self.updateConfigAct = E5Action(
715 self.trUtf8('Update Configuration'), 715 self.trUtf8('Update Configuration'),
716 self.trUtf8('&Update Configuration'), 716 self.trUtf8('&Update Configuration'),
717 0, 0, 717 0, 0,
718 self,'refactoring_update_configuration') 718 self, 'refactoring_update_configuration')
719 self.updateConfigAct.setStatusTip(self.trUtf8( 719 self.updateConfigAct.setStatusTip(self.trUtf8(
720 'Generates a new configuration file overwriting the current one.')) 720 'Generates a new configuration file overwriting the current one.'))
721 self.updateConfigAct.setWhatsThis(self.trUtf8( 721 self.updateConfigAct.setWhatsThis(self.trUtf8(
722 """<b>Update Configuration</b>""" 722 """<b>Update Configuration</b>"""
723 """<p>Generates a new configuration file overwriting""" 723 """<p>Generates a new configuration file overwriting"""
793 smenu.addAction(self.refactoringUndoAct) 793 smenu.addAction(self.refactoringUndoAct)
794 smenu.addAction(self.refactoringRedoAct) 794 smenu.addAction(self.refactoringRedoAct)
795 smenu.addSeparator() 795 smenu.addSeparator()
796 796
797 hmenu = smenu.addMenu(self.trUtf8("History")) 797 hmenu = smenu.addMenu(self.trUtf8("History"))
798 self.connect(hmenu, SIGNAL("aboutToShow()"), 798 self.connect(hmenu, SIGNAL("aboutToShow()"),
799 self.__showRefactoringHistoryMenu) 799 self.__showRefactoringHistoryMenu)
800 hmenu.addAction(self.refactoringUndoHistoryAct) 800 hmenu.addAction(self.refactoringUndoHistoryAct)
801 hmenu.addAction(self.refactoringUndoFileHistoryAct) 801 hmenu.addAction(self.refactoringUndoFileHistoryAct)
802 hmenu.addSeparator() 802 hmenu.addSeparator()
803 hmenu.addAction(self.refactoringRedoHistoryAct) 803 hmenu.addAction(self.refactoringRedoHistoryAct)
932 if handle is not None: 932 if handle is not None:
933 handle.reset() 933 handle.reset()
934 if str(type(err)).split()[-1][1:-2].split('.')[-1] == \ 934 if str(type(err)).split()[-1][1:-2].split('.')[-1] == \
935 'ModuleSyntaxError': 935 'ModuleSyntaxError':
936 res = QMessageBox.warning(self.__ui, title, 936 res = QMessageBox.warning(self.__ui, title,
937 self.trUtf8("Rope error: {0}").format(str(err)), 937 self.trUtf8("Rope error: {0}").format(str(err)),
938 QMessageBox.Ok | QMessageBox.Open) 938 QMessageBox.Ok | QMessageBox.Open)
939 if res == QMessageBox.Open: 939 if res == QMessageBox.Open:
940 e5App().getObject("ViewManager").openSourceFile( 940 e5App().getObject("ViewManager").openSourceFile(
941 os.path.join(self.__e4project.getProjectPath(), 941 os.path.join(self.__e4project.getProjectPath(),
942 err.filename), 942 err.filename),
943 err.lineno) 943 err.lineno)
944 else: 944 else:
945 QMessageBox.warning(self.__ui, title, 945 QMessageBox.warning(self.__ui, title,
946 self.trUtf8("Rope error: {0}").format(str(err))) 946 self.trUtf8("Rope error: {0}").format(str(err)))
947 947
967 967
968 def __renameModule(self): 968 def __renameModule(self):
969 """ 969 """
970 Private slot to handle the Rename Current Module action. 970 Private slot to handle the Rename Current Module action.
971 """ 971 """
972 self.__doRename(self.trUtf8('Rename Current Module'), 972 self.__doRename(self.trUtf8('Rename Current Module'),
973 renameModule=True) 973 renameModule=True)
974 974
975 def __doRename(self, title, isLocal=False, renameModule=False): 975 def __doRename(self, title, isLocal=False, renameModule=False):
976 """ 976 """
977 Private method to perform the various renaming refactorings. 977 Private method to perform the various renaming refactorings.
978 978
979 @param title title of the refactoring (string) 979 @param title title of the refactoring (string)
980 @param isLocal flag indicating to restrict refactoring to 980 @param isLocal flag indicating to restrict refactoring to
981 the local file (boolean) 981 the local file (boolean)
982 @param renameModule flag indicating a module rename refactoring 982 @param renameModule flag indicating a module rename refactoring
983 (boolean) 983 (boolean)
984 """ 984 """
985 aw = e5App().getObject("ViewManager").activeWindow() 985 aw = e5App().getObject("ViewManager").activeWindow()
990 if not renameModule and not aw.hasSelectedText(): 990 if not renameModule and not aw.hasSelectedText():
991 # no selection available 991 # no selection available
992 QMessageBox.warning(self.__ui, title, 992 QMessageBox.warning(self.__ui, title,
993 self.trUtf8("Highlight the declaration you want to rename" 993 self.trUtf8("Highlight the declaration you want to rename"
994 " and try again.")) 994 " and try again."))
995 return 995 return
996 996
997 if isLocal: 997 if isLocal:
998 if not self.confirmBufferIsSaved(aw): 998 if not self.confirmBufferIsSaved(aw):
999 return 999 return
1000 else: 1000 else:
1009 if line != line1: 1009 if line != line1:
1010 # selection span more than one line 1010 # selection span more than one line
1011 QMessageBox.warning(self.__ui, title, 1011 QMessageBox.warning(self.__ui, title,
1012 self.trUtf8("The selection must not extend beyond" 1012 self.trUtf8("The selection must not extend beyond"
1013 " one line.")) 1013 " one line."))
1014 return 1014 return
1015 index = int(index + (index1 - index) / 2) 1015 index = int(index + (index1 - index) / 2)
1016 # keep it inside the object 1016 # keep it inside the object
1017 offset = aw.positionFromLineIndex(line, index) 1017 offset = aw.positionFromLineIndex(line, index)
1018 1018
1019 resource = rope.base.libutils.path_to_resource( 1019 resource = rope.base.libutils.path_to_resource(
1020 self.__project, filename) 1020 self.__project, filename)
1021 try: 1021 try:
1022 renamer = rope.refactor.rename.Rename( 1022 renamer = rope.refactor.rename.Rename(
1023 self.__project, resource, offset) 1023 self.__project, resource, offset)
1024 except Exception as err: 1024 except Exception as err:
1025 self.handleRopeError(err, title) 1025 self.handleRopeError(err, title)
1026 return 1026 return
1027 1027
1028 if isLocal: 1028 if isLocal:
1029 localResource = resource 1029 localResource = resource
1030 else: 1030 else:
1031 localResource = None 1031 localResource = None
1046 if not aw.hasSelectedText(): 1046 if not aw.hasSelectedText():
1047 # no selection available 1047 # no selection available
1048 QMessageBox.warning(self.__ui, title, 1048 QMessageBox.warning(self.__ui, title,
1049 self.trUtf8("Highlight an occurrence to be changed" 1049 self.trUtf8("Highlight an occurrence to be changed"
1050 " and try again.")) 1050 " and try again."))
1051 return 1051 return
1052 1052
1053 if not self.confirmBufferIsSaved(aw): 1053 if not self.confirmBufferIsSaved(aw):
1054 return 1054 return
1055 1055
1056 filename = aw.getFileName() 1056 filename = aw.getFileName()
1062 try: 1062 try:
1063 renamer = rope.refactor.rename.ChangeOccurrences( 1063 renamer = rope.refactor.rename.ChangeOccurrences(
1064 self.__project, resource, offset) 1064 self.__project, resource, offset)
1065 except Exception as err: 1065 except Exception as err:
1066 self.handleRopeError(err, title) 1066 self.handleRopeError(err, title)
1067 return 1067 return
1068 1068
1069 self.dlg = ChangeOccurrencesDialog(self, title, renamer, 1069 self.dlg = ChangeOccurrencesDialog(self, title, renamer,
1070 parent=self.__ui) 1070 parent=self.__ui)
1071 self.dlg.show() 1071 self.dlg.show()
1072 1072
1073 ##################################################### 1073 #####################################################
1074 ## Extract refactorings 1074 ## Extract refactorings
1102 if not aw.hasSelectedText(): 1102 if not aw.hasSelectedText():
1103 # no selection available 1103 # no selection available
1104 QMessageBox.warning(self.__ui, title, 1104 QMessageBox.warning(self.__ui, title,
1105 self.trUtf8("Highlight the region of code you want to extract" 1105 self.trUtf8("Highlight the region of code you want to extract"
1106 " and try again.")) 1106 " and try again."))
1107 return 1107 return
1108 1108
1109 if not self.confirmBufferIsSaved(aw): 1109 if not self.confirmBufferIsSaved(aw):
1110 return 1110 return
1111 1111
1112 filename = aw.getFileName() 1112 filename = aw.getFileName()
1125 self.__project, resource, startOffset, endOffset) 1125 self.__project, resource, startOffset, endOffset)
1126 else: 1126 else:
1127 raise Exception("Invalid extraction kind <{0}>.".format(kind)) 1127 raise Exception("Invalid extraction kind <{0}>.".format(kind))
1128 except Exception as err: 1128 except Exception as err:
1129 self.handleRopeError(err, title) 1129 self.handleRopeError(err, title)
1130 return 1130 return
1131 1131
1132 self.dlg = ExtractDialog(self, title, extractor, parent = self.__ui) 1132 self.dlg = ExtractDialog(self, title, extractor, parent=self.__ui)
1133 self.dlg.show() 1133 self.dlg.show()
1134 1134
1135 ##################################################### 1135 #####################################################
1136 ## Inline refactorings 1136 ## Inline refactorings
1137 ##################################################### 1137 #####################################################
1149 if not aw.hasSelectedText(): 1149 if not aw.hasSelectedText():
1150 # no selection available 1150 # no selection available
1151 QMessageBox.warning(self.__ui, title, 1151 QMessageBox.warning(self.__ui, title,
1152 self.trUtf8("Highlight the local variable, method or parameter" 1152 self.trUtf8("Highlight the local variable, method or parameter"
1153 " you want to inline and try again.")) 1153 " you want to inline and try again."))
1154 return 1154 return
1155 1155
1156 if not self.confirmAllBuffersSaved(): 1156 if not self.confirmAllBuffersSaved():
1157 return 1157 return
1158 1158
1159 filename = aw.getFileName() 1159 filename = aw.getFileName()
1165 try: 1165 try:
1166 inliner = rope.refactor.inline.create_inline( 1166 inliner = rope.refactor.inline.create_inline(
1167 self.__project, resource, offset) 1167 self.__project, resource, offset)
1168 except Exception as err: 1168 except Exception as err:
1169 self.handleRopeError(err, title) 1169 self.handleRopeError(err, title)
1170 return 1170 return
1171 1171
1172 self.dlg = InlineDialog(self, title, inliner, parent = self.__ui) 1172 self.dlg = InlineDialog(self, title, inliner, parent=self.__ui)
1173 self.dlg.show() 1173 self.dlg.show()
1174 1174
1175 ##################################################### 1175 #####################################################
1176 ## Move refactorings 1176 ## Move refactorings
1177 ##################################################### 1177 #####################################################
1189 if not aw.hasSelectedText(): 1189 if not aw.hasSelectedText():
1190 # no selection available 1190 # no selection available
1191 QMessageBox.warning(self.__ui, title, 1191 QMessageBox.warning(self.__ui, title,
1192 self.trUtf8("Highlight the method to move" 1192 self.trUtf8("Highlight the method to move"
1193 " and try again.")) 1193 " and try again."))
1194 return 1194 return
1195 1195
1196 if not self.confirmAllBuffersSaved(): 1196 if not self.confirmAllBuffersSaved():
1197 return 1197 return
1198 1198
1199 filename = aw.getFileName() 1199 filename = aw.getFileName()
1205 try: 1205 try:
1206 mover = rope.refactor.move.create_move( 1206 mover = rope.refactor.move.create_move(
1207 self.__project, resource, offset) 1207 self.__project, resource, offset)
1208 except Exception as err: 1208 except Exception as err:
1209 self.handleRopeError(err, title) 1209 self.handleRopeError(err, title)
1210 return 1210 return
1211 1211
1212 self.dlg = MoveMethodDialog(self, title, mover, parent=self.__ui) 1212 self.dlg = MoveMethodDialog(self, title, mover, parent=self.__ui)
1213 self.dlg.show() 1213 self.dlg.show()
1214 1214
1215 def __moveModule(self): 1215 def __moveModule(self):
1234 try: 1234 try:
1235 mover = rope.refactor.move.create_move( 1235 mover = rope.refactor.move.create_move(
1236 self.__project, resource, offset) 1236 self.__project, resource, offset)
1237 except Exception as err: 1237 except Exception as err:
1238 self.handleRopeError(err, title) 1238 self.handleRopeError(err, title)
1239 return 1239 return
1240 1240
1241 self.dlg = MoveModuleDialog(self, title, mover, parent=self.__ui) 1241 self.dlg = MoveModuleDialog(self, title, mover, parent=self.__ui)
1242 self.dlg.show() 1242 self.dlg.show()
1243 1243
1244 ##################################################### 1244 #####################################################
1257 title = self.trUtf8("Use Function") 1257 title = self.trUtf8("Use Function")
1258 if not aw.hasSelectedText(): 1258 if not aw.hasSelectedText():
1259 # no selection available 1259 # no selection available
1260 QMessageBox.warning(self.__ui, title, 1260 QMessageBox.warning(self.__ui, title,
1261 self.trUtf8("Highlight a global function and try again.")) 1261 self.trUtf8("Highlight a global function and try again."))
1262 return 1262 return
1263 1263
1264 if not self.confirmAllBuffersSaved(): 1264 if not self.confirmAllBuffersSaved():
1265 return 1265 return
1266 1266
1267 filename = aw.getFileName() 1267 filename = aw.getFileName()
1275 self.__project, resource, offset) 1275 self.__project, resource, offset)
1276 except Exception as err: 1276 except Exception as err:
1277 self.handleRopeError(err, title) 1277 self.handleRopeError(err, title)
1278 return 1278 return
1279 1279
1280 self.dlg = UseFunctionDialog(self, title, user, parent = self.__ui) 1280 self.dlg = UseFunctionDialog(self, title, user, parent=self.__ui)
1281 self.dlg.show() 1281 self.dlg.show()
1282 1282
1283 ##################################################### 1283 #####################################################
1284 ## Introduce refactorings 1284 ## Introduce refactorings
1285 ##################################################### 1285 #####################################################
1297 if not aw.hasSelectedText(): 1297 if not aw.hasSelectedText():
1298 # no selection available 1298 # no selection available
1299 QMessageBox.warning(self.__ui, title, 1299 QMessageBox.warning(self.__ui, title,
1300 self.trUtf8("Highlight the class to introduce a factory" 1300 self.trUtf8("Highlight the class to introduce a factory"
1301 " method for and try again.")) 1301 " method for and try again."))
1302 return 1302 return
1303 1303
1304 if not self.confirmAllBuffersSaved(): 1304 if not self.confirmAllBuffersSaved():
1305 return 1305 return
1306 1306
1307 filename = aw.getFileName() 1307 filename = aw.getFileName()
1314 introducer = \ 1314 introducer = \
1315 rope.refactor.introduce_factory.IntroduceFactoryRefactoring( 1315 rope.refactor.introduce_factory.IntroduceFactoryRefactoring(
1316 self.__project, resource, offset) 1316 self.__project, resource, offset)
1317 except Exception as err: 1317 except Exception as err:
1318 self.handleRopeError(err, title) 1318 self.handleRopeError(err, title)
1319 return 1319 return
1320 1320
1321 self.dlg = IntroduceFactoryDialog(self, title, introducer, 1321 self.dlg = IntroduceFactoryDialog(self, title, introducer,
1322 parent=self.__ui) 1322 parent=self.__ui)
1323 self.dlg.show() 1323 self.dlg.show()
1324 1324
1325 def __introduceParameter(self): 1325 def __introduceParameter(self):
1326 """ 1326 """
1335 if not aw.hasSelectedText(): 1335 if not aw.hasSelectedText():
1336 # no selection available 1336 # no selection available
1337 QMessageBox.warning(self.__ui, title, 1337 QMessageBox.warning(self.__ui, title,
1338 self.trUtf8("Highlight the code for the new parameter" 1338 self.trUtf8("Highlight the code for the new parameter"
1339 " and try again.")) 1339 " and try again."))
1340 return 1340 return
1341 1341
1342 if not self.confirmAllBuffersSaved(): 1342 if not self.confirmAllBuffersSaved():
1343 return 1343 return
1344 1344
1345 filename = aw.getFileName() 1345 filename = aw.getFileName()
1351 try: 1351 try:
1352 introducer = rope.refactor.introduce_parameter.IntroduceParameter( 1352 introducer = rope.refactor.introduce_parameter.IntroduceParameter(
1353 self.__project, resource, offset) 1353 self.__project, resource, offset)
1354 except Exception as err: 1354 except Exception as err:
1355 self.handleRopeError(err, title) 1355 self.handleRopeError(err, title)
1356 return 1356 return
1357 1357
1358 self.dlg = IntroduceParameterDialog(self, title, introducer, 1358 self.dlg = IntroduceParameterDialog(self, title, introducer,
1359 parent=self.__ui) 1359 parent=self.__ui)
1360 self.dlg.show() 1360 self.dlg.show()
1361 1361
1362 ##################################################### 1362 #####################################################
1363 ## Import refactorings 1363 ## Import refactorings
1365 1365
1366 def __importsOrganize(self): 1366 def __importsOrganize(self):
1367 """ 1367 """
1368 Private slot to organize imports. 1368 Private slot to organize imports.
1369 """ 1369 """
1370 self.__doImports(self.trUtf8("Organize Imports"), 1370 self.__doImports(self.trUtf8("Organize Imports"),
1371 ImportOrganizer.organize_imports) 1371 ImportOrganizer.organize_imports)
1372 1372
1373 def __importsExpandStar(self): 1373 def __importsExpandStar(self):
1374 """ 1374 """
1375 Private slot to expand star imports. 1375 Private slot to expand star imports.
1376 """ 1376 """
1377 self.__doImports(self.trUtf8("Expand Star Imports"), 1377 self.__doImports(self.trUtf8("Expand Star Imports"),
1378 ImportOrganizer.expand_star_imports) 1378 ImportOrganizer.expand_star_imports)
1379 1379
1380 def __importsRelativeToAbsolute(self): 1380 def __importsRelativeToAbsolute(self):
1381 """ 1381 """
1382 Private slot to transform relative to absolute imports. 1382 Private slot to transform relative to absolute imports.
1383 """ 1383 """
1384 self.__doImports(self.trUtf8("Relative to Absolute"), 1384 self.__doImports(self.trUtf8("Relative to Absolute"),
1385 ImportOrganizer.relatives_to_absolutes) 1385 ImportOrganizer.relatives_to_absolutes)
1386 1386
1387 def __importsFromToImport(self): 1387 def __importsFromToImport(self):
1388 """ 1388 """
1389 Private slot to transform from imports to plain imports. 1389 Private slot to transform from imports to plain imports.
1390 """ 1390 """
1391 self.__doImports(self.trUtf8("Froms to Imports"), 1391 self.__doImports(self.trUtf8("Froms to Imports"),
1392 ImportOrganizer.froms_to_imports) 1392 ImportOrganizer.froms_to_imports)
1393 1393
1394 def __importsHandleLong(self): 1394 def __importsHandleLong(self):
1395 """ 1395 """
1396 Private slot to handle long imports. 1396 Private slot to handle long imports.
1397 """ 1397 """
1398 self.__doImports(self.trUtf8("Handle Long Imports"), 1398 self.__doImports(self.trUtf8("Handle Long Imports"),
1399 ImportOrganizer.handle_long_imports) 1399 ImportOrganizer.handle_long_imports)
1400 1400
1401 def __doImports(self, title, method): 1401 def __doImports(self, title, method):
1402 """ 1402 """
1403 Private method to perform the various imports refactorings. 1403 Private method to perform the various imports refactorings.
1461 if not aw.hasSelectedText(): 1461 if not aw.hasSelectedText():
1462 # no selection available 1462 # no selection available
1463 QMessageBox.warning(self.__ui, title, 1463 QMessageBox.warning(self.__ui, title,
1464 self.trUtf8("Highlight the method or function to change" 1464 self.trUtf8("Highlight the method or function to change"
1465 " and try again.")) 1465 " and try again."))
1466 return 1466 return
1467 1467
1468 if not self.confirmAllBuffersSaved(): 1468 if not self.confirmAllBuffersSaved():
1469 return 1469 return
1470 1470
1471 filename = aw.getFileName() 1471 filename = aw.getFileName()
1477 try: 1477 try:
1478 changer = rope.refactor.change_signature.ChangeSignature( 1478 changer = rope.refactor.change_signature.ChangeSignature(
1479 self.__project, resource, offset) 1479 self.__project, resource, offset)
1480 except Exception as err: 1480 except Exception as err:
1481 self.handleRopeError(err, title) 1481 self.handleRopeError(err, title)
1482 return 1482 return
1483 1483
1484 self.dlg = ChangeSignatureDialog(self, title, changer, 1484 self.dlg = ChangeSignatureDialog(self, title, changer,
1485 parent=self.__ui) 1485 parent=self.__ui)
1486 self.dlg.show() 1486 self.dlg.show()
1487 1487
1488 def __inlineArgumentDefault(self): 1488 def __inlineArgumentDefault(self):
1489 """ 1489 """
1499 if not aw.hasSelectedText(): 1499 if not aw.hasSelectedText():
1500 # no selection available 1500 # no selection available
1501 QMessageBox.warning(self.__ui, title, 1501 QMessageBox.warning(self.__ui, title,
1502 self.trUtf8("Highlight the method or function to inline" 1502 self.trUtf8("Highlight the method or function to inline"
1503 " a parameter's default and try again.")) 1503 " a parameter's default and try again."))
1504 return 1504 return
1505 1505
1506 if not self.confirmAllBuffersSaved(): 1506 if not self.confirmAllBuffersSaved():
1507 return 1507 return
1508 1508
1509 filename = aw.getFileName() 1509 filename = aw.getFileName()
1515 try: 1515 try:
1516 changer = rope.refactor.change_signature.ChangeSignature( 1516 changer = rope.refactor.change_signature.ChangeSignature(
1517 self.__project, resource, offset) 1517 self.__project, resource, offset)
1518 except Exception as err: 1518 except Exception as err:
1519 self.handleRopeError(err, title) 1519 self.handleRopeError(err, title)
1520 return 1520 return
1521 1521
1522 self.dlg = InlineArgumentDefaultDialog(self, title, changer, 1522 self.dlg = InlineArgumentDefaultDialog(self, title, changer,
1523 parent=self.__ui) 1523 parent=self.__ui)
1524 self.dlg.show() 1524 self.dlg.show()
1525 1525
1526 def __transformModuleToPackage(self): 1526 def __transformModuleToPackage(self):
1527 """ 1527 """
1547 self.__project.do(changes) 1547 self.__project.do(changes)
1548 if self.__e5project.isDirty(): 1548 if self.__e5project.isDirty():
1549 self.__e5project.saveProject() 1549 self.__e5project.saveProject()
1550 except Exception as err: 1550 except Exception as err:
1551 self.handleRopeError(err, title) 1551 self.handleRopeError(err, title)
1552 return 1552 return
1553 1553
1554 def __encapsulateAttribute(self): 1554 def __encapsulateAttribute(self):
1555 """ 1555 """
1556 Private slot to encapsulate an attribute. 1556 Private slot to encapsulate an attribute.
1557 """ 1557 """
1564 if not aw.hasSelectedText(): 1564 if not aw.hasSelectedText():
1565 # no selection available 1565 # no selection available
1566 QMessageBox.warning(self.__ui, title, 1566 QMessageBox.warning(self.__ui, title,
1567 self.trUtf8("Highlight the attribute to encapsulate" 1567 self.trUtf8("Highlight the attribute to encapsulate"
1568 " and try again.")) 1568 " and try again."))
1569 return 1569 return
1570 1570
1571 if not self.confirmAllBuffersSaved(): 1571 if not self.confirmAllBuffersSaved():
1572 return 1572 return
1573 1573
1574 filename = aw.getFileName() 1574 filename = aw.getFileName()
1618 if not aw.hasSelectedText(): 1618 if not aw.hasSelectedText():
1619 # no selection available 1619 # no selection available
1620 QMessageBox.warning(self.__ui, title, 1620 QMessageBox.warning(self.__ui, title,
1621 self.trUtf8("Highlight the local variable to make an attribute" 1621 self.trUtf8("Highlight the local variable to make an attribute"
1622 " and try again.")) 1622 " and try again."))
1623 return 1623 return
1624 1624
1625 if not self.confirmAllBuffersSaved(): 1625 if not self.confirmAllBuffersSaved():
1626 return 1626 return
1627 1627
1628 filename = aw.getFileName() 1628 filename = aw.getFileName()
1656 if not aw.hasSelectedText(): 1656 if not aw.hasSelectedText():
1657 # no selection available 1657 # no selection available
1658 QMessageBox.warning(self.__ui, title, 1658 QMessageBox.warning(self.__ui, title,
1659 self.trUtf8("Highlight the method or function to convert" 1659 self.trUtf8("Highlight the method or function to convert"
1660 " and try again.")) 1660 " and try again."))
1661 return 1661 return
1662 1662
1663 if not self.confirmAllBuffersSaved(): 1663 if not self.confirmAllBuffersSaved():
1664 return 1664 return
1665 1665
1666 filename = aw.getFileName() 1666 filename = aw.getFileName()
1672 try: 1672 try:
1673 converter = rope.refactor.method_object.MethodObject( 1673 converter = rope.refactor.method_object.MethodObject(
1674 self.__project, resource, offset) 1674 self.__project, resource, offset)
1675 except Exception as err: 1675 except Exception as err:
1676 self.handleRopeError(err, title) 1676 self.handleRopeError(err, title)
1677 return 1677 return
1678 1678
1679 self.dlg = MethodToMethodObjectDialog(self, title, converter, 1679 self.dlg = MethodToMethodObjectDialog(self, title, converter,
1680 parent=self.__ui) 1680 parent=self.__ui)
1681 self.dlg.show() 1681 self.dlg.show()
1682 1682
1764 self.dlg = HistoryDialog(self, redoList, False, self.__ui) 1764 self.dlg = HistoryDialog(self, redoList, False, self.__ui)
1765 self.dlg.show() 1765 self.dlg.show()
1766 1766
1767 def __showFileUndoHistory(self): 1767 def __showFileUndoHistory(self):
1768 """ 1768 """
1769 Private method to show list of changes related to the current file 1769 Private method to show list of changes related to the current file
1770 available for an undo operation. 1770 available for an undo operation.
1771 """ 1771 """
1772 aw = e5App().getObject("ViewManager").activeWindow() 1772 aw = e5App().getObject("ViewManager").activeWindow()
1773 1773
1774 if aw is None: 1774 if aw is None:
1781 self.dlg = HistoryDialog(self, undoList, True, self.__ui) 1781 self.dlg = HistoryDialog(self, undoList, True, self.__ui)
1782 self.dlg.show() 1782 self.dlg.show()
1783 1783
1784 def __showFileRedoHistory(self): 1784 def __showFileRedoHistory(self):
1785 """ 1785 """
1786 Private method to show list of changes related to the current file 1786 Private method to show list of changes related to the current file
1787 available for a redo operation. 1787 available for a redo operation.
1788 """ 1788 """
1789 aw = e5App().getObject("ViewManager").activeWindow() 1789 aw = e5App().getObject("ViewManager").activeWindow()
1790 1790
1791 if aw is None: 1791 if aw is None:
1830 if not aw.hasSelectedText(): 1830 if not aw.hasSelectedText():
1831 # no selection available 1831 # no selection available
1832 QMessageBox.warning(self.__ui, title, 1832 QMessageBox.warning(self.__ui, title,
1833 self.trUtf8("Highlight the class, method, function or variable" 1833 self.trUtf8("Highlight the class, method, function or variable"
1834 " to search for and try again.")) 1834 " to search for and try again."))
1835 return 1835 return
1836 1836
1837 if not self.confirmAllBuffersSaved(): 1837 if not self.confirmAllBuffersSaved():
1838 return 1838 return
1839 1839
1840 filename = aw.getFileName() 1840 filename = aw.getFileName()
1847 handle.show() 1847 handle.show()
1848 QApplication.processEvents() 1848 QApplication.processEvents()
1849 try: 1849 try:
1850 occurrences = rope.contrib.findit.find_occurrences( 1850 occurrences = rope.contrib.findit.find_occurrences(
1851 self.__project, resource, offset, 1851 self.__project, resource, offset,
1852 unsure = True, in_hierarchy = True, task_handle = handle) 1852 unsure=True, in_hierarchy=True, task_handle=handle)
1853 except Exception as err: 1853 except Exception as err:
1854 self.handleRopeError(err, title, handle) 1854 self.handleRopeError(err, title, handle)
1855 return 1855 return
1856 handle.reset() 1856 handle.reset()
1857 1857
1858 if occurrences: 1858 if occurrences:
1859 self.dlg = MatchesDialog(self.__ui, True) 1859 self.dlg = MatchesDialog(self.__ui, True)
1860 self.dlg.show() 1860 self.dlg.show()
1861 for occurrence in occurrences: 1861 for occurrence in occurrences:
1862 self.dlg.addEntry(occurrence.resource, 1862 self.dlg.addEntry(occurrence.resource,
1863 occurrence.lineno, occurrence.unsure) 1863 occurrence.lineno, occurrence.unsure)
1864 else: 1864 else:
1865 QMessageBox.warning(self.__ui, title, 1865 QMessageBox.warning(self.__ui, title,
1866 self.trUtf8("No occurrences found.")) 1866 self.trUtf8("No occurrences found."))
1867 1867
1879 # no selection available 1879 # no selection available
1880 QMessageBox.warning(self.__ui, title, 1880 QMessageBox.warning(self.__ui, title,
1881 self.trUtf8("Highlight the class, method, function or" 1881 self.trUtf8("Highlight the class, method, function or"
1882 " variable reference to search definition for and" 1882 " variable reference to search definition for and"
1883 " try again.")) 1883 " try again."))
1884 return 1884 return
1885 1885
1886 if not self.confirmAllBuffersSaved(): 1886 if not self.confirmAllBuffersSaved():
1887 return 1887 return
1888 1888
1889 filename = aw.getFileName() 1889 filename = aw.getFileName()
1920 if not aw.hasSelectedText(): 1920 if not aw.hasSelectedText():
1921 # no selection available 1921 # no selection available
1922 QMessageBox.warning(self.__ui, title, 1922 QMessageBox.warning(self.__ui, title,
1923 self.trUtf8("Highlight the method to search for" 1923 self.trUtf8("Highlight the method to search for"
1924 " and try again.")) 1924 " and try again."))
1925 return 1925 return
1926 1926
1927 if not self.confirmAllBuffersSaved(): 1927 if not self.confirmAllBuffersSaved():
1928 return 1928 return
1929 1929
1930 filename = aw.getFileName() 1930 filename = aw.getFileName()
1931 line, index, line1, index1 = aw.getSelection() 1931 line, index, line1, index1 = aw.getSelection()
1932 offset = aw.positionFromLineIndex(line, index) 1932 offset = aw.positionFromLineIndex(line, index)
1933 1933
1934 resource = rope.base.libutils.path_to_resource(self.__project, 1934 resource = rope.base.libutils.path_to_resource(self.__project,
1935 filename) 1935 filename)
1936 handle = ProgressHandle(title, True, self.__ui) 1936 handle = ProgressHandle(title, True, self.__ui)
1937 handle.show() 1937 handle.show()
1938 QApplication.processEvents() 1938 QApplication.processEvents()
1939 try: 1939 try:
1940 occurrences = rope.contrib.findit.find_implementations( 1940 occurrences = rope.contrib.findit.find_implementations(
1941 self.__project, resource, offset, task_handle = handle) 1941 self.__project, resource, offset, task_handle=handle)
1942 except Exception as err: 1942 except Exception as err:
1943 self.handleRopeError(err, title, handle) 1943 self.handleRopeError(err, title, handle)
1944 return 1944 return
1945 handle.reset() 1945 handle.reset()
1946 1946
1947 if occurrences: 1947 if occurrences:
1948 self.dlg = MatchesDialog(self.__ui, True) 1948 self.dlg = MatchesDialog(self.__ui, True)
1949 self.dlg.show() 1949 self.dlg.show()
1950 for occurrence in occurrences: 1950 for occurrence in occurrences:
1951 self.dlg.addEntry(occurrence.resource, 1951 self.dlg.addEntry(occurrence.resource,
1952 occurrence.lineno, occurrence.unsure) 1952 occurrence.lineno, occurrence.unsure)
1953 else: 1953 else:
1954 QMessageBox.warning(self.__ui, title, 1954 QMessageBox.warning(self.__ui, title,
1955 self.trUtf8("No occurrences found.")) 1955 self.trUtf8("No occurrences found."))
1956 1956
1970 self.__editor = MiniEditor(configfile) 1970 self.__editor = MiniEditor(configfile)
1971 self.__editor.show() 1971 self.__editor.show()
1972 if self.__newStyle: 1972 if self.__newStyle:
1973 self.__editor.editorSaved.connect(self.__configChanged) 1973 self.__editor.editorSaved.connect(self.__configChanged)
1974 else: 1974 else:
1975 self.connect(self.__editor, SIGNAL("editorSaved"), 1975 self.connect(self.__editor, SIGNAL("editorSaved"),
1976 self.__configChanged) 1976 self.__configChanged)
1977 else: 1977 else:
1978 QMessageBox.critical(self.__ui, 1978 QMessageBox.critical(self.__ui,
1979 self.trUtf8("Configure Rope"), 1979 self.trUtf8("Configure Rope"),
1980 self.trUtf8("""The Rope configuration file '{0}' does""" 1980 self.trUtf8("""The Rope configuration file '{0}' does"""
2016 def __showRopeHelp(self): 2016 def __showRopeHelp(self):
2017 """ 2017 """
2018 Private slot to show help about the refactorings offered by Rope. 2018 Private slot to show help about the refactorings offered by Rope.
2019 """ 2019 """
2020 if self.__helpDialog is None: 2020 if self.__helpDialog is None:
2021 helpfile = os.path.join(os.path.dirname(__file__), 2021 helpfile = os.path.join(os.path.dirname(__file__),
2022 "rope", "docs", "overview.txt") 2022 "rope", "docs", "overview.txt")
2023 self.__helpDialog = \ 2023 self.__helpDialog = \
2024 HelpDialog(self.trUtf8("Help about rope refactorings"), 2024 HelpDialog(self.trUtf8("Help about rope refactorings"),
2025 helpfile) 2025 helpfile)
2026 self.__helpDialog.show() 2026 self.__helpDialog.show()
2027 2027
2028 def __performSOA(self): 2028 def __performSOA(self):
2029 """ 2029 """
2041 if res == QMessageBox.Yes: 2041 if res == QMessageBox.Yes:
2042 handle = ProgressHandle(title, True, self.__ui) 2042 handle = ProgressHandle(title, True, self.__ui)
2043 handle.show() 2043 handle.show()
2044 QApplication.processEvents() 2044 QApplication.processEvents()
2045 try: 2045 try:
2046 rope.base.libutils.analyze_modules(self.__project, 2046 rope.base.libutils.analyze_modules(self.__project,
2047 task_handle=handle) 2047 task_handle=handle)
2048 handle.reset() 2048 handle.reset()
2049 QMessageBox.information(self.__ui, 2049 QMessageBox.information(self.__ui,
2050 title, 2050 title,
2051 self.trUtf8("""Static object analysis (SOA) done. """ 2051 self.trUtf8("""Static object analysis (SOA) done. """
2075 def __configChanged(self): 2075 def __configChanged(self):
2076 """ 2076 """
2077 Private slot called, when the rope config file has changed. 2077 Private slot called, when the rope config file has changed.
2078 """ 2078 """
2079 self.__project.close() 2079 self.__project.close()
2080 self.__project = rope.base.project.Project(self.__projectpath, 2080 self.__project = rope.base.project.Project(self.__projectpath,
2081 fscommands = self.__fsCommands) 2081 fscommands=self.__fsCommands)
2082 2082
2083 def __defaultConfig(self): 2083 def __defaultConfig(self):
2084 """ 2084 """
2085 Private slot to return the contents of rope's default configuration. 2085 Private slot to return the contents of rope's default configuration.
2086 2086
2114 self.__projectopen = True 2114 self.__projectopen = True
2115 self.__projectpath = self.__e5project.getProjectPath() 2115 self.__projectpath = self.__e5project.getProjectPath()
2116 self.__projectLanguage = self.__e5project.getProjectLanguage() 2116 self.__projectLanguage = self.__e5project.getProjectLanguage()
2117 2117
2118 if self.__projectLanguage in ["Python3"]: 2118 if self.__projectLanguage in ["Python3"]:
2119 self.__project = rope.base.project.Project(self.__projectpath, 2119 self.__project = rope.base.project.Project(self.__projectpath,
2120 fscommands = self.__fsCommands) 2120 fscommands=self.__fsCommands)
2121 for act in self.actions: 2121 for act in self.actions:
2122 act.setEnabled(True) 2122 act.setEnabled(True)
2123 2123
2124 def projectClosed(self): 2124 def projectClosed(self):
2125 """ 2125 """
2147 def confirmBufferIsSaved(self, editor): 2147 def confirmBufferIsSaved(self, editor):
2148 """ 2148 """
2149 Public method to check, if an editor has unsaved changes. 2149 Public method to check, if an editor has unsaved changes.
2150 2150
2151 @param editor reference to the editor to be checked 2151 @param editor reference to the editor to be checked
2152 @return flag indicating, that the editor doesn't contain 2152 @return flag indicating, that the editor doesn't contain
2153 unsaved edits (boolean) 2153 unsaved edits (boolean)
2154 """ 2154 """
2155 res = editor.checkDirty() 2155 res = editor.checkDirty()
2156 self.__project.validate(self.__project.root) 2156 self.__project.validate(self.__project.root)
2157 return res 2157 return res
2158 2158
2159 def confirmAllBuffersSaved(self): 2159 def confirmAllBuffersSaved(self):
2160 """ 2160 """
2161 Private method to check, if any editor has unsaved changes. 2161 Private method to check, if any editor has unsaved changes.
2162 2162
2163 @return flag indicating, that no editor contains unsaved edits 2163 @return flag indicating, that no editor contains unsaved edits
2164 (boolean) 2164 (boolean)
2165 """ 2165 """
2166 res = e5App().getObject("ViewManager").checkAllDirty() 2166 res = e5App().getObject("ViewManager").checkAllDirty()
2167 self.__project.validate(self.__project.root) 2167 self.__project.validate(self.__project.root)
2168 return res 2168 return res
2191 aw = vm.activeWindow() 2191 aw = vm.activeWindow()
2192 if aw is not None: 2192 if aw is not None:
2193 filename = aw.getFileName() 2193 filename = aw.getFileName()
2194 if filename is not None: 2194 if filename is not None:
2195 vm.openSourceFile(filename, aw.getCursorPosition()[0] + 1) 2195 vm.openSourceFile(filename, aw.getCursorPosition()[0] + 1)
2196

eric ide

mercurial