{
  "name": "java",
  "fileExtensions": [".java"],
  "variables": {
    "identifierStart": "[\\p{Han}\\w_$]+",
    "identifierPart": "[\\p{Han}\\w_$0-9]*",
    "identifier": "${identifierStart}${identifierPart}",
    "whiteSpace": "[ \\t\\f]",
    "any": "[\\S\\s]",
    "primitiveType": "void|boolean|byte|char|short|int|long|float|double"
  },
  "states": {
    "default": [
      {
        "pattern": "(@interface)\\b${whiteSpace}+(${identifier})",
        "styles": [1, "keyword", 2, "class"],
        "state": "classHeader"
      },
      {
        "pattern": "\\b(class|interface|enum|record)\\b${whiteSpace}+(${identifier})",
        "styles": [1, "keyword", 2, "class"],
        "state": "classHeader"
      },
      {
        "pattern": "\\b(new)\\b${whiteSpace}+(${identifier})${whiteSpace}*(<)([^()]*)(>)${whiteSpace}*(\\()",
        "styles": [1, "keyword", 2, "class", 3, "punctuation", 5, "punctuation", 6, "punctuation"],
        "subStates": [4, "genericType"]
      },
      {
        "pattern": "\\b(new)\\b${whiteSpace}+(${identifier})${whiteSpace}*(<)([^()]*)(>)${whiteSpace}*(\\[)",
        "styles": [1, "keyword", 2, "class", 3, "punctuation", 5, "punctuation", 6, "punctuation"],
        "subStates": [4, "genericType"]
      },
      {
        "pattern": "\\b(new)\\b${whiteSpace}+(${identifier})${whiteSpace}*(\\()",
        "styles": [1, "keyword", 2, "class", 3, "punctuation"]
      },
      {
        "pattern": "\\b(new)\\b${whiteSpace}+(${identifier})${whiteSpace}*(\\[)",
        "styles": [1, "keyword", 2, "class", 3, "punctuation"]
      },
      {
        "pattern": "\\b(package|import)\\b${whiteSpace}+(${identifier}(?:\\.${identifier})*)(?:(\\.)\\*)?",
        "styles": [1, "keyword", 2, "variable", 3, "punctuation"]
      },
      {
        "pattern": "\\b(public|private|protected|static|final|abstract|synchronized|transient|native|volatile|strictfp|sealed|non-sealed|permits|default)\\b",
        "styles": [1, "keyword"]
      },
      {
        "pattern": "\\b(extends|implements|new|this|super|instanceof|throw|throws|switch|case|if|else|for|while|do|break|continue|return|try|catch|finally|assert|yield|var)\\b",
        "styles": [1, "keyword"]
      },
      {
        "pattern": "\\b(true|false|null)\\b",
        "styles": [1, "builtin"]
      },
      {
        "pattern": "(@${identifier})${whiteSpace}*(\\()",
        "styles": [1, "annotation", 2, "punctuation"],
        "state": "annotationParams"
      },
      {
        "pattern": "@${identifier}",
        "style": "annotation"
      },
      {
        "pattern": "(<)([^()]*)(>>)${whiteSpace}+(${identifier})${whiteSpace}*(<)([^<>()]*)(>)${whiteSpace}+(${identifier})${whiteSpace}*(\\()",
        "styles": [1, "punctuation", 3, "punctuation", 4, "class", 5, "punctuation", 7, "punctuation", 8, "method", 9, "punctuation"],
        "subStates": [2, "genericType", 6, "genericType"]
      },
      {
        "pattern": "(<)([^()]*)(>>)${whiteSpace}+(${identifier})((?:\\[\\])*)${whiteSpace}+(${identifier})${whiteSpace}*(\\()",
        "styles": [1, "punctuation", 3, "punctuation", 4, "class", 5, "punctuation", 6, "method", 7, "punctuation"],
        "subStates": [2, "genericType"]
      },
      {
        "pattern": "(<)([^<>()]*)(>)${whiteSpace}+\\b(${primitiveType})\\b((?:\\[\\])*)${whiteSpace}+(${identifier})${whiteSpace}*(\\()",
        "styles": [1, "punctuation", 3, "punctuation", 4, "keyword", 5, "punctuation", 6, "method", 7, "punctuation"],
        "subStates": [2, "genericType"]
      },
      {
        "pattern": "(<)([^<>()]*)(>)${whiteSpace}+(${identifier})${whiteSpace}*(<)([^<>()]*)(>)${whiteSpace}+(${identifier})${whiteSpace}*(\\()",
        "styles": [1, "punctuation", 3, "punctuation", 4, "class", 5, "punctuation", 7, "punctuation", 8, "method", 9, "punctuation"],
        "subStates": [2, "genericType", 6, "genericType"]
      },
      {
        "pattern": "(<)([^<>()]*)(>)${whiteSpace}+(${identifier})((?:\\[\\])*)${whiteSpace}+(${identifier})${whiteSpace}*(\\()",
        "styles": [1, "punctuation", 3, "punctuation", 4, "class", 5, "punctuation", 6, "method", 7, "punctuation"],
        "subStates": [2, "genericType"]
      },
      {
        "pattern": "\\b(${primitiveType})\\b((?:\\[\\])*)${whiteSpace}+(${identifier})${whiteSpace}*(\\()",
        "styles": [1, "keyword", 2, "punctuation", 3, "method", 4, "punctuation"]
      },
      {
        "pattern": "\\b(${primitiveType})\\b((?:\\[\\])*)${whiteSpace}+(${identifier})${whiteSpace}*([;=,)])",
        "styles": [1, "keyword", 2, "punctuation", 3, "variable", 4, "punctuation"]
      },
      {
        "pattern": "\\b(${primitiveType})\\b",
        "styles": [1, "keyword"]
      },
      {
        "pattern": "\\b(${identifier})${whiteSpace}*(<)([^()]*)(>)((?:\\[\\])*)${whiteSpace}+(${identifier})${whiteSpace}*(\\()",
        "styles": [1, "class", 2, "punctuation", 4, "punctuation", 5, "punctuation", 6, "method", 7, "punctuation"],
        "subStates": [3, "genericType"]
      },
      {
        "pattern": "\\b(${identifier})${whiteSpace}+(${identifier})${whiteSpace}*(\\()",
        "styles": [1, "class", 2, "method", 3, "punctuation"]
      },
      {
        "pattern": "\\b(${identifier})${whiteSpace}*(<)([^()]*)(>)((?:\\[\\])*)${whiteSpace}+(${identifier})${whiteSpace}*([;=,)])",
        "styles": [1, "class", 2, "punctuation", 4, "punctuation", 5, "punctuation", 6, "variable", 7, "punctuation"],
        "subStates": [3, "genericType"]
      },
      {
        "pattern": "\\b(${identifier})((?:\\[\\])*)${whiteSpace}+(${identifier})${whiteSpace}*([;=,)])",
        "styles": [1, "class", 2, "punctuation", 3, "variable", 4, "punctuation"]
      },
      {
        "pattern": "(${identifier})(::)(${identifier})",
        "styles": [1, "class", 2, "punctuation", 3, "method"]
      },
      {
        "pattern": "(${identifier})${whiteSpace}*(\\()",
        "styles": [1, "method", 2, "punctuation"]
      },
      {
        "pattern": "\"\"\"",
        "style": "string",
        "state": "textBlock"
      },
      {
        "pattern": "\"(?:[^\"\\\\]|\\\\.)*\"",
        "style": "string"
      },
      {
        "pattern": "'(?:[^'\\\\]|\\\\.)*'",
        "style": "string"
      },
      {
        "pattern": "\\b0[xX][0-9a-fA-F_]+[lL]?\\b",
        "style": "color"
      },
      {
        "pattern": "\\b0[bB][01_]+[lL]?\\b",
        "style": "number"
      },
      {
        "pattern": "\\b(?:[0-9][0-9_]*\\.?[0-9_]*(?:[eE][+-]?[0-9_]+)?[fFdDlL]?)\\b",
        "style": "number"
      },
      {
        "pattern": "/\\*\\*(?!/)",
        "style": "comment",
        "state": "docComment"
      },
      {
        "pattern": "/\\*",
        "style": "comment",
        "state": "longComment"
      },
      {
        "pattern": "//${any}*",
        "style": "comment"
      },
      {
        "pattern": "->|::",
        "style": "punctuation"
      },
      {
        "pattern": "[.()\\[\\]?!@%^&|+\\-*/<>=,{};:~]",
        "style": "punctuation"
      }
    ],
    "classHeader": [
      {
        "pattern": "(<)([^()]*)(>)",
        "styles": [1, "punctuation", 3, "punctuation"],
        "subStates": [2, "genericType"]
      },
      {
        "pattern": "\\b(extends|implements|permits)\\b",
        "styles": [1, "keyword"]
      },
      {
        "pattern": "(${identifier})${whiteSpace}*(<)([^()]*)(>)",
        "styles": [1, "class", 2, "punctuation", 4, "punctuation"],
        "subStates": [3, "genericType"]
      },
      {
        "pattern": "${identifier}",
        "style": "class"
      },
      {
        "pattern": "\\(",
        "style": "punctuation",
        "state": "recordParams"
      },
      {
        "pattern": "[,:]",
        "style": "punctuation"
      },
      {
        "pattern": "\\{",
        "style": "punctuation",
        "state": "default"
      },
      {
        "onLineEndState": "classHeader"
      }
    ],
    "recordParams": [
      {
        "pattern": "(@${identifier})",
        "styles": [1, "annotation"]
      },
      {
        "pattern": "\\b(${primitiveType})\\b((?:\\[\\])*)${whiteSpace}+(${identifier})",
        "styles": [1, "keyword", 2, "punctuation", 3, "variable"]
      },
      {
        "pattern": "\\b(${identifier})${whiteSpace}*(<)([^()]*)(>)((?:\\[\\])*)${whiteSpace}+(${identifier})",
        "styles": [1, "class", 2, "punctuation", 4, "punctuation", 5, "punctuation", 6, "variable"],
        "subStates": [3, "genericType"]
      },
      {
        "pattern": "\\b(${identifier})((?:\\[\\])*)${whiteSpace}+(${identifier})",
        "styles": [1, "class", 2, "punctuation", 3, "variable"]
      },
      {
        "pattern": "\\)",
        "style": "punctuation",
        "state": "classHeader"
      },
      {
        "pattern": ",",
        "style": "punctuation"
      },
      {
        "onLineEndState": "recordParams"
      }
    ],
    "genericType": [
      {
        "pattern": "\\b(extends|super)\\b",
        "styles": [1, "keyword"]
      },
      {
        "pattern": "\\?",
        "style": "keyword"
      },
      {
        "pattern": "(@)(${identifier})",
        "styles": [1, "punctuation", 2, "annotation"]
      },
      {
        "pattern": "(${identifier})${whiteSpace}*(<)([^()]*)(>)",
        "styles": [1, "class", 2, "punctuation", 4, "punctuation"],
        "subStates": [3, "genericType"]
      },
      {
        "pattern": "${identifier}",
        "style": "class"
      },
      {
        "pattern": "[,\\[\\]<>&.]",
        "style": "punctuation"
      }
    ],
    "annotationParams": [
      {
        "pattern": "\\)",
        "style": "punctuation",
        "state": "default"
      },
      {
        "pattern": "(@${identifier})",
        "styles": [1, "annotation"]
      },
      {
        "pattern": "(${identifier})${whiteSpace}*(=)",
        "styles": [1, "variable", 2, "punctuation"]
      },
      {
        "pattern": "(${identifier})(\\.)(${identifier})",
        "styles": [1, "class", 2, "punctuation", 3, "variable"]
      },
      {
        "pattern": "\"(?:[^\"\\\\]|\\\\.)*\"",
        "style": "string"
      },
      {
        "pattern": "'(?:[^'\\\\]|\\\\.)*'",
        "style": "string"
      },
      {
        "pattern": "\\b(true|false|null)\\b",
        "styles": [1, "builtin"]
      },
      {
        "pattern": "\\b(?:[0-9][0-9_]*\\.?[0-9_]*(?:[eE][+-]?[0-9_]+)?[fFdDlL]?)\\b",
        "style": "number"
      },
      {
        "pattern": "(${identifier})(\\.)(class)\\b",
        "styles": [1, "class", 2, "punctuation", 3, "keyword"]
      },
      {
        "pattern": "${identifier}",
        "style": "variable"
      },
      {
        "pattern": "[,{}\\[\\]]",
        "style": "punctuation"
      }
    ],
    "textBlock": [
      {
        "pattern": "\"\"\"",
        "style": "string",
        "state": "default"
      },
      {
        "pattern": "\\\\.",
        "style": "string"
      },
      {
        "pattern": "${any}",
        "style": "string"
      }
    ],
    "docComment": [
      {
        "pattern": "\\*/",
        "style": "comment",
        "state": "default"
      },
      {
        "pattern": "(@param)${whiteSpace}+(<)(${identifier})(>)",
        "styles": [1, "annotation", 2, "punctuation", 3, "class", 4, "punctuation"]
      },
      {
        "pattern": "(@param)${whiteSpace}+(${identifier})",
        "styles": [1, "annotation", 2, "variable"]
      },
      {
        "pattern": "(@throws|@exception)${whiteSpace}+(${identifier})",
        "styles": [1, "annotation", 2, "class"]
      },
      {
        "pattern": "(@see)${whiteSpace}+(${identifier})(#)(${identifier})",
        "styles": [1, "annotation", 2, "class", 3, "punctuation", 4, "method"]
      },
      {
        "pattern": "(@return|@returns|@since|@version|@author|@deprecated|@serial|@serialField|@serialData|@see|@link|@linkplain|@inheritDoc|@docRoot|@code|@literal|@value|@implSpec|@implNote|@apiNote|@hidden|@snippet)\\b",
        "styles": [1, "annotation"]
      },
      {
        "pattern": "(\\{@(?:link|linkplain|code|literal|value|snippet))${whiteSpace}+(${identifier})(#)(${identifier})(\\})",
        "styles": [1, "annotation", 2, "class", 3, "punctuation", 4, "method", 5, "annotation"]
      },
      {
        "pattern": "(\\{@(?:link|linkplain|code|literal|value|snippet))${whiteSpace}+(${identifier})(\\})",
        "styles": [1, "annotation", 2, "class", 3, "annotation"]
      },
      {
        "pattern": "(</?)(${identifier})([^>]*)(>)",
        "styles": [1, "punctuation", 2, "keyword", 4, "punctuation"]
      },
      {
        "pattern": "${any}",
        "style": "comment"
      }
    ],
    "longComment": [
      {
        "pattern": "\\*/",
        "style": "comment",
        "state": "default"
      },
      {
        "pattern": "${any}",
        "style": "comment"
      }
    ]
  },
  "scopeRules": [
    {
      "start": "{",
      "end": "}",
      "branches": ["case"]
    }
  ]
}
