Ronny Pfannschmidt avatar Ronny Pfannschmidt committed ba6f7a3

add kill completer item type enum patch

Comments (0)

Files changed (2)

kill-completer-types-enum

+# HG changeset patch
+# Parent 4d64b7a6ab15984b72fe40d84bc81e24f8285e97
+diff --git a/pida-plugins/python/python.py b/pida-plugins/python/python.py
+--- a/pida-plugins/python/python.py
++++ b/pida-plugins/python/python.py
+@@ -37,7 +37,7 @@ from pida.core.languages import (Languag
+     Completer, LanguageServiceFeaturesConfig, LanguageInfo, Definer, 
+     Documentator, External)
+ 
+-from pida.utils.languages import (LANG_COMPLETER_TYPES,
++from pida.utils.languages import (
+     LANG_VALIDATOR_TYPES, LANG_VALIDATOR_SUBTYPES, LANG_OUTLINER_TYPES, 
+     LANG_PRIO, Definition, Suggestion, Documentation, ValidationError)
+ 
+@@ -342,22 +342,15 @@ class PythonCompleter(Completer):
+                 r = Suggestion(c.name)
+                 #'variable', 'class', 'function', 'imported' , 'paramter'
+                 if keyword.iskeyword(c.name):
+-                    r.type_ = LANG_COMPLETER_TYPES.KEYWORD
+-                elif c.type == 'variable':
+-                    r.type_ = LANG_COMPLETER_TYPES.VARIABLE
+-                elif c.type == 'class':
+-                    r.type_ = LANG_COMPLETER_TYPES.CLASS
+-                elif c.type == 'builtin':
+-                    r.type_ = LANG_COMPLETER_TYPES.BUILTIN
+-                elif c.type == 'function':
+-                    r.type_ = LANG_COMPLETER_TYPES.FUNCTION
+-                elif c.type == 'parameter':
+-                    r.type_ = LANG_COMPLETER_TYPES.PARAMETER
++                    r.type_ = 'keyword'
++                elif c.type in ('variable','class', 'builtin',
++                                'function', 'parameter',):
++                    r.type_ = c.type_
+                 elif c.type == None:
+                     if c.kind == "parameter_keyword":
+-                        r.type_ = LANG_COMPLETER_TYPES.PARAMETER
++                        r.type_ = 'parameter'
+                 else:
+-                    r.type_ = LANG_COMPLETER_TYPES.UNKNOWN
++                    r.type_ = 'unknown'
+                 yield r
+ 
+ class PythonDefiner(Definer):
+diff --git a/pida/ui/completer.py b/pida/ui/completer.py
+--- a/pida/ui/completer.py
++++ b/pida/ui/completer.py
+@@ -7,8 +7,10 @@
+ import gtk
+ import gobject
+ import os
+-from pida.utils.languages import LANG_COMPLETER_TYPES
++from pida.utils.languages import completer_types
+ 
++
++#XXX: register as stock icons
+ def _load_pix(fn):
+     return gtk.gdk.pixbuf_new_from_file(
+         os.path.join(os.path.dirname(__file__),
+@@ -16,19 +18,19 @@ def _load_pix(fn):
+ 
+ 
+ _PIXMAPS = {
+-    LANG_COMPLETER_TYPES.UNKNOWN:     _load_pix('element-event-16.png'),
+-    LANG_COMPLETER_TYPES.ATTRIBUTE:   _load_pix('source-attribute.png'),
+-    LANG_COMPLETER_TYPES.CLASS:       _load_pix('source-class.png'),
+-    LANG_COMPLETER_TYPES.FUNCTION:    _load_pix('source-attribute.png'), # FIXME
+-    LANG_COMPLETER_TYPES.METHOD:      _load_pix('source-attribute.png'),
+-    LANG_COMPLETER_TYPES.MODULE:      _load_pix('source-method.png'),
+-    LANG_COMPLETER_TYPES.PROPERTY:    _load_pix('source-property.png'),
+-    LANG_COMPLETER_TYPES.EXTRAMETHOD: _load_pix('source-extramethod.png'),
+-    LANG_COMPLETER_TYPES.VARIABLE:    _load_pix('source-attribute.png'), # FIXME
+-    LANG_COMPLETER_TYPES.IMPORT:      _load_pix('source-import.png'),
+-    LANG_COMPLETER_TYPES.PARAMETER:   _load_pix('source-attribute.png'), # FIXME
+-    LANG_COMPLETER_TYPES.BUILTIN:     _load_pix('source-attribute.png'), # FIXME
+-    LANG_COMPLETER_TYPES.KEYWORD:     _load_pix('source-attribute.png'), # FIXME
++    'unknown':     _load_pix('element-event-16.png'),
++    'attribute':   _load_pix('source-attribute.png'),
++    'class':       _load_pix('source-class.png'),
++    'function':    _load_pix('source-attribute.png'), # FIXME
++    'method':      _load_pix('source-attribute.png'),
++    'module':      _load_pix('source-method.png'),
++    'property':    _load_pix('source-property.png'),
++    'extramethod': _load_pix('source-extramethod.png'),
++    'variable':    _load_pix('source-attribute.png'), # FIXME
++    'import':      _load_pix('source-import.png'),
++    'parameter':   _load_pix('source-attribute.png'), # FIXME
++    'builtin':     _load_pix('source-attribute.png'), # FIXME
++    'keyword':     _load_pix('source-attribute.png'), # FIXME
+ }
+ 
+ 
+@@ -39,10 +41,7 @@ class SuggestionsList(gtk.ListStore):
+     @staticmethod
+     def from_dbus(args):
+         rv = list(args)
+-        if args[0] in _PIXMAPS:
+-            rv[0] = _PIXMAPS[args[0]]
+-        else:
+-            rv[0] = _PIXMAPS[LANG_COMPLETER_TYPES.UNKNOWN]
++        rv[0] = _PIXMAPS.get(args[0], _PIXMAPS['unknown'])
+         return rv
+ 
+ class PidaCompleterWindow(gtk.Window):
+@@ -379,8 +378,8 @@ if __name__ == "__main__":
+     i = 0
+     for x in ['ase', 'assdf', 'Asdf', 'zasd', 'Zase', 'form', 'in', 'of', 'BLA',
+               'taT', 'tUt', 'df', 'asdf', 'asdfa', 'sd', 'sdfsf', 'ssdfsdf', 'sd']:
+-        l.append(SuggestionsList.from_dbus((i, x)))
+-        i = i + 1%7
++        l.append(SuggestionsList.from_dbus((completer_types[i], x)))
++        i = (i + 1)%7
+ 
+     p.set_model(l)
+ 
+diff --git a/pida/utils/languages.py b/pida/utils/languages.py
+--- a/pida/utils/languages.py
++++ b/pida/utils/languages.py
+@@ -10,6 +10,7 @@ List of general Language classes.
+ from .addtypes import Enumeration
+ from .path import get_line_from_file
+ 
++import itertools
+ 
+ 
+ #!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+@@ -19,12 +20,26 @@ from .path import get_line_from_file
+ #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ 
+ 
++completer_types = [
++    'unknown',
++    'attribute',
++    'class',
++    'method',
++    'function',
++    'module',
++    'property',
++    'extramethod',
++    'variable',
++    'import',
++    'parameter',
++    'builtin',
++    'keyword',
++    'snippet',
++]
++completer_type_order = dict(zip(completer_types, range(len(completer_types))))
+ 
+-# completer types
+-LANG_COMPLETER_TYPES = Enumeration('LANG_COMPLETER_TYPES',
+-    ('UNKNOWN', 'ATTRIBUTE', 'CLASS', 'METHOD', 'FUNCTION', 'MODULE', 
+-    'PROPERTY', 'EXTRAMETHOD', 'VARIABLE', 'IMPORT', 'PARAMETER', 'BUILTIN', 
+-    'KEYWORD', 'SNIPPET'))
++LANG_COMPLETER_TYPES = Enumeration('LANG_COMPLETER_TYPES', map(str.upper, completer_types))
++
+ 
+ 
+ # main types
+@@ -243,7 +258,7 @@ class Suggestion(unicode):
+     """
+     Suggestions are returned by an Completer class
+     """
+-    type_ = LANG_TYPES.UNKNOWN
++    type_ = 'unknown'
+     doc = None
+     docpath = None
+     signature = None
+kill-completer-types-enum
 pypath-for-options
 core-pdbus-pyxml-introspect #+dbus
 pida-remote-cleanup
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.