UNPKG

highlightjs-apex

Version:

Apex Language of Salesforce highlighting plugin for highlight.js

134 lines 14.1 kB
/*! `apex` grammar compiled for Highlight.js 11.11.1 */ var hljsGrammar=(()=>{"use strict";return e=>{ const t=e.regex,c="[a-zA-Z][a-zA-Z_0-9]*",a="[a-zA-Z_0-9]*",n="\\b"+c+"\\b",s="@"+c,o=/(?=\s*\()/,i=/\s+/,r=/\{/,l=/\s*\}/,p=/\(/,b=/\)/,u={ match:/^\s+\*\s+/,scope:"comment",relevance:0 },d=/(https?):\/\/[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]/,m=/(?<!\?)\./,h=/\?\./,g=[{ match:m,scope:"punctuation",relevance:0},{match:h,scope:"operator",relevance:0 }],E={match:/(?<!\.)\bId\b/,scope:"type",relevance:8};function v(...e){ return t.concat("(?!",e.join("|"),")")}const A={scope:"number", match:t.either(/\b(\d{4}\-\d{2}\-\d{2}T\d{2}\:\d{2}\:\d{2}(\.\d{1,3})?(\-|\+)\d{2}\:\d{2})\b/,/\b(\d{4}\-\d{2}\-\d{2}T\d{2}\:\d{2}\:\d{2}(\.\d{1,3})?(Z)?)\b/,/\b(\d{4}\-\d{2}\-\d{2})\b/,/\b0(x|X)[0-9a-fA-F_]+(U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?\b/,/\b0(b|B)[01_]+(U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?\b/,/\b([0-9]+)?\.[0-9]+((e|E)[0-9]+)?(F|f|D|d|M|m)?\b/,/(-?)\b[0-9]+(e|E)[0-9]+(F|f|D|d|M|m)?\b/,/(-?)\b[0-9]+(F|f|D|d|M|m)\b/,/(-?)\b[0-9]+(U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?\b/,/(-?)(\b0[0-9]+|(\b\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)/), relevance:0 },S=["try","catch","finally","get","set","put","if","for","else","do","while","continue","break","implements","extends","return","throw","when","new"],R=["instanceof","super","this"],T=["abstract","final","global","override","private","protected","public","static","testMethod","transient","virtual","webservice"],y=["anytype|0","blob|0","boolean|0","byte|0","currency|0","date|0","datetime|0","decimal|0","double|0","enum|0","float|0","integer|0","long|0","object|0","pagereference|8","selectoption|8","short|0","sobject|10","string|0","time|0","void|0","float|0"],L=["insert","update","upsert","delete","undelete","merge","convertLead"],O=["AppLauncher","Approval","Auth","Cache","Canvas","ChatterAnswers","CommerceOrders","fsccashflow","CommercePayments","ConnectApi","Context","Database","Datacloud","DataRetrieval","DataSource","Dataweave","Dom","EventBus","ExternalService","Flow","FormulaEval","Functions","id_verification","industriesDigitalLending","Invocable","KbManagement","LxScheduler","Messaging","Metadata","Pref_center","Process","QuickAction","Reports","RichMessageing","Schema","Search","Sfc","Sfdc_Checkout","IndustriesNlpSvc","PlaceQuote","Sfdc_Enablement","Sfdc_surveys","Site","Slack|8","Support","System|0","TerritoryMgmt","TxnSecurity","UserProvisioning","VisualEditor","Wave"],N=["Address","Answers","ApexPages","Approval","Assert","AsyncInfo","AsyncOptions","BusinessHours","Cases","Collator","Compression","Continuation","Cookie","Crypto","Database","Date","Datetime","Decimal","Dom","Domain","DomainCreator","DomainParser","EmailMessages","EncodingUtil","EventBus","Exception","FeatureManagement","FlexQueue","Formula","FormulaRecalcFieldError","FormulaRecalcResult","Http","HttpRequest","HttpResponse","Ideas","IsvPartners","JSON","JSONGenerator","JSONParser","Label","Limits","Location","Matcher","Math","Messaging","MultiStaticResourceCalloutMock","Network","OrgLimit","OrgLimits","Packaging","PageReference","Pattern","QueueableDuplicateSignature","QueueableDuplicateSignature.Builder","QuickAction","Request","ResetPasswordResult","RestContext","RestRequest","RestResponse","Search","Security","SelectOption|8","Site","SObject","SObjectAccessDecision","StaticResourceCalloutMock","Test","TimeZone","Type","URL","UserInfo","UserManagement","UUID","Version","WebServiceCallout","XmlStreamReader","XmlStreamWriter"],C=["AccessType","AccessLevel","CallbackStatus","DomainType","JSONToken","LoggingLevel","Quiddity|10","TriggerOperation","operationType"],D=["false","true","null"],_={ match:/,/,scope:"punctuation",relevance:0 },w=[/--/,/\+\+/,/\&\&|\|\|/,/\*\=|\/\=|\%\=|\+\=|-\=/,/\&\=|\^\=|<<\=|>>\=|>>>\=|\|\=/,/\&|~|\^|\|/,/<<|>>/,/<\=|>\=|\s(<|>)\s/,/\=\=|!\=/,/\=>/,/!(?=\w)/,/(?<=\s)(\?|:)(?=\s)/,h,/(?<=\s)(\?\?)(?=\s)/,/(?<!\?)\?(?!\?|\.|\[)/,/%[^%]|(?<!\n\s+)\*[^\/]|\/[^\/\*]|(?<!\-)\-(?!\-)|(?<!\+)\+(?!\+)/,/(?<!\=|!)\=(?!\=|>)/],I=O.concat(...N),f={ $pattern:t.concat(/(?<!\.)/,n),keyword:[...S,...T,...L],type:y,literal:D },U=[...D,...S,...T,...O,...N,...C,...R,...L],k={ match:t.concat(/\b/,t.either(...R),/\b/),scope:"variable.language",relevance:0 },M=[{match:[t.concat(/\b/,t.either(...C)),/\./,c,/\b\s*(?![\.\(])/],scope:{ 1:"built_in",2:"punctuation",3:"variable"},relevance:0},{ match:[t.concat(/\b/,t.either(...N)),/\./,c,/\b\s*(?![\.\(])/],scope:{ 1:"built_in",2:"punctuation",3:"type"},relevance:0},{ match:[t.concat(/(?<!\.)/,t.either(...O)),/\./,n,/\b(?=\.)/],scope:{ 1:"built_in",2:"punctuation",3:"type"}},{ match:[t.concat(/\b/,t.either(...N),/\b/),/\./,n,o],scope:{1:"built_in", 2:"punctuation",3:"title.function.invoke"}},{ match:[t.concat(/\b/,t.either(...O,...N)),/\./,n,/\b(?!\.)/],scope:{ 1:"built_in",2:"punctuation",3:"keyword"}},{ match:[/\bTrigger\b/,/\./,/(isExecuting|isInsert|isUpdate|isDelete|isBefore|isAfter|isUndelete|new|newMap|old|oldMap|size|operationType)\b(?!\.)/], scope:{1:"built_in",2:"punctuation",3:"type"},relevance:10},{ match:[/\btrigger\b/,/\./,"operationtype",/\./,t.concat(n,/\b/)],scope:{ 1:"built_in",2:"punctuation",3:"keyword",4:"punctuation",5:"variable.constant"}, relevance:10}],F=[{ match:t.either(",",/;/,/(?<=\w)\>/,/\<(?=\w)/,/\{|\}/,/\(|\)/,/\{|\}/), scope:"punctuation",relevance:0},_],P=e.inherit(e.APOS_STRING_MODE,{ scope:"string",relevance:0,contains:[{match:/\\'/,scope:"literal",relevance:0}] }),Y=[{begin:"`",end:"`",scope:"string"},{begin:/'/,end:/'/,scope:"string"},{ begin:/"/,end:/"/,scope:"string"}],x=e.COMMENT("//",/[$\n]/,{relevance:0 }),W=/(\[\d+\])*/,H=/(?:@link|@see)\s+/,G=t.either("#",m),B=[{ match:[/\{*/,H,t.concat(c,m,c,m,c,W),/(?=[\}\s])/],scope:{2:"doctag", 3:"title.function"}},{match:[/(?<!\{\s*)@see\s+/,t.concat(c,G,c,W,/(?=\s)/)], scope:{1:"doctag",2:"title.function"}},{match:[/(?<!\{\s*)@see\s+/,d],scope:{ 1:"doctag",2:"link"}},{match:[/(?<!\{\s*)@see\s+/,t.concat(n,/(?=\s)/)],scope:{ 1:"doctag",2:"title.class"}},{begin:/@example(?!\s+\*\s+\{)/, beginScope:"doctag",end:/(@|\*\/)/,returnEnd:!0,starts:{endsWithParent:!0, subLanguage:["apex","xml","javascript"]}}],K=[{ begin:[/\{*/,H,a,t.concat(G,c),/\s*\(/],beginScope:{2:"doctag",3:"title.class", 4:"title.function"},end:b,contains:[u,{match:[i,c,/\s*(?=[,)])/],scope:{ 2:"variable"}},{match:[c,/(?=\s)/],scope:{1:"type"}},{match:/,/, scope:"punctuation"},x,u]},{match:[/\s/,H,t.concat(a,G,c),/(?=[\}\s])/],scope:{ 2:"doctag",3:"title.function"}},{match:[r,H,t.concat(c,G,c),l],scope:{ 2:"doctag",3:"title.function"}},{match:[r,H,c,l],scope:{2:"doctag", 3:"title.class"}},{begin:[r,H,/(?=")/],beginScope:{2:"doctag"},end:l,contains:Y },{begin:[r,H],beginScope:{2:"doctag"},end:l,returnEnd:!0, subLanguage:["markdown","xml"],contains:[{match:d,scope:"link"}] }],Q=[e.COMMENT("/\\*","\\*/",{relevance:0,contains:[{match:"<br>",relevance:0 },{begin:/\w+@/,relevance:0},{match:[/@(?:exception|throws)/,i,c],scope:{ 1:"doctag",3:"title.class"},relevance:0},B,K,{scope:"doctag",begin:"@param", end:/$/,contains:[{scope:"variable",variants:[{match:c}],endsParent:!0}]},{ variants:Y,contains:[e.BACKSLASH_ESCAPE],relevance:0},{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:[r,"@code"],beginScope:{2:"doctag"},starts:{end:l, contains:[u,{begin:r,end:l,skip:!0}],subLanguage:["apex","xml","javascript"]}},{ begin:[r,s],beginScope:{2:"doctag"},end:l},{match:s,scope:"doctag",relevance:0 },u]}),x,u],z={match:t.either(...w),scope:"operator",relevance:0},V=[{ begin:/\b(list|set|map)(?=\s*<)/,beginScope:"type",end:/\>+/, endScope:"punctuation",contains:[{match:/\<|,/,scope:"punctuation"},{match:n, scope:"type"}],relevance:8},{match:[t.optional(n),/\[/,t.optional(/\d+/),/\]/], scope:{1:"variable",2:"punctuation",3:"number",4:"punctuation"}},{ match:[c,/\[\]/],scope:{1:"type",2:"punctuation"},relevance:0}],Z=[{ match:t.concat(s,/\b(?!\s*\()/),scope:"meta"},{scope:"meta", begin:[t.concat(s,/\b/),/\s*/,p],beginScope:{3:"punctuation"},end:b, endScope:"punctuation",contains:[{match:[n,/\s*=/],scope:{1:"keyword", 2:"operator"},contains:[z]},P,A],keywords:{literal:D}}],j={ match:[/\b[a-zA-Z0-9\.]*Exception/,i,c],scope:{1:"type",3:"variable"}, relevance:0},X=[{match:[/(?<!\.)/,n,/\s*(?=\=[^\>])/],scope:{2:"variable"}, relevance:0},{match:[n,"(?=\\s+"+c+/\s*\=/+")"],scope:{1:"type"},relevance:0},{ match:[n,i,n,/\s*(?=\=[^\>])/],scope:{1:"type",3:"variable"},relevance:0}],q={ match:[/(?<=\=\s*\()/,c,"(?=\\)\\s*"+c+")"],scope:{2:"type"},relevance:0},$={ match:[/\bnew\s+/,c,o],scope:{2:"type"},relevance:0},J={begin:p, beginScope:"punctuation",end:b,endScope:"punctuation",relevance:0,keywords:f, contains:[]},ee=[{match:[/(?<=\.)/,c,o],scope:{2:"title.function.invoke"}, relevance:1,contains:[...g],starts:J},{match:[/^\s*/,v(...S),c,o],scope:{ 3:"title.function.invoke"},relevance:1,starts:J}] ;J.contains=[P,$,Q,z,V,M,A,E,ee,{keywords:{KEYWORDS:f}, match:t.concat(/(?<=\s|\(|,)/,v(...D),c,/\b/,/(?!\.)/),scope:"variable", relevance:0},{match:/\(|,|\./,scope:"punctuation",relevance:0},{match:c, scope:"variable"}];const te={scope:"params",end:b,endScope:"punctuation", relevance:1,keywords:f,contains:[A,P,Q,V,...M,{match:/,|\(/,scope:"punctuation" },E,{match:[/(?<=\(|,)\s*/,c,/(?=\s)/],scope:{2:"type"}},{ match:[i,c,/\s*(?=[,)])/],scope:{2:"variable"}}]},ce={ match:[/\bswitch\s+on\s+/,c],scope:{1:"keyword",2:"variable"}};return{ name:"Apex",aliases:["apex","lightning","soql","sosl"],case_insensitive:!0, disableAutodetect:!1,ignoreIllegals:!1,keywords:f,beginKeywords:"Id", illegal:["</","<#","<]","<div>","\x3c!--","!DOCTYPE",/<iframe\b/,/^#/,/^import \.[a-zA-Z]+\./,/^import [\w]+/,/^import$/,/^include </,/^use\s+</,/\b(const|var)\s+\w+\s*=/,/\bstruct\b/,"System.log","console.log",/\bfor\s+\w+\s+IN\s+/,/\bif\s+\w+\s+IN\s+/,/\bend\s+if\b/,/\bend\s+select\b/,/\b(int|var)\s+\w+\s+=/,/\b(int[0-9]+|bool)\b/,/\b\$/,/\b_/,"::=",/\s#[a-zA-Z]/,/\s_[a-zA-Z]/,/\s\$[a-zA-Z]/,"#if","%if",/\bif(?!\s+\()/,"%endif","#endif","#_",/\d\s+\d/,/\w::\w/,/\bfloat\b/,/(SELECT|RETURNING)\s+\*/,/END\s+LOOP/,/CREATE\s+FUNCTION/,/\bint\b/,/import\s+\w+\s+=\s+require\("\w+"\)/,"/^include\b/",/\buse\s+strict\b/,/\w+\s+=\s+"\S*";/,/\/include\//,/\bend(\.)?\n/,'"""',/\+\+\+/,/<%/,"<%#","%%>","<%%",":-",/\bmergesort\(/,/\bvar\s+env\b/,/\bdef\b\s\W:/,/"[^"]+"/,/\(\*|\*\)/], contains:[Q,Z,P,A,q,V,[{begin:[/\btrigger/,i,c,i,"on",i,c],beginScope:{ 1:"keyword",3:"title.class",5:"operator",7:"type"},end:/(?=\{)/,returnEnd:!0, contains:[Q,{begin:p,end:b,contains:[{ match:/\b(before|after)\s+(insert|update|delete|merge|undelete)\b/, scope:"keyword",relevance:5},_]}]},{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:y,keyword:S},contains:[{ match:[/(?<=\bclass)\s+/,c],scope:{2:"title.class"}},{returnEnd:!0, endsWithParent:!0,beginKeywords:"implements extends",end:r,contains:[{ match:[n,/(?=\.)/],scope:{1:"built_in"}},{match:t.concat(n,/(?=\>)/), scope:"type"},{match:n,scope:"title.class.inherited"},{match:/<|>|,/, scope:"punctuation"},M],relevance:0}]},{begin:[/\benum\s+/,c,/\s*\{/], beginScope:{2:"type",3:"punctuation"},end:l,endScope:"punctuation",relevance:0, contains:[Q,_,{match:t.concat(n),scope:"variable.constant"}]},{ match:[/(public|private|protected)\s+/,c,o],scope:{1:"keyword", 2:"title.function"},starts:te,relevance:1},{ match:[/(?<!new)(?<!return)(?<=\<|\>|\w)\s+/,c,o],scope:{2:"title.function"}, relevance:1,starts:te}],[{match:/as\s+(user|system)\b/,scope:"keyword", relevance:5}],j,{match:[/\bfor\b\s*/,p,c,i,c,/\s*/,/:/],scope:{3:"type", 5:"variable",7:"operator"}},ee,$,k,M,E,{begin:[/\[/,/\s*(?=(SELECT|FIND)\b)/], end:/\]/,beginScope:{1:"punctuation"},endScope:"punctuation",scope:"soql", relevance:10,endsWithParent:!0,keywords:{literal:f.literal,built_in:I}, contains:[A,z,P,_,{match:/\(|\)/,scope:"punctuation",relevance:0},...g,{ begin:[/\bFROM\b/,i],beginScope:{1:"keyword"},end:/(?=\bWHERE\b|\]|\s|\))/, contains:[{match:c,scope:"type"},...g]},{ 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"},{ match:/(NEXT|LAST|THIS)_(90_DAY|DAY|FISCAL_QUARTER|FISCAL_YEAR|MONTH|QUARTER|WEEK|YEAR)S?\b/, 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(...f.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*/,n,/(?!\()/],scope:{3:"variable"}, relevance:0},{match:[/(?<=:|\.)/,c,o],scope:{2:"title.function.invoke"}, relevance:0},{match:/:/,scope:"operator",relevance:0}],illegal:"::" },ce,X,z,F,g,{match:t.concat("(?<=this.)",c,"(?!\\()"),scope:"variable"},{ match:[t.concat(/\b/,v(...U)),c,/(?=\s*\{)/],scope:{2:"property"},relevance:0}]} }})();export default hljsGrammar;