Commits

Justin Weeks committed 61d08d8

Initial starting point of KomoGo. Syntax highlighting of keywords and collapse-able braces completed.

Comments (0)

Files changed (24)

Empty file added.
+   Copyright 2012 Justin Weeks
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

build/components/component.manifest

+component {4359deb5-4fec-4426-81fb-08a8e55abf73} koGo_UDL_Language.py
+category komodo-language Go @activestate.com/koLanguage?language=Go;1
+contract @activestate.com/koLanguage?language=Go;1 {4359deb5-4fec-4426-81fb-08a8e55abf73}

build/components/koGo_UDL_Language.py

+# Registers the Go language in Komodo.
+
+import logging
+from koUDLLanguageBase import KoUDLLanguage
+
+log = logging.getLogger("koGoLanguage")
+#log.setLevel(logging.DEBUG)
+
+def registerLanguage(registry):
+    log.debug("Registering language Go")
+    registry.registerLanguage(KoGoLanguage())
+
+class KoGoLanguage(KoUDLLanguage):
+
+    # ------------ Komodo Registration Information ------------ #
+
+    name = "Go"
+    lexresLangName = "Go"
+    _reg_desc_ = "%s Language" % name
+    _reg_contractid_ = "@activestate.com/koLanguage?language=%s;1" % name
+    _reg_categories_ = [("komodo-language", name)]
+    _reg_clsid_ = "4359deb5-4fec-4426-81fb-08a8e55abf73"
+    defaultExtension = '.go'
+
+    # ------------ Commenting Controls ------------ #
+
+    commentDelimiterInfo = {
+        "line": [
+                '//',   # C-style one line comments
+                #'#',    # Hash-style one line comments
+                #'--',   # SQL-style one line comments
+                #';',    # Lisp-style one line comments
+                #'%',    # Erlang-style one line comments
+                ],
+        "block": [
+                ('/*', '*/')   # C-style block comments
+                #('(*', '*)')   # Pascal-style block comments
+                ],
+    }
+
+    # ------------ Indentation Controls ------------ #
+
+    # To support automatic indenting and dedenting after "{([" and "})]"
+    supportsSmartIndent = "brace"
+    # Other smart indenting types are:
+    #   'text', 'python', 'XML' and 'keyword'
+
+    # Indent/dedent after these words.
+    #_indenting_statements = ['case']
+    #_dedenting_statements = ['return', 'break', 'continue']
+
+    # ------------ Sub-language Controls ------------ #
+
+    #Check: Update 'lang_from_udl_family' as appropriate for your
+    #      lexer definition. There are four UDL language families:
+    #           M (markup), i.e. HTML or XML
+    #           CSL (client-side language), e.g. JavaScript
+    #           SSL (server-side language), e.g. Perl, PHP, Python
+    #           TPL (template language), e.g. RHTML, Django, Smarty
+    #      'lang_from_udl_family' maps each UDL family code (M,
+    #      CSL, ...) to the sub-language name in your language.
+    #      Some examples:
+    #        lang_from_udl_family = {   # A PHP file can contain
+    #           'M': 'HTML',            #   HTML
+    #           'SSL': 'PHP',           #   PHP
+    #           'CSL': 'JavaScript',    #   JavaScript
+    #        }
+    #        lang_from_udl_family = {   # An RHTML file can contain
+    #           'M': 'HTML',            #   HTML
+    #           'SSL': 'Ruby',          #   Ruby
+    #           'CSL': 'JavaScript',    #   JavaScript
+    #           'TPL': 'RHTML',         #   RHTML template code
+    #        }
+    #        lang_from_udl_family = {   # A plain XML can just contain
+    #           'M': 'XML',             #   XML
+    #        }
+    lang_from_udl_family = {'SSL': 'Go'}

build/lexers/Go.lexres

+1:lexer resource
+2:1
+3:1
+4:0
+48:1:0:0
+11:2
+12:Go
+13
+14:0:0
+16:0:5
+15:0:1
+14:1:15
+16:1:21
+15:1:0
+14:2:22
+16:2:29
+15:2:0
+14:3:31
+16:3:46
+15:3:2
+14:4:49
+16:4:56
+15:4:0
+17:2
+18:0
+19:1
+18:3
+19:0
+11:153
+12:break case chan const continue default defer else fallthrough for func go g
+12:oto if import interface map package range return select struct switch type 
+12:var
+21
+22:45:44
+11:1
+12:{
+20:0:46:1
+11:1
+12:}
+20:1:46:-1
+32:2
+33:0:40:3
+33:1:31:2
+34:9
+35:1
+11:1
+12:.
+36:2:-1:-1:1:2:0:0:0
+40
+37:3
+35:2
+11:2
+12://
+36:1:31:-1:0:3:0:0:0
+40
+11:2
+12:/*
+36:1:31:-1:0:4:0:0:0
+40
+11:10
+12:[\s	\r\n]+
+36:2:-1:-1:0:-1:0:0:0
+40
+11:1
+12:"
+36:1:31:-1:0:5:0:0:0
+40
+11:1
+12:'
+36:1:31:-1:0:6:0:0:0
+40
+11:1
+12:`
+36:1:31:-1:0:7:0:0:0
+40
+11:17
+12:0[Xx][0-9a-fA-F]+
+36:2:31:42:0:-1:0:0:0
+40
+11:12
+12:[-+]?0[0-7]*
+36:2:31:42:0:-1:0:0:0
+40
+11:11
+12:[-+]?[1-9]+
+36:2:31:42:0:-1:0:0:0
+40
+11:39
+12:[_a-zA-Z\x80-\xff][_a-zA-Z\x80-\xff\d]*
+36:2:31:45:0:-1:0:0:0
+40
+11:40
+12:[!#%&\(\)\*\+,-\.\/:;<=>\?@\[\]\^\{\}~|]
+36:2:31:46:0:-1:0:0:0
+40
+11:4
+12:NULL
+36:4:31:-1:0:-1:0:0:0
+41
+35:3
+11:6
+12:[\r\n]
+36:2:40:-1:0:2:0:0:0
+40
+11:4
+12:NULL
+36:4:40:-1:0:-1:0:0:0
+41
+35:4
+11:2
+12:*/
+36:1:-1:41:0:2:0:0:0
+40
+11:4
+12:NULL
+36:4:41:-1:0:-1:0:0:0
+41
+35:5
+11:1
+12:"
+36:1:-1:43:0:2:0:0:0
+40
+11:3
+12:\\.
+36:2:-1:-1:0:-1:0:0:0
+40
+11:4
+12:NULL
+36:4:43:-1:0:-1:0:0:0
+41
+35:6
+11:1
+12:'
+36:1:-1:43:0:2:0:0:0
+40
+11:3
+12:\\.
+36:2:-1:-1:0:-1:0:0:0
+40
+11:4
+12:NULL
+36:4:43:-1:0:-1:0:0:0
+41
+35:7
+11:1
+12:`
+36:1:-1:43:0:2:0:0:0
+40
+11:3
+12:\\.
+36:2:-1:-1:0:-1:0:0:0
+40
+11:4
+12:NULL
+36:4:43:-1:0:-1:0:0:0
+41
+35:8
+11:2
+12:*)
+36:1:-1:41:0:2:0:0:0
+40
+11:4
+12:NULL
+36:4:41:-1:0:-1:0:0:0
+41

build/xpi/chrome.manifest

+content komogogo for komodo content/
+skin komogogo for komodo classic/1.0 skin/
+locale komogogo for komodo en-US locale/en-US/
+
+manifest components/component.manifest

build/xpi/components/component.manifest

+component {4359deb5-4fec-4426-81fb-08a8e55abf73} koGo_UDL_Language.py
+category komodo-language Go @activestate.com/koLanguage?language=Go;1
+contract @activestate.com/koLanguage?language=Go;1 {4359deb5-4fec-4426-81fb-08a8e55abf73}

build/xpi/components/koGo_UDL_Language.py

+# Registers the Go language in Komodo.
+
+import logging
+from koUDLLanguageBase import KoUDLLanguage
+
+log = logging.getLogger("koGoLanguage")
+#log.setLevel(logging.DEBUG)
+
+def registerLanguage(registry):
+    log.debug("Registering language Go")
+    registry.registerLanguage(KoGoLanguage())
+
+class KoGoLanguage(KoUDLLanguage):
+
+    # ------------ Komodo Registration Information ------------ #
+
+    name = "Go"
+    lexresLangName = "Go"
+    _reg_desc_ = "%s Language" % name
+    _reg_contractid_ = "@activestate.com/koLanguage?language=%s;1" % name
+    _reg_categories_ = [("komodo-language", name)]
+    _reg_clsid_ = "4359deb5-4fec-4426-81fb-08a8e55abf73"
+    defaultExtension = '.go'
+
+    # ------------ Commenting Controls ------------ #
+
+    commentDelimiterInfo = {
+        "line": [
+                '//',   # C-style one line comments
+                #'#',    # Hash-style one line comments
+                #'--',   # SQL-style one line comments
+                #';',    # Lisp-style one line comments
+                #'%',    # Erlang-style one line comments
+                ],
+        "block": [
+                ('/*', '*/')   # C-style block comments
+                #('(*', '*)')   # Pascal-style block comments
+                ],
+    }
+
+    # ------------ Indentation Controls ------------ #
+
+    # To support automatic indenting and dedenting after "{([" and "})]"
+    supportsSmartIndent = "brace"
+    # Other smart indenting types are:
+    #   'text', 'python', 'XML' and 'keyword'
+
+    # Indent/dedent after these words.
+    #_indenting_statements = ['case']
+    #_dedenting_statements = ['return', 'break', 'continue']
+
+    # ------------ Sub-language Controls ------------ #
+
+    #Check: Update 'lang_from_udl_family' as appropriate for your
+    #      lexer definition. There are four UDL language families:
+    #           M (markup), i.e. HTML or XML
+    #           CSL (client-side language), e.g. JavaScript
+    #           SSL (server-side language), e.g. Perl, PHP, Python
+    #           TPL (template language), e.g. RHTML, Django, Smarty
+    #      'lang_from_udl_family' maps each UDL family code (M,
+    #      CSL, ...) to the sub-language name in your language.
+    #      Some examples:
+    #        lang_from_udl_family = {   # A PHP file can contain
+    #           'M': 'HTML',            #   HTML
+    #           'SSL': 'PHP',           #   PHP
+    #           'CSL': 'JavaScript',    #   JavaScript
+    #        }
+    #        lang_from_udl_family = {   # An RHTML file can contain
+    #           'M': 'HTML',            #   HTML
+    #           'SSL': 'Ruby',          #   Ruby
+    #           'CSL': 'JavaScript',    #   JavaScript
+    #           'TPL': 'RHTML',         #   RHTML template code
+    #        }
+    #        lang_from_udl_family = {   # A plain XML can just contain
+    #           'M': 'XML',             #   XML
+    #        }
+    lang_from_udl_family = {'SSL': 'Go'}

build/xpi/install.rdf

+<?xml version="1.0"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+    <Description about="urn:mozilla:install-manifest">
+<em:unpack>true</em:unpack>
+        <em:id>komogo___go_for_komodo@www.justinweeks.info</em:id>
+        <em:name>komogo___go_for_komodo</em:name>
+        <em:version>0.1</em:version>
+        <em:description>KomoGo is a language extension for Activestate Komodo for the Go language (http://www.golang.org).</em:description>
+        <em:creator>Justin Weeks</em:creator>
+        <em:homepageURL>http://www.justinweeks.info/KomoGo</em:homepageURL>
+        <em:type>2</em:type> <!-- type=extension --> 
+
+        <em:targetApplication>
+            <Description>
+                <!-- Komodo IDE's uuid -->
+                <em:id>{36E66FA0-F259-11D9-850E-000D935D3368}</em:id>
+                <em:minVersion>6.0</em:minVersion>
+                <em:maxVersion>7.*</em:maxVersion>
+            </Description>
+        </em:targetApplication>
+        <em:targetApplication>
+            <Description>
+                <!-- Komodo Edit's uuid -->
+                <em:id>{b1042fb5-9e9c-11db-b107-000d935d3368}</em:id>
+                <em:minVersion>6.0</em:minVersion>
+                <em:maxVersion>7.*</em:maxVersion>
+            </Description>
+        </em:targetApplication>
+    </Description>
+</RDF>

build/xpi/komogo___go_for_komodo-0.1-ko.xpi

Binary file added.

build/xpi/lexers/Go.lexres

+1:lexer resource
+2:1
+3:1
+4:0
+48:1:0:0
+11:2
+12:Go
+13
+14:0:0
+16:0:5
+15:0:1
+14:1:15
+16:1:21
+15:1:0
+14:2:22
+16:2:29
+15:2:0
+14:3:31
+16:3:46
+15:3:2
+14:4:49
+16:4:56
+15:4:0
+17:2
+18:0
+19:1
+18:3
+19:0
+11:153
+12:break case chan const continue default defer else fallthrough for func go g
+12:oto if import interface map package range return select struct switch type 
+12:var
+21
+22:45:44
+11:1
+12:{
+20:0:46:1
+11:1
+12:}
+20:1:46:-1
+32:2
+33:0:40:3
+33:1:31:2
+34:9
+35:1
+11:1
+12:.
+36:2:-1:-1:1:2:0:0:0
+40
+37:3
+35:2
+11:2
+12://
+36:1:31:-1:0:3:0:0:0
+40
+11:2
+12:/*
+36:1:31:-1:0:4:0:0:0
+40
+11:10
+12:[\s	\r\n]+
+36:2:-1:-1:0:-1:0:0:0
+40
+11:1
+12:"
+36:1:31:-1:0:5:0:0:0
+40
+11:1
+12:'
+36:1:31:-1:0:6:0:0:0
+40
+11:1
+12:`
+36:1:31:-1:0:7:0:0:0
+40
+11:17
+12:0[Xx][0-9a-fA-F]+
+36:2:31:42:0:-1:0:0:0
+40
+11:12
+12:[-+]?0[0-7]*
+36:2:31:42:0:-1:0:0:0
+40
+11:11
+12:[-+]?[1-9]+
+36:2:31:42:0:-1:0:0:0
+40
+11:39
+12:[_a-zA-Z\x80-\xff][_a-zA-Z\x80-\xff\d]*
+36:2:31:45:0:-1:0:0:0
+40
+11:40
+12:[!#%&\(\)\*\+,-\.\/:;<=>\?@\[\]\^\{\}~|]
+36:2:31:46:0:-1:0:0:0
+40
+11:4
+12:NULL
+36:4:31:-1:0:-1:0:0:0
+41
+35:3
+11:6
+12:[\r\n]
+36:2:40:-1:0:2:0:0:0
+40
+11:4
+12:NULL
+36:4:40:-1:0:-1:0:0:0
+41
+35:4
+11:2
+12:*/
+36:1:-1:41:0:2:0:0:0
+40
+11:4
+12:NULL
+36:4:41:-1:0:-1:0:0:0
+41
+35:5
+11:1
+12:"
+36:1:-1:43:0:2:0:0:0
+40
+11:3
+12:\\.
+36:2:-1:-1:0:-1:0:0:0
+40
+11:4
+12:NULL
+36:4:43:-1:0:-1:0:0:0
+41
+35:6
+11:1
+12:'
+36:1:-1:43:0:2:0:0:0
+40
+11:3
+12:\\.
+36:2:-1:-1:0:-1:0:0:0
+40
+11:4
+12:NULL
+36:4:43:-1:0:-1:0:0:0
+41
+35:7
+11:1
+12:`
+36:1:-1:43:0:2:0:0:0
+40
+11:3
+12:\\.
+36:2:-1:-1:0:-1:0:0:0
+40
+11:4
+12:NULL
+36:4:43:-1:0:-1:0:0:0
+41
+35:8
+11:2
+12:*)
+36:1:-1:41:0:2:0:0:0
+40
+11:4
+12:NULL
+36:4:41:-1:0:-1:0:0:0
+41

build/xpi/pylib/cile_go.py

+#!/usr/bin/env python
+
+"""A Code Intelligence Language Engine for the Go language.
+
+A "Language Engine" is responsible for scanning content of
+its language and generating CIX output that represents an outline of
+the code elements in that content. See the CIX (Code Intelligence XML)
+format:
+    http://community.activestate.com/faq/codeintel-cix-schema
+    
+Module Usage:
+    from cile_go import scan
+    mtime = os.stat("bar.go")[stat.ST_MTIME]
+    content = open("bar.go", "r").read()
+    scan(content, "bar.go", mtime=mtime)
+"""
+
+__version__ = "1.0.0"
+
+import os
+import sys
+import time
+import optparse
+import logging
+import pprint
+import glob
+
+# Note: c*i*ElementTree is the codeintel system's slightly modified
+# cElementTree. Use it exactly as you would the normal cElementTree API:
+#   http://effbot.org/zone/element-index.htm
+import ciElementTree as ET
+
+from codeintel2.common import CILEError
+
+
+
+#---- exceptions
+
+class GoCILEError(CILEError):
+    pass
+
+
+
+#---- global data
+
+log = logging.getLogger("cile.go")
+#log.setLevel(logging.DEBUG)
+
+
+
+#---- public module interface
+
+def scan_buf(buf, mtime=None, lang="Go"):
+    """Scan the given GoBuffer return an ElementTree (conforming
+    to the CIX schema) giving a summary of its code elements.
+    
+    @param buf {GoBuffer} is the Go buffer to scan
+    @param mtime {int} is a modified time for the file (in seconds since
+        the "epoch"). If it is not specified the _current_ time is used.
+        Note that the default is not to stat() the file and use that
+        because the given content might not reflect the saved file state.
+    """
+    # Dev Notes:
+    # - This stub implementation of the Go CILE return an "empty"
+    #   summary for the given content, i.e. CIX content that says "there
+    #   are no code elements in this Go content".
+    # - Use the following command (in the extension source dir) to
+    #   debug/test your scanner:
+    #       codeintel scan -p -l Go <example-Go-file>
+    #   "codeintel" is a script available in the Komodo SDK.
+    log.info("scan '%s'", buf.path)
+    if mtime is None:
+        mtime = int(time.time())
+
+    # The 'path' attribute must use normalized dir separators.
+    if sys.platform.startswith("win"):
+        path = buf.path.replace('\\', '/')
+    else:
+        path = buf.path
+        
+    tree = ET.Element("codeintel", version="2.0",
+                      xmlns="urn:activestate:cix:2.0")
+    file = ET.SubElement(tree, "file", lang=lang, mtime=str(mtime))
+    blob = ET.SubElement(file, "scope", ilk="blob", lang=lang,
+                         name=os.path.basename(path))
+
+    # Dev Note:
+    # This is where you process the Go content and add CIX elements
+    # to 'blob' as per the CIX schema (cix-2.0.rng). Use the
+    # "buf.accessor" API (see class Accessor in codeintel2.accessor) to
+    # analyze. For example:
+    # - A token stream of the content is available via:
+    #       buf.accessor.gen_tokens()
+    #   Use the "codeintel html -b <example-Go-file>" command as
+    #   a debugging tool.
+    # - "buf.accessor.text" is the whole content of the file. If you have
+    #   a separate tokenizer/scanner tool for Go content, you may
+    #   want to use it.
+
+    return tree
+
+

build/xpi/pylib/codeintel_go.py

+#!/usr/bin/env python
+
+"""Go support for codeintel.
+
+This file will be imported by the codeintel system on startup and the
+register() function called to register this language with the system. All
+Code Intelligence for this language is controlled through this module.
+"""
+
+import os
+import sys
+import logging
+
+from codeintel2.common import *
+from codeintel2.citadel import CitadelBuffer
+from codeintel2.langintel import LangIntel
+from codeintel2.udl import UDLBuffer, UDLCILEDriver, UDLLexer
+from codeintel2.util import CompareNPunctLast
+
+from SilverCity.ScintillaConstants import (
+    SCE_UDL_SSL_DEFAULT, SCE_UDL_SSL_IDENTIFIER,
+    SCE_UDL_SSL_OPERATOR, SCE_UDL_SSL_VARIABLE, SCE_UDL_SSL_WORD,
+)
+
+try:
+    from xpcom.server import UnwrapObject
+    _xpcom_ = True
+except ImportError:
+    _xpcom_ = False
+
+
+
+#---- globals
+
+lang = "Go"
+log = logging.getLogger("codeintel.go")
+#log.setLevel(logging.DEBUG)
+
+
+# These keywords are copied from "Go-mainlex.udl" - be sure to keep both
+# of them in sync.
+keywords = [
+    # Keywords
+        "break",
+        "case",
+        "chan",
+        "const",
+        "continue",
+        "default",
+        "defer",
+        "else",
+        "fallthrough",
+        "for",
+        "func",
+        "go",
+        "goto",
+        "if",
+        "import",
+        "interface",
+        "map",
+        "package",
+        "range",
+        "return",
+        "select",
+        "struct",
+        "switch",
+        "type",
+        "var"
+
+]
+
+#---- Lexer class
+
+# Dev Notes:
+# Komodo's editing component is based on scintilla (scintilla.org). This
+# project provides C++-based lexers for a number of languages -- these
+# lexers are used for syntax coloring and folding in Komodo. Komodo also
+# has a UDL system for writing UDL-based lexers that is simpler than
+# writing C++-based lexers and has support for multi-language files.
+#
+# The codeintel system has a Lexer class that is a wrapper around these
+# lexers. You must define a Lexer class for lang Go. If Komodo's
+# scintilla lexer for Go is UDL-based, then this is simply:
+#
+#   from codeintel2.udl import UDLLexer
+#   class GoLexer(UDLLexer):
+#       lang = lang
+#
+# Otherwise (the lexer for Go is one of Komodo's existing C++ lexers
+# then this is something like the following. See lang_python.py or
+# lang_perl.py in your Komodo installation for an example. "SilverCity"
+# is the name of a package that provides Python module APIs for Scintilla
+# lexers.
+#
+#   import SilverCity
+#   from SilverCity.Lexer import Lexer
+#   from SilverCity import ScintillaConstants
+#   class GoLexer(Lexer):
+#       lang = lang
+#       def __init__(self):
+#           self._properties = SilverCity.PropertySet()
+#           self._lexer = SilverCity.find_lexer_module_by_id(ScintillaConstants.SCLEX_GO)
+#           self._keyword_lists = [
+#               # Dev Notes: What goes here depends on the C++ lexer
+#               # implementation.
+#           ]
+
+
+from codeintel2.udl import UDLLexer
+class GoLexer(UDLLexer):
+        lang = lang
+
+
+#---- LangIntel class
+
+# Dev Notes:
+# All language should define a LangIntel class. (In some rare cases it
+# isn't needed but there is little reason not to have the empty subclass.)
+#
+# One instance of the LangIntel class will be created for each codeintel
+# language. Code browser functionality and some buffer functionality
+# often defers to the LangIntel singleton.
+#
+# This is especially important for multi-lang files. For example, an
+# HTML buffer uses the JavaScriptLangIntel and the CSSLangIntel for
+# handling codeintel functionality in <script> and <style> tags.
+#
+# See other lang_*.py and codeintel_*.py files in your Komodo installation for
+# examples of usage.
+class GoLangIntel(LangIntel):
+    lang = lang
+
+    ##
+    # Implicit codeintel triggering event, i.e. when typing in the editor.
+    #
+    # @param buf {components.interfaces.koICodeIntelBuffer}
+    # @param pos {int} The cursor position in the editor/text.
+    # @param implicit {bool} Automatically called, else manually called?
+    #
+    def trg_from_pos(self, buf, pos, implicit=True, DEBUG=False, ac=None):
+        #DEBUG = True
+        if pos < 1:
+            return None
+
+        # accessor {codeintel2.accessor.Accessor} - Examine text and styling.
+        accessor = buf.accessor
+        last_pos = pos-1
+        char = accessor.char_at_pos(last_pos)
+        style = accessor.style_at_pos(last_pos)
+        if DEBUG:
+            print "trg_from_pos: char: %r, style: %d" % (char, accessor.style_at_pos(last_pos), )
+        if style in (SCE_UDL_SSL_WORD, SCE_UDL_SSL_IDENTIFIER):
+            # Functions/builtins completion trigger.
+            start, end = accessor.contiguous_style_range_from_pos(last_pos)
+            if DEBUG:
+                print "identifier style, start: %d, end: %d" % (start, end)
+            # Trigger when two characters have been typed.
+            if (last_pos - start) == 1:
+                if DEBUG:
+                    print "triggered:: complete identifiers"
+                return Trigger(self.lang, TRG_FORM_CPLN, "identifiers",
+                               start, implicit,
+                               word_start=start, word_end=end)
+        return None
+
+    ##
+    # Explicit triggering event, i.e. Ctrl+J.
+    #
+    # @param buf {components.interfaces.koICodeIntelBuffer}
+    # @param pos {int} The cursor position in the editor/text.
+    # @param implicit {bool} Automatically called, else manually called?
+    #
+    def preceding_trg_from_pos(self, buf, pos, curr_pos,
+                               preceding_trg_terminators=None, DEBUG=False):
+        #DEBUG = True
+        if pos < 1:
+            return None
+
+        # accessor {codeintel2.accessor.Accessor} - Examine text and styling.
+        accessor = buf.accessor
+        last_pos = pos-1
+        char = accessor.char_at_pos(last_pos)
+        style = accessor.style_at_pos(last_pos)
+        if DEBUG:
+            print "pos: %d, curr_pos: %d" % (pos, curr_pos)
+            print "char: %r, style: %d" % (char, style)
+        if style in (SCE_UDL_SSL_WORD, SCE_UDL_SSL_IDENTIFIER):
+            # Functions/builtins completion trigger.
+            start, end = accessor.contiguous_style_range_from_pos(last_pos)
+            if DEBUG:
+                print "triggered:: complete identifiers"
+            return Trigger(self.lang, TRG_FORM_CPLN, "identifiers",
+                           start, implicit=False,
+                           word_start=start, word_end=end)
+        return None
+
+    ##
+    # Provide the list of completions or the calltip string.
+    # Completions are a list of tuple (type, name) items.
+    #
+    # Note: This example is *not* asynchronous.
+    def async_eval_at_trg(self, buf, trg, ctlr):
+        if _xpcom_:
+            trg = UnwrapObject(trg)
+            ctlr = UnwrapObject(ctlr)
+        pos = trg.pos
+        ctlr.start(buf, trg)
+
+        if trg.id == (self.lang, TRG_FORM_CPLN, "identifiers"):
+            word_start = trg.extra.get("word_start")
+            word_end = trg.extra.get("word_end")
+            if word_start is not None and word_end is not None:
+                # Only return keywords that start with the given 2-char prefix.
+                prefix = buf.accessor.text_range(word_start, word_end)[:2]
+                cplns = [x for x in keywords if x.startswith(prefix)]
+                cplns = [("keyword", x) for x in sorted(cplns, cmp=CompareNPunctLast)]
+                ctlr.set_cplns(cplns)
+                ctlr.done("success")
+                return
+
+        ctlr.error("Unknown trigger type: %r" % (trg, ))
+        ctlr.done("error")
+
+
+#---- Buffer class
+
+# Dev Notes:
+# Every language must define a Buffer class. An instance of this class
+# is created for every file of this language opened in Komodo. Most of
+# that APIs for scanning, looking for autocomplete/calltip trigger points
+# and determining the appropriate completions and calltips are called on
+# this class.
+#
+# Currently a full explanation of these API is beyond the scope of this
+# stub. Resources for more info are:
+# - the base class definitions (Buffer, CitadelBuffer, UDLBuffer) for
+#   descriptions of the APIs
+# - lang_*.py files in your Komodo installation as examples
+# - the upcoming "Anatomy of a Komodo Extension" tutorial
+# - the Komodo community forums:
+#   http://community.activestate.com/products/Komodo
+# - the Komodo discussion lists:
+#   http://listserv.activestate.com/mailman/listinfo/komodo-discuss
+#   http://listserv.activestate.com/mailman/listinfo/komodo-beta
+#
+class GoBuffer(UDLBuffer):
+    # Dev Note: What to sub-class from?
+    # - If this is a UDL-based language: codeintel2.udl.UDLBuffer
+    # - Else if this is a programming language (it has functions,
+    #   variables, classes, etc.): codeintel2.citadel.CitadelBuffer
+    # - Otherwise: codeintel2.buffer.Buffer
+    lang = lang
+
+    # Uncomment and assign the appropriate languages - these are used to
+    # determine which language controls the completions for a given UDL family.
+    #m_lang = "HTML"
+    #m_lang = "XML"
+    #css_lang = "CSS"
+    #csl_lang = "JavaScript"
+    ssl_lang = "Go"
+    #tpl_lang = "Go"
+
+    cb_show_if_empty = True
+
+    # Close the completion dialog when encountering any of these chars.
+    cpln_stop_chars = " ()*-=+<>{}[]^&|;:'\",.?~`!@#%\\/"
+
+
+#---- CILE Driver class
+
+# Dev Notes:
+# A CILE (Code Intelligence Language Engine) is the code that scans
+# Go content and returns a description of the code in that file.
+# See "cile_go.py" for more details.
+#
+# The CILE Driver is a class that calls this CILE. If Go is
+# multi-lang (i.e. can contain sections of different language content,
+# e.g. HTML can contain markup, JavaScript and CSS), then you will need
+# to also implement "scan_multilang()".
+class GoCILEDriver(UDLCILEDriver):
+    lang = lang
+
+    def scan_purelang(self, buf):
+        import cile_go
+        return cile_go.scan_buf(buf)
+
+
+
+
+#---- registration
+
+def register(mgr):
+    """Register language support with the Manager."""
+    mgr.set_lang_info(
+        lang,
+        silvercity_lexer=GoLexer(),
+        buf_class=GoBuffer,
+        langintel_class=GoLangIntel,
+        import_handler_class=None,
+        cile_driver_class=GoCILEDriver,
+        # Dev Note: set to false if this language does not support
+        # autocomplete/calltips.
+        is_cpln_lang=True)
+

build/xpi/templates/All Languages/Go.go

Empty file added.

build/xpi/templates/Common/Go.go

Empty file added.

build/xpi/udl/go-mainlex.udl

+# UDL lexer for Go.
+#
+# Note: UDL is a state machine and it uses regular expressions to move between
+#       the different language states.
+#
+
+language Go
+
+################ Boilerplate ################
+
+# Boilerplate - need to start with family set to markup and IN_M_DEFAULT state,
+# we'll later perform a null-transition change to get into the SSL state.
+family markup
+initial IN_M_DEFAULT
+# Null-transition to get into SSL state
+state IN_M_DEFAULT:
+/./ : redo, => IN_SSL_DEFAULT
+
+################ Language Start ################
+
+family ssl # server side language
+
+# Specify the min and max styles we'll be referring to.
+start_style SSL_DEFAULT
+end_style SSL_VARIABLE
+
+# If the language has keywords, specify which style needs to be transformed
+keyword_style SSL_IDENTIFIER => SSL_WORD
+keywords [
+        # Keywords
+        "break",
+        "case",
+        "chan",
+        "const",
+        "continue",
+        "default",
+        "defer",
+        "else",
+        "fallthrough",
+        "for",
+        "func",
+        "go",
+        "goto",
+        "if",
+        "import",
+        "interface",
+        "map",
+        "package",
+        "range",
+        "return",
+        "select",
+        "struct",
+        "switch",
+        "type",
+        "var"
+
+        ]
+
+# Set the basic patterns we'll be using for styling transitions.
+# For most programming languages, names cannot start with a number, but they
+# often allow a number after the first character - e.g. "bar21a"
+pattern FIRSTNAMECHAR = '_a-zA-Z\x80-\xff' # names (identifier, keyword, variable...) only can start with these chars
+pattern NAMECHAR = '$FIRSTNAMECHAR\d'      # rest of the name, after the first char
+pattern WS = '\s\t\r\n'                    # whitespace
+pattern OP = '!#%&\(\)\*\+,-\.\/:;<=>\?@\[\]\^\{\}~|'  # operator characters - escaping special regex values
+
+################ Default Style ################
+
+# Define what happens when in default (initial) state. This is where we set up
+# the transitions to other states.
+state IN_SSL_DEFAULT:
+
+# ----------- Entering Comments ---------- #
+
+# C-style one line comments
+'//' : paint(upto, SSL_DEFAULT),  => IN_SSL_COMMENT_TO_EOL
+
+# Hash-style one line comments
+#'#' : paint(upto, SSL_DEFAULT),  => IN_SSL_COMMENT_TO_EOL
+
+# SQL-style one line comments
+#'--' : paint(upto, SSL_DEFAULT),  => IN_SSL_COMMENT_TO_EOL
+
+# Lisp-style one line comments
+#';' : paint(upto, SSL_DEFAULT),  => IN_SSL_COMMENT_TO_EOL
+
+# Erlang-style one line comments
+#'%' : paint(upto, SSL_DEFAULT),  => IN_SSL_COMMENT_TO_EOL
+
+# C-style block comments
+'/*' : paint(upto, SSL_DEFAULT), => IN_SSL_COMMENT_C_BLOCK
+
+# Pascal-style block comments
+#'(*' : paint(upto, SSL_DEFAULT), => IN_SSL_COMMENT_PASCAL_BLOCK
+
+# ----------- Entering Whitespace ---------- #
+
+# Just stay in whatever style we currently are using.
+/[$WS]+/  : #stay
+
+# ----------- Entering Strings ---------- #
+
+'"' : paint(upto, SSL_DEFAULT), => IN_SSL_DSTRING
+'\'' : paint(upto, SSL_DEFAULT), => IN_SSL_SSTRING
+'`' : paint(upto, SSL_DEFAULT), => IN_SSL_XSTRING
+
+# ----------- Entering Numbers ---------- #
+
+# Go process a number, try to do it in regexes octal and hex first.
+/0[Xx][0-9a-fA-F]+/ : paint(upto, SSL_DEFAULT), paint(include, SSL_NUMBER)  # Hex numbers
+/[-+]?0[0-7]*/ : paint(upto, SSL_DEFAULT), paint(include, SSL_NUMBER)       # Octal numbers
+/[-+]?[1-9]+/ : paint(upto, SSL_DEFAULT), paint(include, SSL_NUMBER)        # Regular numbers
+
+# ----------- Entering Identifiers ---------- #
+
+/[$FIRSTNAMECHAR][$NAMECHAR]*/ : paint(upto, SSL_DEFAULT), paint(include, SSL_IDENTIFIER)
+
+# ----------- Entering Operators ---------- #
+
+/[$OP]/ : paint(upto, SSL_DEFAULT), paint(include, SSL_OPERATOR)
+
+
+################ In Comments - determines how we exit a comment ################
+
+state IN_SSL_COMMENT_TO_EOL: 
+/[\r\n]/ : paint(upto, SSL_COMMENT), => IN_SSL_DEFAULT  # back to default state
+
+state IN_SSL_COMMENT_C_BLOCK: 
+'*/' : paint(include, SSL_COMMENTBLOCK), => IN_SSL_DEFAULT  # back to default state
+
+state IN_SSL_COMMENT_PASCAL_BLOCK: 
+'*)' : paint(include, SSL_COMMENTBLOCK), => IN_SSL_DEFAULT  # back to default state
+
+################ In Strings - determines how we exit a string ################
+
+state IN_SSL_DSTRING:
+'"' : paint(include, SSL_STRING), => IN_SSL_DEFAULT  # back to default state
+/\\./ : #stay, anything escaped means it's still a string
+
+state IN_SSL_SSTRING:
+'\'' : paint(include, SSL_STRING), => IN_SSL_DEFAULT  # back to default state
+/\\./ : #stay, anything escaped means it's still a string
+
+state IN_SSL_XSTRING:
+'`' : paint(include, SSL_STRING), => IN_SSL_DEFAULT  # back to default state
+/\\./ : #stay, anything escaped means it's still a string
+
+################ End of State Handling ################
+
+
+################ Fold Handling ################
+
+# Uncomment to enable folding on "{" and "}"
+
+fold "{" SSL_OPERATOR +
+fold "}" SSL_OPERATOR -
+
+################ End of Fold Handling ################
+content komogogo for komodo content/
+skin komogogo for komodo classic/1.0 skin/
+locale komogogo for komodo en-US locale/en-US/
+

components/koGo_UDL_Language.py

+# Registers the Go language in Komodo.
+
+import logging
+from koUDLLanguageBase import KoUDLLanguage
+
+log = logging.getLogger("koGoLanguage")
+#log.setLevel(logging.DEBUG)
+
+def registerLanguage(registry):
+    log.debug("Registering language Go")
+    registry.registerLanguage(KoGoLanguage())
+
+class KoGoLanguage(KoUDLLanguage):
+
+    # ------------ Komodo Registration Information ------------ #
+
+    name = "Go"
+    lexresLangName = "Go"
+    _reg_desc_ = "%s Language" % name
+    _reg_contractid_ = "@activestate.com/koLanguage?language=%s;1" % name
+    _reg_categories_ = [("komodo-language", name)]
+    _reg_clsid_ = "4359deb5-4fec-4426-81fb-08a8e55abf73"
+    defaultExtension = '.go'
+
+    # ------------ Commenting Controls ------------ #
+
+    commentDelimiterInfo = {
+        "line": [
+                '//',   # C-style one line comments
+                #'#',    # Hash-style one line comments
+                #'--',   # SQL-style one line comments
+                #';',    # Lisp-style one line comments
+                #'%',    # Erlang-style one line comments
+                ],
+        "block": [
+                ('/*', '*/')   # C-style block comments
+                #('(*', '*)')   # Pascal-style block comments
+                ],
+    }
+
+    # ------------ Indentation Controls ------------ #
+
+    # To support automatic indenting and dedenting after "{([" and "})]"
+    supportsSmartIndent = "brace"
+    # Other smart indenting types are:
+    #   'text', 'python', 'XML' and 'keyword'
+
+    # Indent/dedent after these words.
+    #_indenting_statements = ['case']
+    #_dedenting_statements = ['return', 'break', 'continue']
+
+    # ------------ Sub-language Controls ------------ #
+
+    #Check: Update 'lang_from_udl_family' as appropriate for your
+    #      lexer definition. There are four UDL language families:
+    #           M (markup), i.e. HTML or XML
+    #           CSL (client-side language), e.g. JavaScript
+    #           SSL (server-side language), e.g. Perl, PHP, Python
+    #           TPL (template language), e.g. RHTML, Django, Smarty
+    #      'lang_from_udl_family' maps each UDL family code (M,
+    #      CSL, ...) to the sub-language name in your language.
+    #      Some examples:
+    #        lang_from_udl_family = {   # A PHP file can contain
+    #           'M': 'HTML',            #   HTML
+    #           'SSL': 'PHP',           #   PHP
+    #           'CSL': 'JavaScript',    #   JavaScript
+    #        }
+    #        lang_from_udl_family = {   # An RHTML file can contain
+    #           'M': 'HTML',            #   HTML
+    #           'SSL': 'Ruby',          #   Ruby
+    #           'CSL': 'JavaScript',    #   JavaScript
+    #           'TPL': 'RHTML',         #   RHTML template code
+    #        }
+    #        lang_from_udl_family = {   # A plain XML can just contain
+    #           'M': 'XML',             #   XML
+    #        }
+    lang_from_udl_family = {'SSL': 'Go'}
+<?xml version="1.0"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+    <Description about="urn:mozilla:install-manifest">
+        <em:id>komogo___go_for_komodo@www.justinweeks.info</em:id>
+        <em:name>komogo___go_for_komodo</em:name>
+        <em:version>0.1</em:version>
+        <em:description>KomoGo is a language extension for Activestate Komodo for the Go language (http://www.golang.org).</em:description>
+        <em:creator>Justin Weeks</em:creator>
+        <em:homepageURL>http://www.justinweeks.info/KomoGo</em:homepageURL>
+        <em:type>2</em:type> <!-- type=extension --> 
+
+        <em:targetApplication>
+            <Description>
+                <!-- Komodo IDE's uuid -->
+                <em:id>{36E66FA0-F259-11D9-850E-000D935D3368}</em:id>
+                <em:minVersion>6.0</em:minVersion>
+                <em:maxVersion>7.*</em:maxVersion>
+            </Description>
+        </em:targetApplication>
+        <em:targetApplication>
+            <Description>
+                <!-- Komodo Edit's uuid -->
+                <em:id>{b1042fb5-9e9c-11db-b107-000d935d3368}</em:id>
+                <em:minVersion>6.0</em:minVersion>
+                <em:maxVersion>7.*</em:maxVersion>
+            </Description>
+        </em:targetApplication>
+    </Description>
+</RDF>
+#!/usr/bin/env python
+
+"""A Code Intelligence Language Engine for the Go language.
+
+A "Language Engine" is responsible for scanning content of
+its language and generating CIX output that represents an outline of
+the code elements in that content. See the CIX (Code Intelligence XML)
+format:
+    http://community.activestate.com/faq/codeintel-cix-schema
+    
+Module Usage:
+    from cile_go import scan
+    mtime = os.stat("bar.go")[stat.ST_MTIME]
+    content = open("bar.go", "r").read()
+    scan(content, "bar.go", mtime=mtime)
+"""
+
+__version__ = "1.0.0"
+
+import os
+import sys
+import time
+import optparse
+import logging
+import pprint
+import glob
+
+# Note: c*i*ElementTree is the codeintel system's slightly modified
+# cElementTree. Use it exactly as you would the normal cElementTree API:
+#   http://effbot.org/zone/element-index.htm
+import ciElementTree as ET
+
+from codeintel2.common import CILEError
+
+
+
+#---- exceptions
+
+class GoCILEError(CILEError):
+    pass
+
+
+
+#---- global data
+
+log = logging.getLogger("cile.go")
+#log.setLevel(logging.DEBUG)
+
+
+
+#---- public module interface
+
+def scan_buf(buf, mtime=None, lang="Go"):
+    """Scan the given GoBuffer return an ElementTree (conforming
+    to the CIX schema) giving a summary of its code elements.
+    
+    @param buf {GoBuffer} is the Go buffer to scan
+    @param mtime {int} is a modified time for the file (in seconds since
+        the "epoch"). If it is not specified the _current_ time is used.
+        Note that the default is not to stat() the file and use that
+        because the given content might not reflect the saved file state.
+    """
+    # Dev Notes:
+    # - This stub implementation of the Go CILE return an "empty"
+    #   summary for the given content, i.e. CIX content that says "there
+    #   are no code elements in this Go content".
+    # - Use the following command (in the extension source dir) to
+    #   debug/test your scanner:
+    #       codeintel scan -p -l Go <example-Go-file>
+    #   "codeintel" is a script available in the Komodo SDK.
+    log.info("scan '%s'", buf.path)
+    if mtime is None:
+        mtime = int(time.time())
+
+    # The 'path' attribute must use normalized dir separators.
+    if sys.platform.startswith("win"):
+        path = buf.path.replace('\\', '/')
+    else:
+        path = buf.path
+        
+    tree = ET.Element("codeintel", version="2.0",
+                      xmlns="urn:activestate:cix:2.0")
+    file = ET.SubElement(tree, "file", lang=lang, mtime=str(mtime))
+    blob = ET.SubElement(file, "scope", ilk="blob", lang=lang,
+                         name=os.path.basename(path))
+
+    # Dev Note:
+    # This is where you process the Go content and add CIX elements
+    # to 'blob' as per the CIX schema (cix-2.0.rng). Use the
+    # "buf.accessor" API (see class Accessor in codeintel2.accessor) to
+    # analyze. For example:
+    # - A token stream of the content is available via:
+    #       buf.accessor.gen_tokens()
+    #   Use the "codeintel html -b <example-Go-file>" command as
+    #   a debugging tool.
+    # - "buf.accessor.text" is the whole content of the file. If you have
+    #   a separate tokenizer/scanner tool for Go content, you may
+    #   want to use it.
+
+    return tree
+
+

pylib/codeintel_go.py

+#!/usr/bin/env python
+
+"""Go support for codeintel.
+
+This file will be imported by the codeintel system on startup and the
+register() function called to register this language with the system. All
+Code Intelligence for this language is controlled through this module.
+"""
+
+import os
+import sys
+import logging
+
+from codeintel2.common import *
+from codeintel2.citadel import CitadelBuffer
+from codeintel2.langintel import LangIntel
+from codeintel2.udl import UDLBuffer, UDLCILEDriver, UDLLexer
+from codeintel2.util import CompareNPunctLast
+
+from SilverCity.ScintillaConstants import (
+    SCE_UDL_SSL_DEFAULT, SCE_UDL_SSL_IDENTIFIER,
+    SCE_UDL_SSL_OPERATOR, SCE_UDL_SSL_VARIABLE, SCE_UDL_SSL_WORD,
+)
+
+try:
+    from xpcom.server import UnwrapObject
+    _xpcom_ = True
+except ImportError:
+    _xpcom_ = False
+
+
+
+#---- globals
+
+lang = "Go"
+log = logging.getLogger("codeintel.go")
+#log.setLevel(logging.DEBUG)
+
+
+# These keywords are copied from "Go-mainlex.udl" - be sure to keep both
+# of them in sync.
+keywords = [
+    # Keywords
+        "break",
+        "case",
+        "chan",
+        "const",
+        "continue",
+        "default",
+        "defer",
+        "else",
+        "fallthrough",
+        "for",
+        "func",
+        "go",
+        "goto",
+        "if",
+        "import",
+        "interface",
+        "map",
+        "package",
+        "range",
+        "return",
+        "select",
+        "struct",
+        "switch",
+        "type",
+        "var"
+
+]
+
+#---- Lexer class
+
+# Dev Notes:
+# Komodo's editing component is based on scintilla (scintilla.org). This
+# project provides C++-based lexers for a number of languages -- these
+# lexers are used for syntax coloring and folding in Komodo. Komodo also
+# has a UDL system for writing UDL-based lexers that is simpler than
+# writing C++-based lexers and has support for multi-language files.
+#
+# The codeintel system has a Lexer class that is a wrapper around these
+# lexers. You must define a Lexer class for lang Go. If Komodo's
+# scintilla lexer for Go is UDL-based, then this is simply:
+#
+#   from codeintel2.udl import UDLLexer
+#   class GoLexer(UDLLexer):
+#       lang = lang
+#
+# Otherwise (the lexer for Go is one of Komodo's existing C++ lexers
+# then this is something like the following. See lang_python.py or
+# lang_perl.py in your Komodo installation for an example. "SilverCity"
+# is the name of a package that provides Python module APIs for Scintilla
+# lexers.
+#
+#   import SilverCity
+#   from SilverCity.Lexer import Lexer
+#   from SilverCity import ScintillaConstants
+#   class GoLexer(Lexer):
+#       lang = lang
+#       def __init__(self):
+#           self._properties = SilverCity.PropertySet()
+#           self._lexer = SilverCity.find_lexer_module_by_id(ScintillaConstants.SCLEX_GO)
+#           self._keyword_lists = [
+#               # Dev Notes: What goes here depends on the C++ lexer
+#               # implementation.
+#           ]
+
+
+from codeintel2.udl import UDLLexer
+class GoLexer(UDLLexer):
+        lang = lang
+
+
+#---- LangIntel class
+
+# Dev Notes:
+# All language should define a LangIntel class. (In some rare cases it
+# isn't needed but there is little reason not to have the empty subclass.)
+#
+# One instance of the LangIntel class will be created for each codeintel
+# language. Code browser functionality and some buffer functionality
+# often defers to the LangIntel singleton.
+#
+# This is especially important for multi-lang files. For example, an
+# HTML buffer uses the JavaScriptLangIntel and the CSSLangIntel for
+# handling codeintel functionality in <script> and <style> tags.
+#
+# See other lang_*.py and codeintel_*.py files in your Komodo installation for
+# examples of usage.
+class GoLangIntel(LangIntel):
+    lang = lang
+
+    ##
+    # Implicit codeintel triggering event, i.e. when typing in the editor.
+    #
+    # @param buf {components.interfaces.koICodeIntelBuffer}
+    # @param pos {int} The cursor position in the editor/text.
+    # @param implicit {bool} Automatically called, else manually called?
+    #
+    def trg_from_pos(self, buf, pos, implicit=True, DEBUG=False, ac=None):
+        #DEBUG = True
+        if pos < 1:
+            return None
+
+        # accessor {codeintel2.accessor.Accessor} - Examine text and styling.
+        accessor = buf.accessor
+        last_pos = pos-1
+        char = accessor.char_at_pos(last_pos)
+        style = accessor.style_at_pos(last_pos)
+        if DEBUG:
+            print "trg_from_pos: char: %r, style: %d" % (char, accessor.style_at_pos(last_pos), )
+        if style in (SCE_UDL_SSL_WORD, SCE_UDL_SSL_IDENTIFIER):
+            # Functions/builtins completion trigger.
+            start, end = accessor.contiguous_style_range_from_pos(last_pos)
+            if DEBUG:
+                print "identifier style, start: %d, end: %d" % (start, end)
+            # Trigger when two characters have been typed.
+            if (last_pos - start) == 1:
+                if DEBUG:
+                    print "triggered:: complete identifiers"
+                return Trigger(self.lang, TRG_FORM_CPLN, "identifiers",
+                               start, implicit,
+                               word_start=start, word_end=end)
+        return None
+
+    ##
+    # Explicit triggering event, i.e. Ctrl+J.
+    #
+    # @param buf {components.interfaces.koICodeIntelBuffer}
+    # @param pos {int} The cursor position in the editor/text.
+    # @param implicit {bool} Automatically called, else manually called?
+    #
+    def preceding_trg_from_pos(self, buf, pos, curr_pos,
+                               preceding_trg_terminators=None, DEBUG=False):
+        #DEBUG = True
+        if pos < 1:
+            return None
+
+        # accessor {codeintel2.accessor.Accessor} - Examine text and styling.
+        accessor = buf.accessor
+        last_pos = pos-1
+        char = accessor.char_at_pos(last_pos)
+        style = accessor.style_at_pos(last_pos)
+        if DEBUG:
+            print "pos: %d, curr_pos: %d" % (pos, curr_pos)
+            print "char: %r, style: %d" % (char, style)
+        if style in (SCE_UDL_SSL_WORD, SCE_UDL_SSL_IDENTIFIER):
+            # Functions/builtins completion trigger.
+            start, end = accessor.contiguous_style_range_from_pos(last_pos)
+            if DEBUG:
+                print "triggered:: complete identifiers"
+            return Trigger(self.lang, TRG_FORM_CPLN, "identifiers",
+                           start, implicit=False,
+                           word_start=start, word_end=end)
+        return None
+
+    ##
+    # Provide the list of completions or the calltip string.
+    # Completions are a list of tuple (type, name) items.
+    #
+    # Note: This example is *not* asynchronous.
+    def async_eval_at_trg(self, buf, trg, ctlr):
+        if _xpcom_:
+            trg = UnwrapObject(trg)
+            ctlr = UnwrapObject(ctlr)
+        pos = trg.pos
+        ctlr.start(buf, trg)
+
+        if trg.id == (self.lang, TRG_FORM_CPLN, "identifiers"):
+            word_start = trg.extra.get("word_start")
+            word_end = trg.extra.get("word_end")
+            if word_start is not None and word_end is not None:
+                # Only return keywords that start with the given 2-char prefix.
+                prefix = buf.accessor.text_range(word_start, word_end)[:2]
+                cplns = [x for x in keywords if x.startswith(prefix)]
+                cplns = [("keyword", x) for x in sorted(cplns, cmp=CompareNPunctLast)]
+                ctlr.set_cplns(cplns)
+                ctlr.done("success")
+                return
+
+        ctlr.error("Unknown trigger type: %r" % (trg, ))
+        ctlr.done("error")
+
+
+#---- Buffer class
+
+# Dev Notes:
+# Every language must define a Buffer class. An instance of this class
+# is created for every file of this language opened in Komodo. Most of
+# that APIs for scanning, looking for autocomplete/calltip trigger points
+# and determining the appropriate completions and calltips are called on
+# this class.
+#
+# Currently a full explanation of these API is beyond the scope of this
+# stub. Resources for more info are:
+# - the base class definitions (Buffer, CitadelBuffer, UDLBuffer) for
+#   descriptions of the APIs
+# - lang_*.py files in your Komodo installation as examples
+# - the upcoming "Anatomy of a Komodo Extension" tutorial
+# - the Komodo community forums:
+#   http://community.activestate.com/products/Komodo
+# - the Komodo discussion lists:
+#   http://listserv.activestate.com/mailman/listinfo/komodo-discuss
+#   http://listserv.activestate.com/mailman/listinfo/komodo-beta
+#
+class GoBuffer(UDLBuffer):
+    # Dev Note: What to sub-class from?
+    # - If this is a UDL-based language: codeintel2.udl.UDLBuffer
+    # - Else if this is a programming language (it has functions,
+    #   variables, classes, etc.): codeintel2.citadel.CitadelBuffer
+    # - Otherwise: codeintel2.buffer.Buffer
+    lang = lang
+
+    # Uncomment and assign the appropriate languages - these are used to
+    # determine which language controls the completions for a given UDL family.
+    #m_lang = "HTML"
+    #m_lang = "XML"
+    #css_lang = "CSS"
+    #csl_lang = "JavaScript"
+    ssl_lang = "Go"
+    #tpl_lang = "Go"
+
+    cb_show_if_empty = True
+
+    # Close the completion dialog when encountering any of these chars.
+    cpln_stop_chars = " ()*-=+<>{}[]^&|;:'\",.?~`!@#%\\/"
+
+
+#---- CILE Driver class
+
+# Dev Notes:
+# A CILE (Code Intelligence Language Engine) is the code that scans
+# Go content and returns a description of the code in that file.
+# See "cile_go.py" for more details.
+#
+# The CILE Driver is a class that calls this CILE. If Go is
+# multi-lang (i.e. can contain sections of different language content,
+# e.g. HTML can contain markup, JavaScript and CSS), then you will need
+# to also implement "scan_multilang()".
+class GoCILEDriver(UDLCILEDriver):
+    lang = lang
+
+    def scan_purelang(self, buf):
+        import cile_go
+        return cile_go.scan_buf(buf)
+
+
+
+
+#---- registration
+
+def register(mgr):
+    """Register language support with the Manager."""
+    mgr.set_lang_info(
+        lang,
+        silvercity_lexer=GoLexer(),
+        buf_class=GoBuffer,
+        langintel_class=GoLangIntel,
+        import_handler_class=None,
+        cile_driver_class=GoCILEDriver,
+        # Dev Note: set to false if this language does not support
+        # autocomplete/calltips.
+        is_cpln_lang=True)
+

templates/All Languages/Go.go

Empty file added.

templates/Common/Go.go

Empty file added.

udl/go-mainlex.udl

+# UDL lexer for Go.
+#
+# Note: UDL is a state machine and it uses regular expressions to move between
+#       the different language states.
+#
+
+language Go
+
+################ Boilerplate ################
+
+# Boilerplate - need to start with family set to markup and IN_M_DEFAULT state,
+# we'll later perform a null-transition change to get into the SSL state.
+family markup
+initial IN_M_DEFAULT
+# Null-transition to get into SSL state
+state IN_M_DEFAULT:
+/./ : redo, => IN_SSL_DEFAULT
+
+################ Language Start ################
+
+family ssl # server side language
+
+# Specify the min and max styles we'll be referring to.
+start_style SSL_DEFAULT
+end_style SSL_VARIABLE
+
+# If the language has keywords, specify which style needs to be transformed
+keyword_style SSL_IDENTIFIER => SSL_WORD
+keywords [
+        # Keywords
+        "break",
+        "case",
+        "chan",
+        "const",
+        "continue",
+        "default",
+        "defer",
+        "else",
+        "fallthrough",
+        "for",
+        "func",
+        "go",
+        "goto",
+        "if",
+        "import",
+        "interface",
+        "map",
+        "package",
+        "range",
+        "return",
+        "select",
+        "struct",
+        "switch",
+        "type",
+        "var"
+
+        ]
+
+# Set the basic patterns we'll be using for styling transitions.
+# For most programming languages, names cannot start with a number, but they
+# often allow a number after the first character - e.g. "bar21a"
+pattern FIRSTNAMECHAR = '_a-zA-Z\x80-\xff' # names (identifier, keyword, variable...) only can start with these chars
+pattern NAMECHAR = '$FIRSTNAMECHAR\d'      # rest of the name, after the first char
+pattern WS = '\s\t\r\n'                    # whitespace
+pattern OP = '!#%&\(\)\*\+,-\.\/:;<=>\?@\[\]\^\{\}~|'  # operator characters - escaping special regex values
+
+################ Default Style ################
+
+# Define what happens when in default (initial) state. This is where we set up
+# the transitions to other states.
+state IN_SSL_DEFAULT:
+
+# ----------- Entering Comments ---------- #
+
+# C-style one line comments
+'//' : paint(upto, SSL_DEFAULT),  => IN_SSL_COMMENT_TO_EOL
+
+# Hash-style one line comments
+#'#' : paint(upto, SSL_DEFAULT),  => IN_SSL_COMMENT_TO_EOL
+
+# SQL-style one line comments
+#'--' : paint(upto, SSL_DEFAULT),  => IN_SSL_COMMENT_TO_EOL
+
+# Lisp-style one line comments
+#';' : paint(upto, SSL_DEFAULT),  => IN_SSL_COMMENT_TO_EOL
+
+# Erlang-style one line comments
+#'%' : paint(upto, SSL_DEFAULT),  => IN_SSL_COMMENT_TO_EOL
+
+# C-style block comments
+'/*' : paint(upto, SSL_DEFAULT), => IN_SSL_COMMENT_C_BLOCK
+
+# Pascal-style block comments
+#'(*' : paint(upto, SSL_DEFAULT), => IN_SSL_COMMENT_PASCAL_BLOCK
+
+# ----------- Entering Whitespace ---------- #
+
+# Just stay in whatever style we currently are using.
+/[$WS]+/  : #stay
+
+# ----------- Entering Strings ---------- #
+
+'"' : paint(upto, SSL_DEFAULT), => IN_SSL_DSTRING
+'\'' : paint(upto, SSL_DEFAULT), => IN_SSL_SSTRING
+'`' : paint(upto, SSL_DEFAULT), => IN_SSL_XSTRING
+
+# ----------- Entering Numbers ---------- #
+
+# Go process a number, try to do it in regexes octal and hex first.
+/0[Xx][0-9a-fA-F]+/ : paint(upto, SSL_DEFAULT), paint(include, SSL_NUMBER)  # Hex numbers
+/[-+]?0[0-7]*/ : paint(upto, SSL_DEFAULT), paint(include, SSL_NUMBER)       # Octal numbers
+/[-+]?[1-9]+/ : paint(upto, SSL_DEFAULT), paint(include, SSL_NUMBER)        # Regular numbers
+
+# ----------- Entering Identifiers ---------- #
+
+/[$FIRSTNAMECHAR][$NAMECHAR]*/ : paint(upto, SSL_DEFAULT), paint(include, SSL_IDENTIFIER)
+
+# ----------- Entering Operators ---------- #
+
+/[$OP]/ : paint(upto, SSL_DEFAULT), paint(include, SSL_OPERATOR)
+
+
+################ In Comments - determines how we exit a comment ################
+
+state IN_SSL_COMMENT_TO_EOL: 
+/[\r\n]/ : paint(upto, SSL_COMMENT), => IN_SSL_DEFAULT  # back to default state
+
+state IN_SSL_COMMENT_C_BLOCK: 
+'*/' : paint(include, SSL_COMMENTBLOCK), => IN_SSL_DEFAULT  # back to default state
+
+state IN_SSL_COMMENT_PASCAL_BLOCK: 
+'*)' : paint(include, SSL_COMMENTBLOCK), => IN_SSL_DEFAULT  # back to default state
+
+################ In Strings - determines how we exit a string ################
+
+state IN_SSL_DSTRING:
+'"' : paint(include, SSL_STRING), => IN_SSL_DEFAULT  # back to default state
+/\\./ : #stay, anything escaped means it's still a string
+
+state IN_SSL_SSTRING:
+'\'' : paint(include, SSL_STRING), => IN_SSL_DEFAULT  # back to default state
+/\\./ : #stay, anything escaped means it's still a string
+
+state IN_SSL_XSTRING:
+'`' : paint(include, SSL_STRING), => IN_SSL_DEFAULT  # back to default state
+/\\./ : #stay, anything escaped means it's still a string
+
+################ End of State Handling ################
+
+
+################ Fold Handling ################
+
+# Uncomment to enable folding on "{" and "}"
+
+fold "{" SSL_OPERATOR +
+fold "}" SSL_OPERATOR -
+
+################ End of Fold Handling ################