24 # Start-Of-Header |
24 # Start-Of-Header |
25 name = "Refactoring Rope Plugin" |
25 name = "Refactoring Rope Plugin" |
26 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
26 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
27 autoactivate = True |
27 autoactivate = True |
28 deactivateable = True |
28 deactivateable = True |
29 version = "4.0.7" |
29 version = "4.1.0" |
30 className = "RefactoringRopePlugin" |
30 className = "RefactoringRopePlugin" |
31 packageName = "RefactoringRope" |
31 packageName = "RefactoringRope" |
32 internalPackages = "rope" |
32 internalPackages = "rope" |
33 shortDescription = "Refactoring using the Rope library." |
33 shortDescription = "Refactoring using the Rope library." |
34 longDescription = """This plug-in implements refactoring functionality""" \ |
34 longDescription = """This plug-in implements refactoring functionality""" \ |
394 """ |
394 """ |
395 editor = self.sender() |
395 editor = self.sender() |
396 lang = self.__determineLanguage() |
396 lang = self.__determineLanguage() |
397 |
397 |
398 if language in lang: |
398 if language in lang: |
399 if editor.autoCompletionHook() != self.codeAssist: |
399 try: |
400 self.__connectEditor(editor) |
400 if editor.getCompletionListHook("rope") is None or \ |
|
401 editor.getCallTipHook("rope") is None: |
|
402 self.__connectEditor(editor) |
|
403 except AttributeError: |
|
404 # old interface (before 6.1.0) |
|
405 if editor.autoCompletionHook() != self.codeAssist or \ |
|
406 editor.callTipHook() != self.codeAssistCallTip: |
|
407 self.__connectEditor(editor) |
401 else: |
408 else: |
402 self.__disconnectEditor(editor) |
409 self.__disconnectEditor(editor) |
403 |
410 |
404 def __connectEditor(self, editor): |
411 def __connectEditor(self, editor): |
405 """ |
412 """ |
426 editor.editorSaved.disconnect(self.__editorSaved) |
433 editor.editorSaved.disconnect(self.__editorSaved) |
427 except TypeError: |
434 except TypeError: |
428 # just ignore it |
435 # just ignore it |
429 pass |
436 pass |
430 |
437 |
431 if editor.autoCompletionHook() == self.codeAssist: |
438 try: |
432 self.__unsetAutoCompletionHook(editor) |
439 if editor.getCompletionListHook("rope"): |
433 if editor.callTipHook() == self.codeAssistCallTip: |
440 self.__unsetAutoCompletionHook(editor) |
434 self.__unsetCalltipsHook(editor) |
441 except AttributeError: |
|
442 # old interface (before 6.1.0) |
|
443 if editor.autoCompletionHook() == self.codeAssist: |
|
444 self.__unsetAutoCompletionHook(editor) |
|
445 try: |
|
446 if editor.getCallTipHook("rope"): |
|
447 self.__unsetCalltipsHook(editor) |
|
448 except AttributeError: |
|
449 # old interface (before 6.1.0) |
|
450 if editor.callTipHook() == self.codeAssistCallTip: |
|
451 self.__unsetCalltipsHook(editor) |
435 |
452 |
436 def __completionListSelected(self, id, txt): |
453 def __completionListSelected(self, id, txt): |
437 """ |
454 """ |
438 Private slot to handle the selection from the completion list. |
455 Private slot to handle the selection from the completion list. |
439 |
456 |
468 """ |
485 """ |
469 Private method to set the autocompletion hook. |
486 Private method to set the autocompletion hook. |
470 |
487 |
471 @param editor reference to the editor (QScintilla.Editor) |
488 @param editor reference to the editor (QScintilla.Editor) |
472 """ |
489 """ |
473 editor.userListActivated.connect(self.__completionListSelected) |
490 try: |
474 editor.setAutoCompletionHook(self.codeAssist) |
491 editor.addCompletionListHook("rope", self.getCompletionsList) |
|
492 except AttributeError: |
|
493 # old interface (before 6.1.0) |
|
494 editor.userListActivated.connect(self.__completionListSelected) |
|
495 editor.setAutoCompletionHook(self.codeAssist) |
475 |
496 |
476 def __unsetAutoCompletionHook(self, editor): |
497 def __unsetAutoCompletionHook(self, editor): |
477 """ |
498 """ |
478 Private method to unset the autocompletion hook. |
499 Private method to unset the autocompletion hook. |
479 |
500 |
480 @param editor reference to the editor (QScintilla.Editor) |
501 @param editor reference to the editor (QScintilla.Editor) |
481 """ |
502 """ |
482 editor.unsetAutoCompletionHook() |
503 try: |
483 editor.userListActivated.disconnect(self.__completionListSelected) |
504 editor.removeCompletionListHook("rope") |
|
505 except AttributeError: |
|
506 # old interface (before 6.1.0) |
|
507 editor.unsetAutoCompletionHook() |
|
508 editor.userListActivated.disconnect(self.__completionListSelected) |
484 |
509 |
485 def codeAssist(self, editor, context=False): |
510 def codeAssist(self, editor, context=False): |
486 """ |
511 """ |
487 Public method to determine the autocompletion proposals. |
512 Public method to determine the autocompletion proposals. |
488 |
513 |
563 """ |
588 """ |
564 Private method to set the calltip hook. |
589 Private method to set the calltip hook. |
565 |
590 |
566 @param editor reference to the editor (QScintilla.Editor) |
591 @param editor reference to the editor (QScintilla.Editor) |
567 """ |
592 """ |
568 editor.setCallTipHook(self.codeAssistCallTip) |
593 try: |
|
594 editor.addCallTipHook("rope", self.codeAssistCallTip) |
|
595 except AttributeError: |
|
596 # old interface (before 6.1.0) |
|
597 editor.setCallTipHook(self.codeAssistCallTip) |
569 |
598 |
570 def __unsetCalltipsHook(self, editor): |
599 def __unsetCalltipsHook(self, editor): |
571 """ |
600 """ |
572 Private method to unset the calltip hook. |
601 Private method to unset the calltip hook. |
573 |
602 |
574 @param editor reference to the editor (QScintilla.Editor) |
603 @param editor reference to the editor (QScintilla.Editor) |
575 """ |
604 """ |
576 editor.unsetCallTipHook() |
605 try: |
|
606 editor.removeCallTipHook("rope") |
|
607 except AttributeError: |
|
608 # old interface (before 6.1.0) |
|
609 editor.unsetCallTipHook() |
577 |
610 |
578 def codeAssistCallTip(self, editor, pos, commas): |
611 def codeAssistCallTip(self, editor, pos, commas): |
579 """ |
612 """ |
580 Public method to return a list of calltips. |
613 Public method to return a list of calltips. |
581 |
614 |