PluginRefactoringRope.py

changeset 125
e775b4f9d07c
parent 122
3696915ebc80
child 127
9b9bd5b7f100
diff -r 0cd494bdf312 -r e775b4f9d07c PluginRefactoringRope.py
--- a/PluginRefactoringRope.py	Wed Apr 08 12:59:39 2015 +0200
+++ b/PluginRefactoringRope.py	Sun May 31 18:11:14 2015 +0200
@@ -26,7 +26,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "4.0.7"
+version = "4.1.0"
 className = "RefactoringRopePlugin"
 packageName = "RefactoringRope"
 internalPackages = "rope"
@@ -396,8 +396,15 @@
         lang = self.__determineLanguage()
         
         if language in lang:
-            if editor.autoCompletionHook() != self.codeAssist:
-                self.__connectEditor(editor)
+            try:
+                if editor.getCompletionListHook("rope") is None or \
+                        editor.getCallTipHook("rope") is None:
+                    self.__connectEditor(editor)
+            except AttributeError:
+                # old interface (before 6.1.0)
+                if editor.autoCompletionHook() != self.codeAssist or \
+                        editor.callTipHook() != self.codeAssistCallTip:
+                    self.__connectEditor(editor)
         else:
             self.__disconnectEditor(editor)
     
@@ -428,10 +435,20 @@
             # just ignore it
             pass
         
-        if editor.autoCompletionHook() == self.codeAssist:
-            self.__unsetAutoCompletionHook(editor)
-        if editor.callTipHook() == self.codeAssistCallTip:
-            self.__unsetCalltipsHook(editor)
+        try:
+            if editor.getCompletionListHook("rope"):
+                self.__unsetAutoCompletionHook(editor)
+        except AttributeError:
+            # old interface (before 6.1.0)
+            if editor.autoCompletionHook() == self.codeAssist:
+                self.__unsetAutoCompletionHook(editor)
+        try:
+            if editor.getCallTipHook("rope"):
+                self.__unsetCalltipsHook(editor)
+        except AttributeError:
+            # old interface (before 6.1.0)
+            if editor.callTipHook() == self.codeAssistCallTip:
+                self.__unsetCalltipsHook(editor)
     
     def __completionListSelected(self, id, txt):
         """
@@ -470,8 +487,12 @@
         
         @param editor reference to the editor (QScintilla.Editor)
         """
-        editor.userListActivated.connect(self.__completionListSelected)
-        editor.setAutoCompletionHook(self.codeAssist)
+        try:
+            editor.addCompletionListHook("rope", self.getCompletionsList)
+        except AttributeError:
+            # old interface (before 6.1.0)
+            editor.userListActivated.connect(self.__completionListSelected)
+            editor.setAutoCompletionHook(self.codeAssist)
     
     def __unsetAutoCompletionHook(self, editor):
         """
@@ -479,8 +500,12 @@
         
         @param editor reference to the editor (QScintilla.Editor)
         """
-        editor.unsetAutoCompletionHook()
-        editor.userListActivated.disconnect(self.__completionListSelected)
+        try:
+            editor.removeCompletionListHook("rope")
+        except AttributeError:
+            # old interface (before 6.1.0)
+            editor.unsetAutoCompletionHook()
+            editor.userListActivated.disconnect(self.__completionListSelected)
     
     def codeAssist(self, editor, context=False):
         """
@@ -565,7 +590,11 @@
         
         @param editor reference to the editor (QScintilla.Editor)
         """
-        editor.setCallTipHook(self.codeAssistCallTip)
+        try:
+            editor.addCallTipHook("rope", self.codeAssistCallTip)
+        except AttributeError:
+            # old interface (before 6.1.0)
+            editor.setCallTipHook(self.codeAssistCallTip)
     
     def __unsetCalltipsHook(self, editor):
         """
@@ -573,7 +602,11 @@
         
         @param editor reference to the editor (QScintilla.Editor)
         """
-        editor.unsetCallTipHook()
+        try:
+            editor.removeCallTipHook("rope")
+        except AttributeError:
+            # old interface (before 6.1.0)
+            editor.unsetCallTipHook()
     
     def codeAssistCallTip(self, editor, pos, commas):
         """

eric ide

mercurial