Fixed a bug and made the method to get a list of completions publicly available. release-3.0.4

Sun, 22 Mar 2015 17:25:15 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 22 Mar 2015 17:25:15 +0100
changeset 116
a109c6b8ac77
parent 115
5dd8c9180803
child 117
6b72af1608e8

Fixed a bug and made the method to get a list of completions publicly available.

AssistantEric/APIsManager.py file | annotate | diff | comparison | revisions
AssistantEric/Assistant.py file | annotate | diff | comparison | revisions
AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html file | annotate | diff | comparison | revisions
ChangeLog file | annotate | diff | comparison | revisions
PluginAssistantEric.py file | annotate | diff | comparison | revisions
PluginAssistantEric.zip file | annotate | diff | comparison | revisions
--- a/AssistantEric/APIsManager.py	Fri Feb 27 18:26:06 2015 +0100
+++ b/AssistantEric/APIsManager.py	Sun Mar 22 17:25:15 2015 +0100
@@ -874,7 +874,9 @@
                         if self.__enoughCommas(sig, commas):
                             if showContext:
                                 calltips.append("{0}{1}{2}{3}".format(
-                                    fullCtx, contextSeparator, word, sig))
+                                    fullCtx,
+                                    contextSeparator if fullCtx else "",
+                                    word, sig))
                             else:
                                 calltips.append("{0}{1}".format(word, sig))
                 del query
--- 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):
         """
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html	Fri Feb 27 18:26:06 2015 +0100
+++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html	Sun Mar 22 17:25:15 2015 +0100
@@ -118,6 +118,9 @@
 <td><a href="#Assistant.deactivate">deactivate</a></td>
 <td>Public method to perform actions upon deactivation.</td>
 </tr><tr>
+<td><a href="#Assistant.getCompletionsList">getCompletionsList</a></td>
+<td>Public method to get a list of possible completions.</td>
+</tr><tr>
 <td><a href="#Assistant.setEnabled">setEnabled</a></td>
 <td>Public method to enable or disable a feature.</td>
 </tr>
@@ -446,7 +449,26 @@
 <b>deactivate</b>(<i></i>)
 <p>
         Public method to perform actions upon deactivation.
-</p><a NAME="Assistant.setEnabled" ID="Assistant.setEnabled"></a>
+</p><a NAME="Assistant.getCompletionsList" ID="Assistant.getCompletionsList"></a>
+<h4>Assistant.getCompletionsList</h4>
+<b>getCompletionsList</b>(<i>editor, context</i>)
+<p>
+        Public method to get a list of possible completions.
+</p><dl>
+<dt><i>editor</i></dt>
+<dd>
+reference to the editor object, that called this method
+            (QScintilla.Editor)
+</dd><dt><i>context</i></dt>
+<dd>
+flag indicating to autocomplete a context (boolean)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+list of possible completions (list of strings)
+</dd>
+</dl><a NAME="Assistant.setEnabled" ID="Assistant.setEnabled"></a>
 <h4>Assistant.setEnabled</h4>
 <b>setEnabled</b>(<i>key, enabled</i>)
 <p>
--- a/ChangeLog	Fri Feb 27 18:26:06 2015 +0100
+++ b/ChangeLog	Sun Mar 22 17:25:15 2015 +0100
@@ -1,5 +1,9 @@
 ChangeLog
 ---------
+Version 3.0.4:
+- made the method to get a list of completions publicly available
+- bug fixes
+
 Version 3.0.3:
 - replaced the icon for the configuration page
 
--- a/PluginAssistantEric.py	Fri Feb 27 18:26:06 2015 +0100
+++ b/PluginAssistantEric.py	Sun Mar 22 17:25:15 2015 +0100
@@ -24,7 +24,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "3.0.3"
+version = "3.0.4"
 className = "AssistantEricPlugin"
 packageName = "AssistantEric"
 shortDescription = "Alternative autocompletion and calltips provider."
Binary file PluginAssistantEric.zip has changed

eric ide

mercurial