Small enhancement to the autocompletions change in order to show context for document derived completions.

Sun, 25 Sep 2011 17:40:17 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 25 Sep 2011 17:40:17 +0200
changeset 35
6b706b02c2dd
parent 34
f35565337953
child 36
d4d279e10fa8

Small enhancement to the autocompletions change in order to show context for document derived completions.

AssistantEric/Assistant.py file | annotate | diff | comparison | revisions
AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html file | annotate | diff | comparison | revisions
PluginAssistantEric.zip file | annotate | diff | comparison | revisions
--- a/AssistantEric/Assistant.py	Sun Sep 25 17:22:03 2011 +0200
+++ b/AssistantEric/Assistant.py	Sun Sep 25 17:40:17 2011 +0200
@@ -327,7 +327,7 @@
                     api, word, context, prefix, mod, editor)
             
             if self.__plugin.getPreferences("AutoCompletionSource") & AcsDocument:
-                docCompletionsList = self.getCompletionsFromDocument(
+                docCompletionsList = self.__getDocumentCompletions(
                     editor, word, context, sep, prefix, mod)
             
             completionsList = list(
@@ -427,9 +427,9 @@
                         completionsList.append(entry)
         return completionsList
     
-    def getCompletionsFromDocument(self, editor, word, context, sep, prefix, module):
+    def __getDocumentCompletions(self, editor, word, context, sep, prefix, module):
         """
-        Public method to determine autocompletion proposals from the document.
+        Private method to determine autocompletion proposals from the document.
         
         @param editor reference to the editor object (QScintilla.Editor)
         @param word string to be completed (string)
@@ -464,10 +464,10 @@
                                 if (prefix == "cls" and \
                                     method.modifier == method.Class) or \
                                    prefix == "self":
-                                    comps.append((method.name, iconID))
+                                    comps.append((method.name, cl.name, iconID))
                             else:
                                 # eric 5.1 cannot differentiate method types
-                                comps.append((method.name, iconID))
+                                comps.append((method.name, cl.name, iconID))
                         if prefix != "cls":
                             for attribute in cl.attributes.values():
                                 # determine icon type
@@ -477,7 +477,7 @@
                                     iconID = Editor.AttributeProtectedID
                                 else:
                                     iconID = Editor.AttributePrivateID
-                                comps.append((attribute.name, iconID))
+                                comps.append((attribute.name, cl.name, iconID))
                         for attribute in cl.globals.values():
                             # determine icon type
                             if attribute.isPrivate():
@@ -486,15 +486,15 @@
                                 iconID = Editor.AttributeProtectedID
                             else:
                                 iconID = Editor.AttributePrivateID
-                            comps.append((attribute.name, iconID))
+                            comps.append((attribute.name, cl.name, iconID))
                         
                         if word != prefix:
                             completionsList.extend(
-                                ["{0}?{1}".format(c[0], c[1])
+                                ["{0} ({1})?{2}".format(c[0], c[1], c[2])
                                  for c in comps if c[0].startswith(word)])
                         else:
                             completionsList.extend(
-                                ["{0}?{1}".format(c[0], c[1])
+                                ["{0} ({1})?{2}".format(c[0], c[1], c[2])
                                  for c in comps])
                         break
             else:
@@ -517,7 +517,7 @@
                                 iconID = Editor.MethodProtectedID
                             else:
                                 iconID = Editor.MethodID
-                            comps.append((method.name, iconID))
+                            comps.append((method.name, cl.name, iconID))
                     for attribute in cl.globals.values():
                         # determine icon type
                         if attribute.isPrivate():
@@ -526,15 +526,15 @@
                             iconID = Editor.AttributeProtectedID
                         else:
                             iconID = Editor.AttributePrivateID
-                        comps.append((attribute.name, iconID))
+                        comps.append((attribute.name, cl.name, iconID))
                     
                     if word != prefix:
                         completionsList.extend(
-                            ["{0}?{1}".format(c[0], c[1])
+                            ["{0} ({1})?{2}".format(c[0], c[1], c[2])
                              for c in comps if c[0].startswith(word)])
                     else:
                         completionsList.extend(
-                            ["{0}?{1}".format(c[0], c[1])
+                            ["{0} ({1})?{2}".format(c[0], c[1], c[2])
                              for c in comps])
         
         if not prefixFound:
@@ -649,7 +649,7 @@
                 api, word, commas, prefix, mod, editor)
         
         if self.__plugin.getPreferences("AutoCompletionSource") & AcsDocument:
-            documentCalltips = self.__getCalltipsFromDocument(
+            documentCalltips = self.__getDocumentCalltips(
                 word, prefix, mod, editor)
         
         return sorted(
@@ -687,7 +687,7 @@
         
         return calltips
     
-    def __getCalltipsFromDocument(self, word, prefix, module, editor):
+    def __getDocumentCalltips(self, word, prefix, module, editor):
         """
         Private method to determine calltips from the document.
         
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html	Sun Sep 25 17:22:03 2011 +0200
+++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html	Sun Sep 25 17:40:17 2011 +0200
@@ -77,11 +77,14 @@
 <td><a href="#Assistant.__getApiCompletions">__getApiCompletions</a></td>
 <td>Private method to determine a list of completions from an API object.</td>
 </tr><tr>
-<td><a href="#Assistant.__getCalltipsFromDocument">__getCalltipsFromDocument</a></td>
+<td><a href="#Assistant.__getCharacter">__getCharacter</a></td>
+<td>Private method to get the character to the left of the current position in the current line.</td>
+</tr><tr>
+<td><a href="#Assistant.__getDocumentCalltips">__getDocumentCalltips</a></td>
 <td>Private method to determine calltips from the document.</td>
 </tr><tr>
-<td><a href="#Assistant.__getCharacter">__getCharacter</a></td>
-<td>Private method to get the character to the left of the current position in the current line.</td>
+<td><a href="#Assistant.__getDocumentCompletions">__getDocumentCompletions</a></td>
+<td>Private method to determine autocompletion proposals from the document.</td>
 </tr><tr>
 <td><a href="#Assistant.__preferencesChanged">__preferencesChanged</a></td>
 <td>Private method to handle a change of the global configuration.</td>
@@ -113,9 +116,6 @@
 <td><a href="#Assistant.deactivate">deactivate</a></td>
 <td>Public method to perform actions upon deactivation.</td>
 </tr><tr>
-<td><a href="#Assistant.getCompletionsFromDocument">getCompletionsFromDocument</a></td>
-<td>Public method to determine autocompletion proposals from the document.</td>
-</tr><tr>
 <td><a href="#Assistant.setEnabled">setEnabled</a></td>
 <td>Public method to enable or disable a feature.</td>
 </tr>
@@ -230,9 +230,29 @@
 <dd>
 list of possible completions (list of strings)
 </dd>
-</dl><a NAME="Assistant.__getCalltipsFromDocument" ID="Assistant.__getCalltipsFromDocument"></a>
-<h4>Assistant.__getCalltipsFromDocument</h4>
-<b>__getCalltipsFromDocument</b>(<i>word, prefix, module, editor</i>)
+</dl><a NAME="Assistant.__getCharacter" ID="Assistant.__getCharacter"></a>
+<h4>Assistant.__getCharacter</h4>
+<b>__getCharacter</b>(<i>pos, editor</i>)
+<p>
+        Private method to get the character to the left of the current position
+        in the current line.
+</p><dl>
+<dt><i>pos</i></dt>
+<dd>
+position to get character at (integer)
+</dd><dt><i>editor</i></dt>
+<dd>
+reference to the editor object to work with (QScintilla.Editor)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+requested character or "", if there are no more (string) and
+            the next position (i.e. pos - 1)
+</dd>
+</dl><a NAME="Assistant.__getDocumentCalltips" ID="Assistant.__getDocumentCalltips"></a>
+<h4>Assistant.__getDocumentCalltips</h4>
+<b>__getDocumentCalltips</b>(<i>word, prefix, module, editor</i>)
 <p>
         Private method to determine calltips from the document.
 </p><dl>
@@ -254,25 +274,35 @@
 <dd>
 list of calltips (list of string)
 </dd>
-</dl><a NAME="Assistant.__getCharacter" ID="Assistant.__getCharacter"></a>
-<h4>Assistant.__getCharacter</h4>
-<b>__getCharacter</b>(<i>pos, editor</i>)
+</dl><a NAME="Assistant.__getDocumentCompletions" ID="Assistant.__getDocumentCompletions"></a>
+<h4>Assistant.__getDocumentCompletions</h4>
+<b>__getDocumentCompletions</b>(<i>editor, word, context, sep, prefix, module</i>)
 <p>
-        Private method to get the character to the left of the current position
-        in the current line.
+        Private method to determine autocompletion proposals from the document.
 </p><dl>
-<dt><i>pos</i></dt>
+<dt><i>editor</i></dt>
+<dd>
+reference to the editor object (QScintilla.Editor)
+</dd><dt><i>word</i></dt>
+<dd>
+string to be completed (string)
+</dd><dt><i>context</i></dt>
 <dd>
-position to get character at (integer)
-</dd><dt><i>editor</i></dt>
+flag indicating to autocomplete a context (boolean)
+</dd><dt><i>sep</i></dt>
 <dd>
-reference to the editor object to work with (QScintilla.Editor)
+separator string (string)
+</dd><dt><i>prefix</i></dt>
+<dd>
+prefix of the word to be completed (string)
+</dd><dt><i>module</i></dt>
+<dd>
+reference to the scanned module info (Module)
 </dd>
 </dl><dl>
 <dt>Returns:</dt>
 <dd>
-requested character or "", if there are no more (string) and
-            the next position (i.e. pos - 1)
+list of possible completions (list of strings)
 </dd>
 </dl><a NAME="Assistant.__preferencesChanged" ID="Assistant.__preferencesChanged"></a>
 <h4>Assistant.__preferencesChanged</h4>
@@ -369,37 +399,7 @@
 <b>deactivate</b>(<i></i>)
 <p>
         Public method to perform actions upon deactivation.
-</p><a NAME="Assistant.getCompletionsFromDocument" ID="Assistant.getCompletionsFromDocument"></a>
-<h4>Assistant.getCompletionsFromDocument</h4>
-<b>getCompletionsFromDocument</b>(<i>editor, word, context, sep, prefix, module</i>)
-<p>
-        Public method to determine autocompletion proposals from the document.
-</p><dl>
-<dt><i>editor</i></dt>
-<dd>
-reference to the editor object (QScintilla.Editor)
-</dd><dt><i>word</i></dt>
-<dd>
-string to be completed (string)
-</dd><dt><i>context</i></dt>
-<dd>
-flag indicating to autocomplete a context (boolean)
-</dd><dt><i>sep</i></dt>
-<dd>
-separator string (string)
-</dd><dt><i>prefix</i></dt>
-<dd>
-prefix of the word to be completed (string)
-</dd><dt><i>module</i></dt>
-<dd>
-reference to the scanned module info (Module)
-</dd>
-</dl><dl>
-<dt>Returns:</dt>
-<dd>
-list of possible completions (list of strings)
-</dd>
-</dl><a NAME="Assistant.setEnabled" ID="Assistant.setEnabled"></a>
+</p><a NAME="Assistant.setEnabled" ID="Assistant.setEnabled"></a>
 <h4>Assistant.setEnabled</h4>
 <b>setEnabled</b>(<i>key, enabled</i>)
 <p>
Binary file PluginAssistantEric.zip has changed

eric ide

mercurial