|
| 1 | +#!python |
| 2 | +# Komodo TorqueScript language service. |
| 3 | + |
| 4 | +"""Language package for TorqueScript""" |
| 5 | + |
| 6 | +import os |
| 7 | +import re |
| 8 | +import logging |
| 9 | + |
| 10 | +import process |
| 11 | +import koprocessutils |
| 12 | + |
| 13 | +from koLanguageServiceBase import * |
| 14 | +from koUDLLanguageBase import KoUDLLanguage |
| 15 | +from xpcom import components, ServerException |
| 16 | +import xpcom.server |
| 17 | + |
| 18 | +sci_constants = components.interfaces.ISciMoz |
| 19 | + |
| 20 | + |
| 21 | +log = logging.getLogger("koTorqueScriptLanguage") |
| 22 | +log.setLevel(logging.DEBUG) |
| 23 | + |
| 24 | + |
| 25 | +def registerLanguage(registry): |
| 26 | + log.debug("Registering language TorqueScript") |
| 27 | + registry.registerLanguage(KoTorqueScriptLanguage()) |
| 28 | + |
| 29 | + |
| 30 | +class KoTorqueScriptLanguage(KoUDLLanguage, KoLanguageBaseDedentMixin): |
| 31 | + name = "TorqueScript" |
| 32 | + _reg_desc_ = "%s Language" % name |
| 33 | + _reg_contractid_ = "@activestate.com/koLanguage?language=%s;1" % name |
| 34 | + _reg_clsid_ = "c144db8f-e44e-497d-9bd3-ba56d13a96c8" |
| 35 | + _reg_categories_ = [("komodo-language", name)] |
| 36 | + _com_interfaces_ = [components.interfaces.koILanguage, |
| 37 | + components.interfaces.nsIObserver] |
| 38 | + |
| 39 | + lexresLangName = "TorqueScript" |
| 40 | + lang_from_udl_family = { 'SSL' : 'TorqueScript', 'M' : 'TorqueML'} |
| 41 | + namedBlockRE = r'^(.*?function\s+[&]*?\s*[\w_]*)|(^.*?(package)\s+[\w_]*)|(^.*?(datablock|singleton)\s+\(\s+[\w_]*\))' |
| 42 | + namedBlockDescription = 'PHP functions and classes' |
| 43 | + |
| 44 | + defaultExtension = ".cs" |
| 45 | + variableIndicators = '$%' |
| 46 | + downloadURL = 'http://www.garagegames.com' |
| 47 | + commentDelimiterInfo = { |
| 48 | + "line": [ "//" ], |
| 49 | + "block": [ ("/*", "*/") ] |
| 50 | + } |
| 51 | + _dedenting_statements = [u'return', u'break', u'continue'] |
| 52 | + _indenting_statements = [u'case'] |
| 53 | + supportsSmartIndent = "brace" |
| 54 | + _indent_chars = "{}" |
| 55 | + _indent_open_chars = "{" |
| 56 | + _indent_close_chars = "}" |
| 57 | + _lineup_chars = u"{}()[]" |
| 58 | + _lineup_open_chars = "([{" # Perl tells the difference between the indent and lineup {}'s |
| 59 | + _lineup_close_chars = ")]}" |
| 60 | + sample = """package Sample{ |
| 61 | + function foo(%bar) { |
| 62 | + echo("baz" SPC $global_awesome); |
| 63 | + commandToServer('do_more_stuff'); |
| 64 | + return 5; |
| 65 | + } |
| 66 | +}; |
| 67 | +activatePackage(Sample);""" |
| 68 | + |
| 69 | + def __init__(self): |
| 70 | + KoUDLLanguage.__init__(self) |
| 71 | + KoLanguageBaseDedentMixin.__init__(self) |
| 72 | + |
| 73 | + self.matchingSoftChars = {"(": (")", None), |
| 74 | + "{": ("}", None), |
| 75 | + "[": ("]", None), |
| 76 | + '"': ('"', self.softchar_accept_matching_double_quote), |
| 77 | + "'": ("'", self.softchar_accept_matching_single_quote), |
| 78 | + } |
| 79 | + |
| 80 | + self._setupIndentCheckSoftChar() |
| 81 | + |
| 82 | + |
0 commit comments