mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-29 21:11:38 +01:00
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
This commit is contained in:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user