{ "$schema": "https://raw.githubusercontent.com/ealap/tmlanguage/master/tmlanguage.json", "name": "Java", "scopeName": "source.java", "patterns": [ { "include": "#class-declaration" }, { "include": "#annotations" }, { "include": "#keywords" }, { "include": "#comments" } ], "repository": { "class-declaration": { "patterns": [ { "begin": "\\b(class|interface|enum)\\b", "end": "}", "name": "meta.class-declaration", "beginCaptures": { "1": { "name": "keyword.class" } }, "patterns": [ { "include": "#keywords" }, { "include": "#comments" }, { "match": "\\b([a-z]\\w*\\.)*([A-Z]\\w*)\\b", "captures": { "2": { "name": "entity.name.type" } } }, { "begin": "{", "end": "(?=})", "name": "meta.class-body", "patterns": [ { "include": "#class-declaration" }, { "include": "#field-initializer" }, { "include": "#method-declaration" }, { "include": "#type-parameters-declaration" }, { "include": "#block" }, { "include": "#annotations" }, { "include": "#keywords" }, { "include": "#comments" }, { "include": "#types" } ] } ] } ] }, "field-initializer": { "patterns": [ { "begin": "\\=", "end": ";", "name": "meta.field-initializer", "patterns": [ { "include": "#expressions" } ] } ] }, "method-declaration": { "patterns": [ { "begin": "(\\w+)\\(", "end": "\\)", "name": "meta.method-declaration", "beginCaptures": { "1": { "name": "entity.name.function" } }, "patterns": [ { "include": "#annotations" }, { "include": "#keywords" }, { "include": "#comments" }, { "include": "#types" } ] } ] }, "type-parameters-declaration": { "match": "<[^<>]+>", "name": "meta.type-parameters-declaration", "captures": { "0": { "patterns": [ { "include": "#keywords" }, { "include": "#comments" }, { "match": "\\b([A-Z]\\w*)\\b", "name": "entity.name.type" } ] } } }, "block": { "begin": "{", "end": "}", "name": "meta.block", "patterns": [ { "include": "#block" }, { "include": "#types" }, { "include": "#expressions" } ] }, "annotations": { "patterns": [ { "begin": "(@\\s*[^\\s(]+)(\\()", "beginCaptures": { "1": { "name": "punctuation.definition.tag" }, "2": { "name": "punctuation.definition.tag.left" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.tag.right" } }, "name": "meta.annotation.java", "patterns": [ { "captures": { "1": { "name": "punctuation.definition.tag.key" }, "2": { "name": "punctuation.definition.tag.assign" } }, "match": "(\\w*)\\s*(=)" }, { "include": "#keywords" }, { "include": "#comments" }, { "include": "#constants" } ] }, { "match": "@interface\\s+\\w*|@\\s*\\w+", "name": "punctuation.definition.tag" } ] }, "expressions": { "patterns": [ { "include": "#keywords" }, { "include": "#comments" }, { "include": "#constants" }, { "include": "#type-arguments" }, { "include": "#parens" }, { "begin": "\\(", "end": "\\)", "patterns": [ { "include": "#expressions" } ] }, { "include": "#new" } ] }, "keywords": { "patterns": [ { "match": ",", "name": "keyword.other.comma" }, { "match": ";", "name": "keyword.other.semi" }, { "match": "\\b(package|import)\\b", "name": "keyword.package" }, { "match": "\\b(try|catch|finally|throw|throws|return|break|continue|do|for|while|switch|case|if|else|goto|synchronize|assert)\\b", "name": "keyword.control" }, { "match": "\\b(instanceof)\\b", "name": "keyword.control" }, { "match": "\\.(class)\\b", "captures": { "1": { "name": "keyword.class" } } }, { "match": "\\b(default):", "captures": { "1": { "name": "keyword.control.default" } } }, { "match": "\\b(private|public|protected|abstract|default(?!=:)|static|final|volatile|const|extends|implements|synchronized)\\b", "name": "storage.modifier.java" }, { "match": "\\b(this|super)\\b", "name": "variable.language.java" }, { "match": "\\?", "name": "constant.numeric" }, { "match": "\\b(byte|short|int|long|char|float|double|boolean|void)\\b", "name": "keyword.type" }, { "match": "\\bvar\\b", "name": "keyword.other.var" } ] }, "comments": { "patterns": [ { "begin": "/\\*", "end": "\\*/", "name": "comment.block" }, { "begin": "//", "end": "$", "name": "comment.line" } ] }, "constants": { "patterns": [ { "match": "\\b(null|true|false)\\b", "name": "constant.numeric" }, { "match": "(?x)\n\\b(?<([^<>]|\\g)*>)", "captures": { "1": { "name": "entity.name.type" }, "2": { "name": "meta.type-parameters-declaration", "patterns": [ { "include": "#keywords" }, { "include": "#comments" }, { "match": "\\b([a-z]\\w*\\.)*([A-Z]\\w*)\\b", "captures": { "2": { "name": "entity.name.type" } } } ] } } } ] }, "new": { "begin": "\\b(new)\\b", "end": "(?=;|\\)|\\.|,|:|}|=)", "name": "meta.new", "captures": { "1": { "name": "keyword.control" } }, "patterns": [ { "include": "#expressions" }, { "match": "\\b([a-z]\\w*\\.)*([A-Z]\\w*)\\b", "captures": { "2": { "name": "entity.name.type" } } }, { "begin": "{", "end": "}", "name": "meta.anonymous-class", "patterns": [ { "include": "#class-declaration" }, { "include": "#field-initializer" }, { "include": "#method-declaration" }, { "include": "#type-parameters-declaration" }, { "include": "#block" }, { "include": "#annotations" }, { "include": "#keywords" }, { "include": "#comments" }, { "include": "#types" } ] } ] }, "type-arguments": { "patterns": [ { "match": "\\.(?<([^<>]|\\g)*>)", "name": "meta.type-arguments", "captures": { "1": { "patterns": [ { "include": "#keywords" }, { "include": "#comments" }, { "match": "\\b([a-z]\\w*\\.)*([A-Z]\\w*)\\b", "captures": { "2": { "name": "entity.name.type" } } } ] } } } ] } } }