AssistantEric/Assistant.py

changeset 116
a109c6b8ac77
parent 107
728fde5bfdb1
child 118
67d952a9036e
diff -r 5dd8c9180803 -r a109c6b8ac77 AssistantEric/Assistant.py
--- a/AssistantEric/Assistant.py	Fri Feb 27 18:26:06 2015 +0100
+++ b/AssistantEric/Assistant.py	Sun Mar 22 17:25:15 2015 +0100
@@ -240,10 +240,25 @@
         
         if editor.isListActive():
             editor.cancelList()
+            
+        completionsList = self.getCompletionsList(editor, context)
+        if len(completionsList) > 0:
+            completionsList.sort()
+            editor.showUserList(EditorAutoCompletionListID,
+                                completionsList)
         
+    def getCompletionsList(self, editor, context):
+        """
+        Public method to get a list of possible completions.
+        
+        @param editor reference to the editor object, that called this method
+            (QScintilla.Editor)
+        @param context flag indicating to autocomplete a context (boolean)
+        @return list of possible completions (list of strings)
+        """
         language = editor.getLanguage()
         if language == "":
-            return
+            return []
         
         line, col = editor.getCursorPosition()
         self.__completingContext = context
@@ -353,10 +368,9 @@
                 completionsList = self.__getCompletions(
                     word, context, "", language, mod, editor, importCompletion,
                     sep)
-            if len(completionsList) > 0:
-                completionsList.sort()
-                editor.showUserList(EditorAutoCompletionListID,
-                                    completionsList)
+            return completionsList
+        
+        return []
 
     def __getCompletions(self, word, context, prefix, language, module, editor,
                          importCompletion, sep):
@@ -758,11 +772,11 @@
             documentCalltips = self.__getDocumentCalltips(
                 word, prefix, mod, editor)
         
-        return sorted(
+        return list(sorted(
             set(apiCalltips)
             .union(set(projectCalltips))
             .union(set(documentCalltips))
-        )
+        ))
     
     def __getApiCalltips(self, api, word, commas, prefix, module, editor):
         """

eric ide

mercurial