diff --git a/dist/apex.es.min.js b/dist/apex.es.min.js index 62ab9e9..67bba78 100644 --- a/dist/apex.es.min.js +++ b/dist/apex.es.min.js @@ -1,115 +1,115 @@ /*! `apex` grammar compiled for Highlight.js 11.11.1 */ var hljsGrammar=(()=>{"use strict";return e=>{ -const t=e.regex,n="[a-zA-Z][a-zA-Z_0-9]*",a="\\b"+n+"\\b",c="@"+n,s=/(?=\s*\()/,o=/\s+/,i=/(?>\=|>>>\=|\|\=/,/\&|~|\^|\|/,/<<|>>/,/<\=|>\=|\s(<|>)\s/,/\=\=|!\=/,/\=>/,/!(?=\w)/,/(?<=\s)(\?|:)(?=\s)/,r,/(?<=\s)(\?\?)(?=\s)/,/(?)/],L=v.concat(...S),O={ -$pattern:t.concat(/(?>\=|>>>\=|\|\=/,/\&|~|\^|\|/,/<<|>>/,/<\=|>\=|\s(<|>)\s/,/\=\=|!\=/,/\=>/,/!(?=\w)/,/(?<=\s)(\?|:)(?=\s)/,u,/(?<=\s)(\?\?)(?=\s)/,/(?)/],C=T.concat(...y),D={ +$pattern:t.concat(/(?/,/\<(?=\w)/,/\{|\}/,/\(|\)/,/\{|\}/), -scope:"punctuation",relevance:0},T],I=e.inherit(e.APOS_STRING_MODE,{ +scope:"punctuation",relevance:0},N],k=e.inherit(e.APOS_STRING_MODE,{ scope:"string",relevance:1,contains:[{match:/\\'/,scope:"literal",relevance:1}] -}),_=[{begin:"`",end:"`",scope:"string"},{begin:/'/,end:/'/,scope:"string"},{ -begin:/"/,end:/"/,scope:"string"}],f=e.COMMENT("//",/[$\n]/,{relevance:0 -}),U=[e.COMMENT("/\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0 -},{match:[/@(?:exception|throws)/,o,t.concat(n,i,n)],scope:{1:"doctag", +}),M=[{begin:"`",end:"`",scope:"string"},{begin:/'/,end:/'/,scope:"string"},{ +begin:/"/,end:/"/,scope:"string"}],F=e.COMMENT("//",/[$\n]/,{relevance:0 +}),P=[e.COMMENT("/\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0 +},{match:[/@(?:exception|throws)/,o,t.concat(n,b,n)],scope:{1:"doctag", 3:"title.class"},relevance:0},{match:[/@(?:exception|throws)/,o,n],scope:{ 1:"doctag",3:"title.class"},relevance:0},{ -begin:[/\{/,/@(?:link|see)/,o,/[a-zA-Z_0-9]*/,t.concat(/(?:#|\.)/,n),s], -beginScope:{2:"doctag",4:"title.class",5:"title.method"},end:/\}/,contains:[{ +begin:[i,/@(?:link|see)/,o,/[a-zA-Z_0-9]*/,t.concat(/(?:#|\.)/,n),s], +beginScope:{2:"doctag",4:"title.class",5:"title.method"},end:r,contains:[{ match:/(?:\(|\))/,scope:"punctuation"},{match:[o,n,/\s*(?=[,)])/],scope:{ 2:"variable"}},{match:[n,/(?=\s)/],scope:{1:"type"}}]},{ -begin:[/\{/,/@(?:link|see)/,o,/[a-zA-Z_0-9]*/,t.concat(/(?:#|\.)/,n,/\s*(?=\})/)], -beginScope:{2:"doctag",4:"title.class",5:"title.method"},end:/\}/,returnEnd:!0 -},{begin:[/\{/,/@(?:link|see)/,o,a],beginScope:{2:"doctag",4:"title.class"}, -end:/\}/,returnEnd:!0},{begin:[/\{/,/@(?:link|see)(?=\s+")/],beginScope:{ -2:"doctag"},end:/\}/,returnEnd:!0,contains:_},{begin:[/\{/,/@(?:link|see)/], -beginScope:{2:"doctag"},end:/\}/,returnEnd:!0,subLanguage:["markdown","xml"]},{ -begin:[/\{/,/@literal/],beginScope:{2:"doctag"},end:/\}/,returnEnd:!0, +begin:[i,/@(?:link|see)/,o,/[a-zA-Z_0-9]*/,t.concat(/(?:#|\.)/,n,/\s*(?=\})/)], +beginScope:{2:"doctag",4:"title.class",5:"title.method"},end:r,returnEnd:!0},{ +begin:[i,/@(?:link|see)/,o,a],beginScope:{2:"doctag",4:"title.class"},end:r, +returnEnd:!0},{begin:[i,/@(?:link|see)(?=\s+")/],beginScope:{2:"doctag"},end:r, +returnEnd:!0,contains:M},{begin:[i,/@(?:link|see)/],beginScope:{2:"doctag"}, +end:r,returnEnd:!0,subLanguage:["markdown","xml"]},{begin:[i,/@literal/], +beginScope:{2:"doctag"},end:r,returnEnd:!0, subLanguage:["apex","xml","javascript"]},{match:c,scope:"doctag",relevance:0},{ match:[/(?<=@param)\s+/,n],scope:{2:"variable"},relevance:0},{ -contains:[e.BACKSLASH_ESCAPE],relevance:0,variants:_},{begin:/[0-9]+\.[0-9]+/, +contains:[e.BACKSLASH_ESCAPE],relevance:0,variants:M},{begin:/[0-9]+\.[0-9]+/, end:/\.*\s+/,scope:"number",excludeEnd:!0},{ begin:t.either(/\d{4}-\d{1,2}-\d{1,2}/,/\d{1,2}\/\d{1,2}\/\d{4}/), -scope:"literal"},{begin:[/\{/,/@code/],beginScope:{2:"doctag"},starts:{end:/\}/, -returnEnd:!0,contains:[{match:/^\s+\*\s+/,skip:!0,relevance:0},{begin:/\{/, -end:/\}/,skip:!0}],subLanguage:["apex","xml","javascript"]}}]}),f],k={ -match:t.either(...y),scope:"operator",relevance:0},M=[{ +scope:"literal"},{begin:[i,/@code/],beginScope:{2:"doctag"},starts:{end:r, +returnEnd:!0,contains:[{match:/^\s+\*\s+/,skip:!0,relevance:0},{begin:i,end:r, +skip:!0}],subLanguage:["apex","xml","javascript"]}}]}),F],Y={ +match:t.either(...w),scope:"operator",relevance:0},x=[{ begin:/\b(list|set|map)(?=\s*<)/,beginScope:"type",end:/\>+/, endScope:"punctuation",contains:[{match:/\<|\,/,scope:"punctuation"},{match:a, scope:"type"}],relevance:8},{match:[t.optional(a),/\[/,t.optional(/\d+/),/\]/], scope:{1:"variable",2:"punctuation",3:"number",4:"punctuation"}},{ -match:[n,/\[\]/],scope:{1:"type",2:"punctuation"},relevance:0}],F=[{ +match:[n,/\[\]/],scope:{1:"type",2:"punctuation"},relevance:0}],W=[{ match:t.concat(c,/\b(?!\s*\()/),scope:"meta"},{scope:"meta", -begin:[t.concat(c,/\b/),/\s*/,/\(/],beginScope:{3:"punctuation"},end:/\)/, +begin:[t.concat(c,/\b/),/\s*/,l],beginScope:{3:"punctuation"},end:p, endScope:"punctuation",contains:[{match:[a,/\s*=/],scope:{1:"keyword", -2:"operator"},contains:[k]},I,u],keywords:{literal:R}}],P={ +2:"operator"},contains:[Y]},k,g],keywords:{literal:O}}],H={ match:[/\b[a-zA-Z0-9\.]*Exception/,o,n],scope:{1:"type",3:"variable"}, -relevance:0},Y=[{match:[/(?])/],scope:{2:"variable"}, +relevance:0},G=[{match:[/(?])/],scope:{2:"variable"}, relevance:0},{match:[a,"(?=\\s+"+n+/\s*\=/+")"],scope:{1:"type"},relevance:0},{ -match:[a,o,a,/\s*(?=\=[^\>])/],scope:{1:"type",3:"variable"},relevance:0}],x={ -match:[/(?<=\=\s*\()/,n,"(?=\\)\\s*"+n+")"],scope:{2:"type"},relevance:0},W={ -match:[/\bnew\s+/,n,s],scope:{2:"type"},relevance:0};let H={begin:/\(/, -beginScope:"punctuation",end:/\)/,endScope:"punctuation",relevance:0,keywords:O, -contains:[]};const G=[{match:[/(?<=\.)/,n,s],scope:{2:"title.function.invoke1"}, -relevance:1,contains:[...l],starts:H},{match:[/^\s*/,b(...d),n,s],scope:{ -3:"title.function.invoke"},relevance:1,starts:H}] -;H.contains=[I,W,U,k,M,w,u,p,G,{keywords:{KEYWORDS:O}, -match:t.concat(/(?<=\s|\(|\,)/,b(...R),n,/\b/,/(?!\.)/),scope:"variable", +match:[a,o,a,/\s*(?=\=[^\>])/],scope:{1:"type",3:"variable"},relevance:0}],B={ +match:[/(?<=\=\s*\()/,n,"(?=\\)\\s*"+n+")"],scope:{2:"type"},relevance:0},K={ +match:[/\bnew\s+/,n,s],scope:{2:"type"},relevance:0};let Q={begin:l, +beginScope:"punctuation",end:p,endScope:"punctuation",relevance:0,keywords:D, +contains:[]};const V=[{match:[/(?<=\.)/,n,s],scope:{2:"title.function.invoke1"}, +relevance:1,contains:[...d],starts:Q},{match:[/^\s*/,E(...h),n,s],scope:{ +3:"title.function.invoke"},relevance:1,starts:Q}] +;Q.contains=[k,K,P,Y,x,f,g,m,V,{keywords:{KEYWORDS:D}, +match:t.concat(/(?<=\s|\(|\,)/,E(...O),n,/\b/,/(?!\.)/),scope:"variable", relevance:0},{match:/\(|\,|\./,scope:"punctuation",relevance:0},{match:n, -scope:"variable"}];const B={scope:"params",end:/\)/,endScope:"punctuation", -relevance:1,keywords:O,contains:[u,I,U,M,...w,{match:/\,|\(/,scope:"punctuation" -},p,{match:[/(?<=\(|\,)\s*/,n,/(?=\s)/],scope:{2:"type"}},{ -match:[o,n,/\s*(?=[,)])/],scope:{2:"variable"}}]},Q={ +scope:"variable"}];const z={scope:"params",end:p,endScope:"punctuation", +relevance:1,keywords:D,contains:[g,k,P,x,...f,{match:/\,|\(/,scope:"punctuation" +},m,{match:[/(?<=\(|\,)\s*/,n,/(?=\s)/],scope:{2:"type"}},{ +match:[o,n,/\s*(?=[,)])/],scope:{2:"variable"}}]},Z={ match:[/\bswitch\s+on\s+/,n],scope:{1:"keyword",2:"variable"}};return{ name:"Apex",aliases:["apex","lightning","soql","sosl"],case_insensitive:!0, -disableAutodetect:!1,ignoreIllegals:!1,keywords:O, +disableAutodetect:!1,ignoreIllegals:!1,keywords:D,beginKeywords:"Id", illegal:["","\x3c!--","!DOCTYPE",/","<%%",":-",/\bmergesort\(/,/\bvar\s+env\b/,/\bdef\b\s\W:/,/"[^"]+"/,/\(\*|\*\)/], -contains:[U,F,I,u,x,M,[{begin:[/\btrigger/,o,n,o,"on",o,n],beginScope:{ +contains:[P,W,k,g,B,x,[{begin:[/\btrigger/,o,n,o,"on",o,n],beginScope:{ 1:"keyword",3:"title.class",5:"operator",7:"type"},end:/(?=\{)/,returnEnd:!0, -contains:[U,{begin:/\(/,end:/\)/,contains:[{ +contains:[P,{begin:l,end:p,contains:[{ match:/\b(before|after)\s+(insert|update|delete|merge|undelete)\b/, -scope:"keyword",relevance:5},T]}]},{relevance:5, +scope:"keyword",relevance:5},N]}]},{relevance:5, match:/\b(with|without|inherited)\s+sharing\b/,scope:"keyword"},{ begin:[/(?!\.)/,/\b(class|interface)\b(?!\?|\.)/],beginScope:{2:"keyword"}, -end:/(?=\{)/,relevance:1,keywords:{type:h,keyword:d},contains:[{ +end:/(?=\{)/,relevance:1,keywords:{type:A,keyword:h},contains:[{ match:[/(?<=\bclass)\s+/,n],scope:{2:"title.class"}},{returnEnd:!0, -endsWithParent:!0,beginKeywords:"implements extends",end:/\{/,contains:[{ +endsWithParent:!0,beginKeywords:"implements extends",end:i,contains:[{ match:[a,/(?=\.)/],scope:{1:"built_in"}},{match:t.concat(a,/(?=\>)/), scope:"type"},{match:a,scope:"title.class.inherited"},{match:/<|>|,/, -scope:"punctuation"},w],relevance:0}]},{begin:[/\benum\s+/,n,/\s*\{/], -beginScope:{2:"type",3:"punctuation"},end:/\}/,endScope:"punctuation", -relevance:0,contains:[U,T,{match:t.concat(a),scope:"variable.constant"}]},{ +scope:"punctuation"},f],relevance:0}]},{begin:[/\benum\s+/,n,/\s*\{/], +beginScope:{2:"type",3:"punctuation"},end:r,endScope:"punctuation",relevance:0, +contains:[P,N,{match:t.concat(a),scope:"variable.constant"}]},{ match:[/(public|private|protected)\s+/,n,s],scope:{1:"keyword", -2:"title.function"},starts:B,relevance:1},{ +2:"title.function"},starts:z,relevance:1},{ match:[/(?|\w)\s+/,n,s],scope:{2:"title.function"}, -relevance:1,starts:B}],[{match:/as\s+(user|system)\b/,scope:"keyword", -relevance:5}],P,{match:[/\bfor\b\s*/,/\(/,n,o,n,/\s*/,/:/],scope:{3:"type", -5:"variable",7:"operator"}},G,W,C,w,p,{begin:[/\[/,/\s*(?=(SELECT|FIND)\b)/], +relevance:1,starts:z}],[{match:/as\s+(user|system)\b/,scope:"keyword", +relevance:5}],H,{match:[/\bfor\b\s*/,l,n,o,n,/\s*/,/:/],scope:{3:"type", +5:"variable",7:"operator"}},V,K,_,f,m,{begin:[/\[/,/\s*(?=(SELECT|FIND)\b)/], end:/\]/,beginScope:{1:"punctuation"},endScope:"punctuation",scope:"soql", -relevance:10,endsWithParent:!0,keywords:{literal:O.literal,built_in:L}, -contains:[u,k,I,T,{match:/\(|\)/,scope:"punctuation",relevance:0},...l,{ +relevance:10,endsWithParent:!0,keywords:{literal:D.literal,built_in:C}, +contains:[g,Y,k,N,{match:/\(|\)/,scope:"punctuation",relevance:0},...d,{ begin:[/\bFROM\b/,o],beginScope:{1:"keyword"},end:/(?=\bWHERE\b|\]|\s|\))/, -contains:[{match:n,scope:"type"},...l]},{ +contains:[{match:n,scope:"type"},...d]},{ match:t.concat(/\b/,t.either("CALENDAR_MONTH","CALENDAR_QUARTER","CALENDAR_YEAR","DAY_IN_MONTH","DAY_IN_WEEK","DAY_IN_YEAR","DAY_ONLY","FISCAL_MONTH","FISCAL_QUARTER","FISCAL_YEAR","HOUR_IN_DAY","WEEK_IN_MONTH","WEEK_IN_YEAR","AVG","convertCurrency","convertTimezone","COUNT_DISTINCT","COUNT","DISTANCE","EXCLUDES","FIELDS","FORMAT","GEOLOCATION","GROUPING","ROLLUP","CUBE","INCLUDES","MAX","MIN","SUM","toLabel","USER_MODE","SYSTEM_MODE","SECURITY_ENFORCED"),/\b/), scope:"title.function"},{match:/\b(GROUP|ORDER)\s+BY\b/,scope:"title.function" },{match:/\b(TODAY|TOMORROW|YESTERDAY)\b/,scope:"keyword"},{ @@ -117,10 +117,10 @@ match:/(NEXT|LAST|THIS)_(90_DAY|DAY|FISCAL_QUARTER|FISCAL_YEAR|MONTH|QUARTER|WEE scope:"keyword",relevance:8},{ match:[/(NEXT|LAST)_N_(DAY|FISCAL_QUARTER|FISCAL_YEAR|MONTH|QUARTER|WEEK|YEAR)S/,/\s*:\s*/,/\d+/], scope:{1:"keyword",2:"operator",3:"number"},relevance:8},{ -match:t.concat(/\b/,t.either(...O.keyword,"ABOVE_OR_BELOW","ABOVE","ACTIVE","ADVANCED","ALL","ANY","ARRAY","AS","ASC","BELOW","CATEGORY","CONTAINS","CUSTOM","DATA","DESC","DIVISION","ELSE","END","FIND","FROM","METADATA","NETWORK","ON","PricebookId","RETURNING","ROLLUP","ROWS","SEARCH","SELECT","SNIPPET","SORT","SPELL_CORRECTION","STANDARD","THEN","USING","WHEN","WHERE","WITH","SCOPE","Delegated","Everything","Mine","My_Territory","My_Team_Territory","Team","AND","AT","FIRST","FOR","HAVING","IN","LAST","LIKE","LIMIT","LISTVIEW","NOT","NULLS","OFFSET","OR","REFERENCE","TRACKING","TYPEOF","UPDATE","VIEW","VIEWSTAT"),/\b/), +match:t.concat(/\b/,t.either(...D.keyword,"ABOVE_OR_BELOW","ABOVE","ACTIVE","ADVANCED","ALL","ANY","ARRAY","AS","ASC","BELOW","CATEGORY","CONTAINS","CUSTOM","DATA","DESC","DIVISION","ELSE","END","FIND","FROM","METADATA","NETWORK","ON","PricebookId","RETURNING","ROLLUP","ROWS","SEARCH","SELECT","SNIPPET","SORT","SPELL_CORRECTION","STANDARD","THEN","USING","WHEN","WHERE","WITH","SCOPE","Delegated","Everything","Mine","My_Territory","My_Team_Territory","Team","AND","AT","FIRST","FOR","HAVING","IN","LAST","LIKE","LIMIT","LISTVIEW","NOT","NULLS","OFFSET","OR","REFERENCE","TRACKING","TYPEOF","UPDATE","VIEW","VIEWSTAT"),/\b/), scope:"keyword"},{match:[/(?<=:)/,/\s*/,a,/(?!\()/],scope:{3:"variable"}, -relevance:0},{match:[/(?<=:|\.)/,n,/(?=\s*\()/],scope:{2:"title.function.invoke" -},relevance:0},{match:/:/,scope:"operator",relevance:0}],illegal:"::" -},Q,Y,k,D,l,{match:t.concat("(?<=this.)",n,"(?!\\()"),scope:"variable"},{ -match:[t.concat(/\b/,b(...N)),n,o,/(?=\{)/],scope:{2:"property"},relevance:0}]}} +relevance:0},{match:[/(?<=:|\.)/,n,s],scope:{2:"title.function.invoke"}, +relevance:0},{match:/:/,scope:"operator",relevance:0}],illegal:"::"},Z,G,Y,U,d,{ +match:t.concat("(?<=this.)",n,"(?!\\()"),scope:"variable"},{ +match:[t.concat(/\b/,E(...I)),n,o,/(?=\{)/],scope:{2:"property"},relevance:0}]}} })();export default hljsGrammar; \ No newline at end of file diff --git a/dist/apex.min.js b/dist/apex.min.js index b6c0569..9552d87 100644 --- a/dist/apex.min.js +++ b/dist/apex.min.js @@ -1,115 +1,115 @@ /*! `apex` grammar compiled for Highlight.js 11.11.1 */ (()=>{var e=(()=>{"use strict";return e=>{ -const t=e.regex,n="[a-zA-Z][a-zA-Z_0-9]*",a="\\b"+n+"\\b",c="@"+n,s=/(?=\s*\()/,o=/\s+/,i=/(?>\=|>>>\=|\|\=/,/\&|~|\^|\|/,/<<|>>/,/<\=|>\=|\s(<|>)\s/,/\=\=|!\=/,/\=>/,/!(?=\w)/,/(?<=\s)(\?|:)(?=\s)/,r,/(?<=\s)(\?\?)(?=\s)/,/(?)/],L=v.concat(...S),O={ -$pattern:t.concat(/(?>\=|>>>\=|\|\=/,/\&|~|\^|\|/,/<<|>>/,/<\=|>\=|\s(<|>)\s/,/\=\=|!\=/,/\=>/,/!(?=\w)/,/(?<=\s)(\?|:)(?=\s)/,u,/(?<=\s)(\?\?)(?=\s)/,/(?)/],C=T.concat(...y),D={ +$pattern:t.concat(/(?/,/\<(?=\w)/,/\{|\}/,/\(|\)/,/\{|\}/), -scope:"punctuation",relevance:0},T],I=e.inherit(e.APOS_STRING_MODE,{ +scope:"punctuation",relevance:0},N],k=e.inherit(e.APOS_STRING_MODE,{ scope:"string",relevance:1,contains:[{match:/\\'/,scope:"literal",relevance:1}] -}),_=[{begin:"`",end:"`",scope:"string"},{begin:/'/,end:/'/,scope:"string"},{ -begin:/"/,end:/"/,scope:"string"}],U=e.COMMENT("//",/[$\n]/,{relevance:0 -}),f=[e.COMMENT("/\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0 -},{match:[/@(?:exception|throws)/,o,t.concat(n,i,n)],scope:{1:"doctag", +}),M=[{begin:"`",end:"`",scope:"string"},{begin:/'/,end:/'/,scope:"string"},{ +begin:/"/,end:/"/,scope:"string"}],F=e.COMMENT("//",/[$\n]/,{relevance:0 +}),P=[e.COMMENT("/\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0 +},{match:[/@(?:exception|throws)/,o,t.concat(n,b,n)],scope:{1:"doctag", 3:"title.class"},relevance:0},{match:[/@(?:exception|throws)/,o,n],scope:{ 1:"doctag",3:"title.class"},relevance:0},{ -begin:[/\{/,/@(?:link|see)/,o,/[a-zA-Z_0-9]*/,t.concat(/(?:#|\.)/,n),s], -beginScope:{2:"doctag",4:"title.class",5:"title.method"},end:/\}/,contains:[{ +begin:[i,/@(?:link|see)/,o,/[a-zA-Z_0-9]*/,t.concat(/(?:#|\.)/,n),s], +beginScope:{2:"doctag",4:"title.class",5:"title.method"},end:r,contains:[{ match:/(?:\(|\))/,scope:"punctuation"},{match:[o,n,/\s*(?=[,)])/],scope:{ 2:"variable"}},{match:[n,/(?=\s)/],scope:{1:"type"}}]},{ -begin:[/\{/,/@(?:link|see)/,o,/[a-zA-Z_0-9]*/,t.concat(/(?:#|\.)/,n,/\s*(?=\})/)], -beginScope:{2:"doctag",4:"title.class",5:"title.method"},end:/\}/,returnEnd:!0 -},{begin:[/\{/,/@(?:link|see)/,o,a],beginScope:{2:"doctag",4:"title.class"}, -end:/\}/,returnEnd:!0},{begin:[/\{/,/@(?:link|see)(?=\s+")/],beginScope:{ -2:"doctag"},end:/\}/,returnEnd:!0,contains:_},{begin:[/\{/,/@(?:link|see)/], -beginScope:{2:"doctag"},end:/\}/,returnEnd:!0,subLanguage:["markdown","xml"]},{ -begin:[/\{/,/@literal/],beginScope:{2:"doctag"},end:/\}/,returnEnd:!0, +begin:[i,/@(?:link|see)/,o,/[a-zA-Z_0-9]*/,t.concat(/(?:#|\.)/,n,/\s*(?=\})/)], +beginScope:{2:"doctag",4:"title.class",5:"title.method"},end:r,returnEnd:!0},{ +begin:[i,/@(?:link|see)/,o,a],beginScope:{2:"doctag",4:"title.class"},end:r, +returnEnd:!0},{begin:[i,/@(?:link|see)(?=\s+")/],beginScope:{2:"doctag"},end:r, +returnEnd:!0,contains:M},{begin:[i,/@(?:link|see)/],beginScope:{2:"doctag"}, +end:r,returnEnd:!0,subLanguage:["markdown","xml"]},{begin:[i,/@literal/], +beginScope:{2:"doctag"},end:r,returnEnd:!0, subLanguage:["apex","xml","javascript"]},{match:c,scope:"doctag",relevance:0},{ match:[/(?<=@param)\s+/,n],scope:{2:"variable"},relevance:0},{ -contains:[e.BACKSLASH_ESCAPE],relevance:0,variants:_},{begin:/[0-9]+\.[0-9]+/, +contains:[e.BACKSLASH_ESCAPE],relevance:0,variants:M},{begin:/[0-9]+\.[0-9]+/, end:/\.*\s+/,scope:"number",excludeEnd:!0},{ begin:t.either(/\d{4}-\d{1,2}-\d{1,2}/,/\d{1,2}\/\d{1,2}\/\d{4}/), -scope:"literal"},{begin:[/\{/,/@code/],beginScope:{2:"doctag"},starts:{end:/\}/, -returnEnd:!0,contains:[{match:/^\s+\*\s+/,skip:!0,relevance:0},{begin:/\{/, -end:/\}/,skip:!0}],subLanguage:["apex","xml","javascript"]}}]}),U],k={ -match:t.either(...y),scope:"operator",relevance:0},M=[{ +scope:"literal"},{begin:[i,/@code/],beginScope:{2:"doctag"},starts:{end:r, +returnEnd:!0,contains:[{match:/^\s+\*\s+/,skip:!0,relevance:0},{begin:i,end:r, +skip:!0}],subLanguage:["apex","xml","javascript"]}}]}),F],Y={ +match:t.either(...w),scope:"operator",relevance:0},x=[{ begin:/\b(list|set|map)(?=\s*<)/,beginScope:"type",end:/\>+/, endScope:"punctuation",contains:[{match:/\<|\,/,scope:"punctuation"},{match:a, scope:"type"}],relevance:8},{match:[t.optional(a),/\[/,t.optional(/\d+/),/\]/], scope:{1:"variable",2:"punctuation",3:"number",4:"punctuation"}},{ -match:[n,/\[\]/],scope:{1:"type",2:"punctuation"},relevance:0}],F=[{ +match:[n,/\[\]/],scope:{1:"type",2:"punctuation"},relevance:0}],W=[{ match:t.concat(c,/\b(?!\s*\()/),scope:"meta"},{scope:"meta", -begin:[t.concat(c,/\b/),/\s*/,/\(/],beginScope:{3:"punctuation"},end:/\)/, +begin:[t.concat(c,/\b/),/\s*/,l],beginScope:{3:"punctuation"},end:p, endScope:"punctuation",contains:[{match:[a,/\s*=/],scope:{1:"keyword", -2:"operator"},contains:[k]},I,u],keywords:{literal:R}}],P={ +2:"operator"},contains:[Y]},k,g],keywords:{literal:O}}],H={ match:[/\b[a-zA-Z0-9\.]*Exception/,o,n],scope:{1:"type",3:"variable"}, -relevance:0},Y=[{match:[/(?])/],scope:{2:"variable"}, +relevance:0},B=[{match:[/(?])/],scope:{2:"variable"}, relevance:0},{match:[a,"(?=\\s+"+n+/\s*\=/+")"],scope:{1:"type"},relevance:0},{ -match:[a,o,a,/\s*(?=\=[^\>])/],scope:{1:"type",3:"variable"},relevance:0}],x={ -match:[/(?<=\=\s*\()/,n,"(?=\\)\\s*"+n+")"],scope:{2:"type"},relevance:0},W={ -match:[/\bnew\s+/,n,s],scope:{2:"type"},relevance:0};let H={begin:/\(/, -beginScope:"punctuation",end:/\)/,endScope:"punctuation",relevance:0,keywords:O, -contains:[]};const B=[{match:[/(?<=\.)/,n,s],scope:{2:"title.function.invoke1"}, -relevance:1,contains:[...l],starts:H},{match:[/^\s*/,b(...d),n,s],scope:{ -3:"title.function.invoke"},relevance:1,starts:H}] -;H.contains=[I,W,f,k,M,w,u,p,B,{keywords:{KEYWORDS:O}, -match:t.concat(/(?<=\s|\(|\,)/,b(...R),n,/\b/,/(?!\.)/),scope:"variable", +match:[a,o,a,/\s*(?=\=[^\>])/],scope:{1:"type",3:"variable"},relevance:0}],G={ +match:[/(?<=\=\s*\()/,n,"(?=\\)\\s*"+n+")"],scope:{2:"type"},relevance:0},K={ +match:[/\bnew\s+/,n,s],scope:{2:"type"},relevance:0};let Q={begin:l, +beginScope:"punctuation",end:p,endScope:"punctuation",relevance:0,keywords:D, +contains:[]};const V=[{match:[/(?<=\.)/,n,s],scope:{2:"title.function.invoke1"}, +relevance:1,contains:[...d],starts:Q},{match:[/^\s*/,E(...h),n,s],scope:{ +3:"title.function.invoke"},relevance:1,starts:Q}] +;Q.contains=[k,K,P,Y,x,U,g,m,V,{keywords:{KEYWORDS:D}, +match:t.concat(/(?<=\s|\(|\,)/,E(...O),n,/\b/,/(?!\.)/),scope:"variable", relevance:0},{match:/\(|\,|\./,scope:"punctuation",relevance:0},{match:n, -scope:"variable"}];const G={scope:"params",end:/\)/,endScope:"punctuation", -relevance:1,keywords:O,contains:[u,I,f,M,...w,{match:/\,|\(/,scope:"punctuation" -},p,{match:[/(?<=\(|\,)\s*/,n,/(?=\s)/],scope:{2:"type"}},{ -match:[o,n,/\s*(?=[,)])/],scope:{2:"variable"}}]},Q={ +scope:"variable"}];const z={scope:"params",end:p,endScope:"punctuation", +relevance:1,keywords:D,contains:[g,k,P,x,...U,{match:/\,|\(/,scope:"punctuation" +},m,{match:[/(?<=\(|\,)\s*/,n,/(?=\s)/],scope:{2:"type"}},{ +match:[o,n,/\s*(?=[,)])/],scope:{2:"variable"}}]},Z={ match:[/\bswitch\s+on\s+/,n],scope:{1:"keyword",2:"variable"}};return{ name:"Apex",aliases:["apex","lightning","soql","sosl"],case_insensitive:!0, -disableAutodetect:!1,ignoreIllegals:!1,keywords:O, +disableAutodetect:!1,ignoreIllegals:!1,keywords:D,beginKeywords:"Id", illegal:["","\x3c!--","!DOCTYPE",/","<%%",":-",/\bmergesort\(/,/\bvar\s+env\b/,/\bdef\b\s\W:/,/"[^"]+"/,/\(\*|\*\)/], -contains:[f,F,I,u,x,M,[{begin:[/\btrigger/,o,n,o,"on",o,n],beginScope:{ +contains:[P,W,k,g,G,x,[{begin:[/\btrigger/,o,n,o,"on",o,n],beginScope:{ 1:"keyword",3:"title.class",5:"operator",7:"type"},end:/(?=\{)/,returnEnd:!0, -contains:[f,{begin:/\(/,end:/\)/,contains:[{ +contains:[P,{begin:l,end:p,contains:[{ match:/\b(before|after)\s+(insert|update|delete|merge|undelete)\b/, -scope:"keyword",relevance:5},T]}]},{relevance:5, +scope:"keyword",relevance:5},N]}]},{relevance:5, match:/\b(with|without|inherited)\s+sharing\b/,scope:"keyword"},{ begin:[/(?!\.)/,/\b(class|interface)\b(?!\?|\.)/],beginScope:{2:"keyword"}, -end:/(?=\{)/,relevance:1,keywords:{type:g,keyword:d},contains:[{ +end:/(?=\{)/,relevance:1,keywords:{type:A,keyword:h},contains:[{ match:[/(?<=\bclass)\s+/,n],scope:{2:"title.class"}},{returnEnd:!0, -endsWithParent:!0,beginKeywords:"implements extends",end:/\{/,contains:[{ +endsWithParent:!0,beginKeywords:"implements extends",end:i,contains:[{ match:[a,/(?=\.)/],scope:{1:"built_in"}},{match:t.concat(a,/(?=\>)/), scope:"type"},{match:a,scope:"title.class.inherited"},{match:/<|>|,/, -scope:"punctuation"},w],relevance:0}]},{begin:[/\benum\s+/,n,/\s*\{/], -beginScope:{2:"type",3:"punctuation"},end:/\}/,endScope:"punctuation", -relevance:0,contains:[f,T,{match:t.concat(a),scope:"variable.constant"}]},{ +scope:"punctuation"},U],relevance:0}]},{begin:[/\benum\s+/,n,/\s*\{/], +beginScope:{2:"type",3:"punctuation"},end:r,endScope:"punctuation",relevance:0, +contains:[P,N,{match:t.concat(a),scope:"variable.constant"}]},{ match:[/(public|private|protected)\s+/,n,s],scope:{1:"keyword", -2:"title.function"},starts:G,relevance:1},{ +2:"title.function"},starts:z,relevance:1},{ match:[/(?|\w)\s+/,n,s],scope:{2:"title.function"}, -relevance:1,starts:G}],[{match:/as\s+(user|system)\b/,scope:"keyword", -relevance:5}],P,{match:[/\bfor\b\s*/,/\(/,n,o,n,/\s*/,/:/],scope:{3:"type", -5:"variable",7:"operator"}},B,W,C,w,p,{begin:[/\[/,/\s*(?=(SELECT|FIND)\b)/], +relevance:1,starts:z}],[{match:/as\s+(user|system)\b/,scope:"keyword", +relevance:5}],H,{match:[/\bfor\b\s*/,l,n,o,n,/\s*/,/:/],scope:{3:"type", +5:"variable",7:"operator"}},V,K,_,U,m,{begin:[/\[/,/\s*(?=(SELECT|FIND)\b)/], end:/\]/,beginScope:{1:"punctuation"},endScope:"punctuation",scope:"soql", -relevance:10,endsWithParent:!0,keywords:{literal:O.literal,built_in:L}, -contains:[u,k,I,T,{match:/\(|\)/,scope:"punctuation",relevance:0},...l,{ +relevance:10,endsWithParent:!0,keywords:{literal:D.literal,built_in:C}, +contains:[g,Y,k,N,{match:/\(|\)/,scope:"punctuation",relevance:0},...d,{ begin:[/\bFROM\b/,o],beginScope:{1:"keyword"},end:/(?=\bWHERE\b|\]|\s|\))/, -contains:[{match:n,scope:"type"},...l]},{ +contains:[{match:n,scope:"type"},...d]},{ match:t.concat(/\b/,t.either("CALENDAR_MONTH","CALENDAR_QUARTER","CALENDAR_YEAR","DAY_IN_MONTH","DAY_IN_WEEK","DAY_IN_YEAR","DAY_ONLY","FISCAL_MONTH","FISCAL_QUARTER","FISCAL_YEAR","HOUR_IN_DAY","WEEK_IN_MONTH","WEEK_IN_YEAR","AVG","convertCurrency","convertTimezone","COUNT_DISTINCT","COUNT","DISTANCE","EXCLUDES","FIELDS","FORMAT","GEOLOCATION","GROUPING","ROLLUP","CUBE","INCLUDES","MAX","MIN","SUM","toLabel","USER_MODE","SYSTEM_MODE","SECURITY_ENFORCED"),/\b/), scope:"title.function"},{match:/\b(GROUP|ORDER)\s+BY\b/,scope:"title.function" },{match:/\b(TODAY|TOMORROW|YESTERDAY)\b/,scope:"keyword"},{ @@ -117,10 +117,10 @@ match:/(NEXT|LAST|THIS)_(90_DAY|DAY|FISCAL_QUARTER|FISCAL_YEAR|MONTH|QUARTER|WEE scope:"keyword",relevance:8},{ match:[/(NEXT|LAST)_N_(DAY|FISCAL_QUARTER|FISCAL_YEAR|MONTH|QUARTER|WEEK|YEAR)S/,/\s*:\s*/,/\d+/], scope:{1:"keyword",2:"operator",3:"number"},relevance:8},{ -match:t.concat(/\b/,t.either(...O.keyword,"ABOVE_OR_BELOW","ABOVE","ACTIVE","ADVANCED","ALL","ANY","ARRAY","AS","ASC","BELOW","CATEGORY","CONTAINS","CUSTOM","DATA","DESC","DIVISION","ELSE","END","FIND","FROM","METADATA","NETWORK","ON","PricebookId","RETURNING","ROLLUP","ROWS","SEARCH","SELECT","SNIPPET","SORT","SPELL_CORRECTION","STANDARD","THEN","USING","WHEN","WHERE","WITH","SCOPE","Delegated","Everything","Mine","My_Territory","My_Team_Territory","Team","AND","AT","FIRST","FOR","HAVING","IN","LAST","LIKE","LIMIT","LISTVIEW","NOT","NULLS","OFFSET","OR","REFERENCE","TRACKING","TYPEOF","UPDATE","VIEW","VIEWSTAT"),/\b/), +match:t.concat(/\b/,t.either(...D.keyword,"ABOVE_OR_BELOW","ABOVE","ACTIVE","ADVANCED","ALL","ANY","ARRAY","AS","ASC","BELOW","CATEGORY","CONTAINS","CUSTOM","DATA","DESC","DIVISION","ELSE","END","FIND","FROM","METADATA","NETWORK","ON","PricebookId","RETURNING","ROLLUP","ROWS","SEARCH","SELECT","SNIPPET","SORT","SPELL_CORRECTION","STANDARD","THEN","USING","WHEN","WHERE","WITH","SCOPE","Delegated","Everything","Mine","My_Territory","My_Team_Territory","Team","AND","AT","FIRST","FOR","HAVING","IN","LAST","LIKE","LIMIT","LISTVIEW","NOT","NULLS","OFFSET","OR","REFERENCE","TRACKING","TYPEOF","UPDATE","VIEW","VIEWSTAT"),/\b/), scope:"keyword"},{match:[/(?<=:)/,/\s*/,a,/(?!\()/],scope:{3:"variable"}, -relevance:0},{match:[/(?<=:|\.)/,n,/(?=\s*\()/],scope:{2:"title.function.invoke" -},relevance:0},{match:/:/,scope:"operator",relevance:0}],illegal:"::" -},Q,Y,k,D,l,{match:t.concat("(?<=this.)",n,"(?!\\()"),scope:"variable"},{ -match:[t.concat(/\b/,b(...N)),n,o,/(?=\{)/],scope:{2:"property"},relevance:0}]}} +relevance:0},{match:[/(?<=:|\.)/,n,s],scope:{2:"title.function.invoke"}, +relevance:0},{match:/:/,scope:"operator",relevance:0}],illegal:"::"},Z,B,Y,f,d,{ +match:t.concat("(?<=this.)",n,"(?!\\()"),scope:"variable"},{ +match:[t.concat(/\b/,E(...I)),n,o,/(?=\{)/],scope:{2:"property"},relevance:0}]}} })();hljs.registerLanguage("apex",e)})(); \ No newline at end of file diff --git a/src/languages/apex.js b/src/languages/apex.js index 95da1a0..e7deb71 100644 --- a/src/languages/apex.js +++ b/src/languages/apex.js @@ -14,6 +14,10 @@ export default function (hljs) { const SPACEPARENS_LOOKAHEAD = /(?=\s*\()/; //const PARENS_LOOKAHEAD = /(?=\()/; const SPACE = /\s+/; + const OPENCURLY = /\{/; + const CLOSECURLY = /\}/; + const OPENPARENS = /\(/; + const CLOSEPARENS = /\)/; const ACCESSOR = /(?)/), scope: 'type' }, @@ -788,8 +793,8 @@ export default function (hljs) { contains: [ COMMENTS, { - begin: /\(/, - end: /\)/, + begin: OPENPARENS, + end: CLOSEPARENS, contains: [ { match: /\b(before|after)\s+(insert|update|delete|merge|undelete)\b/, @@ -827,7 +832,7 @@ export default function (hljs) { // enum declaration begin: [/\benum\s+/, APEX_IDENT_RE, /\s*\{/], beginScope: { 2: 'type', 3: 'punctuation' }, - end: /\}/, + end: CLOSECURLY, endScope: 'punctuation', relevance: 0, contains: [ @@ -1074,7 +1079,7 @@ export default function (hljs) { }, { // any non-soql function used in the query - match: [/(?<=:|\.)/, APEX_IDENT_RE, /(?=\s*\()/], + match: [/(?<=:|\.)/, APEX_IDENT_RE, SPACEPARENS_LOOKAHEAD], scope: { 2: 'title.function.invoke' }, relevance: 0 }, @@ -1087,7 +1092,7 @@ export default function (hljs) { const FOR_LOOP = { match: [ /\bfor\b\s*/, - /\(/, + OPENPARENS, APEX_IDENT_RE, SPACE, APEX_IDENT_RE, @@ -1152,7 +1157,7 @@ export default function (hljs) { /\d\s+\d/, //clojure /\w::\w/, /\bfloat\b/, // many languages - /(SELECT|RETURNING)\s+\*/, + /(SELECT|RETURNING)\s+\*/, // SOQL requires explicit fields /END\s+LOOP/, /CREATE\s+FUNCTION/, /\bint\b/, @@ -1217,6 +1222,7 @@ export default function (hljs) { disableAutodetect: false, ignoreIllegals: false, keywords: KEYWORDS, + beginKeywords: 'Id', //TODO: Check this illegal: ILLEGALS, contains: [...APEX_PARTS] };