From 8743507344f335d2a3bb0e4c2b33090b7c059389 Mon Sep 17 00:00:00 2001 From: Ramya Rao Date: Mon, 24 Apr 2017 14:37:34 -0700 Subject: [PATCH] Update Go grammar to atom/language-go@6de3f61 (#25216) * Update Go grammar to atom/language-go@6de3f61 * Updating UT for Go grammar * More test fixes for Go grammar --- extensions/go/syntaxes/go.json | 349 +++++++++--------- .../go/test/colorize-fixtures/test-13777.go | 2 +- .../test/colorize-results/test-13777_go.json | 54 ++- .../go/test/colorize-results/test_go.json | 2 +- 4 files changed, 226 insertions(+), 181 deletions(-) diff --git a/extensions/go/syntaxes/go.json b/extensions/go/syntaxes/go.json index 21be4436592..0cfcf1940ad 100644 --- a/extensions/go/syntaxes/go.json +++ b/extensions/go/syntaxes/go.json @@ -95,7 +95,7 @@ }, { "comment": "Function declarations", - "match": "^(\\bfunc\\b)(?:\\s+(\\([^\\)]+\\)\\s+)?([a-zA-Z_]\\w*)(?=\\())?", + "match": "^(\\bfunc\\b)(?:\\s+(\\([^\\)]+\\)\\s+)?(\\w+)(?=\\())?", "captures": { "1": { "name": "keyword.function.go" @@ -111,19 +111,37 @@ ] }, "3": { - "name": "entity.name.function" + "patterns": [ + { + "match": "\\d\\w*", + "name": "invalid.illegal.identifier.go" + }, + { + "match": "\\w+", + "name": "entity.name.function.go" + } + ] } } }, { "comment": "Functions", - "match": "(\\bfunc\\b)|([a-zA-Z_]\\w*)(?=\\()", + "match": "(\\bfunc\\b)|(\\w+)(?=\\()", "captures": { "1": { "name": "keyword.function.go" }, "2": { - "name": "support.function.go" + "patterns": [ + { + "match": "\\d\\w*", + "name": "invalid.illegal.identifier.go" + }, + { + "match": "\\w+", + "name": "support.function.go" + } + ] } } }, @@ -143,157 +161,111 @@ "name": "constant.language.go" }, { - "comment": "Package declarations", - "match": "(?<=package)\\s+([a-zA-Z_]\\w*)", - "captures": { - "1": { - "name": "entity.name.package.go" - } - } - }, - { - "comment": "Single line import declarations", - "match": "(?<=import)(\\s+((?!\\s+\")[^\\s]*)?\\s*)((\")([^\"]*)(\"))", - "captures": { - "2": { - "name": "entity.alias.import.go" - }, - "3": { - "name": "string.quoted.double.go" - }, - "4": { - "name": "punctuation.definition.string.begin.go" - }, - "5": { - "name": "entity.name.import.go" - }, - "6": { - "name": "punctuation.definition.string.end.go" - } - } - }, - { - "comment": "Multiline import declarations", - "begin": "(?<=import)\\s+(\\()", + "begin": "\\b(package)\\s+", "beginCaptures": { "1": { - "name": "punctuation.other.bracket.round.go" + "name": "keyword.package.go" } }, + "end": "(?!\\G)", "patterns": [ { - "match": "((?!\\s+\")[^\\s]*)?\\s+((\")([^\"]*)(\"))", - "captures": { - "1": { - "name": "entity.alias.import.go" - }, - "2": { - "name": "string.quoted.double.go" - }, - "3": { - "name": "punctuation.definition.string.begin.go" - }, - "4": { - "name": "entity.name.import.go" - }, - "5": { - "name": "punctuation.definition.string.end.go" - } - } + "match": "\\d\\w*", + "name": "invalid.illegal.identifier.go" }, { - "include": "#comments" + "match": "\\w+", + "name": "entity.name.package.go" } - ], - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.other.bracket.round.go" - } - } + ] }, { - "comment": "Type declarations", - "match": "(?<=type)\\s+([a-zA-Z_]\\w*)", - "captures": { + "begin": "\\b(type)\\s+", + "beginCaptures": { "1": { + "name": "keyword.type.go" + } + }, + "end": "(?!\\G)", + "patterns": [ + { + "match": "\\d\\w*", + "name": "invalid.illegal.identifier.go" + }, + { + "match": "\\w+", "name": "entity.name.type.go" } - } + ] }, { - "comment": "Shorthand variable declaration and assignments", - "match": "[a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*(?=\\s*:=)", - "captures": { - "0": { - "patterns": [ - { - "match": "[a-zA-Z_]\\w*", - "name": "variable.other.assignment.go" - }, - { - "include": "#delimiters" - } - ] - } - } - }, - { - "comment": "Assignments to existing variables", - "match": "(?