Skip to content

Commit

Permalink
fix: handle words starting with "this" e.g. thisAccount (#48)
Browse files Browse the repository at this point in the history
Was ignoring thisA and highlighting ccount
  • Loading branch information
dschach committed Feb 6, 2024
1 parent 8d2bad4 commit 85641da
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 46 deletions.
10 changes: 5 additions & 5 deletions demo/testcode.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Map<Id, CustomObject__c> myMap = new Map<Id, CustomObject__c>([SELECT Id FROM CustomObject__c WHERE Id NOT IN :newRecordsMap.keySet()]);
Map<Id, String> myMap = new Map<Id, String>{a => b, c => d};

delete myAccount;
delete thisAccount;
Account a;
String s;
delete [SELECT Id FROM Account];
Expand All @@ -51,10 +51,10 @@

public List<SelectOption> recordTypes { get; private set; }

Database.insert(myAccounts, false, AccessLevel.USER_MODE);
delete myAccount;
Database.insert(thisAccounts, false, AccessLevel.USER_MODE);
delete thisAccount;
delete [SELECT Id FROM Account];
myAcct = (Account)myacct;
thisAcct = (Account)thisAcct;

public String myString { get; set; }

Expand Down Expand Up @@ -517,7 +517,7 @@
Boolean ai = (Boolean) false;
System.debug('Should not be called');
if (1 > 5) { // wtf!?
Database.insert(myAccounts);
Database.insert(thisAccounts);
}
}

Expand Down
35 changes: 17 additions & 18 deletions dist/apex.es.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ relevance:0}];function l(...e){return t.concat("(?!",e.join("|"),")")}const p={
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
},b=["try","catch","finally","get","set","put","if","for","else","do","while","continue","break","implements","extends","return","throw","when","new"],u=["instanceof","super","this"],d=["abstract","final","global","override","private","protected","public","static","testMethod","transient","virtual","webservice"],m=["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"],E=["insert","update","upsert","delete","undelete","merge","convertLead"],A=["AppLauncher","Approval","Auth","Cache","Canvas","ChatterAnswers","CommercePayments","ConnectApi","Database","Datacloud","Dataweave","DataSource","Dom","EventBus","ExternalService","Flow","Functions","Invocable","KbManagement","LxScheduler","Messaging","Metadata","Pref_center","Process","QuickAction","Reports","RichMessageing","Schema","Search","Sfc","Sfdc_Checkout","sfdc_surveys","Site","Support","System","TerritoryMgmt","TxnSecurity","UserProvisioning","VisualEditor","Wave"],h=["AccessLevel","Address","Answers","ApexPages","Approval","Assert","AsyncInfo","AsyncOptions","BusinessHours","Cases","Collator","Continuation","Cookie","Crypto","Database","Date","Datetime","Decimal","Domain","DomainCreator","DomainParser","EmailMessages","EncodingUtil","EventBus","Exception","FeatureManagement","FlexQueue","Formula","FormulaRecalcFieldError","FormulaRecalcResult","Http","HttpRequest","HttpResponse","Ideas","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","Site","SObject","SObjectAccessDecision","StaticResourceCalloutMock","Test","TimeZone","Type","URL","UserInfo","UserManagement","Version","WebServiceCallout","XmlStreamReader","XmlStreamWriter"],v=["AccessType","AccessLevel","DomainType","JSONToken","LoggingLevel","Quiddity","TriggerOperation","operationType"],S=["false","true","null"],g={
},b=["try","catch","finally","get","set","put","if","for","else","do","while","continue","break","implements","extends","return","throw","when","new"],u=["instanceof","super","this"],d=["abstract","final","global","override","private","protected","public","static","testMethod","transient","virtual","webservice"],m=["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"],E=["insert","update","upsert","delete","undelete","merge","convertLead"],A=["AppLauncher","Approval","Auth","Cache","Canvas","ChatterAnswers","CommercePayments","ConnectApi","Database","Datacloud","Dataweave","DataSource","Dom","EventBus","ExternalService","Flow","Functions","Invocable","KbManagement","LxScheduler","Messaging","Metadata","Pref_center","Process","QuickAction","Reports","RichMessageing","Schema","Search","Sfc","Sfdc_Checkout","sfdc_surveys","Site","Support","System","TerritoryMgmt","TxnSecurity","UserProvisioning","VisualEditor","Wave"],h=["AccessLevel","Address","Answers","ApexPages","Approval","Assert","AsyncInfo","AsyncOptions","BusinessHours","Cases","Collator","Continuation","Cookie","Crypto","Database","Date","Datetime","Decimal","Domain","DomainCreator","DomainParser","EmailMessages","EncodingUtil","EventBus","Exception","FeatureManagement","FlexQueue","Formula","FormulaRecalcFieldError","FormulaRecalcResult","Http","HttpRequest","HttpResponse","Ideas","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","Site","SObject","SObjectAccessDecision","StaticResourceCalloutMock","Test","TimeZone","Type","URL","UserInfo","UserManagement","Version","WebServiceCallout","XmlStreamReader","XmlStreamWriter"],v=["AccessType","AccessLevel","DomainType","JSONToken","LoggingLevel","Quiddity","TriggerOperation","operationType"],S=["false","true","null"],R={
match:/,/,scope:"punctuation",relevance:0
},R=[/--/,/\+\+/,/\&\&|\|\|/,/\*\=|\/\=|\%\=|\+\=|-\=/,/\&\=|\^\=|<<\=|>>\=|>>>\=|\|\=/,/\&|~|\^|\|/,/<<|>>/,/<\=|>\=|\s(<|>)\s/,/\=\=|!\=/,/\=>/,/!(?=\w)/,/(?<=\s)(\?|:)(?=\s)/,r,/(?<!\?)\?(?!\?|\.|\[)/,/%[^%]|\*[^\/]|\/[^\/\*]|(?<!\-)\-(?!\-)|(?<!\+)\+(?!\+)/,/(?<!\=|!)\=(?!\=|>)/],T=A.concat(...h),y={
$pattern:t.concat(/(?<!\.)\b/,a,/(?!\s*\()/),keyword:[...b,...d,...E],
"variable.language":u,type:m,literal:S
},T=[/--/,/\+\+/,/\&\&|\|\|/,/\*\=|\/\=|\%\=|\+\=|-\=/,/\&\=|\^\=|<<\=|>>\=|>>>\=|\|\=/,/\&|~|\^|\|/,/<<|>>/,/<\=|>\=|\s(<|>)\s/,/\=\=|!\=/,/\=>/,/!(?=\w)/,/(?<=\s)(\?|:)(?=\s)/,r,/(?<!\?)\?(?!\?|\.|\[)/,/%[^%]|\*[^\/]|\/[^\/\*]|(?<!\-)\-(?!\-)|(?<!\+)\+(?!\+)/,/(?<!\=|!)\=(?!\=|>)/],g=A.concat(...h),y={
$pattern:t.concat(/(?<!\.)\b/,a,/\b/),keyword:[...b,...d,...E],type:m,literal:S
},L=[...S,...b,...d,...A,...h,...v,...u,...E],N={
match:t.concat(/\b/,t.either(...u),/\b/),scope:"variable.language",relevance:0
},O=[{match:[t.concat(/\b/,t.either(...v)),/\./,a,/\b\s*(?![\.\(])/],scope:{
1:"built_in",2:"punctuation",3:"variable"},relevance:0},{
1:"built_in",2:"punctuation",3:"variable1"},relevance:0},{
match:[t.concat(/\b/,t.either(...h)),/\./,a,/\b\s*(?![\.\(])/],scope:{
1:"built_in",2:"punctuation",3:"type"},relevance:0},{
match:[t.concat(/\b/,t.either(...A)),/\./,t.concat(c,/\b(?=\.)/)],scope:{
1:"built_in",2:"punctuation",3:"type"}},{
match:[t.concat(/\b/,t.either(...A)),/\./,c,/\b(?=\.)/],scope:{1:"built_in",
2:"punctuation",3:"type"}},{
match:[t.concat(/\b/,t.either(...A,...h)),/\./,c,/\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(?!\.)/],
Expand All @@ -27,16 +26,16 @@ match:[/\btrigger\b/,/\./,"operationtype",/\./,t.concat(c,/\b/)],scope:{
1:"built_in",2:"punctuation",3:"keyword",4:"punctuation",5:"variable.constant"},
relevance:10}],w=[{
match:t.either(",",/;/,/(?<=\w)\>/,/\<(?=\w)/,/\{|\}/,/\(|\)/,/\{|\}/),
scope:"punctuation",relevance:0},g],C=e.inherit(e.APOS_STRING_MODE,{
scope:"punctuation",relevance:0},R],C=e.inherit(e.APOS_STRING_MODE,{
scope:"string",relevance:0,contains:[{match:/\\'/,scope:"literal",relevance:0}]
}),D=e.COMMENT("//",/[$\n]/,{relevance:0}),I=[e.COMMENT("/\\*","\\*/",{
relevance:0,contains:[{begin:/\w+@/,relevance:0},{
match:[/@(?:exception|throws)/,s,a],scope:{1:"doctag",3:"title.class"},
relevance:0},{begin:"@[A-Za-z_-]+",scope:"doctag",relevance:0},{
match:[/(?<=@param)\s+/,a],scope:{2:"variable"},relevance:0},{excludeBegin:!0,
match:[/(?<=@param)\s+/,a],scope:{2:"variable2"},relevance:0},{excludeBegin:!0,
excludeEnd:!0,contains:[e.BACKSLASH_ESCAPE],relevance:0,variants:[{begin:"`",
end:"`",scope:"subst"},{begin:/'/,end:/'/,scope:"string"}]}]}),D],_={
match:t.either(...R),scope:"operator",relevance:0},U={match:/(?<!\.)\bId\b/,
match:t.either(...T),scope:"operator",relevance:0},U={match:/(?<!\.)\bId\b/,
scope:"type",relevance:8},f=[{begin:/\b(list|set|map)(?=\s*<)/,
beginScope:"type",end:/\>+/,endScope:"punctuation",contains:[{match:/\<|\,/,
scope:"punctuation"},{match:c,scope:"type"}],relevance:8},{
Expand All @@ -47,7 +46,7 @@ match:[t.optional(c),/\[/,t.optional(/\d+/),/\]/],scope:{1:"variable",
},end:/\)/,endScope:"punctuation",contains:[{match:[c,/\s*=/],scope:{
1:"keyword",2:"operator"},contains:[_]},C,p],keywords:{literal:S}}],k={
match:[/\b[a-zA-Z0-9\.]*Exception/,s,a],scope:{1:"type",3:"variable"},
relevance:0},F={match:[/(?<!\.)/,c,/\s*(?=\=[^\>])/],scope:{2:"variable"},
relevance:0},F={match:[/(?<!\.)/,c,/\s*(?=\=[^\>])/],scope:{2:"variable3"},
relevance:0},P={match:[/(?<=\=\s*\()/,a,"(?=\\)\\s*"+a+")"],scope:{2:"type"},
relevance:0},Y={match:[/\bnew\s+/,a,o],scope:{2:"type"},relevance:0};let W={
scope:"params_call",begin:/\(/,beginScope:"punctuation",end:/\)/,
Expand All @@ -58,10 +57,10 @@ contains:[...i],starts:W},{match:[/^\s*/,l(...b),a,o],scope:{
;W.contains=[C,Y,I,_,f,O,p,U,x,{keywords:{KEYWORDS:y},
match:t.concat(/(?<=\s|\(|\,)/,l(...S),a,/\b/,/(?!\.)/),scope:"variable",
relevance:0},{match:/\(|\,|\./,scope:"punctuation",relevance:0},{match:a,
scope:"variable"}];const H={scope:"params",end:/\)/,endScope:"punctuation",
scope:"variable4"}];const H={scope:"params",end:/\)/,endScope:"punctuation",
relevance:1,keywords:y,contains:[p,C,I,f,...O,{match:/\,|\(/,scope:"punctuation"
},U,{match:[/(?<=\(|\,)\s*/,a,/(?=\s)/],scope:{2:"type"}},{
match:[s,a,/\s*(?=[,)])/],scope:{2:"variable"}}]},G={
match:[s,a,/\s*(?=[,)])/],scope:{2:"variable5"}}]},G={
match:[/\bswitch\s+on\s+/,a],scope:{1:"keyword",2:"variable"}};return{
name:"Apex",aliases:["apex","lightning","soql"],case_insensitive:!0,
disableAutodetect:!1,ignoreIllegals:!1,keywords:y,
Expand All @@ -70,7 +69,7 @@ contains:[I,M,C,p,P,f,[{begin:[/\btrigger/,s,a,s,"on",s,a],beginScope:{
1:"keyword",3:"title.class",5:"operator",7:"type"},end:/(?=\{)/,returnEnd:!0,
contains:[I,{begin:/\(/,end:/\)/,contains:[{
match:/\b(before|after)\s+(insert|update|delete|merge|undelete)\b/,
scope:"keyword",relevance:5},g]}]},{relevance:5,
scope:"keyword",relevance:5},R]}]},{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:m,keyword:b},contains:[{
Expand All @@ -80,15 +79,15 @@ match:[c,/(?=\.)/],scope:{1:"built_in"}},{match:t.concat(c,/(?=\>)/),
scope:"type"},{match:c,scope:"title.class.inherited"},{match:/<|>|,/,
scope:"punctuation"},O],relevance:0}]},{begin:[/\benum\s+/,a,/\s*\{/],
beginScope:{2:"type",3:"punctuation"},end:/\}/,endScope:"punctuation",
relevance:0,contains:[I,g,{match:t.concat(c),scope:"variable.constant"}]},{
relevance:0,contains:[I,R,{match:t.concat(c),scope:"variable.constant"}]},{
match:[/(public|private|protected)\s+/,a,o],scope:{1:"keyword",
2:"title.function"},starts:H,relevance:1},{
match:[/(?<!new)(?<!return)(?<=\<|\>|\w)\s+/,a,o],scope:{2:"title.function"},
relevance:1,starts:H}],[{match:/as\s+(user|system)\b/,scope:"keyword"}],k,{
match:[/\bfor\b\s*/,/\(/,a,s,a,/\s*/,/:/],scope:{3:"type",5:"variable",
7:"operator"}},x,Y,N,O,U,{begin:[/\[/,/\s*(?=(SELECT|FIND)\b)/],end:/\]/,
beginScope:{1:"punctuation"},endScope:"punctuation",scope:"soql",relevance:10,
endsWithParent:!0,keywords:{literal:y.literal,built_in:T},contains:[p,_,C,g,{
endsWithParent:!0,keywords:{literal:y.literal,built_in:g},contains:[p,_,C,R,{
match:/\(|\)/,scope:"punctuation",relevance:0},...i,{begin:[/\bFROM\b/,s],
beginScope:{1:"keyword"},end:/(?=\bWHERE\b|\]|\s|\))/,contains:[{match:a,
scope:"type"},...i]},{
Expand All @@ -100,9 +99,9 @@ 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(...y.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","SECURITY_ENFORCED","SELECT","SNIPPET","SORT","SPELL_CORRECTION","STANDARD","THEN","USER_MODE","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*/,c,/(?!\()/],scope:{3:"variable"},
scope:"keyword"},{match:[/(?<=:)/,/\s*/,c,/(?!\()/],scope:{3:"variable6"},
relevance:0},{match:[/(?<=:|\.)/,a,/(?=\s*\()/],scope:{2:"title.function.invoke"
},relevance:0},{match:/:/,scope:"operator",relevance:0}],illegal:"::"
},G,F,_,w,i,{match:t.concat("(?<=this.)",a,"(?!\\()"),scope:"variable"},{
},G,F,_,w,i,{match:t.concat("(?<=this.\b)",a,"(?!\\()"),scope:"variable7"},{
match:[t.concat(/\b/,l(...L)),a,s,/(?=\{)/],scope:{2:"property"},relevance:0}]}}
})();export default hljsGrammar;
Loading

0 comments on commit 85641da

Please sign in to comment.