Source

pida-patches / kill-outliner-types-enum

# HG changeset patch
# Parent f2bd1a42824a40be9726449bad84f44470288189

diff --git a/pida-plugins/ctags/ctags.py b/pida-plugins/ctags/ctags.py
--- a/pida-plugins/ctags/ctags.py
+++ b/pida-plugins/ctags/ctags.py
@@ -37,7 +37,7 @@ from pida.core.options import OptionsCon
 from pida.core.languages import (LanguageService, Outliner, Validator,
     Completer, LanguageServiceFeaturesConfig, LanguageInfo, Definer, Documentator)
 
-from pida.utils.languages import (LANG_PRIO, LANG_OUTLINER_TYPES, OutlineItem )
+from pida.utils.languages import LANG_PRIO, OutlineItem
 
 # locale
 from pida.core.locale import Locale
@@ -282,19 +282,21 @@ class CtagsOutliner(Outliner):
 		v	variable        
         """
         def v2t(i):
-            if i == 'm': return LANG_OUTLINER_TYPES.MEMBER
-            if i == 'c': return LANG_OUTLINER_TYPES.CLASS
-            if i == 'd': return LANG_OUTLINER_TYPES.DEFINE
-            if i == 'e': return LANG_OUTLINER_TYPES.ENUMERATION
-            if i == 'f': return LANG_OUTLINER_TYPES.FUNCTION
-            if i == 'g': return LANG_OUTLINER_TYPES.ENUMERATION_NAME
-            if i == 'n': return LANG_OUTLINER_TYPES.NAMESPACE
-            if i == 'p': return LANG_OUTLINER_TYPES.PROTOTYPE
-            if i == 's': return LANG_OUTLINER_TYPES.STRUCTURE
-            if i == 't': return LANG_OUTLINER_TYPES.TYPEDEF
-            if i == 'u': return LANG_OUTLINER_TYPES.UNION
-            if i == 'v': return LANG_OUTLINER_TYPES.VARIABLE
-            return LANG_OUTLINER_TYPES.UNKNOWN
+            mapping = {
+                'm': 'member',
+                'c': 'class',
+                'd': 'define',
+                'e': 'enumeration',
+                'f': 'function',
+                'g': 'enumeration_name',
+                'n': 'namespace',
+                'p': 'prototype',
+                's': 'structure',
+                't': 'typedef',
+                'u': 'union',
+                'v': 'variable',
+            }
+            return mapping.get(i, 'unknown')
 
         if len(tokrow) == 4 and isinstance(tokrow[3], int):
             return tokrow[3]
@@ -304,8 +306,8 @@ class CtagsOutliner(Outliner):
                 return v2t(i)# most common case: just one char
             elif i[:4] == "kind":
                 return v2t(i[5:])
-            return LANG_OUTLINER_TYPES.UNKNOWN
-        return LANG_OUTLINER_TYPES.UNKNOWN
+            return 'unknown'
+        return 'unknown'
 
 
     def _get_container_name(self, tokrow):
@@ -327,15 +329,9 @@ class CtagsOutliner(Outliner):
         """ class, enumerations, structs and unions are considerer containers.
             See Issue 13 for some issues we had with this.
         """
-        if self._get_type(tokrow) in (
-            LANG_OUTLINER_TYPES.CLASS,
-            LANG_OUTLINER_TYPES.ENUMERATION_NAME,
-            LANG_OUTLINER_TYPES.STRUCTURE,
-            LANG_OUTLINER_TYPES.UNION,
-            LANG_OUTLINER_TYPES.TYPEDEF): 
-                return True
-        return False
-            
+        return self._get_type(tokrow) in (
+            'class', 'enumeration_name',
+            'structure', 'union', 'typedef')
         # remove temp file
         #os.remove(tmpfile)
 
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
@@ -38,7 +38,6 @@ from pida.core.languages import (Languag
     Documentator, External)
 
 from pida.utils.languages import (
-    LANG_OUTLINER_TYPES, 
     LANG_PRIO, Definition, Suggestion, Documentation, ValidationError)
 
 # services
@@ -131,14 +130,10 @@ class PythonOutliner(Outliner):
     description = _("A very deep and precises, but slow outliner")
 
 
-    filter_type = (LANG_OUTLINER_TYPES.IMPORT,
-                    LANG_OUTLINER_TYPES.BUILTIN,
-                    LANG_OUTLINER_TYPES.METHOD,
-                    LANG_OUTLINER_TYPES.FUNCTION,
-                    LANG_OUTLINER_TYPES.PROPERTY,
-                    LANG_OUTLINER_TYPES.ATTRIBUTE,
-                    LANG_OUTLINER_TYPES.SUPERMETHOD,
-                    )
+    filter_type = (
+        'import', 'builtin', 'method', 'function',
+        'property', 'attribute', 'supermethod',
+        )
 
     def get_outline(self):
         from rope.base.exceptions import RopeError
diff --git a/pida-plugins/python/ropebrowser.py b/pida-plugins/python/ropebrowser.py
--- a/pida-plugins/python/ropebrowser.py
+++ b/pida-plugins/python/ropebrowser.py
@@ -14,7 +14,7 @@ from pida.core.projects import Project a
 from rope.base.project import Project, get_no_project
 from rope.base import pynames, pyobjects, builtins
 
-from pida.utils.languages import LANG_OUTLINER_TYPES, OutlineItem
+from pida.utils.languages import OutlineItem
 from itertools import count
 
 OUTLINE_COUNTER = count()
@@ -70,7 +70,7 @@ class TreeOptions(object):
     position = 0
     has_children = False
     icon_name = 'source-property'
-    filter_type =  LANG_OUTLINER_TYPES.UNKNOWN
+    filter_type = 'unknown'
 
     def __init__(self, treeitem, obj):
         pass
@@ -91,7 +91,7 @@ class FunctionOptions(TreeOptions):
     icon_name = 'source-function'
     type_color = '#900000'
     position = 2
-    filter_type = LANG_OUTLINER_TYPES.UNKNOWN
+    filter_type = 'unknown'
 
     def __init__(self, item, obj):
         decs = []
@@ -126,13 +126,13 @@ class EvaluatedOptions(TreeOptions):
     type_name = 'p'
     icon_name = 'source-property'
     type_color = '#900090'
-    filter_type = LANG_OUTLINER_TYPES.PROPERTY
+    filter_type = 'property'
 
 class MethodOptions(FunctionOptions):
 
     type_name = 'm'
     icon_name = 'source-method'
-    filter_type = LANG_OUTLINER_TYPES.METHOD
+    filter_type = 'method'
 
 
 class SuperMethodOptions(MethodOptions):
@@ -140,7 +140,7 @@ class SuperMethodOptions(MethodOptions):
     type_name = '(m)'
     icon_name = 'source-extramethod'
     position = 6
-    filter_type = LANG_OUTLINER_TYPES.SUPERMETHOD
+    filter_type = 'supermethod'
 
 
 class ClassMethodOptions(MethodOptions):
@@ -188,7 +188,7 @@ class AssignedOptions(TreeOptions):
     icon_name = 'source-attribute'
     type_color = '#009000'
     position = 5
-    filter_type = LANG_OUTLINER_TYPES.ATTRIBUTE
+    filter_type = 'attribute'
 
 
 class BuiltinOptions(TreeOptions):
@@ -197,7 +197,7 @@ class BuiltinOptions(TreeOptions):
     icon_name = None
     type_color = '#999999'
     position = 7
-    filter_type = LANG_OUTLINER_TYPES.BUILTIN
+    filter_type = 'builtin'
 
 
 class ImportedOptions(TreeOptions):
@@ -206,7 +206,7 @@ class ImportedOptions(TreeOptions):
     icon_name = 'source-import'
     type_color = '#999999'
     position = 8
-    filter_type = LANG_OUTLINER_TYPES.IMPORT
+    filter_type = 'import'
 
 
 def get_option_for_item(item, node, obj, parent_obj=None):
diff --git a/pida-plugins/rst/rst.py b/pida-plugins/rst/rst.py
--- a/pida-plugins/rst/rst.py
+++ b/pida-plugins/rst/rst.py
@@ -13,7 +13,7 @@ from collections import defaultdict
 # PIDA imports
 from pida.core.languages import LanguageService, Outliner, Validator
 from pida.utils.languages import (
-    LANG_PRIO, LANG_OUTLINER_TYPES,
+    LANG_PRIO,
     OutlineItem, ValidationError,
 )
 from pida.services.language import DOCTYPES
@@ -247,8 +247,7 @@ class RSTOutliner(Outliner):
     name = "rst outliner"
     description = _("An outliner for ReStructuredText")
 
-    section_types = (LANG_OUTLINER_TYPES.SECTION,
-                     LANG_OUTLINER_TYPES.PARAGRAPH)
+    section_types = ('section', 'paragraph')
 
     def get_outline(self):
         self.doc_items = RSTTokenList()
@@ -280,7 +279,7 @@ class RSTOutliner(Outliner):
                   isinstance(node, nodes.figure)):
                 new_item = True
                 name = node.attributes['uri']
-                type = LANG_OUTLINER_TYPES.UNKNOWN
+                type = 'unknown'
                 is_container = False
                 # nodes with options have no line attribute
                 linenumber = node.line or node.parent.line
diff --git a/pida/services/language/gui.py b/pida/services/language/gui.py
--- a/pida/services/language/gui.py
+++ b/pida/services/language/gui.py
@@ -517,7 +517,7 @@ class BrowserView(PidaView):
                 )
             for f in self.filter_map:
                 tool_button = gtk.ToggleToolButton()
-                tool_button.set_name(str(f))
+                tool_button.set_name(f)
                 tool_button.set_active(self.filter_map[f])
                 #FIXME no tooltip on win32
                 if not on_windows:
@@ -539,7 +539,7 @@ class BrowserView(PidaView):
         self.options_vbox.show_all()
 
     def on_filter_toggled(self, but, outliner):
-        self.filter_map[int(but.get_name())] = not self.filter_map[int(but.get_name())]
+        self.filter_map[but.get_name()] = not self.filter_map[but.get_name()]
         #self.set_outliner(outliner, self.document)
         self.filter_model.refilter()
 
diff --git a/pida/services/language/outlinefilter.py b/pida/services/language/outlinefilter.py
--- a/pida/services/language/outlinefilter.py
+++ b/pida/services/language/outlinefilter.py
@@ -1,56 +1,54 @@
-from pida.utils.languages import LANG_OUTLINER_TYPES
-
 FILTERMAP = {
-    LANG_OUTLINER_TYPES.IMPORT: {
+    'import': {
         "name": "import",
         "alias": "include",
         "display": "Imports",
         "icon": "source-import",
         "default": True 
     },
-    LANG_OUTLINER_TYPES.BUILTIN: {
+    'builtin': {
         "name": "builtin",
         "alias": "",
         "display": "Builtins",
         "icon": "source-module",
         "default": True
     },
-    LANG_OUTLINER_TYPES.ATTRIBUTE: {
+    'attribute': {
         "name": "attribute",
         "alias": "",
         "display": "Attributes",
         "icon": "source-attribute",
         "default": True
     },
-    LANG_OUTLINER_TYPES.METHOD: {
+    'method': {
         "name": "method",
         "alias": "",
         "display": "Methods",
         "icon": "source-method",
         "default": True
     },
-    LANG_OUTLINER_TYPES.PROPERTY: {
+    'property': {
         "name": "property",
         "alias": "",
         "display": "Properties",
         "icon": "source-property",
         "default": True
     },
-    LANG_OUTLINER_TYPES.FUNCTION: {
+    'function': {
         "name": "function",
         "alias": "",
         "display": "Functions",
         "icon": "source-function",
         "default": True
     },
-    LANG_OUTLINER_TYPES.SUPERMETHOD: {
+    'supermethod': {
         "name": "import",
         "alias": "include",
         "display": "Super methods",
         "icon": "source-extramethod",
         "default": True 
     },
-    LANG_OUTLINER_TYPES.SUPERPROPERTY: {
+    'superproperty': {
         "name": "import",
         "alias": "include",
         "display": "Super properties",