@@ -169,6 +169,7 @@ const grammar = {
169169 { include : '#variable-initializer' } ,
170170 { include : '#constructor-declaration' } ,
171171 { include : '#method-declaration' } ,
172+ { include : '#initializer-block' } ,
172173 { include : '#punctuation-semicolon' }
173174 ]
174175 } ,
@@ -210,7 +211,7 @@ const grammar = {
210211 ]
211212 } ,
212213 'conditional-operator' : {
213- begin : '(?<!\\?)\\?(?!\\?|\\.|\\[)' ,
214+ begin : '(?<!\\?)\\?(?!\\?|\\.(?!\\d) |\\[)' ,
214215 beginCaptures : {
215216 0 : { name : 'keyword.operator.conditional.question-mark.apex' }
216217 } ,
@@ -261,6 +262,12 @@ const grammar = {
261262 ]
262263 } ,
263264 directives : { patterns : [ { include : '#punctuation-semicolon' } ] } ,
265+ 'dml-expression' : {
266+ begin : '\\b(delete|insert|undelete|update|upsert)\\b\\s+(?!new\\b)' ,
267+ beginCaptures : { 1 : { name : 'support.function.apex' } } ,
268+ end : '(?<=\\;)' ,
269+ patterns : [ { include : '#expression' } , { include : '#punctuation-semicolon' } ]
270+ } ,
264271 'do-statement' : {
265272 begin : '(?<!\\.)\\b(do)\\b' ,
266273 beginCaptures : { 1 : { name : 'keyword.control.loop.do.apex' } } ,
@@ -338,6 +345,7 @@ const grammar = {
338345 expression : {
339346 patterns : [
340347 { include : '#comment' } ,
348+ { include : '#dml-expression' } ,
341349 { include : '#merge-expression' } ,
342350 { include : '#support-expression' } ,
343351 { include : '#throw-expression' } ,
@@ -386,12 +394,20 @@ const grammar = {
386394 ]
387395 } ,
388396 'extends-class' : {
389- begin : '(extends)\\b\\s+([_[:alpha:]][_[:alnum:]]*)' ,
390- beginCaptures : {
391- 1 : { name : 'keyword.other.extends.apex' } ,
392- 2 : { name : 'entity.name.type.extends.apex' }
393- } ,
394- end : '(?={|implements)'
397+ begin : '(extends)\\b\\s+' ,
398+ beginCaptures : { 1 : { name : 'keyword.other.extends.apex' } } ,
399+ end : '(?={|implements)' ,
400+ patterns : [
401+ {
402+ begin : '(?=[_[:alpha:]][_[:alnum:]]*\\s*\\.)' ,
403+ end : '(?={|implements)' ,
404+ patterns : [ { include : '#support-type' } , { include : '#type' } ]
405+ } ,
406+ {
407+ captures : { 1 : { name : 'entity.name.type.extends.apex' } } ,
408+ match : '([_[:alpha:]][_[:alnum:]]*)'
409+ }
410+ ]
395411 } ,
396412 'field-declaration' : {
397413 begin :
@@ -494,12 +510,24 @@ const grammar = {
494510 ]
495511 } ,
496512 'implements-class' : {
497- begin : '(implements)\\b\\s+([_[:alpha:]][_[:alnum:]]*)' ,
498- beginCaptures : {
499- 1 : { name : 'keyword.other.implements.apex' } ,
500- 2 : { name : 'entity.name.type.implements.apex' }
501- } ,
502- end : '(?={|extends)'
513+ begin : '(implements)\\b' ,
514+ beginCaptures : { 1 : { name : 'keyword.other.implements.apex' } } ,
515+ end : '(?={|extends)' ,
516+ patterns : [
517+ {
518+ begin : '(?=[_[:alpha:]][_[:alnum:]]*\\s*\\.)' ,
519+ end : '(?={|extends|,)' ,
520+ patterns : [ { include : '#support-type' } , { include : '#type' } ]
521+ } ,
522+ {
523+ captures : {
524+ 1 : { name : 'entity.name.type.implements.apex' } ,
525+ 2 : { name : 'punctuation.separator.comma.apex' }
526+ } ,
527+ match : '([_[:alpha:]][_[:alnum:]]*)\\b\\s*(,)?'
528+ } ,
529+ { include : '#punctuation-comma' }
530+ ]
503531 } ,
504532 'indexer-declaration' : {
505533 begin :
@@ -517,6 +545,13 @@ const grammar = {
517545 { include : '#variable-initializer' }
518546 ]
519547 } ,
548+ 'initializer-block' : {
549+ begin : '\\{' ,
550+ beginCaptures : { 0 : { name : 'punctuation.curlybrace.open.apex' } } ,
551+ end : '\\}' ,
552+ endCaptures : { 0 : { name : 'punctuation.curlybrace.close.apex' } } ,
553+ patterns : [ { include : '#statement' } ]
554+ } ,
520555 'initializer-expression' : {
521556 begin : '\\{' ,
522557 beginCaptures : { 0 : { name : 'punctuation.curlybrace.open.apex' } } ,
@@ -865,7 +900,7 @@ const grammar = {
865900 6 : { name : 'entity.name.variable.parameter.apex' }
866901 } ,
867902 match :
868- '(?x)\n(?:(?:\\b(this)\\b)\\s+)?\n(?<type_name>\n (?:\n (?:ref\\s+)? # ref return\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n)\\s+\n(\\g<identifier>)'
903+ '(?x)\n(?:(?:\\b(this|final )\\b)\\s+)?\n(?<type_name>\n (?:\n (?:ref\\s+)? # ref return\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n)\\s+\n(\\g<identifier>)'
869904 } ,
870905 'parenthesized-expression' : {
871906 begin : '\\(' ,
@@ -1198,8 +1233,7 @@ const grammar = {
11981233 ]
11991234 } ,
12001235 'switch-statement' : {
1201- begin :
1202- "(?x)\n(switch)\\b\\s+\n(on)\\b\\s+\n(?:([_.?\\'\\(\\)[:alnum:]]+)\\s*)?\n(\\{)" ,
1236+ begin : '(?x)\n(switch)\\b\\s+\n(on)\\b\\s+\n(.*)\n(\\{)' ,
12031237 beginCaptures : {
12041238 1 : { name : 'keyword.control.switch.apex' } ,
12051239 2 : { name : 'keyword.control.switch.on.apex' } ,
@@ -1385,7 +1419,7 @@ const grammar = {
13851419 'type-builtin' : {
13861420 captures : { 1 : { name : 'keyword.type.apex' } } ,
13871421 match :
1388- '\\b(Blob|Boolean|byte|Date|Datetime|Decimal|Double|ID|Integer|Long|Object|String|Time|void)\\b'
1422+ '\\b(Blob|Boolean|byte|Date|Datetime|Decimal|Double|Id| ID|Integer|Long|Object|String|Time|void)\\b'
13891423 } ,
13901424 'type-declarations' : {
13911425 patterns : [
@@ -1459,14 +1493,18 @@ const grammar = {
14591493 1 : { name : 'keyword.control.switch.when.apex' } ,
14601494 2 : { name : 'keyword.control.switch.else.apex' }
14611495 } ,
1462- end : '(?< =\\})' ,
1496+ end : '(?=\\})|(?=when\\b )' ,
14631497 patterns : [ { include : '#block' } , { include : '#expression' } ]
14641498 } ,
14651499 'when-multiple-statement' : {
14661500 begin : '(when)\\b\\s*' ,
14671501 beginCaptures : { 1 : { name : 'keyword.control.switch.when.apex' } } ,
1468- end : '(?<=\\})' ,
1469- patterns : [ { include : '#block' } , { include : '#expression' } ]
1502+ end : '(?=\\})|(?=when\\b)' ,
1503+ patterns : [
1504+ { include : '#block' } ,
1505+ { include : '#expression' } ,
1506+ { include : '#punctuation-comma' }
1507+ ]
14701508 } ,
14711509 'when-sobject-statement' : {
14721510 begin : '(when)\\b\\s+([_[:alnum:]]+)\\s+([_[:alnum:]]+)\\s*' ,
@@ -1475,46 +1513,29 @@ const grammar = {
14751513 2 : { name : 'storage.type.apex' } ,
14761514 3 : { name : 'entity.name.variable.local.apex' }
14771515 } ,
1478- end : '(?< =\\})' ,
1516+ end : '(?=\\})|(?=when\\b )' ,
14791517 patterns : [ { include : '#block' } , { include : '#expression' } ]
14801518 } ,
14811519 'when-statement' : {
1482- begin : " (when)\\b\\s+([\\' _\\-[:alnum:]]+)\\s*" ,
1520+ begin : ' (when)\\b\\s+([_\\-[:alnum:]]+)\\s*' ,
14831521 beginCaptures : {
14841522 1 : { name : 'keyword.control.switch.when.apex' } ,
14851523 2 : { patterns : [ { include : '#expression' } ] }
14861524 } ,
1487- end : '(?< =\\})' ,
1525+ end : '(?=\\})|(?=when\\b )' ,
14881526 patterns : [ { include : '#block' } , { include : '#expression' } ]
14891527 } ,
14901528 'when-string' : {
1491- begin : "(when)( \\b\\s*)((\\')[_.\\,\\'\\s*[:alnum:]]+) " ,
1529+ begin : "(when)\\b\\s*('[^'\\n]*')(\\s*(,)\\s*('[^'\\n]*'))*\\s* " ,
14921530 beginCaptures : {
14931531 1 : { name : 'keyword.control.switch.when.apex' } ,
1494- 2 : { name : 'punctuation.whitespace.apex' } ,
1495- 3 : {
1496- patterns : [
1497- { include : '#when-string-statement' } ,
1498- { include : '#punctuation-comma' }
1499- ]
1500- }
1532+ 2 : { patterns : [ { include : '#string-literal' } ] } ,
1533+ 4 : { patterns : [ { include : '#punctuation-comma' } ] } ,
1534+ 5 : { patterns : [ { include : '#string-literal' } ] }
15011535 } ,
1502- end : '(?< =\\})' ,
1536+ end : '(?=\\})|(?=when\\b )' ,
15031537 patterns : [ { include : '#block' } , { include : '#expression' } ]
15041538 } ,
1505- 'when-string-statement' : {
1506- patterns : [
1507- {
1508- begin : "\\'" ,
1509- beginCaptures : {
1510- 0 : { name : 'punctuation.definition.string.begin.apex' }
1511- } ,
1512- end : "\\'" ,
1513- endCaptures : { 0 : { name : 'punctuation.definition.string.end.apex' } } ,
1514- name : 'string.quoted.single.apex'
1515- }
1516- ]
1517- } ,
15181539 'where-clause' : {
15191540 captures : { 1 : { name : 'keyword.operator.query.where.apex' } } ,
15201541 match : '\\b(WHERE)\\b\\s*'
0 commit comments