lectures.alex.balgavy.eu

Lecture notes from university.
git clone git://git.alex.balgavy.eu/lectures.alex.balgavy.eu.git
Log | Files | Refs | Submodules

Java.sublime-syntax (37211B)


      1 %YAML 1.2
      2 ---
      3 # http://www.sublimetext.com/docs/3/syntax.html
      4 name: Java
      5 file_extensions:
      6   - java
      7   - bsh
      8 scope: source.java
      9 
     10 variables:
     11   primitives: (?:boolean|byte|char|short|int|float|long|double)
     12   storage_modifiers: (?:public|private|protected|static|final|native|synchronized|strictfp|abstract|transient|default|volatile)
     13 
     14   id: (?:[\p{L}_$][\p{L}\p{N}_$]*)
     15   classcase_id: (?:\p{Lu}[\p{L}\p{N}_$]*)
     16   lowercase_id: (?:[_$]*\p{Ll}[\p{Ll}\p{N}_$]*\b)
     17   uppercase_id: (?:[_$]*\p{Lu}[\p{Lu}\p{N}_$]*\b)
     18 
     19   # One dot is mandatory to not compete with other regexes that match an id.
     20   before_fqn: (?={{lowercase_id}}\s*\.)
     21 
     22   # utility lookaround
     23   lambda_lookahead: (?:\(.*\)|{{id}})\s*->
     24 
     25   # digits
     26   ddigits0: '\d[\d_]*?(_*)'
     27   ddigits: (?:(_*){{ddigits0}})
     28   hdigits: (?:(_*)\h[\h_]*?(_*))
     29   exponent: '[-+]?{{ddigits}}'
     30   eexponent: (?:[eE]{{exponent}})
     31   pexponent: (?:[pP]{{exponent}})
     32 
     33 contexts:
     34   prototype:
     35     - match: (?=%>)
     36       pop: true
     37     - include: comments
     38     - include: illegal-keywords
     39 
     40   any_POP:
     41     - match: (?=\S)
     42       pop: true
     43 
     44   immediate_POP:
     45     - match: ''
     46       pop: true
     47 
     48   main:
     49     - include: prototype
     50     - include: package-statement
     51     - include: import-statement
     52     - include: module
     53     - include: class
     54     - include: annotations
     55     # Get modifiers defined on a different line than the class
     56     - include: storage-modifiers
     57     - include: stray-braces
     58     - include: code
     59 
     60   punctuation-accessor-dot:
     61     - match: \.
     62       scope: punctuation.accessor.dot.java
     63 
     64   punctuation-separator-comma:
     65     - match: \,
     66       scope: punctuation.separator.comma.java
     67 
     68   punctuation-terminator-semicolon:
     69     - match: ;
     70       scope: punctuation.terminator.java
     71 
     72   dot-separated-identifier:
     73     - match: '{{id}}'
     74     - include: punctuation-accessor-dot
     75     - include: immediate_POP
     76 
     77   package-statement:
     78     - match: \bpackage\b
     79       scope: keyword.other.package.java
     80       push:
     81         - - meta_scope: meta.package-declaration.java
     82           - include: immediate_POP
     83         - - match: '{{id}}'
     84             set:
     85               - meta_scope: meta.path.java entity.name.namespace.java
     86               - include: dot-separated-identifier
     87           - include: any_POP
     88 
     89   import-statement:
     90     - match: \bimport\b
     91       scope: keyword.control.import.java
     92       push:
     93         - - meta_scope: meta.import.java
     94           - include: immediate_POP
     95         - import-statement-body
     96 
     97   import-statement-body:
     98     - match: \bstatic\b
     99       scope: keyword.control.import.static.java
    100       set: static-import-statement-body
    101     - include: before-next-import
    102     - match: '{{lowercase_id}}'
    103       scope: meta.path.java support.type.package.java
    104       set:
    105         - meta_content_scope: meta.path.java
    106         - include: before-next-import
    107         - include: package
    108         - match: \*
    109           scope: meta.path.java keyword.operator.wildcard.asterisk.java
    110           pop: true
    111         - match: '{{classcase_id}}'
    112           scope: support.class.import.java
    113           set:
    114             - include: before-next-import
    115             - include: punctuation-accessor-dot
    116             - include: import-class
    117             - include: import-wildcard
    118             - include: any_POP
    119         - include: any_POP
    120     - include: any_POP
    121 
    122   static-import-statement-body:
    123     - include: before-next-import
    124     - match: '{{lowercase_id}}'
    125       scope: meta.path.java support.type.package.java
    126       set:
    127         - meta_content_scope: meta.path.java
    128         - include: before-next-import
    129         - include: package
    130         - match: '{{classcase_id}}'
    131           scope: support.class.import.java
    132           set:
    133             - include: before-next-import
    134             - include: punctuation-accessor-dot
    135             - include: import-constant
    136             - include: import-class
    137             - include: import-function
    138             - include: import-wildcard
    139             - include: any_POP
    140         - include: any_POP
    141     - include: any_POP
    142 
    143   before-next-import:
    144     # Prevent next import statement to be consumed when a current statement isn't terminated with ';'.
    145     - match: (?=\bimport\b)
    146       pop: true
    147     # For a case of a statement immediately before a class definition.
    148     - match: (?=\b(?:{{storage_modifiers}}|class|interface|enum)\b)
    149       pop: true
    150 
    151   package:
    152     - match: '{{lowercase_id}}'
    153       scope: support.type.package.java
    154     - include: punctuation-accessor-dot
    155 
    156   all-types:
    157     - include: primitive-types
    158     - include: object-types
    159 
    160   import-constant:
    161     - match: '{{uppercase_id}}'
    162       scope: constant.other.import.java
    163 
    164   import-class:
    165     - match: '{{classcase_id}}'
    166       scope: support.class.import.java
    167 
    168   import-function:
    169     - match: '{{id}}'
    170       scope: support.function.import.java
    171 
    172   import-wildcard:
    173     - match: \*
    174       scope: keyword.operator.wildcard.asterisk.java
    175 
    176   annotations:
    177     - match: \@
    178       scope: punctuation.definition.annotation.java
    179       push:
    180         - - meta_scope: meta.annotation.java
    181           - include: immediate_POP
    182         - annotation-parameters
    183         - - meta_content_scope: meta.annotation.identifier.java
    184           - include: immediate_POP
    185         - annotation-type-reference
    186 
    187   annotation-type-reference:
    188     - match: '{{before_fqn}}'
    189       set:
    190         - meta_scope: meta.path.java
    191         - match: '{{lowercase_id}}'
    192           scope: variable.annotation.package.java
    193         - include: punctuation-accessor-dot
    194         - include: annotation-type-no-fqn
    195     - include: annotation-type-no-fqn
    196 
    197   annotation-type-no-fqn:
    198     - match: '{{classcase_id}}'
    199       scope: variable.annotation.java
    200       set: after-annotation-type-reference
    201     - include: any_POP
    202 
    203   after-annotation-type-reference:
    204     - match: \.
    205       scope: punctuation.accessor.dot.java
    206       set: annotation-type-no-fqn
    207     - include: any_POP
    208 
    209   annotation-parameters:
    210     - match: \(
    211       scope: punctuation.section.parens.begin.java
    212       set:
    213         - meta_scope: meta.annotation.parameters.java
    214         - match: \)
    215           scope: punctuation.section.parens.end.java
    216           pop: true
    217         - match: ({{id}})\s*(=)
    218           captures:
    219             1: variable.parameter.java
    220             2: keyword.operator.assignment.java
    221           push:
    222             - match: (?=[,})])
    223               pop: true
    224             - include: annotations
    225             - include: code
    226         - include: annotation-array-initialization
    227         - include: annotations
    228         - include: code
    229     - include: any_POP
    230 
    231   annotation-array-initialization:
    232     - match: \{
    233       scope: punctuation.section.braces.begin.java
    234       push:
    235         - meta_scope: meta.braces.annotation-array-initialization.java
    236         - include: array-initialization-common
    237         - include: annotations
    238 
    239   anonymous-classes-and-new:
    240     - match: \bnew\b
    241       scope: keyword.other.storage.new.java
    242       push:
    243         - - meta_scope: meta.instantiation.java
    244           - include: immediate_POP
    245         - instantiation
    246 
    247   instantiation:
    248     - match: \b{{primitives}}\b
    249       scope: storage.type.primitive.java
    250       set: array-definition
    251     - match: '{{before_fqn}}'
    252       set: [after-object-type-in-instantiation, object-type-fqn]
    253     - include: object-type-instantiation-no-fqn
    254 
    255   object-type-instantiation-no-fqn:
    256     - match: '{{classcase_id}}'
    257       scope: support.class.java
    258       set: after-object-type-in-instantiation
    259     - include: any_POP
    260 
    261   after-object-type-in-instantiation:
    262     - match: (?=\[)
    263       set: array-definition
    264     - match: (?=\()
    265       set: object-construction
    266     - match: <>
    267       scope: punctuation.definition.generic.diamond.java
    268       set: object-construction
    269     - match: (?=<)
    270       set: [after-generic-in-instantiation, generic-type-invocation]
    271     - match: \.
    272       scope: punctuation.accessor.dot.java
    273       set: object-type-instantiation-no-fqn
    274     - include: any_POP
    275 
    276   after-generic-in-instantiation:
    277     - match: (?=\[)
    278       set: array-definition
    279     - include: object-construction
    280 
    281   object-construction:
    282     - match: \(
    283       scope: punctuation.section.parens.begin.java
    284       set:
    285         - meta_scope: meta.parens.constructor-arguments.java
    286         - match: \)
    287           scope: punctuation.section.parens.end.java
    288           set:
    289             - match: \{
    290               scope: punctuation.section.braces.begin.java
    291               set:
    292                 - meta_scope: meta.class.body.anonymous.java
    293                 - match: \}
    294                   scope: punctuation.section.braces.end.java
    295                   pop: true
    296                 - include: class-body
    297             - include: any_POP
    298         - include: illegal-parens-terminators
    299         - include: code
    300     - include: any_POP
    301 
    302   array-definition:
    303     - match: \[
    304       scope: punctuation.section.brackets.begin.java
    305       set:
    306         - meta_scope: meta.brackets.array-initialization.java
    307         - match: \]
    308           scope: punctuation.section.brackets.end.java
    309           set:
    310             - match: (?=\[)
    311               set: array-definition
    312             - match: \{
    313               scope: punctuation.section.braces.begin.java
    314               set: array-initialization
    315             - include: any_POP
    316         - include: code
    317     - include: any_POP
    318 
    319   array-initialization:
    320     - meta_scope: meta.braces.array-initialization.java
    321     - include: array-initialization-common
    322 
    323   array-initialization-common:
    324     - match: \}
    325       scope: punctuation.section.braces.end.java
    326       pop: true
    327     - match: \{
    328       scope: punctuation.section.braces.begin.java
    329       push: array-initialization
    330     - include: code
    331 
    332   class:
    333     - match: (?=({{storage_modifiers}}\s+)*(?:class|(?:@)?interface|enum)\b)
    334       push: [class-meta, class-type]
    335 
    336   class-meta:
    337     - meta_scope: meta.class.java
    338     - include: immediate_POP
    339 
    340   class-type:
    341     - include: storage-modifiers
    342     - match: (?:class|(\@?)interface)\b
    343       scope: storage.type.java
    344       captures:
    345         1: punctuation.definition.type.java
    346       set:
    347         - class-block
    348         - class-extends
    349         - generic-type-declaration
    350         - class-name
    351     - match: enum\b
    352       scope: storage.type.java
    353       set:
    354         - enum-block
    355         - class-extends
    356         - generic-type-declaration
    357         - class-name
    358     - include: any_POP
    359 
    360   class-name:
    361     - meta_scope: meta.class.identifier.java
    362     - match: (?!extends|implements){{id}}\b
    363       scope: entity.name.class.java
    364       pop: true
    365     - include: any_POP
    366 
    367   class-extends:
    368     - match: extends\b
    369       scope: keyword.declaration.extends.java
    370       push:
    371         - - meta_scope: meta.class.extends.java
    372           - match: \,
    373             scope: punctuation.separator.comma.java
    374             push: inherited-object-type-reference
    375           - include: any_POP
    376         - inherited-object-type-reference
    377     - match: implements\b
    378       scope: keyword.declaration.implements.java
    379       push:
    380         - - meta_scope: meta.class.implements.java
    381           - match: \,
    382             scope: punctuation.separator.comma.java
    383             push: inherited-object-type-reference
    384           - include: any_POP
    385         - inherited-object-type-reference
    386     - include: any_POP
    387 
    388   class-block:
    389     - match: \{
    390       scope: punctuation.section.block.begin.java
    391       set:
    392         - meta_scope: meta.class.body.java meta.block.java
    393         - match: \}
    394           scope: punctuation.section.block.end.java
    395           pop: true
    396         - include: class-body
    397     - include: any_POP
    398 
    399   class-body:
    400     - include: class
    401     - include: annotations
    402     - include: fields-and-methods
    403     - include: constants-and-special-vars
    404     - include: storage-modifiers
    405     - include: all-types
    406     - include: static-code-block
    407     - include: punctuation-separator-comma
    408     - include: punctuation-terminator-semicolon
    409     - match: (?=<)
    410       push: generic-type-declaration
    411 
    412   enum-block:
    413     - match: \{
    414       scope: punctuation.section.block.begin.java
    415       set:
    416         - meta_scope: meta.class.body.java meta.block.java
    417         - match: \}
    418           scope: punctuation.section.block.end.java
    419           pop: true
    420         - include: enum-body
    421     - include: any_POP
    422 
    423   enum-body:
    424     - match: ^(?=\s*([[:upper:]_][[:upper:][:digit:]_]*|(?!{{primitives}}|{{storage_modifiers}})[[:lower:]_][[:alnum:]_]*)\s*[,;{(])
    425       push:
    426         - match: (?=[;}])
    427           pop: true
    428         - match: \w+
    429           scope: constant.other.enum.java
    430           push:
    431             - meta_scope: meta.enum.java
    432             - match: \{
    433               scope: punctuation.section.block.begin.java
    434               push:
    435                 - meta_scope: meta.enum.body.java meta.block.java
    436                 - match: \}
    437                   scope: punctuation.section.block.end.java
    438                   pop: true
    439                 - include: enum-body
    440             - include: parens
    441             - include: any_POP
    442         - include: punctuation-separator-comma
    443     - include: class-body
    444 
    445   code:
    446     - include: constants-and-special-vars
    447     - include: assignment
    448     - include: lambdas
    449     - include: strings
    450     - include: anonymous-classes-and-new
    451     - include: keywords-control
    452     - include: method-invocations
    453     - include: uppercase-identifiers
    454     - include: all-types
    455     - include: keywords
    456     - include: code-block-include
    457     - include: parens
    458   code-block-include:
    459     - match: \{
    460       scope: punctuation.section.block.begin.java
    461       push:
    462         - meta_scope: meta.block.java
    463         - match: \}
    464           scope: punctuation.section.block.end.java
    465           pop: true
    466         - include: code-block
    467   code-block:
    468     - include: storage-modifiers
    469     - include: var-type
    470     - include: code
    471     - include: annotations
    472     - include: code-block-include
    473     - include: stray-parens
    474   comments:
    475     - match: /\*\*/
    476       scope: comment.block.empty.java punctuation.definition.comment.java
    477     - include: scope:text.html.javadoc
    478     - include: comments-inline
    479   comments-inline:
    480     - match: /\*
    481       scope: punctuation.definition.comment.java
    482       push:
    483         - meta_scope: comment.block.java
    484         - match: \*/
    485           scope: punctuation.definition.comment.java
    486           pop: true
    487     - match: //
    488       scope: punctuation.definition.comment.java
    489       push:
    490         - meta_scope: comment.line.double-slash.java
    491         - match: \n
    492           pop: true
    493         - match: (?=%>)
    494           pop: true
    495 
    496   constants-and-special-vars:
    497     - match: \b(true|false|null)\b
    498       scope: constant.language.java
    499     - match: \b(this|super)\b
    500       scope: variable.language.java
    501     # hexadecimal floats
    502     - match: |-
    503         \b(0[xX])(?x:
    504           # 0x1., 0x1.1, 0x1.1p1, 0x1.1p-1, 0x1.p1, 0x1.p-1 | 0x1p1
    505           {{hdigits}} (?: (\.) (?: {{hdigits}}? {{pexponent}}? \b )? | {{pexponent}} \b )
    506           # 0x.1, 0x.1p1, 0x.1p-1
    507           | (\.) {{hdigits}} {{pexponent}}? \b
    508         )
    509       scope: constant.numeric.float.hexadecimal.java
    510       captures:
    511         1: punctuation.definition.numeric.hexadecimal.java
    512         2: invalid.illegal.numeric.java
    513         3: invalid.illegal.numeric.java
    514         4: punctuation.separator.decimal.java
    515         5: invalid.illegal.numeric.java
    516         6: invalid.illegal.numeric.java
    517         7: invalid.illegal.numeric.java
    518         8: invalid.illegal.numeric.java
    519         9: invalid.illegal.numeric.java
    520         10: invalid.illegal.numeric.java
    521         11: punctuation.separator.decimal.java
    522         12: invalid.illegal.numeric.java
    523         13: invalid.illegal.numeric.java
    524         14: invalid.illegal.numeric.java
    525         15: invalid.illegal.numeric.java
    526     # decimal floats
    527     - match: |-
    528         (?x:
    529           \b{{ddigits0}}
    530           (?:
    531             # 1., 1.1, 1.1e1, 1.1e-1, 1.e1, 1.e-1, 1.d, 1.1d, 1.1e1d, 1.1e-1d, 1.e1d, 1.e-1d
    532             (\.) (?: {{ddigits}}? {{eexponent}}? ([dDfF])? \b )?
    533             # 1e1 1e1d
    534             | {{eexponent}} ([dDfF])? \b
    535             # 1d
    536             | ([dDfF]) \b
    537           )
    538           # .1, .1e1, .1e-1
    539           | (\.) {{ddigits}} {{eexponent}}? ([dDfF])? \b
    540         )
    541       scope: constant.numeric.float.decimal.java
    542       captures:
    543         1: invalid.illegal.numeric.java
    544         2: punctuation.separator.decimal.java
    545         3: invalid.illegal.numeric.java
    546         4: invalid.illegal.numeric.java
    547         5: invalid.illegal.numeric.java
    548         6: invalid.illegal.numeric.java
    549         7: storage.type.numeric.java
    550         8: invalid.illegal.numeric.java
    551         9: invalid.illegal.numeric.java
    552         10: storage.type.numeric.java
    553         11: storage.type.numeric.java
    554         12: punctuation.separator.decimal.java
    555         13: invalid.illegal.numeric.java
    556         14: invalid.illegal.numeric.java
    557         15: invalid.illegal.numeric.java
    558         16: invalid.illegal.numeric.java
    559         17: storage.type.numeric.java
    560     # binary integers
    561     - match: \b(0[bB])(_*)[01][01_]*?(_*)([lL])?\b
    562       scope: constant.numeric.integer.binary.java
    563       captures:
    564         1: punctuation.definition.numeric.binary.java
    565         2: invalid.illegal.numeric.java
    566         3: invalid.illegal.numeric.java
    567         4: storage.type.numeric.java
    568     # hexadecimal integers
    569     - match: \b(0[xX]){{hdigits}}([lL])?\b
    570       scope: constant.numeric.integer.hexadecimal.java
    571       captures:
    572         1: punctuation.definition.numeric.hexadecimal.java
    573         2: invalid.illegal.numeric.java
    574         3: invalid.illegal.numeric.java
    575         4: storage.type.numeric.java
    576     # octal integers
    577     - match: \b(0)(?:(_+)|[0-7_]+?(_*)|([\d_]+))([lL])?\b
    578       scope: constant.numeric.integer.octal.java
    579       captures:
    580         1: punctuation.definition.numeric.octal.java
    581         2: invalid.illegal.numeric.java
    582         3: invalid.illegal.numeric.java
    583         4: invalid.illegal.numeric.java
    584         5: storage.type.numeric.java
    585     # decimal integers
    586     - match: \b{{ddigits0}}([lL])?\b
    587       scope: constant.numeric.integer.decimal.java
    588       captures:
    589         1: invalid.illegal.numeric.java
    590         2: storage.type.numeric.java
    591 
    592   keywords:
    593     - match: '::'
    594       scope: punctuation.accessor.double-colon.java
    595       push:
    596         - match: '{{id}}'
    597           scope: variable.function.reference.java
    598           pop: true
    599         - include: any_POP
    600     - match: '\?|:'
    601       scope: keyword.operator.ternary.java
    602     - match: \binstanceof\b
    603       scope: keyword.operator.word.instanceof.java
    604     - match: (<<|>>>?)
    605       scope: keyword.operator.bitshift.java
    606     - match: (==|!=|<=|>=|<>|<|>)
    607       scope: keyword.operator.comparison.java
    608     - match: (\-\-|\+\+)
    609       scope: keyword.operator.increment-decrement.java
    610     - match: (\-|\+|\*|\/|%)
    611       scope: keyword.operator.arithmetic.java
    612     - match: (!|&&|\|\|)
    613       scope: keyword.operator.logical.java
    614     - match: (~|\^|&|\|)
    615       scope: keyword.operator.bitwise.java
    616     - match: (\.)(class\b)?
    617       captures:
    618         1: punctuation.accessor.dot.java
    619         2: variable.language.java
    620     - include: punctuation-separator-comma
    621     - include: punctuation-terminator-semicolon
    622 
    623   keywords-control:
    624     # exceptions
    625     - match: \bcatch\b
    626       scope: keyword.control.exception.catch.java
    627       push:
    628         - meta_scope: meta.catch.java
    629         - match: (?=\()
    630           set:
    631             - match: \(
    632               scope: punctuation.section.parens.begin.java
    633               set:
    634                 - meta_scope: meta.catch.parameters.java meta.parens.java
    635                 - match: \)
    636                   scope: punctuation.section.parens.end.java
    637                   pop: true
    638                 - match: \|
    639                   scope: punctuation.separator.bar.java
    640                 - include: parameters
    641         - include: any_POP
    642     - match: \bfinally\b
    643       scope: keyword.control.exception.finally.java
    644     - match: \btry\b
    645       scope: keyword.control.exception.try.java
    646       push: declaration-statement-parens
    647     # flow
    648     - match: \bassert\b
    649       scope: keyword.control.flow.assert.java
    650       push:
    651         - meta_scope: meta.assertion.java
    652         - match: (?=;)
    653           pop: true
    654         - match: ':'
    655           scope: punctuation.separator.expressions.java
    656         - include: code
    657     - match: \bbreak\b
    658       scope: keyword.control.flow.break.java
    659     - match: \bcontinue\b
    660       scope: keyword.control.flow.continue.java
    661     - match: \breturn\b
    662       scope: keyword.control.flow.return.java
    663     - match: \bthrow\b
    664       scope: keyword.control.flow.throw.java
    665     # conditional
    666     - match: \bif\b
    667       scope: keyword.control.conditional.if.java
    668     - match: \belse\b
    669       scope: keyword.control.conditional.else.java
    670     - match: \bswitch\b
    671       scope: keyword.control.conditional.switch.java
    672     - match: \bcase\b
    673       scope: keyword.control.conditional.case.java
    674     - match: \bdefault\b
    675       scope: keyword.control.conditional.default.java
    676     # loop
    677     - match: \bdo\b
    678       scope: keyword.control.loop.do-while.java
    679     - match: \bfor\b
    680       scope: keyword.control.loop.for.java
    681       push: declaration-statement-parens
    682     - match: \bwhile\b
    683       scope: keyword.control.loop.while.java
    684 
    685   illegal-keywords:
    686     - match: \b(goto|const)\b
    687       scope: invalid.illegal.keyword.java
    688 
    689   illegal-open-block:
    690     - match: \s?(?={)
    691       scope: invalid.illegal.stray-terminator-end
    692       pop: true
    693 
    694   illegal-semicolon:
    695     - match: ;
    696       scope: invalid.illegal.stray-terminator-end
    697       pop: true
    698 
    699   illegal-parens-terminators:
    700     # Pops the stack if anything matches
    701     - include: illegal-semicolon
    702     - include: illegal-open-block
    703 
    704   method-invocations:
    705     - match: (\.)\s*(?=<)
    706       captures:
    707         1: punctuation.accessor.dot.java
    708       push: generic-type-invocation
    709     - match: ({{id}})\s*(\()
    710       captures:
    711         1: variable.function.java
    712         2: punctuation.section.parens.begin.java
    713       push:
    714         - meta_scope: meta.function-call.java
    715         - match: \)
    716           scope: punctuation.section.parens.end.java
    717           pop: true
    718         - include: illegal-parens-terminators
    719         - include: code
    720 
    721   fields-and-methods:
    722     - match: \bvoid\b
    723       scope: storage.type.void.java
    724       push: method
    725     - match: (?={{id}}\s*\()
    726       push: method
    727     - match: '{{before_fqn}}'
    728       push: [field-or-method, after-object-and-array-types, object-type-fqn]
    729     - match: \b{{classcase_id}}
    730       scope: support.class.java
    731       push: [field-or-method, after-object-and-array-types]
    732     - match: \b{{primitives}}\b
    733       scope: storage.type.primitive.java
    734       push: [field-or-method, array-brackets]
    735 
    736   field-or-method:
    737     - match: (?={{id}}\s*\()
    738       set: method
    739     - match: (?=\S)
    740       set:
    741       - include: before-next-field
    742       - match: (?:({{uppercase_id}})|({{id}}))
    743         captures:
    744           1: entity.name.constant.java
    745           2: meta.field.java
    746         push: [static-assignment, array-brackets]
    747       - include: punctuation-separator-comma
    748       - include: any_POP
    749 
    750   before-next-field:
    751     # Prevent style from being removed from whole file when making a new expression
    752     - match: (?=\b(?:{{storage_modifiers}}|{{primitives}}|void)\b)
    753       pop: true
    754 
    755   method:
    756     - meta_scope: meta.method.java
    757     - match: ({{classcase_id}})\s*(?=\()
    758       captures:
    759         1: meta.method.identifier.java entity.name.function.constructor.java
    760     - match: ({{id}})\s*(?=\()
    761       captures:
    762         1: meta.method.identifier.java entity.name.function.java
    763     - match: \(
    764       scope: punctuation.section.parens.begin.java
    765       push:
    766         - meta_scope: meta.method.parameters.java meta.parens.java
    767         - match: \)
    768           scope: punctuation.section.parens.end.java
    769           pop: true
    770         - include: parameters
    771         - match: \S
    772           scope: invalid.illegal.missing-parameter-end
    773           pop: true
    774     - include: throws
    775     - include: annotation-default
    776     - match: \{
    777       scope: punctuation.section.block.begin.java
    778       set:
    779         - meta_scope: meta.method.java meta.method.body.java
    780         - match: \}
    781           scope: punctuation.section.block.end.java
    782           pop: true
    783         - include: code-block
    784     - include: any_POP
    785 
    786   throws:
    787     - match: \bthrows\b
    788       scope: keyword.declaration.throws.java
    789       push:
    790       - - meta_scope: meta.method.throws.java
    791         - match: \,
    792           scope: punctuation.separator.comma.java
    793           push: object-type-reference
    794         - include: any_POP
    795       - object-type-reference
    796 
    797   # Stand-along uppercase id, either type or constant.
    798   # Should be used only inside code blocks.
    799   uppercase-identifiers:
    800     # Popular JDK classes
    801     - match: \b(?:UUID|UR[LI])\b
    802       scope: support.class.java
    803       push: after-object-type
    804     # Generic type variable
    805     - match: \b\p{Lu}\b
    806       scope: support.class.java
    807       push: after-object-type
    808     # Uppercase constants
    809     - match: \b{{uppercase_id}}
    810       scope: constant.other.java
    811 
    812   # Stand-alone type, maybe type of the variable or class object reference.
    813   # Should be used only inside code blocks.
    814   object-types:
    815     # Here the match is more complex than 'before_fqn'.
    816     # In code block we can't simply distinguish package from variable.
    817     - match: (?=\b(?:{{lowercase_id}}\.)+\p{Lu})
    818       push: [after-object-type, object-type-fqn]
    819     - match: \b{{classcase_id}}\b
    820       scope: support.class.java
    821       push: after-object-type
    822 
    823   object-type-fqn:
    824     - meta_scope: meta.path.java
    825     - include: package
    826     - match: '{{classcase_id}}'
    827       scope: support.class.java
    828       pop: true
    829     - include: any_POP
    830 
    831   after-object-type:
    832     - match: (?=<)
    833       set: [array-brackets, generic-type-invocation]
    834     - match: \.(?!\.)
    835       scope: punctuation.accessor.dot.java
    836       set:
    837         - match: (?=<)
    838           set: generic-type-invocation
    839         - match: (?:(class)\b|({{uppercase_id}}))
    840           captures:
    841             1: variable.language.java
    842             2: constant.other.java
    843           pop: true
    844         - match: '{{classcase_id}}'
    845           scope: support.class.java
    846           set: after-object-type
    847         - include: any_POP
    848     - include: array-brackets
    849 
    850   # Used in 'throws' and generic bounds
    851   object-type-reference:
    852     - match: '{{before_fqn}}'
    853       set:
    854         - meta_scope: meta.path.java
    855         - include: package
    856         - include: object-type-reference-no-fqn
    857     - include: object-type-reference-no-fqn
    858 
    859   object-type-reference-no-fqn:
    860     - match: '{{classcase_id}}'
    861       scope: support.class.java
    862       set: after-object-type-reference
    863     - include: any_POP
    864 
    865   after-object-type-reference:
    866     - match: (?=<)
    867       set: generic-type-invocation
    868     - match: \.
    869       scope: punctuation.accessor.dot.java
    870       set: object-type-reference-no-fqn
    871     - include: any_POP
    872 
    873   # Used in method's and generic's parameters
    874   object-and-array-types:
    875     - match: '{{before_fqn}}'
    876       push:
    877         - meta_scope: meta.path.java
    878         - include: package
    879         - include: object-and-array-types-no-fqn
    880     - match: \b({{primitives}})(?=\s*\[)
    881       scope: storage.type.primitive.java
    882       push: array-brackets
    883     - match: \b{{classcase_id}}
    884       scope: support.class.java
    885       push: after-object-and-array-types
    886 
    887   object-and-array-types-no-fqn:
    888     - match: '{{classcase_id}}'
    889       scope: support.class.java
    890       set: after-object-and-array-types
    891     - include: any_POP
    892 
    893   after-object-and-array-types:
    894     - match: (?=<)
    895       set: [array-brackets, generic-type-invocation]
    896     - match: \.(?!\.)
    897       scope: punctuation.accessor.dot.java
    898       set: object-and-array-types-no-fqn
    899     - include: array-brackets
    900 
    901   # Used in class-level 'extends' and 'implements'
    902   inherited-object-type-reference:
    903     - match: '{{before_fqn}}'
    904       set:
    905         - meta_scope: meta.path.java
    906         - match: '{{lowercase_id}}'
    907           scope: entity.other.inherited-class.package.java
    908         - include: punctuation-accessor-dot
    909         - include: inherited-object-type-reference-no-fqn
    910     - include: inherited-object-type-reference-no-fqn
    911 
    912   inherited-object-type-reference-no-fqn:
    913     - match: (?!class|extends|implements|interface){{id}}
    914       scope: entity.other.inherited-class.java
    915       set: after-inherited-object-type-reference
    916     - include: any_POP
    917 
    918   after-inherited-object-type-reference:
    919     - match: (?=<)
    920       set: generic-type-invocation
    921     - match: \.
    922       scope: punctuation.accessor.dot.java
    923       set: inherited-object-type-reference-no-fqn
    924     - include: any_POP
    925 
    926   generic-type-declaration:
    927     - match: <
    928       scope: punctuation.definition.generic.begin.java
    929       push: generic-type-parameter
    930     - include: any_POP
    931 
    932   generic-type-terminator:
    933     - include: illegal-semicolon
    934     # These characters can't appear in a generic. If we've matched
    935     # them then someone forgot to close it.
    936     - match: (?=[{}()])
    937       pop: true
    938     - match: '>'
    939       scope: punctuation.definition.generic.end.java
    940       pop: true
    941 
    942   generic-type-parameter:
    943     - meta_scope: meta.generic.declaration.java
    944     - match: \b{{id}}\b
    945       scope: variable.parameter.type.java
    946       push: generic-type-bounds
    947     - include: generic-type-terminator
    948 
    949   generic-type-bounds:
    950     - match: (,)|(?=>)
    951       captures:
    952         1: punctuation.separator.comma.java
    953       pop: true
    954     - match: \bextends\b
    955       scope: keyword.declaration.extends.java
    956       push: [generic-type-extends-multiple-bounds, object-type-reference]
    957     - match: \bsuper\b
    958       scope: keyword.declaration.super.java
    959       push: object-type-reference
    960 
    961   generic-type-extends-multiple-bounds:
    962     - match: '&'
    963       scope: keyword.operator.multiple-bounds.java
    964       set: [generic-type-extends-multiple-bounds, object-type-reference]
    965     - include: any_POP
    966 
    967   generic-type-invocation:
    968     - match: <
    969       scope: punctuation.definition.generic.begin.java
    970       set: generic-type-argument
    971     - include: any_POP
    972 
    973   generic-type-argument:
    974     - meta_scope: meta.generic.java
    975     - match: \?
    976       scope: keyword.operator.wildcard.java
    977       push: generic-type-bounds
    978     - include: generic-type-terminator
    979     - include: object-and-array-types
    980     - include: punctuation-separator-comma
    981 
    982   annotation-default:
    983     - match: \bdefault\b
    984       scope: keyword.declaration.default.java
    985       push:
    986         - meta_scope: meta.annotation.default.java
    987         - match: (?=;)
    988           pop: true
    989         - include: code
    990 
    991   parameters:
    992     - match: \bfinal\b
    993       scope: storage.modifier.java
    994     - include: annotations
    995     - include: primitive-types
    996     - include: object-and-array-types
    997     - match: \.\.\.
    998       scope: keyword.operator.variadic.java
    999     - match: '{{id}}'
   1000       scope: variable.parameter.java
   1001       push: array-brackets
   1002     - include: punctuation-separator-comma
   1003 
   1004   lambdas:
   1005     - match: (?={{lambda_lookahead}})
   1006       push: lambda-params
   1007 
   1008   lambda-params:
   1009     - meta_scope: meta.function.anonymous.parameters.java
   1010     - match: \(
   1011       scope: punctuation.section.parens.begin.java
   1012       set:
   1013         - meta_scope: meta.function.anonymous.parameters.java
   1014         - match: \)
   1015           scope: punctuation.section.parens.end.java
   1016           set: lambda-arrow
   1017         - include: parameters
   1018     - match: '{{id}}'
   1019       scope: variable.parameter.java
   1020       set: lambda-arrow
   1021 
   1022   lambda-arrow:
   1023     - match: ->
   1024       scope: storage.type.function.anonymous.java
   1025       set:
   1026         - meta_scope: meta.function.anonymous.body.java
   1027         - match: (?=[)};])
   1028           pop: true
   1029         - include: code
   1030 
   1031   parens:
   1032     - match: \(
   1033       scope: punctuation.section.parens.begin.java
   1034       push:
   1035         - meta_scope: meta.parens.java
   1036         - match: \)
   1037           scope: punctuation.section.parens.end.java
   1038           pop: true
   1039         - include: illegal-parens-terminators
   1040         - include: code
   1041 
   1042   declaration-statement-parens:
   1043     - match: \(
   1044       scope: punctuation.section.parens.begin.java
   1045       set:
   1046         - meta_scope: meta.parens.java
   1047         - match: \)
   1048           scope: punctuation.section.parens.end.java
   1049           pop: true
   1050         - include: illegal-open-block
   1051         - include: code-block
   1052     - include: any_POP
   1053 
   1054   primitive-types:
   1055     - match: \b{{primitives}}\b
   1056       scope: storage.type.primitive.java
   1057       push: array-brackets
   1058 
   1059   var-type:
   1060     - match: \bvar\b
   1061       scope: storage.type.var.java
   1062 
   1063   array-brackets:
   1064     - match: \[\s*\]
   1065       scope: storage.modifier.array.java
   1066     - include: any_POP
   1067 
   1068   static-assignment:
   1069     - match: \=
   1070       scope: keyword.operator.assignment.java
   1071       set:
   1072         - meta_scope: meta.assignment.rhs.java
   1073         - match: (?=[,;])
   1074           pop: true
   1075         - include: before-next-field
   1076         - include: code
   1077         - include: stray-parens
   1078     - include: any_POP
   1079 
   1080   assignment:
   1081     - match: ([|&^*/+-]\=|\=(?!=))
   1082       scope: keyword.operator.assignment.java
   1083       push:
   1084         - meta_scope: meta.assignment.rhs.java
   1085         - match: (?=;|\)|\}|,)
   1086           pop: true
   1087         - include: code
   1088   static-code-block:
   1089     - match: \{
   1090       scope: punctuation.section.block.begin.java
   1091       push:
   1092         - meta_scope: meta.static.body.java
   1093         - match: \}
   1094           scope: punctuation.section.block.end.java
   1095           pop: true
   1096         - include: code-block
   1097   storage-modifiers:
   1098     - match: \b{{storage_modifiers}}\b
   1099       scope: storage.modifier.java
   1100   stray-braces:
   1101     - match: \}
   1102       scope: invalid.illegal.stray-brace-end
   1103   stray-parens:
   1104     - match: \)
   1105       scope: invalid.illegal.stray-parens-end
   1106 
   1107   strings:
   1108     - match: \"
   1109       scope: punctuation.definition.string.begin.java
   1110       push:
   1111         - meta_include_prototype: false
   1112         - meta_scope: string.quoted.double.java
   1113         - match: \"
   1114           scope: punctuation.definition.string.end.java
   1115           pop: true
   1116         - include: strings-common
   1117     - match: \'
   1118       scope: punctuation.definition.string.begin.java
   1119       push:
   1120         - meta_include_prototype: false
   1121         - meta_scope: string.quoted.single.java
   1122         - match: \'
   1123           scope: punctuation.definition.string.end.java
   1124           pop: true
   1125         - include: strings-common
   1126 
   1127   strings-common:
   1128     - match: \n
   1129       scope: invalid.illegal.newline.java
   1130       pop: true
   1131     - match: \\.
   1132       scope: constant.character.escape.java
   1133 
   1134   module:
   1135     - match: (?=\b(?:open\s+)?module\b)
   1136       push:
   1137       - - meta_scope: meta.module.java
   1138         - include: immediate_POP
   1139       - - match: \bopen\b
   1140           scope: storage.modifier.java
   1141         - match: \bmodule\b
   1142           scope: storage.type.java
   1143           set: [module-body, module-identifier-scope, module-identifier]
   1144 
   1145   module-identifier-scope:
   1146     - meta_scope: meta.module.identifier.java
   1147     - include: immediate_POP
   1148 
   1149   module-identifier:
   1150     - match: '{{id}}'
   1151       set:
   1152         - - meta_scope: entity.name.module.java
   1153           - include: immediate_POP
   1154         - dot-separated-identifier
   1155     - include: any_POP
   1156 
   1157   module-body:
   1158     - match: \{
   1159       scope: punctuation.section.braces.begin.java
   1160       set:
   1161         - meta_scope: meta.module.body.java
   1162         - include: module-body-content
   1163         - match: \}
   1164           scope: punctuation.section.braces.end.java
   1165           pop: true
   1166     - include: any_POP
   1167 
   1168   module-body-content:
   1169     - match: \bexports\b
   1170       scope: keyword.other.module.exports.java
   1171       push: [exports-statement-scope, exports-or-opens-statement]
   1172     - match: \bopens\b
   1173       scope: keyword.other.module.opens.java
   1174       push: [opens-statement-scope, exports-or-opens-statement]
   1175     - match: \brequires\b
   1176       scope: keyword.other.module.requires.java
   1177       push: requires-statement
   1178     - match: \buses\b
   1179       scope: keyword.other.module.uses.java
   1180       push: [uses-statement-scope, object-type-reference]
   1181     - match: \bprovides\b
   1182       scope: keyword.other.module.provides.java
   1183       push: [provides-statement-scope, provides-with-statement, object-type-reference]
   1184     - include: punctuation-terminator-semicolon
   1185 
   1186   # Should always come before module/package patterns
   1187   module-statement-terminator:
   1188     - match: (?=[;\}])
   1189       pop: true
   1190     - match: (?=\b(?:requires|exports|uses|provides|opens)\b)
   1191       pop: true
   1192 
   1193   support-type-module:
   1194     - match: '{{id}}'
   1195       push:
   1196         - - meta_scope: support.type.module.java
   1197           - include: immediate_POP
   1198         - dot-separated-identifier
   1199 
   1200   exports-statement-scope:
   1201     - meta_scope: meta.exports.java
   1202     - include: immediate_POP
   1203 
   1204   opens-statement-scope:
   1205     - meta_scope: meta.opens.java
   1206     - include: immediate_POP
   1207 
   1208   exports-or-opens-statement:
   1209     - match: \bto\b
   1210       scope: keyword.other.module.to.java
   1211       set:
   1212         - include: module-statement-terminator
   1213         - include: support-type-module
   1214         - include: punctuation-separator-comma
   1215     - include: module-statement-terminator
   1216     - match: '{{id}}'
   1217       push:
   1218         - - meta_scope: support.type.package.java
   1219           - include: immediate_POP
   1220         - dot-separated-identifier
   1221 
   1222   requires-statement:
   1223     - meta_scope: meta.requires.java
   1224     - match: \btransitive\b
   1225       scope: keyword.other.module.transitive.java
   1226     - include: module-statement-terminator
   1227     - include: support-type-module
   1228 
   1229   uses-statement-scope:
   1230     - meta_scope: meta.uses.java
   1231     - include: immediate_POP
   1232 
   1233   provides-statement-scope:
   1234     - meta_scope: meta.provides.java
   1235     - include: immediate_POP
   1236 
   1237   provides-with-statement:
   1238     - match: \bwith\b
   1239       scope: keyword.other.module.with.java
   1240       set:
   1241         - - match: \,
   1242             scope: punctuation.separator.comma.java
   1243             push: object-type-reference
   1244           - include: any_POP
   1245         - object-type-reference
   1246     - include: any_POP