* Update Go grammar to atom/language-go@6de3f61

* Updating UT for Go grammar

* More test fixes for Go grammar
This commit is contained in:
Ramya Rao 2017-04-24 14:37:34 -07:00 committed by GitHub
parent 29b2fe53ee
commit 8743507344
4 changed files with 226 additions and 181 deletions

View file

@ -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": "(?<!var )\\s*([a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*)(?=\\s*=[^=])",
"captures": {
"begin": "\\b(import)\\s+",
"beginCaptures": {
"1": {
"patterns": [
{
"match": "[a-zA-Z_]\\w*",
"name": "variable.other.assignment.go"
},
{
"include": "#delimiters"
}
]
"name": "keyword.import.go"
}
}
},
"end": "(?!\\G)",
"patterns": [
{
"include": "#imports"
}
]
},
{
"comment": "Single line variable declarations/assignments",
"match": "(?<=var)\\s+(.*)$",
"captures": {
"1": {
"patterns": [
{
"include": "#variables"
}
]
}
}
},
{
"comment": "Multiline variable declarations/assignments",
"begin": "(\\bvar\\b)\\s+(\\()",
"begin": "\\b(var)\\s+",
"beginCaptures": {
"1": {
"name": "keyword.var.go"
},
"2": {
"name": "punctuation.other.bracket.round.go"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.other.bracket.round.go"
}
},
"end": "(?!\\G)",
"patterns": [
{
"include": "#variables"
},
{
"include": "$self"
}
]
},
{
"match": "(?<!var)\\s*(\\w+(?:,\\s*\\w+)*)(?=\\s*=(?!=))",
"captures": {
"1": {
"patterns": [
{
"match": "\\d\\w*",
"name": "invalid.illegal.identifier.go"
},
{
"match": "\\w+",
"name": "variable.other.assignment.go"
},
{
"include": "#delimiters"
}
]
}
}
},
{
"match": "\\w+(?:,\\s*\\w+)*(?=\\s*:=)",
"captures": {
"0": {
"patterns": [
{
"match": "\\d\\w*",
"name": "invalid.illegal.identifier.go"
},
{
"match": "\\w+",
"name": "variable.other.assignment.go"
},
{
"include": "#delimiters"
}
]
}
}
},
{
"comment": "Terminators",
"match": ";",
@ -375,6 +347,52 @@
}
]
},
"imports": {
"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"
}
}
},
{
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "punctuation.other.bracket.round.go"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.other.bracket.round.go"
}
},
"patterns": [
{
"include": "#imports"
},
{
"include": "#comments"
}
]
}
]
},
"keywords": {
"patterns": [
{
@ -398,29 +416,13 @@
"match": "\\binterface\\b",
"name": "keyword.interface.go"
},
{
"match": "\\bimport\\b",
"name": "keyword.import.go"
},
{
"match": "\\bmap\\b",
"name": "keyword.map.go"
},
{
"match": "\\bpackage\\b",
"name": "keyword.package.go"
},
{
"match": "\\bstruct\\b",
"name": "keyword.struct.go"
},
{
"match": "\\btype\\b",
"name": "keyword.type.go"
},
{
"match": "\\bvar\\b",
"name": "keyword.var.go"
}
]
},
@ -534,15 +536,18 @@
]
},
"variables": {
"comment": "First add tests and make sure existing tests still pass when changing anything here!",
"patterns": [
{
"match": "([a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*)\\s*(=.*)",
"match": "(\\w+(?:,\\s*\\w+)*)(\\s+\\*?\\w+\\s*)?(?=\\s*=)",
"captures": {
"1": {
"patterns": [
{
"match": "[a-zA-Z_]\\w*",
"match": "\\d\\w*",
"name": "invalid.illegal.identifier.go"
},
{
"match": "\\w+",
"name": "variable.other.assignment.go"
},
{
@ -560,42 +565,16 @@
}
},
{
"match": "([a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*)(\\s+[\\*]?[a-zA-Z_]\\w*\\s*)(=.*)",
"match": "(\\w+(?:,\\s*\\w+)*)(\\s+(\\[\\d*\\])*\\*?\\w+\\s*[^=].*)",
"captures": {
"1": {
"patterns": [
{
"match": "[a-zA-Z_]\\w*",
"name": "variable.other.assignment.go"
"match": "\\d\\w*",
"name": "invalid.illegal.identifier.go"
},
{
"include": "#delimiters"
}
]
},
"2": {
"patterns": [
{
"include": "$self"
}
]
},
"3": {
"patterns": [
{
"include": "$self"
}
]
}
}
},
{
"match": "([a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*)(\\s+[\\[\\]\\*]{0,3}[a-zA-Z_]\\w*\\s*[^=].*)",
"captures": {
"1": {
"patterns": [
{
"match": "[a-zA-Z_]\\w*",
"match": "\\w+",
"name": "variable.other.declaration.go"
},
{
@ -611,9 +590,31 @@
]
}
}
},
{
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "punctuation.other.bracket.round.go"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.other.bracket.round.go"
}
},
"patterns": [
{
"include": "#variables"
},
{
"include": "$self"
}
]
}
]
}
},
"version": "https://github.com/atom/language-go/commit/d941ce3155b500e65b4d7fbc53ea51b9c92ec1cb"
"version": "https://github.com/atom/language-go/commit/6de3f61efa8e8afb9ef0d5bc19c797c8469ec9f8"
}

View file

@ -1 +1 @@
var e [][]*aType // ( bug in highligher?)
var e [][]*aType // ( comments after var are now green )

View file

@ -11,7 +11,7 @@
}
},
{
"c": " e [][]*aType // ( ",
"c": " ",
"t": "source.go",
"r": {
"dark_plus": "default: #D4D4D4",
@ -22,7 +22,7 @@
}
},
{
"c": "bug",
"c": "e",
"t": "source.go variable.other.declaration.go",
"r": {
"dark_plus": "variable: #9CDCFE",
@ -33,7 +33,7 @@
}
},
{
"c": " in highligher?",
"c": " ",
"t": "source.go",
"r": {
"dark_plus": "default: #D4D4D4",
@ -44,8 +44,8 @@
}
},
{
"c": ")",
"t": "source.go punctuation.other.bracket.round.go",
"c": "[][]",
"t": "source.go punctuation.other.bracket.square.go",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
@ -53,5 +53,49 @@
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": "*",
"t": "source.go keyword.operator.address.go",
"r": {
"dark_plus": "keyword.operator: #D4D4D4",
"light_plus": "keyword.operator: #000000",
"dark_vs": "keyword.operator: #D4D4D4",
"light_vs": "keyword.operator: #000000",
"hc_black": "keyword.operator: #D4D4D4"
}
},
{
"c": "aType ",
"t": "source.go",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF"
}
},
{
"c": "//",
"t": "source.go comment.line.double-slash.go punctuation.definition.comment.go",
"r": {
"dark_plus": "comment: #608B4E",
"light_plus": "comment: #008000",
"dark_vs": "comment: #608B4E",
"light_vs": "comment: #008000",
"hc_black": "comment: #7CA668"
}
},
{
"c": " ( comments after var are now green )",
"t": "source.go comment.line.double-slash.go",
"r": {
"dark_plus": "comment: #608B4E",
"light_plus": "comment: #008000",
"dark_vs": "comment: #608B4E",
"light_vs": "comment: #008000",
"hc_black": "comment: #7CA668"
}
}
]

View file

@ -188,7 +188,7 @@
},
{
"c": "main",
"t": "source.go entity.name.function",
"t": "source.go entity.name.function.go",
"r": {
"dark_plus": "entity.name.function: #DCDCAA",
"light_plus": "entity.name.function: #795E26",