Source

pida-patches / kill-most-language-enum-definitions

Full commit
# HG changeset patch
# User Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
# Date 1280876358 -7200
# Node ID f9d89ccc19e59f68bf1962d9bc6a566eb4597e5a
# Parent d2deb6f3af308ed68f2952d00e9a6c533cf5c978
imported patch kill-most-language-enum-definitions

diff --git a/pida/core/languages.py b/pida/core/languages.py
--- a/pida/core/languages.py
+++ b/pida/core/languages.py
@@ -16,7 +16,7 @@ from pida.core.projects import Project
 from pida.core.service import Service
 from pida.core.features import FeaturesConfig
 from pida.utils.languages import (
-    LANG_COMPLETER_TYPES, LANG_PRIO,
+    LANG_PRIO,
     Suggestion, Definition, ValidationError, Documentation)
 from pida.utils.path import get_relative_path
 # locale
diff --git a/pida/utils/languages.py b/pida/utils/languages.py
--- a/pida/utils/languages.py
+++ b/pida/utils/languages.py
@@ -36,31 +36,30 @@ completer_types = [
     'keyword',
     'snippet',
 ]
-completer_type_order = dict(zip(completer_types, range(len(completer_types))))
-
-LANG_COMPLETER_TYPES = Enumeration('LANG_COMPLETER_TYPES', map(str.upper, completer_types))
 
 
 
 # main types
-LANG_VALIDATOR_TYPES = Enumeration('LANG_TYPES',
-    ('UNKNOWN', 'INFO', 'WARNING', 'ERROR', 'FATAL'))
+validator_types = ('unknown', 'info', 'warning', 'error', 'fatal')
 
 # validation sub types
-LANG_VALIDATOR_SUBTYPES = Enumeration('LANG_VALIDATION_ERRORS',
-    ('UNKNOWN', 'SYNTAX', 'INDENTATION', 'UNDEFINED', 'REDEFINED', 'BADSTYLE',
-     'DUPLICATE', 'UNUSED', 'FIXME', 'PROTECTION', 'DANGEROUS'))
+validator_subtypes = (
+    'unknown', 'syntax', 'indentation', 'undefined', 'redefined', 'badstyle',
+    'duplicate', 'unused', 'fixme', 'protection', 'dangerous',
+)
 
 # validation sub types
 
-LANG_TYPES = Enumeration('LANG_TYPES',
- ('', 'UNKNOWN', 
- 'ATTRIBUTE', 'BUILTIN', 'CLASS', 'DEFINE', 'ENUMERATION',
- 'ENUMERATION_NAME', 'FUNCTION', 'IMPORT', 'MEMBER', 'METHOD', 'PROPERTY',
- 'PROTOTYPE', 'STRUCTURE', 'SUPERMETHOD', 'SUPERPROPERTY', 'TYPEDEF', 'UNION',
- 'VARIABLE', 'NAMESPACE', 'ELEMENT', 'SECTION', 'CHAPTER', 'PARAGRAPH'))
+types = (
+    'unknown', 'attribute', 'builtin', 'class', 'define', 'enumeration',
+    'enumeration_name', 'function', 'import', 'member', 'method', 'property',
+    'prototype', 'structure', 'supermethod', 'superproperty', 'typedef',
+    'union', 'variable',
+    'namespace', 'element',
+    'section', 'chapter', 'paragraph',
+)
 
-LANG_OUTLINER_TYPES = LANG_TYPES
+outliner_types = types
 
 LANG_PRIO = Enumeration('LANG_PRIORITIES',
 (
@@ -74,29 +73,29 @@ LANG_PRIO = Enumeration('LANG_PRIORITIES
 
 
 LANG_IMAGE_MAP = {
-    LANG_TYPES.ATTRIBUTE: 'source-attribute',
-    LANG_TYPES.BUILTIN: 'source-attribute',
-    LANG_TYPES.CLASS: 'source-class',
-    LANG_TYPES.DEFINE: 'source-define',
-    LANG_TYPES.ENUMERATION: 'source-enum',
-    LANG_TYPES.ENUMERATION_NAME: 'source-enumarator',
-    LANG_TYPES.FUNCTION: 'source-function',
-    LANG_TYPES.IMPORT: 'source-import',
-    LANG_TYPES.MEMBER: 'source-member',
-    LANG_TYPES.METHOD: 'source-method',
-    LANG_TYPES.PROTOTYPE: 'source-interface',
-    LANG_TYPES.PROPERTY: 'source-property',
-    LANG_TYPES.METHOD: 'source-method',
-    LANG_TYPES.SUPERMETHOD: 'source-extramethod',
-    #FIXME: superproperty icon
-    LANG_TYPES.SUPERPROPERTY: 'source-property',
-    LANG_TYPES.TYPEDEF: 'source-typedef',
-    LANG_TYPES.UNION: 'source-union',
-    LANG_TYPES.VARIABLE: 'source-variable',
-    LANG_TYPES.SECTION: 'source-section',
-    LANG_TYPES.PARAGRAPH: 'source-paragraph',
-    LANG_TYPES.NAMESPACE: 'source-namespace',
-    LANG_TYPES.ELEMENT: 'source-element',
+    'attribute': 'Source-attribute',
+    'builtin': 'source-attribute',
+    'class': 'source-class',
+    'define': 'source-define',
+    'enumeration': 'source-enum',
+    'enumeration_name': 'source-enumarator',
+    'function': 'source-function',
+    'import': 'source-import',
+    'member': 'source-member',
+    'method': 'source-method',
+    'prototype': 'source-interface',
+    'property': 'source-property',
+    'method': 'source-method',
+    'supermethod': 'source-extramethod',
+    #fixme: SUPERPROPERTY ICON
+    'superproperty': 'source-property',
+    'typedef': 'source-typedef',
+    'union': 'source-union',
+    'variable': 'source-variable',
+    'section': 'source-section',
+    'paragraph': 'source-paragraph',
+    'namespace': 'source-namespace',
+    'element': 'source-element',
 }
 
 
@@ -148,10 +147,9 @@ class ValidationError(InitObject):
     """<span foreground="%(typec)s" style="italic" weight="bold">%(type)s</span"""
     """>:<span style="italic">%(subtype)s</span>\n%(message)s""" % 
                       {'lineno':self.lineno, 
-                      'type':_(self.type_.capitalize()),
-                      'subtype':_(LANG_VALIDATOR_SUBTYPES.whatis(
-                                    self.subtype).capitalize()),
-                      'message':self.message,
+                      'type': self.type_.capitalize(),
+                      'subtype': self.subtype.capitalize(),
+                      'message': self.message,
                       'linecolor': color_to_string(self.lookup_color('pida-lineno')),
                       'typec': color_to_string(typec),
                       })
@@ -177,7 +175,7 @@ class OutlineItem(InitObject):
     """
     Outlines are returned by an Outliner class
     """
-    type = LANG_TYPES.UNKNOWN
+    type = 'unknown'
     name = ''
     parent = None
     id = None
@@ -217,7 +215,7 @@ class OutlineItem(InitObject):
 
 class Definition(InitObject):
     """Returned by a Definer instance"""
-    type = LANG_TYPES.UNKNOWN
+    type = 'unknown'
     file_name = None
     offset = None
     length = None