// This is a TextMate grammar distributed by `starry-night`. // This grammar is developed at // // and licensed `bsd-3-clause`. // See for more info. /** * @import {Grammar} from '@wooorm/starry-night' */ /** @type {Grammar} */ const grammar = { extensions: ['.cls', '.apex', '.trigger'], names: ['apex'], patterns: [ {include: '#javadoc-comment'}, {include: '#comment'}, {include: '#directives'}, {include: '#declarations'}, {include: '#script-top-level'} ], repository: { 'annotation-declaration': { begin: '([@][_[:alpha:]]+)\\b', beginCaptures: {1: {name: 'storage.type.annotation.apex'}}, patterns: [ { begin: '\\(', beginCaptures: {0: {name: 'punctuation.parenthesis.open.apex'}}, end: '\\)', endCaptures: {0: {name: 'punctuation.parenthesis.close.apex'}}, patterns: [{include: '#expression'}] }, {include: '#statement'} ] }, 'argument-list': { begin: '\\(', beginCaptures: {0: {name: 'punctuation.parenthesis.open.apex'}}, end: '\\)', endCaptures: {0: {name: 'punctuation.parenthesis.close.apex'}}, patterns: [ {include: '#named-argument'}, {include: '#expression'}, {include: '#punctuation-comma'} ] }, 'array-creation-expression': { begin: '(?x)\n\\b(new)\\b\\s*\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n)?\\s*\n(?=\\[)', beginCaptures: { 1: {name: 'keyword.control.new.apex'}, 2: {patterns: [{include: '#support-type'}, {include: '#type'}]} }, end: '(?<=\\])', patterns: [{include: '#bracketed-argument-list'}] }, block: { begin: '\\{', beginCaptures: {0: {name: 'punctuation.curlybrace.open.apex'}}, end: '\\}', endCaptures: {0: {name: 'punctuation.curlybrace.close.apex'}}, patterns: [{include: '#statement'}] }, 'boolean-literal': { patterns: [ { match: '(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n)\\s*\n(\\))(?=\\s*@?[_[:alnum:]\\(])' }, 'catch-clause': { begin: '(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n)\\s*\n(?:(\\g)\\b)?' } ] }, {include: '#comment'}, {include: '#block'} ] }, 'class-declaration': { begin: '(?=\\bclass\\b)', end: '(?<=\\})', patterns: [ { begin: '(?x)\n\\b(class)\\b\\s+\n(@?[_[:alpha:]][_[:alnum:]]*)\\s*', beginCaptures: { 1: {name: 'keyword.other.class.apex'}, 2: {name: 'entity.name.type.class.apex'} }, end: '(?=\\{)', patterns: [ {include: '#javadoc-comment'}, {include: '#comment'}, {include: '#type-parameter-list'}, {include: '#extends-class'}, {include: '#implements-class'} ] }, { begin: '\\{', beginCaptures: {0: {name: 'punctuation.curlybrace.open.apex'}}, end: '\\}', endCaptures: {0: {name: 'punctuation.curlybrace.close.apex'}}, patterns: [{include: '#class-or-trigger-members'}] }, {include: '#javadoc-comment'}, {include: '#comment'} ] }, 'class-or-trigger-members': { patterns: [ {include: '#javadoc-comment'}, {include: '#comment'}, {include: '#storage-modifier'}, {include: '#sharing-modifier'}, {include: '#type-declarations'}, {include: '#field-declaration'}, {include: '#property-declaration'}, {include: '#indexer-declaration'}, {include: '#variable-initializer'}, {include: '#constructor-declaration'}, {include: '#method-declaration'}, {include: '#initializer-block'}, {include: '#punctuation-semicolon'} ] }, 'colon-expression': { match: ':', name: 'keyword.operator.conditional.colon.apex' }, comment: { patterns: [ { begin: '/\\*(\\*)?', beginCaptures: {0: {name: 'punctuation.definition.comment.apex'}}, end: '\\*/', endCaptures: {0: {name: 'punctuation.definition.comment.apex'}}, name: 'comment.block.apex' }, { begin: '(^\\s+)?(?=//)', beginCaptures: { 1: {name: 'punctuation.whitespace.comment.leading.apex'} }, end: '(?=$)', patterns: [ { begin: '(?)', patterns: [{include: '#constructor-initializer'}] }, {include: '#parenthesized-parameter-list'}, {include: '#comment'}, {include: '#expression-body'}, {include: '#block'} ] }, 'constructor-initializer': { begin: '\\b(?:(this))\\b\\s*(?=\\()', beginCaptures: {1: {name: 'keyword.other.this.apex'}}, end: '(?<=\\))', patterns: [{include: '#argument-list'}] }, 'date-literal-with-params': { captures: {1: {name: 'keyword.operator.query.date.apex'}}, match: '\\b((LAST_N_DAYS|NEXT_N_DAYS|NEXT_N_WEEKS|LAST_N_WEEKS|NEXT_N_MONTHS|LAST_N_MONTHS|NEXT_N_QUARTERS|LAST_N_QUARTERS|NEXT_N_YEARS|LAST_N_YEARS|NEXT_N_FISCAL_QUARTERS|LAST_N_FISCAL_QUARTERS|NEXT_N_FISCAL_YEARS|LAST_N_FISCAL_YEARS)\\s*\\:\\d+)\\b' }, 'date-literals': { captures: {1: {name: 'keyword.operator.query.date.apex'}}, match: '\\b(YESTERDAY|TODAY|TOMORROW|LAST_WEEK|THIS_WEEK|NEXT_WEEK|LAST_MONTH|THIS_MONTH|NEXT_MONTH|LAST_90_DAYS|NEXT_90_DAYS|THIS_QUARTER|LAST_QUARTER|NEXT_QUARTER|THIS_YEAR|LAST_YEAR|NEXT_YEAR|THIS_FISCAL_QUARTER|LAST_FISCAL_QUARTER|NEXT_FISCAL_QUARTER|THIS_FISCAL_YEAR|LAST_FISCAL_YEAR|NEXT_FISCAL_YEAR)\\b\\s*' }, declarations: { patterns: [ {include: '#type-declarations'}, {include: '#punctuation-semicolon'} ] }, directives: {patterns: [{include: '#punctuation-semicolon'}]}, 'dml-expression': { begin: '\\b(delete|insert|undelete|update|upsert)\\b\\s+(?!new\\b)', beginCaptures: {1: {name: 'support.function.apex'}}, end: '(?<=\\;)', patterns: [{include: '#expression'}, {include: '#punctuation-semicolon'}] }, 'do-statement': { begin: '(?', beginCaptures: {0: {name: 'keyword.operator.arrow.apex'}}, end: '(?=[,\\);}])', patterns: [{include: '#expression'}] }, 'expression-operators': { patterns: [ { match: '\\*=|/=|%=|\\+=|-=', name: 'keyword.operator.assignment.compound.apex' }, { match: '\\&=|\\^=|<<=|>>=|\\|=', name: 'keyword.operator.assignment.compound.bitwise.apex' }, {match: '<<|>>', name: 'keyword.operator.bitwise.shift.apex'}, {match: '==|!=', name: 'keyword.operator.comparison.apex'}, {match: '<=|>=|<|>', name: 'keyword.operator.relational.apex'}, {match: '\\!|&&|\\|\\|', name: 'keyword.operator.logical.apex'}, {match: '\\&|~|\\^|\\|', name: 'keyword.operator.bitwise.apex'}, {match: '\\=', name: 'keyword.operator.assignment.apex'}, {match: '--', name: 'keyword.operator.decrement.apex'}, {match: '\\+\\+', name: 'keyword.operator.increment.apex'}, {match: '%|\\*|/|-|\\+', name: 'keyword.operator.arithmetic.apex'} ] }, 'extends-class': { begin: '(extends)\\b\\s+', beginCaptures: {1: {name: 'keyword.other.extends.apex'}}, end: '(?={|implements)', patterns: [ { begin: '(?=[_[:alpha:]][_[:alnum:]]*\\s*\\.)', end: '(?={|implements)', patterns: [{include: '#support-type'}, {include: '#type'}] }, { captures: {1: {name: 'entity.name.type.extends.apex'}}, match: '([_[:alpha:]][_[:alnum:]]*)' } ] }, 'field-declaration': { begin: '(?x)\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n)\\s+\n(\\g)\\s* # first field name\n(?!=>|==)(?=,|;|=|$)', beginCaptures: { 1: {patterns: [{include: '#support-type'}, {include: '#type'}]}, 5: {name: 'entity.name.variable.field.apex'} }, end: '(?=;)', patterns: [ { match: '@?[_[:alpha:]][_[:alnum:]]*', name: 'entity.name.variable.field.apex' }, {include: '#punctuation-comma'}, {include: '#comment'}, {include: '#variable-initializer'}, {include: '#class-or-trigger-members'} ] }, 'finally-clause': { begin: '(?\n (?\n (?:\n (?:ref\\s+)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n )\\s+\n)\n(?\\g\\s*\\.\\s*)?\n(?this)\\s*\n(?=\\[)', beginCaptures: { 1: {patterns: [{include: '#type'}]}, 6: {patterns: [{include: '#type'}, {include: '#punctuation-accessor'}]}, 7: {name: 'keyword.other.this.apex'} }, end: '(?<=\\})|(?=;)', patterns: [ {include: '#comment'}, {include: '#property-accessors'}, {include: '#expression-body'}, {include: '#variable-initializer'} ] }, 'initializer-block': { begin: '\\{', beginCaptures: {0: {name: 'punctuation.curlybrace.open.apex'}}, end: '\\}', endCaptures: {0: {name: 'punctuation.curlybrace.close.apex'}}, patterns: [{include: '#statement'}] }, 'initializer-expression': { begin: '\\{', beginCaptures: {0: {name: 'punctuation.curlybrace.open.apex'}}, end: '\\}', endCaptures: {0: {name: 'punctuation.curlybrace.close.apex'}}, patterns: [{include: '#expression'}, {include: '#punctuation-comma'}] }, 'interface-declaration': { begin: '(?=\\binterface\\b)', end: '(?<=\\})', patterns: [ { begin: '(?x)\n(interface)\\b\\s+\n(@?[_[:alpha:]][_[:alnum:]]*)', beginCaptures: { 1: {name: 'keyword.other.interface.apex'}, 2: {name: 'entity.name.type.interface.apex'} }, end: '(?=\\{)', patterns: [ {include: '#javadoc-comment'}, {include: '#comment'}, {include: '#type-parameter-list'}, {include: '#extends-class'} ] }, { begin: '\\{', beginCaptures: {0: {name: 'punctuation.curlybrace.open.apex'}}, end: '\\}', endCaptures: {0: {name: 'punctuation.curlybrace.close.apex'}}, patterns: [{include: '#interface-members'}] }, {include: '#javadoc-comment'}, {include: '#comment'} ] }, 'interface-members': { patterns: [ {include: '#javadoc-comment'}, {include: '#comment'}, {include: '#property-declaration'}, {include: '#indexer-declaration'}, {include: '#method-declaration'}, {include: '#punctuation-semicolon'} ] }, 'invocation-expression': { begin: '(?x)\n(?:(\\??\\.)\\s*)? # safe navigator or accessor\n(@?[_[:alpha:]][_[:alnum:]]*)\\s* # method name\n(?\\s*<([^<>]|\\g)+>\\s*)?\\s* # type arguments\n(?=\\() # open paren of argument list', beginCaptures: { 1: { patterns: [ {include: '#punctuation-accessor'}, {include: '#operator-safe-navigation'} ] }, 2: {name: 'entity.name.function.apex'}, 3: {patterns: [{include: '#type-arguments'}]} }, end: '(?<=\\))', patterns: [{include: '#argument-list'}] }, 'javadoc-comment': { patterns: [ { begin: '^\\s*(/\\*\\*)(?!/)', beginCaptures: {1: {name: 'punctuation.definition.comment.apex'}}, end: '\\*/', endCaptures: {0: {name: 'punctuation.definition.comment.apex'}}, name: 'comment.block.javadoc.apex', patterns: [ { match: '@(deprecated|author|return|see|serial|since|version|usage|name|link)\\b', name: 'keyword.other.documentation.javadoc.apex' }, { captures: { 1: {name: 'keyword.other.documentation.javadoc.apex'}, 2: {name: 'entity.name.variable.parameter.apex'} }, match: '(@param)\\s+(\\S+)' }, { captures: { 1: {name: 'keyword.other.documentation.javadoc.apex'}, 2: {name: 'entity.name.type.class.apex'} }, match: '(@(?:exception|throws))\\s+(\\S+)' }, { captures: {1: {name: 'string.quoted.single.apex'}}, match: '(`([^`]+?)`)' } ] } ] }, literal: { patterns: [ {include: '#boolean-literal'}, {include: '#null-literal'}, {include: '#numeric-literal'}, {include: '#string-literal'} ] }, 'local-constant-declaration': { begin: '(?x)\n(?\\b(?:const)\\b)\\s*\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n)\\s+\n(\\g)\\s*\n(?=,|;|=)', beginCaptures: { 1: {name: 'storage.modifier.apex'}, 2: {patterns: [{include: '#type'}]}, 6: {name: 'entity.name.variable.local.apex'} }, end: '(?=;)', patterns: [ { match: '@?[_[:alpha:]][_[:alnum:]]*', name: 'entity.name.variable.local.apex' }, {include: '#punctuation-comma'}, {include: '#comment'}, {include: '#variable-initializer'} ] }, 'local-declaration': { patterns: [ {include: '#local-constant-declaration'}, {include: '#local-variable-declaration'} ] }, 'local-variable-declaration': { begin: '(?x)\n(?:\n (?:(\\bref)\\s+)?(\\bvar\\b)| # ref local\n (?\n (?:\n (?:ref\\s+)? # ref local\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n )\n)\\s+\n(\\g)\\s*\n(?=,|;|=|\\))', beginCaptures: { 1: {name: 'storage.modifier.apex'}, 2: {name: 'keyword.other.var.apex'}, 3: {patterns: [{include: '#support-type'}, {include: '#type'}]}, 7: {name: 'entity.name.variable.local.apex'} }, end: '(?=;|\\))', patterns: [ { match: '@?[_[:alpha:]][_[:alnum:]]*', name: 'entity.name.variable.local.apex' }, {include: '#punctuation-comma'}, {include: '#comment'}, {include: '#variable-initializer'} ] }, 'member-access-expression': { patterns: [ { captures: { 1: { patterns: [ {include: '#punctuation-accessor'}, {include: '#operator-safe-navigation'} ] }, 2: {name: 'variable.other.object.property.apex'} }, match: '(?x)\n(\\??\\.)\\s* # safe navigator or accessor\n(@?[_[:alpha:]][_[:alnum:]]*)\\s* # property name\n(?![_[:alnum:]]|\\(|(\\?)?\\[|<) # next character is not alpha-numeric, nor a (, [, or <. Also, test for ?[' }, { captures: { 1: { patterns: [ {include: '#punctuation-accessor'}, {include: '#operator-safe-navigation'} ] }, 2: {name: 'variable.other.object.apex'}, 3: {patterns: [{include: '#type-arguments'}]} }, match: '(?x)\n(\\??\\.)?\\s*\n(@?[_[:alpha:]][_[:alnum:]]*)\n(?\\s*<([^<>]|\\g)+>\\s*)\n(?=\n (\\s*\\?)?\n \\s*\\.\\s*@?[_[:alpha:]][_[:alnum:]]*\n)' }, { captures: {1: {name: 'variable.other.object.apex'}}, match: '(?x)\n(@?[_[:alpha:]][_[:alnum:]]*)\n(?=\n (\\s*\\?)?\n \\s*\\.\\s*@?[_[:alpha:]][_[:alnum:]]*\n)' } ] }, 'merge-expression': { begin: '(merge)\\b\\s+', beginCaptures: {1: {name: 'support.function.apex'}}, end: '(?<=\\;)', patterns: [ {include: '#object-creation-expression'}, {include: '#merge-type-statement'}, {include: '#expression'}, {include: '#punctuation-semicolon'} ] }, 'merge-type-statement': { captures: { 1: {name: 'variable.other.readwrite.apex'}, 2: {name: 'variable.other.readwrite.apex'}, 3: {name: 'punctuation.terminator.statement.apex'} }, match: '([_[:alpha:]]*)\\b\\s+([_[:alpha:]]*)\\b\\s*(\\;)' }, 'method-declaration': { begin: '(?x)\n(?\n (?\n (?:\n (?:ref\\s+)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n )\\s+\n)\n(?\\g\\s*\\.\\s*)?\n(\\g)\\s*\n(<([^<>]+)>)?\\s*\n(?=\\()', beginCaptures: { 1: {patterns: [{include: '#support-type'}, {include: '#type'}]}, 6: {patterns: [{include: '#type'}, {include: '#punctuation-accessor'}]}, 7: { patterns: [ {include: '#support-type'}, {include: '#method-name-custom'} ] }, 8: {patterns: [{include: '#type-parameter-list'}]} }, end: '(?<=\\})|(?=;)', patterns: [ {include: '#comment'}, {include: '#parenthesized-parameter-list'}, {include: '#expression-body'}, {include: '#block'} ] }, 'method-name-custom': { match: '@?[_[:alpha:]][_[:alnum:]]*', name: 'entity.name.function.apex' }, 'named-argument': { begin: '(@?[_[:alpha:]][_[:alnum:]]*)\\s*(:)', beginCaptures: { 1: {name: 'entity.name.variable.parameter.apex'}, 2: {name: 'punctuation.separator.colon.apex'} }, end: '(?=(,|\\)|\\]))', patterns: [{include: '#expression'}] }, 'null-literal': { match: '(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n)\\s*\n(?=\\{|$)' }, 'object-creation-expression-with-parameters': { begin: '(?x)\n(delete|insert|undelete|update|upsert)?\n\\s*(new)\\s+\n(?\n (?:\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n)\\s*\n(?=\\()', beginCaptures: { 1: {name: 'support.function.apex'}, 2: {name: 'keyword.control.new.apex'}, 3: {patterns: [{include: '#support-type'}, {include: '#type'}]} }, end: '(?<=\\))', patterns: [{include: '#argument-list'}] }, 'operator-assignment': { match: '(?\n (?:\n (?:ref\\s+)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n)\\s+\n(\\g)' }, 'parenthesized-expression': { begin: '\\(', beginCaptures: {0: {name: 'punctuation.parenthesis.open.apex'}}, end: '\\)', endCaptures: {0: {name: 'punctuation.parenthesis.close.apex'}}, patterns: [{include: '#expression'}] }, 'parenthesized-parameter-list': { begin: '(\\()', beginCaptures: {0: {name: 'punctuation.parenthesis.open.apex'}}, end: '(\\))', endCaptures: {0: {name: 'punctuation.parenthesis.close.apex'}}, patterns: [ {include: '#comment'}, {include: '#parameter'}, {include: '#punctuation-comma'}, {include: '#variable-initializer'} ] }, 'property-accessors': { begin: '\\{', beginCaptures: {0: {name: 'punctuation.curlybrace.open.apex'}}, end: '\\}', endCaptures: {0: {name: 'punctuation.curlybrace.close.apex'}}, patterns: [ {match: '\\b(private|protected)\\b', name: 'storage.modifier.apex'}, {match: '\\b(get)\\b', name: 'keyword.other.get.apex'}, {match: '\\b(set)\\b', name: 'keyword.other.set.apex'}, {include: '#comment'}, {include: '#expression-body'}, {include: '#block'}, {include: '#punctuation-semicolon'} ] }, 'property-declaration': { begin: '(?x)\n(?!.*\\b(?:class|interface|enum)\\b)\\s*\n(?\n (?\n (?:\n (?:ref\\s+)? # ref return\n (?:\n (?:(?@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (? # identifier + type arguments (if any)\n \\g\\s*\n (?\\s*<(?:[^<>]|\\g)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g)*\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s*\\[(?:\\s*,\\s*)*\\]\\s*)* # array suffix?\n )\n )\\s+\n)\n(?\\g\\s*\\.\\s*)?\n(?\\g)\\s*\n(?=\\{|=>|$)', beginCaptures: { 1: {patterns: [{include: '#type'}]}, 6: {patterns: [{include: '#type'}, {include: '#punctuation-accessor'}]}, 7: {name: 'entity.name.variable.property.apex'} }, end: '(?<=\\})|(?=;)', patterns: [ {include: '#comment'}, {include: '#property-accessors'}, {include: '#expression-body'}, {include: '#variable-initializer'}, {include: '#class-or-trigger-members'} ] }, 'punctuation-accessor': {match: '\\.', name: 'punctuation.accessor.apex'}, 'punctuation-comma': {match: ',', name: 'punctuation.separator.comma.apex'}, 'punctuation-semicolon': { match: ';', name: 'punctuation.terminator.statement.apex' }, 'query-operators': { captures: {1: {name: 'keyword.operator.query.apex'}}, match: '\\b(ABOVE|AND|AT|FOR REFERENCE|FOR UPDATE|FOR VIEW|GROUP BY|HAVING|IN|LIKE|LIMIT|NOT IN|NOT|OFFSET|OR|TYPEOF|UPDATE TRACKING|UPDATE VIEWSTAT|WITH DATA CATEGORY|WITH)\\b\\s*' }, 'return-statement': { begin: '(?', endCaptures: { 0: {name: 'punctuation.definition.typeparameters.end.apex'} }, patterns: [ {include: '#comment'}, {include: '#support-type'}, {include: '#punctuation-comma'} ] }, 'support-class': { captures: {1: {name: 'support.class.apex'}}, match: '\\b(ApexPages|Database|DMLException|Exception|PageReference|Savepoint|SchedulableContext|Schema|SObject|System|Test)\\b' }, 'support-expression': { begin: '(?x)\n(ApexPages|Database|DMLException|Exception|PageReference|Savepoint|SchedulableContext|Schema|SObject|System|Test)(?=\\.|\\s) # supported apex namespaces', beginCaptures: {1: {name: 'support.class.apex'}}, end: '(?<=\\)|$)|(?=\\})|(?=;)|(?=\\)|(?=\\]))|(?=\\,)', patterns: [ {include: '#support-type'}, { captures: { 1: {name: 'punctuation.accessor.apex'}, 2: {name: 'support.function.apex'} }, match: '(?:(\\.))([[:alpha:]]*)(?=\\()' }, { captures: { 1: {name: 'punctuation.accessor.apex'}, 2: {name: 'support.type.apex'} }, match: '(?:(\\.))([[:alpha:]]+)' }, { begin: '\\(', beginCaptures: {0: {name: 'punctuation.parenthesis.open.apex'}}, end: '\\)', endCaptures: {0: {name: 'punctuation.parenthesis.close.apex'}}, patterns: [{include: '#expression'}, {include: '#punctuation-comma'}] }, {include: '#comment'}, {include: '#statement'} ] }, 'support-functions': { captures: {1: {name: 'support.function.apex'}}, match: '\\b(delete|execute|finish|insert|start|undelete|update|upsert)\\b' }, 'support-name': { patterns: [ { captures: { 1: {name: 'punctuation.accessor.apex'}, 2: {name: 'support.function.apex'} }, match: '(\\.)\\s*([[:alpha:]]*)(?=\\()' }, { begin: '\\(', beginCaptures: {0: {name: 'punctuation.parenthesis.open.apex'}}, end: '\\)', endCaptures: {0: {name: 'punctuation.parenthesis.close.apex'}}, patterns: [{include: '#expression'}, {include: '#punctuation-comma'}] }, { captures: { 1: {name: 'punctuation.accessor.apex'}, 2: {name: 'support.type.apex'} }, match: '(\\.)\\s*([_[:alpha:]]*)' } ] }, 'support-type': { name: 'support.apex', patterns: [ {include: '#comment'}, {include: '#support-class'}, {include: '#support-functions'}, {include: '#support-name'} ] }, 'switch-statement': { begin: '(?x)\n(switch)\\b\\s+\n(on)\\b\\s+\n(.*)\n(\\{)', beginCaptures: { 1: {name: 'keyword.control.switch.apex'}, 2: {name: 'keyword.control.switch.on.apex'}, 3: { patterns: [ {include: '#statement'}, {include: '#parenthesized-expression'} ] }, 4: {name: 'punctuation.curlybrace.open.apex'} }, end: '(\\})', endCaptures: {0: {name: 'punctuation.curlybrace.close.apex'}}, patterns: [ {include: '#when-string'}, {include: '#when-else-statement'}, {include: '#when-sobject-statement'}, {include: '#when-statement'}, {include: '#when-multiple-statement'}, {include: '#expression'}, {include: '#punctuation-comma'}, {include: '#punctuation-semicolon'} ] }, 'this-expression': { captures: {1: {name: 'keyword.other.this.apex'}}, match: '\\b(?:(this))\\b' }, 'throw-expression': { captures: {1: {name: 'keyword.control.flow.throw.apex'}}, match: '(?', endCaptures: { 0: {name: 'punctuation.definition.typeparameters.end.apex'} }, patterns: [ {include: '#comment'}, {include: '#support-type'}, {include: '#type'}, {include: '#punctuation-comma'} ] }, 'type-array-suffix': { begin: '\\[', beginCaptures: {0: {name: 'punctuation.squarebracket.open.apex'}}, end: '\\]', endCaptures: {0: {name: 'punctuation.squarebracket.close.apex'}}, patterns: [{include: '#punctuation-comma'}] }, 'type-builtin': { captures: {1: {name: 'keyword.type.apex'}}, match: '\\b(Blob|Boolean|byte|Date|Datetime|Decimal|Double|Id|ID|Integer|Long|Object|String|Time|void)\\b' }, 'type-declarations': { patterns: [ {include: '#javadoc-comment'}, {include: '#comment'}, {include: '#annotation-declaration'}, {include: '#storage-modifier'}, {include: '#sharing-modifier'}, {include: '#class-declaration'}, {include: '#enum-declaration'}, {include: '#interface-declaration'}, {include: '#trigger-declaration'}, {include: '#punctuation-semicolon'} ] }, 'type-name': { patterns: [ { captures: { 1: {name: 'storage.type.apex'}, 2: {name: 'punctuation.accessor.apex'} }, match: '(@?[_[:alpha:]][_[:alnum:]]*)\\s*(\\.)' }, { captures: { 1: {name: 'punctuation.accessor.apex'}, 2: {name: 'storage.type.apex'} }, match: '(\\.)\\s*(@?[_[:alpha:]][_[:alnum:]]*)' }, {match: '@?[_[:alpha:]][_[:alnum:]]*', name: 'storage.type.apex'} ] }, 'type-nullable-suffix': { captures: {0: {name: 'punctuation.separator.question-mark.apex'}}, match: '\\?' }, 'type-parameter-list': { begin: '\\<', beginCaptures: { 0: {name: 'punctuation.definition.typeparameters.begin.apex'} }, end: '\\>', endCaptures: { 0: {name: 'punctuation.definition.typeparameters.end.apex'} }, patterns: [ { captures: {1: {name: 'entity.name.type.type-parameter.apex'}}, match: '(@?[_[:alpha:]][_[:alnum:]]*)\\b' }, {include: '#comment'}, {include: '#punctuation-comma'} ] }, 'using-scope': { captures: {1: {name: 'keyword.operator.query.using.apex'}}, match: '((USING SCOPE)\\b\\s*(Delegated|Everything|Mine|My_Territory|My_Team_Territory|Team))\\b\\s*' }, 'variable-initializer': { begin: '(?)', beginCaptures: {1: {name: 'keyword.operator.assignment.apex'}}, end: '(?=[,\\)\\];}])', patterns: [{include: '#expression'}] }, 'when-else-statement': { begin: '(when)\\b\\s+(else)\\b\\s*', beginCaptures: { 1: {name: 'keyword.control.switch.when.apex'}, 2: {name: 'keyword.control.switch.else.apex'} }, end: '(?=\\})|(?=when\\b)', patterns: [{include: '#block'}, {include: '#expression'}] }, 'when-multiple-statement': { begin: '(when)\\b\\s*', beginCaptures: {1: {name: 'keyword.control.switch.when.apex'}}, end: '(?=\\})|(?=when\\b)', patterns: [ {include: '#block'}, {include: '#expression'}, {include: '#punctuation-comma'} ] }, 'when-sobject-statement': { begin: '(when)\\b\\s+([_[:alnum:]]+)\\s+([_[:alnum:]]+)\\s*', beginCaptures: { 1: {name: 'keyword.control.switch.when.apex'}, 2: {name: 'storage.type.apex'}, 3: {name: 'entity.name.variable.local.apex'} }, end: '(?=\\})|(?=when\\b)', patterns: [{include: '#block'}, {include: '#expression'}] }, 'when-statement': { begin: '(when)\\b\\s+([_\\-[:alnum:]]+)\\s*', beginCaptures: { 1: {name: 'keyword.control.switch.when.apex'}, 2: {patterns: [{include: '#expression'}]} }, end: '(?=\\})|(?=when\\b)', patterns: [{include: '#block'}, {include: '#expression'}] }, 'when-string': { begin: "(when)\\b\\s*('[^'\\n]*')(\\s*(,)\\s*('[^'\\n]*'))*\\s*", beginCaptures: { 1: {name: 'keyword.control.switch.when.apex'}, 2: {patterns: [{include: '#string-literal'}]}, 4: {patterns: [{include: '#punctuation-comma'}]}, 5: {patterns: [{include: '#string-literal'}]} }, end: '(?=\\})|(?=when\\b)', patterns: [{include: '#block'}, {include: '#expression'}] }, 'where-clause': { captures: {1: {name: 'keyword.operator.query.where.apex'}}, match: '\\b(WHERE)\\b\\s*' }, 'while-statement': { begin: '(?', endCaptures: {0: {name: 'punctuation.definition.string.end.apex'}}, name: 'string.unquoted.cdata.apex' }, 'xml-character-entity': { patterns: [ { captures: { 1: {name: 'punctuation.definition.constant.apex'}, 3: {name: 'punctuation.definition.constant.apex'} }, match: '(?x)\n(&)\n(\n (?:[[:alpha:]:_][[:alnum:]:_.-]*)|\n (?:\\#[[:digit:]]+)|\n (?:\\#x[[:xdigit:]]+)\n)\n(;)', name: 'constant.character.entity.apex' }, {match: '&', name: 'invalid.illegal.bad-ampersand.apex'} ] }, 'xml-comment': { begin: '', endCaptures: {0: {name: 'punctuation.definition.comment.apex'}}, name: 'comment.block.apex' }, 'xml-doc-comment': { patterns: [ {include: '#xml-comment'}, {include: '#xml-character-entity'}, {include: '#xml-cdata'}, {include: '#xml-tag'} ] }, 'xml-string': { patterns: [ { begin: "\\'", beginCaptures: { 0: {name: 'punctuation.definition.string.begin.apex'} }, end: "\\'", endCaptures: {0: {name: 'punctuation.definition.string.end.apex'}}, name: 'string.quoted.single.apex', patterns: [{include: '#xml-character-entity'}] }, { begin: '\\"', beginCaptures: { 0: {name: 'punctuation.definition.stringdoublequote.begin.apex'} }, end: '\\"', endCaptures: { 0: {name: 'punctuation.definition.stringdoublequote.end.apex'} }, name: 'string.quoted.double.apex', patterns: [{include: '#xml-character-entity'}] } ] }, 'xml-tag': { begin: '(?x)\n()', endCaptures: {1: {name: 'punctuation.definition.tag.apex'}}, name: 'meta.tag.apex', patterns: [{include: '#xml-attribute'}] } }, scopeName: 'source.apex' } export default grammar