diff --git a/src/Models/TextMateHelper.cs b/src/Models/TextMateHelper.cs index b070c1cf..fdb2cb66 100644 --- a/src/Models/TextMateHelper.cs +++ b/src/Models/TextMateHelper.cs @@ -24,7 +24,7 @@ namespace SourceGit.Models _backend = new RegistryOptions(defaultTheme); _extraGrammars = new List(); - string[] extraGrammarFiles = ["toml.json", "kotlin.json"]; + string[] extraGrammarFiles = ["toml.json", "kotlin.json", "haxe.json", "hxml.json"]; foreach (var file in extraGrammarFiles) { var asset = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/Grammars/{file}", diff --git a/src/Resources/Grammars/haxe.json b/src/Resources/Grammars/haxe.json new file mode 100644 index 00000000..12acc538 --- /dev/null +++ b/src/Resources/Grammars/haxe.json @@ -0,0 +1,2488 @@ +{ + "information_for_contributors": [ + "This file has been copied from https://github.com/vshaxe/haxe-TmLanguage/blob/ddad8b4c6d0781ac20be0481174ec1be772c5da5/haxe.tmLanguage", + "and converted to JSON using https://marketplace.visualstudio.com/items?itemName=pedro-w.tmlanguage" + ], + "fileTypes": [ + "hx", + "dump" + ], + "name": "Haxe", + "scopeName": "source.hx", + "uuid": "67c72f9f-862c-4e48-8951-dcc22c0bb4ea", + "patterns": [ + { + "include": "#all" + } + ], + "repository": { + "all": { + "patterns": [ + { + "include": "#global" + }, + { + "include": "#package" + }, + { + "include": "#import" + }, + { + "include": "#using" + }, + { + "match": "\\b(final)\\b(?=\\s+(class|interface|extern|private)\\b)", + "name": "storage.modifier.hx" + }, + { + "include": "#abstract" + }, + { + "include": "#class" + }, + { + "include": "#enum" + }, + { + "include": "#interface" + }, + { + "include": "#typedef" + }, + { + "include": "#block" + }, + { + "include": "#block-contents" + } + ] + }, + "global": { + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#conditional-compilation" + } + ] + }, + "block": { + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.begin.hx" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.end.hx" + } + }, + "patterns": [ + { + "include": "#block" + }, + { + "include": "#block-contents" + } + ] + }, + "block-contents": { + "patterns": [ + { + "include": "#global" + }, + { + "include": "#regex" + }, + { + "include": "#array" + }, + { + "include": "#constants" + }, + { + "include": "#strings" + }, + { + "include": "#metadata" + }, + { + "include": "#method" + }, + { + "include": "#variable" + }, + { + "include": "#modifiers" + }, + { + "include": "#new-expr" + }, + { + "include": "#for-loop" + }, + { + "include": "#keywords" + }, + { + "include": "#arrow-function" + }, + { + "include": "#method-call" + }, + { + "include": "#enum-constructor-call" + }, + { + "include": "#punctuation-braces" + }, + { + "include": "#macro-reification" + }, + { + "include": "#operators" + }, + { + "include": "#operator-assignment" + }, + { + "include": "#punctuation-terminator" + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#punctuation-accessor" + }, + { + "include": "#identifiers" + } + ] + }, + "identifiers": { + "patterns": [ + { + "include": "#constant-name" + }, + { + "include": "#type-name" + }, + { + "include": "#identifier-name" + } + ] + }, + "package": { + "begin": "package\\b", + "beginCaptures": { + "0": { + "name": "keyword.other.package.hx" + } + }, + "end": "$|(;)", + "endCaptures": { + "1": { + "name": "punctuation.terminator.hx" + } + }, + "patterns": [ + { + "include": "#type-path" + }, + { + "include": "#type-path-package-name" + } + ] + }, + "using": { + "begin": "using\\b", + "beginCaptures": { + "0": { + "name": "keyword.other.using.hx" + } + }, + "end": "$|(;)", + "endCaptures": { + "1": { + "name": "punctuation.terminator.hx" + } + }, + "patterns": [ + { + "include": "#type-path" + }, + { + "include": "#type-path-package-name" + } + ] + }, + "import": { + "begin": "import\\b", + "beginCaptures": { + "0": { + "name": "keyword.control.import.hx" + } + }, + "end": "$|(;)", + "endCaptures": { + "1": { + "name": "punctuation.terminator.hx" + } + }, + "patterns": [ + { + "include": "#type-path" + }, + { + "match": "\\b(as)\\b", + "name": "keyword.control.as.hx" + }, + { + "match": "\\b(in)\\b", + "name": "keyword.control.in.hx" + }, + { + "match": "\\*", + "name": "constant.language.import-all.hx" + }, + { + "match": "\\b([_A-Za-z]\\w*)\\b(?=\\s*(as|in|$|(;)))", + "name": "variable.other.hxt" + }, + { + "include": "#type-path-package-name" + } + ] + }, + "type-path": { + "patterns": [ + { + "include": "#global" + }, + { + "include": "#punctuation-accessor" + }, + { + "include": "#type-path-type-name" + } + ] + }, + "type-path-type-name": { + "match": "\\b(_*[A-Z]\\w*)\\b", + "name": "entity.name.type.hx" + }, + "type-path-package-name": { + "match": "\\b([_A-Za-z]\\w*)\\b", + "name": "support.package.hx" + }, + "abstract": { + "begin": "(?=abstract\\s+[A-Z])", + "end": "(?<=\\})|(;)", + "endCaptures": { + "1": { + "name": "punctuation.terminator.hx" + } + }, + "name": "meta.abstract.hx", + "patterns": [ + { + "include": "#abstract-name" + }, + { + "include": "#abstract-name-post" + }, + { + "include": "#abstract-block" + } + ] + }, + "abstract-name": { + "begin": "\\b(abstract)\\b", + "beginCaptures": { + "1": { + "name": "storage.type.class.hx" + } + }, + "end": "([_A-Za-z]\\w*)", + "endCaptures": { + "1": { + "name": "entity.name.type.class.hx" + } + }, + "patterns": [ + { + "include": "#global" + } + ] + }, + "abstract-name-post": { + "begin": "(?<=\\w)", + "end": "([\\{;])", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.begin.hx" + } + }, + "patterns": [ + { + "include": "#global" + }, + { + "match": "\\b(from|to)\\b", + "name": "keyword.other.hx" + }, + { + "include": "#type" + }, + { + "match": "[\\(\\)]", + "name": "punctuation.definition.other.hx" + } + ] + }, + "abstract-block": { + "begin": "(?<=\\{)", + "end": "(\\})", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.end.hx" + } + }, + "name": "meta.block.hx", + "patterns": [ + { + "include": "#method" + }, + { + "include": "#modifiers" + }, + { + "include": "#variable" + }, + { + "include": "#block" + }, + { + "include": "#block-contents" + } + ] + }, + "class": { + "begin": "(?=class)", + "end": "(?<=\\})|(;)", + "endCaptures": { + "1": { + "name": "punctuation.terminator.hx" + } + }, + "name": "meta.class.hx", + "patterns": [ + { + "include": "#class-name" + }, + { + "include": "#class-name-post" + }, + { + "include": "#class-block" + } + ] + }, + "class-name": { + "begin": "\\b(class)\\b", + "beginCaptures": { + "1": { + "name": "storage.type.class.hx" + } + }, + "end": "([_A-Za-z]\\w*)", + "endCaptures": { + "1": { + "name": "entity.name.type.class.hx" + } + }, + "name": "meta.class.identifier.hx", + "patterns": [ + { + "include": "#global" + } + ] + }, + "class-name-post": { + "begin": "(?<=\\w)", + "end": "([\\{;])", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.begin.hx" + } + }, + "patterns": [ + { + "include": "#modifiers-inheritance" + }, + { + "include": "#type" + } + ] + }, + "class-block": { + "begin": "(?<=\\{)", + "end": "(\\})", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.end.hx" + } + }, + "name": "meta.block.hx", + "patterns": [ + { + "include": "#method" + }, + { + "include": "#modifiers" + }, + { + "include": "#variable" + }, + { + "include": "#block" + }, + { + "include": "#block-contents" + } + ] + }, + "enum": { + "begin": "(?=enum\\s+[A-Z])", + "end": "(?<=\\})|(;)", + "endCaptures": { + "1": { + "name": "punctuation.terminator.hx" + } + }, + "name": "meta.enum.hx", + "patterns": [ + { + "include": "#enum-name" + }, + { + "include": "#enum-name-post" + }, + { + "include": "#enum-block" + } + ] + }, + "enum-name": { + "begin": "\\b(enum)\\b", + "beginCaptures": { + "1": { + "name": "storage.type.class.hx" + } + }, + "end": "([_A-Za-z]\\w*)", + "endCaptures": { + "1": { + "name": "entity.name.type.class.hx" + } + }, + "patterns": [ + { + "include": "#global" + } + ] + }, + "enum-name-post": { + "begin": "(?<=\\w)", + "end": "([\\{;])", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.begin.hx" + } + }, + "patterns": [ + { + "include": "#type" + } + ] + }, + "enum-block": { + "begin": "(?<=\\{)", + "end": "(\\})", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.end.hx" + } + }, + "name": "meta.block.hx", + "patterns": [ + { + "include": "#global" + }, + { + "include": "#metadata" + }, + { + "include": "#parameters" + }, + { + "include": "#identifiers" + } + ] + }, + "interface": { + "begin": "(?=interface)", + "end": "(?<=\\})|(;)", + "endCaptures": { + "1": { + "name": "punctuation.terminator.hx" + } + }, + "name": "meta.interface.hx", + "patterns": [ + { + "include": "#interface-name" + }, + { + "include": "#interface-name-post" + }, + { + "include": "#interface-block" + } + ] + }, + "interface-name": { + "begin": "\\b(interface)\\b", + "beginCaptures": { + "1": { + "name": "storage.type.class.hx" + } + }, + "end": "([_A-Za-z]\\w*)", + "endCaptures": { + "1": { + "name": "entity.name.type.class.hx" + } + }, + "patterns": [ + { + "include": "#global" + } + ] + }, + "interface-name-post": { + "begin": "(?<=\\w)", + "end": "([\\{;])", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.begin.hx" + } + }, + "patterns": [ + { + "include": "#global" + }, + { + "include": "#modifiers-inheritance" + }, + { + "include": "#type" + } + ] + }, + "interface-block": { + "begin": "(?<=\\{)", + "end": "(\\})", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.end.hx" + } + }, + "name": "meta.block.hx", + "patterns": [ + { + "include": "#method" + }, + { + "include": "#variable" + }, + { + "include": "#block" + }, + { + "include": "#block-contents" + } + ] + }, + "typedef": { + "begin": "(?=typedef)", + "end": "(?<=\\})|(;)", + "endCaptures": { + "1": { + "name": "punctuation.terminator.hx" + } + }, + "name": "meta.typedef.hx", + "patterns": [ + { + "include": "#typedef-name" + }, + { + "include": "#typedef-name-post" + }, + { + "include": "#typedef-block" + } + ] + }, + "typedef-name": { + "begin": "\\b(typedef)\\b", + "beginCaptures": { + "1": { + "name": "storage.type.class.hx" + } + }, + "end": "([_A-Za-z]\\w*)", + "endCaptures": { + "1": { + "name": "entity.name.type.class.hx" + } + }, + "patterns": [ + { + "include": "#global" + } + ] + }, + "typedef-name-post": { + "begin": "(?<=\\w)", + "end": "(\\{)|(?=;)", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.begin.hx" + } + }, + "patterns": [ + { + "include": "#global" + }, + { + "include": "#punctuation-brackets" + }, + { + "include": "#punctuation-separator" + }, + { + "include": "#operator-assignment" + }, + { + "include": "#type" + } + ] + }, + "typedef-block": { + "begin": "(?<=\\{)", + "end": "(\\})", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.end.hx" + } + }, + "name": "meta.block.hx", + "patterns": [ + { + "include": "#global" + }, + { + "include": "#metadata" + }, + { + "include": "#method" + }, + { + "include": "#variable" + }, + { + "include": "#modifiers" + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#operator-optional" + }, + { + "include": "#typedef-extension" + }, + { + "include": "#typedef-simple-field-type-hint" + }, + { + "include": "#identifier-name" + }, + { + "include": "#strings" + } + ] + }, + "typedef-extension": { + "begin": ">", + "end": ",|$", + "patterns": [ + { + "include": "#type" + } + ] + }, + "typedef-simple-field-type-hint": { + "begin": ":", + "beginCaptures": { + "0": { + "name": "keyword.operator.type.annotation.hx" + } + }, + "end": "(?=\\}|,|;)", + "patterns": [ + { + "include": "#type" + } + ] + }, + "regex": { + "begin": "(~/)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.string.begin.hx" + } + }, + "end": "(/)([gimsu]*)", + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.hx" + }, + "2": { + "name": "keyword.other.hx" + } + }, + "name": "string.regexp.hx", + "patterns": [ + { + "include": "#regexp" + } + ] + }, + "regex-character-class": { + "patterns": [ + { + "match": "\\\\[wWsSdDtrnvf]|\\.", + "name": "constant.other.character-class.regexp" + }, + { + "match": "\\\\([0-7]{3}|x\\h\\h|u\\h\\h\\h\\h)", + "name": "constant.character.numeric.regexp" + }, + { + "match": "\\\\c[A-Z]", + "name": "constant.character.control.regexp" + }, + { + "match": "\\\\.", + "name": "constant.character.escape.backslash.regexp" + } + ] + }, + "regexp": { + "patterns": [ + { + "match": "\\\\[bB]|\\^|\\$", + "name": "keyword.control.anchor.regexp" + }, + { + "match": "\\\\[1-9]\\d*", + "name": "keyword.other.back-reference.regexp" + }, + { + "match": "[?+*]|\\{(\\d+,\\d+|\\d+,|,\\d+|\\d+)\\}\\??", + "name": "keyword.operator.quantifier.regexp" + }, + { + "match": "\\|", + "name": "keyword.operator.or.regexp" + }, + { + "begin": "(\\()((\\?=)|(\\?!))", + "beginCaptures": { + "1": { + "name": "punctuation.definition.group.regexp" + }, + "2": { + "name": "punctuation.definition.group.assertion.regexp" + }, + "3": { + "name": "meta.assertion.look-ahead.regexp" + }, + "4": { + "name": "meta.assertion.negative-look-ahead.regexp" + } + }, + "end": "(\\))", + "endCaptures": { + "1": { + "name": "punctuation.definition.group.regexp" + } + }, + "name": "meta.group.assertion.regexp", + "patterns": [ + { + "include": "#regexp" + } + ] + }, + { + "begin": "\\((\\?:)?", + "beginCaptures": { + "0": { + "name": "punctuation.definition.group.regexp" + }, + "1": { + "name": "punctuation.definition.group.capture.regexp" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.group.regexp" + } + }, + "name": "meta.group.regexp", + "patterns": [ + { + "include": "#regexp" + } + ] + }, + { + "begin": "(\\[)(\\^)?", + "beginCaptures": { + "1": { + "name": "punctuation.definition.character-class.regexp" + }, + "2": { + "name": "keyword.operator.negation.regexp" + } + }, + "end": "(\\])", + "endCaptures": { + "1": { + "name": "punctuation.definition.character-class.regexp" + } + }, + "name": "constant.other.character-class.set.regexp", + "patterns": [ + { + "match": "(?:.|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))", + "captures": { + "1": { + "name": "constant.character.numeric.regexp" + }, + "2": { + "name": "constant.character.control.regexp" + }, + "3": { + "name": "constant.character.escape.backslash.regexp" + }, + "4": { + "name": "constant.character.numeric.regexp" + }, + "5": { + "name": "constant.character.control.regexp" + }, + "6": { + "name": "constant.character.escape.backslash.regexp" + } + }, + "name": "constant.other.character-class.range.regexp" + }, + { + "include": "#regex-character-class" + } + ] + }, + { + "include": "#regex-character-class" + } + ] + }, + "array": { + "begin": "\\[", + "beginCaptures": { + "0": { + "name": "punctuation.definition.array.begin.hx" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "punctuation.definition.array.end.hx" + } + }, + "name": "meta.array.literal.hx", + "patterns": [ + { + "include": "#block" + }, + { + "include": "#block-contents" + } + ] + }, + "constants": { + "patterns": [ + { + "match": "\\b(true|false|null)\\b", + "name": "constant.language.hx" + }, + { + "match": "\\b(?:0[xX][0-9a-fA-F][_0-9a-fA-F]*([iu][0-9][0-9_]*)?)\\b", + "captures": { + "0": { + "name": "constant.numeric.hex.hx" + }, + "1": { + "name": "constant.numeric.suffix.hx" + } + } + }, + { + "match": "\\b(?:0[bB][01][_01]*([iu][0-9][0-9_]*)?)\\b", + "captures": { + "0": { + "name": "constant.numeric.bin.hx" + }, + "1": { + "name": "constant.numeric.suffix.hx" + } + } + }, + { + "match": "(?x)\n(?])", + "end": "(\\{)|(;)", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.begin.hx" + }, + "2": { + "name": "punctuation.terminator.hx" + } + }, + "patterns": [ + { + "include": "#parameters" + }, + { + "include": "#method-return-type-hint" + }, + { + "include": "#block" + }, + { + "include": "#block-contents" + } + ] + }, + "method-block": { + "begin": "(?<=\\{)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.block.begin.hx" + } + }, + "end": "(\\})", + "endCaptures": { + "1": { + "name": "punctuation.definition.block.end.hx" + } + }, + "name": "meta.method.block.hx", + "patterns": [ + { + "include": "#block" + }, + { + "include": "#block-contents" + } + ] + }, + "parameters": { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "punctuation.definition.parameters.begin.hx" + } + }, + "end": "\\s*(\\)(?!\\s*->))", + "endCaptures": { + "1": { + "name": "punctuation.definition.parameters.end.hx" + } + }, + "name": "meta.parameters.hx", + "patterns": [ + { + "include": "#parameter" + } + ] + }, + "parameter": { + "begin": "(?<=\\(|,)", + "end": "(?=\\)(?!\\s*->)|,)", + "patterns": [ + { + "include": "#parameter-name" + }, + { + "include": "#parameter-type-hint" + }, + { + "include": "#parameter-assign" + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#global" + } + ] + }, + "parameter-name": { + "begin": "(?<=\\(|,)", + "end": "([_a-zA-Z]\\w*)", + "endCaptures": { + "1": { + "name": "variable.parameter.hx" + } + }, + "patterns": [ + { + "include": "#global" + }, + { + "include": "#metadata" + }, + { + "include": "#operator-optional" + } + ] + }, + "parameter-type-hint": { + "begin": ":", + "beginCaptures": { + "0": { + "name": "keyword.operator.type.annotation.hx" + } + }, + "end": "(?=\\)(?!\\s*->)|,|=)", + "patterns": [ + { + "include": "#type" + } + ] + }, + "parameter-assign": { + "begin": "=", + "beginCaptures": { + "0": { + "name": "keyword.operator.assignment.hx" + } + }, + "end": "(?=\\)|,)", + "patterns": [ + { + "include": "#block" + }, + { + "include": "#block-contents" + } + ] + }, + "arrow-function": { + "begin": "(\\()(?=[^(]*?\\)\\s*->)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.parameters.begin.hx" + } + }, + "end": "(\\))\\s*(->)", + "endCaptures": { + "1": { + "name": "punctuation.definition.parameters.end.hx" + }, + "2": { + "name": "storage.type.function.arrow.hx" + } + }, + "name": "meta.method.arrow.hx", + "patterns": [ + { + "include": "#arrow-function-parameter" + } + ] + }, + "arrow-function-parameter": { + "begin": "(?<=\\(|,)", + "end": "(?=\\)|,)", + "patterns": [ + { + "include": "#parameter-name" + }, + { + "include": "#arrow-function-parameter-type-hint" + }, + { + "include": "#parameter-assign" + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#global" + } + ] + }, + "arrow-function-parameter-type-hint": { + "begin": ":", + "beginCaptures": { + "0": { + "name": "keyword.operator.type.annotation.hx" + } + }, + "end": "(?=\\)|,|=)", + "patterns": [ + { + "include": "#type" + } + ] + }, + "method-return-type-hint": { + "begin": "(?<=\\))\\s*(:)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.hx" + } + }, + "end": "(?=\\{|;|[a-z0-9])", + "patterns": [ + { + "include": "#type" + } + ] + }, + "operator-optional": { + "match": "(\\?)(?!\\s)", + "name": "keyword.operator.optional.hx" + }, + "variable": { + "begin": "(?=\\b(var|final)\\b)", + "end": "(?=$)|(;)", + "endCaptures": { + "1": { + "name": "punctuation.terminator.hx" + } + }, + "patterns": [ + { + "include": "#variable-name" + }, + { + "include": "#variable-name-next" + }, + { + "include": "#variable-assign" + }, + { + "include": "#variable-name-post" + } + ] + }, + "variable-name": { + "begin": "\\b(var|final)\\b", + "beginCaptures": { + "1": { + "name": "storage.type.variable.hx" + } + }, + "end": "(?=$)|([_a-zA-Z]\\w*)", + "endCaptures": { + "1": { + "name": "variable.other.hx" + } + }, + "patterns": [ + { + "include": "#operator-optional" + } + ] + }, + "variable-name-next": { + "begin": ",", + "beginCaptures": { + "0": { + "name": "punctuation.separator.comma.hx" + } + }, + "end": "([_a-zA-Z]\\w*)", + "endCaptures": { + "1": { + "name": "variable.other.hx" + } + }, + "patterns": [ + { + "include": "#global" + } + ] + }, + "variable-type-hint": { + "begin": ":", + "beginCaptures": { + "0": { + "name": "keyword.operator.type.annotation.hx" + } + }, + "end": "(?=$|;|,|=)", + "patterns": [ + { + "include": "#type" + } + ] + }, + "variable-assign": { + "begin": "=", + "beginCaptures": { + "0": { + "name": "keyword.operator.assignment.hx" + } + }, + "end": "(?=;|,)", + "patterns": [ + { + "include": "#block" + }, + { + "include": "#block-contents" + } + ] + }, + "variable-name-post": { + "begin": "(?<=\\w)", + "end": "(?=;)|(?==)", + "patterns": [ + { + "include": "#variable-accessors" + }, + { + "include": "#variable-type-hint" + }, + { + "include": "#block-contents" + } + ] + }, + "variable-accessors": { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "punctuation.definition.parameters.begin.hx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.parameters.end.hx" + } + }, + "name": "meta.parameters.hx", + "patterns": [ + { + "include": "#global" + }, + { + "include": "#keywords-accessor" + }, + { + "include": "#accessor-method" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "keywords-accessor": { + "match": "\\b(default|get|set|dynamic|never|null)\\b", + "name": "storage.type.property.hx" + }, + "accessor-method": { + "patterns": [ + { + "match": "\\b(get|set)_[_A-Za-z]\\w*\\b", + "name": "entity.name.function.hx" + } + ] + }, + "modifiers": { + "patterns": [ + { + "match": "\\b(enum)\\b", + "name": "storage.type.class" + }, + { + "match": "\\b(public|private|static|dynamic|inline|macro|extern|override|overload|abstract)\\b", + "name": "storage.modifier.hx" + }, + { + "match": "\\b(final)\\b(?=\\s+(public|private|static|dynamic|inline|macro|extern|override|overload|abstract|function))", + "name": "storage.modifier.hx" + } + ] + }, + "new-expr": { + "name": "new.expr.hx", + "begin": "(?", + "name": "keyword.operator.extractor.hx" + }, + { + "include": "#operator-assignment" + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#keywords" + }, + { + "include": "#method-call" + }, + { + "include": "#identifiers" + } + ] + }, + { + "match": "\\b(if|else|return|do|while|for|break|continue|switch|case|default)\\b", + "name": "keyword.control.flow-control.hx" + }, + { + "match": "\\b(cast|untyped)\\b", + "name": "keyword.other.untyped.hx" + }, + { + "match": "\\btrace\\b", + "name": "keyword.other.trace.hx" + }, + { + "match": "\\$type\\b", + "name": "keyword.other.type.hx" + }, + { + "match": "\\__(global|this)__\\b", + "name": "keyword.other.untyped-property.hx" + }, + { + "match": "\\b(this|super)\\b", + "name": "variable.language.hx" + }, + { + "match": "\\bnew\\b", + "name": "keyword.operator.new.hx" + }, + { + "match": "\\b(abstract|class|enum|interface|typedef)\\b", + "name": "storage.type.hx" + }, + { + "match": "->", + "name": "storage.type.function.arrow.hx" + }, + { + "include": "#modifiers" + }, + { + "include": "#modifiers-inheritance" + } + ] + }, + "punctuation-braces": { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.hx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.hx" + } + }, + "patterns": [ + { + "include": "#keywords" + }, + { + "include": "#block" + }, + { + "include": "#block-contents" + }, + { + "include": "#type-check" + } + ] + }, + "type-check": { + "begin": "(?>>|<<|>>)", + "name": "keyword.operator.bitwise.hx" + }, + { + "match": "(==|!=|<=|>=|<|>)", + "name": "keyword.operator.comparison.hx" + }, + { + "match": "(!)", + "name": "keyword.operator.logical.hx" + }, + { + "match": "(\\-\\-|\\+\\+)", + "name": "keyword.operator.increment-decrement.hx" + }, + { + "match": "(\\-|\\+|\\*|\\/|%)", + "name": "keyword.operator.arithmetic.hx" + }, + { + "match": "\\.\\.\\.", + "name": "keyword.operator.intiterator.hx" + }, + { + "match": "=>", + "name": "keyword.operator.arrow.hx" + }, + { + "match": "\\?\\?", + "name": "keyword.operator.nullcoalescing.hx" + }, + { + "match": "\\?\\.", + "name": "keyword.operator.safenavigation.hx" + }, + { + "match": "\\bis\\b(?!\\()", + "name": "keyword.other.hx" + }, + { + "begin": "\\?", + "beginCaptures": { + "0": { + "name": "keyword.operator.ternary.hx" + } + }, + "end": ":", + "endCaptures": { + "0": { + "name": "keyword.operator.ternary.hx" + } + }, + "patterns": [ + { + "include": "#block-contents" + } + ] + } + ] + }, + "punctuation-comma": { + "match": ",", + "name": "punctuation.separator.comma.hx" + }, + "punctuation-accessor": { + "match": "\\.", + "name": "punctuation.accessor.hx" + }, + "punctuation-terminator": { + "match": ";", + "name": "punctuation.terminator.hx" + }, + "constant-name": { + "match": "\\b([_A-Z][_A-Z0-9]*)\\b", + "name": "variable.other.hx" + }, + "type": { + "patterns": [ + { + "include": "#global" + }, + { + "include": "#macro-reification" + }, + { + "include": "#type-name" + }, + { + "include": "#type-parameters" + }, + { + "match": "->", + "name": "keyword.operator.type.function.hx" + }, + { + "match": "&", + "name": "keyword.operator.type.intersection.hx" + }, + { + "match": "\\?(?=\\s*[_A-Z])", + "name": "keyword.operator.optional" + }, + { + "match": "\\?(?!\\s*[_A-Z])", + "name": "punctuation.definition.tag" + }, + { + "begin": "(\\{)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.begin.hx" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#typedef-block" + } + ] + }, + { + "include": "#function-type" + } + ] + }, + "function-type": { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "punctuation.definition.parameters.begin.hx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.parameters.end.hx" + } + }, + "patterns": [ + { + "include": "#function-type-parameter" + } + ] + }, + "function-type-parameter": { + "begin": "(?<=\\(|,)", + "end": "(?=\\)|,)", + "patterns": [ + { + "include": "#global" + }, + { + "include": "#metadata" + }, + { + "include": "#operator-optional" + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#function-type-parameter-name" + }, + { + "include": "#function-type-parameter-type-hint" + }, + { + "include": "#parameter-assign" + }, + { + "include": "#type" + }, + { + "include": "#global" + } + ] + }, + "function-type-parameter-name": { + "match": "([_a-zA-Z]\\w*)(?=\\s*:)", + "captures": { + "1": { + "name": "variable.parameter.hx" + } + } + }, + "function-type-parameter-type-hint": { + "begin": ":", + "beginCaptures": { + "0": { + "name": "keyword.operator.type.annotation.hx" + } + }, + "end": "(?=\\)|,|=)", + "patterns": [ + { + "include": "#type" + } + ] + }, + "type-name": { + "patterns": [ + { + "match": "\\b(Any|Array|ArrayAccess|Bool|Class|Date|DateTools|Dynamic|Enum|EnumValue|EReg|Float|IMap|Int|IntIterator|Iterable|Iterator|KeyValueIterator|KeyValueIterable|Lambda|List|ListIterator|ListNode|Map|Math|Null|Reflect|Single|Std|String|StringBuf|StringTools|Sys|Type|UInt|UnicodeString|ValueType|Void|Xml|XmlType)(?:(\\.)(_*[A-Z]\\w*[a-z]\\w*))*\\b", + "captures": { + "1": { + "name": "support.class.builtin.hx" + }, + "2": { + "name": "support.package.hx" + }, + "3": { + "name": "entity.name.type.hx" + } + } + }, + { + "match": "\\b(?)", + "endCaptures": { + "1": { + "name": "punctuation.definition.typeparameters.end.hx" + } + }, + "name": "meta.type-parameters.hx", + "patterns": [ + { + "include": "#type" + }, + { + "include": "#type-parameter-constraint-old" + }, + { + "include": "#type-parameter-constraint-new" + }, + { + "include": "#global" + }, + { + "include": "#regex" + }, + { + "include": "#array" + }, + { + "include": "#constants" + }, + { + "include": "#strings" + }, + { + "include": "#metadata" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "type-parameter-constraint-old": { + "begin": "(:)\\s*(\\()", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.hx" + }, + "2": { + "name": "punctuation.definition.constraint.begin.hx" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.constraint.end.hx" + } + }, + "patterns": [ + { + "include": "#type" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "type-parameter-constraint-new": { + "match": ":", + "name": "keyword.operator.type.annotation.hxt" + }, + "identifier-name": { + "match": "\\b([_A-Za-z]\\w*)\\b", + "name": "variable.other.hx" + } + } +} \ No newline at end of file diff --git a/src/Resources/Grammars/hxml.json b/src/Resources/Grammars/hxml.json new file mode 100644 index 00000000..829c403e --- /dev/null +++ b/src/Resources/Grammars/hxml.json @@ -0,0 +1,70 @@ +{ + "information_for_contributors": [ + "This file has been copied from https://github.com/vshaxe/haxe-TmLanguage/blob/ddad8b4c6d0781ac20be0481174ec1be772c5da5/hxml.tmLanguage", + "and converted to JSON using https://marketplace.visualstudio.com/items?itemName=pedro-w.tmlanguage" + ], + "fileTypes": [ + "hxml" + ], + "foldingStartMarker": "--next", + "foldingStopMarker": "\\n\\n", + "keyEquivalent": "^@H", + "name": "Hxml", + "patterns": [ + { + "captures": { + "1": { + "name": "punctuation.definition.comment.hxml" + } + }, + "match": "(#).*$\\n?", + "name": "comment.line.number-sign.hxml" + }, + { + "begin": "(?