diff --git a/demo/testcode.css b/demo/testcode.css index 8aacf00..a38738d 100644 --- a/demo/testcode.css +++ b/demo/testcode.css @@ -1,7 +1,74 @@ -/*! - Theme: Monokai - Author: Wimer Hazenberg (http://www.monokai.nl) - License: ~ MIT (or more permissive) [via base16-schemes-source] - Maintainer: @highlightjs/core-team - Version: 2021.09.0 -*/pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#f8f8f2;background:#272822}.hljs ::selection,.hljs::selection{background-color:#49483e;color:#f8f8f2}.hljs-comment{color:#75715e}.hljs-tag{color:#a59f85}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#f8f8f2}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#f92672}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#fd971f}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#f4bf75}.hljs-strong{font-weight:700;color:#f4bf75}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#a6e22e}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#a1efe4}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#66d9ef}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#ae81ff}.hljs-emphasis{color:#ae81ff;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#c63}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700} \ No newline at end of file +/* + +Atom One Dark With support for ReasonML by Gidi Morris, based off work by Daniel Gamage + +Original One Dark Syntax theme from https://github.com/atom/one-dark-syntax + +*/ +.hljs { + color: #abb2bf; + background: #282c34; +} +.hljs-keyword, .hljs-operator { + color: #F92672; +} +.hljs-pattern-match { + color: #F92672; +} +.hljs-pattern-match .hljs-constructor { + color: #61aeee; +} +.hljs-function { + color: #61aeee; +} +.hljs-function .hljs-params { + color: #A6E22E; +} +.hljs-function .hljs-params .hljs-typing { + color: #FD971F; +} +.hljs-module-access .hljs-module { + color: #7e57c2; +} +.hljs-constructor { + color: #e2b93d; +} +.hljs-constructor .hljs-string { + color: #9CCC65; +} +.hljs-comment, .hljs-quote { + color: #b18eb1; + font-style: italic; +} +.hljs-doctag, .hljs-formula { + color: #c678dd; +} +.hljs-section, .hljs-name, .hljs-selector-tag, .hljs-deletion, .hljs-subst { + color: #e06c75; +} +.hljs-literal { + color: #56b6c2; +} +.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute, .hljs-meta .hljs-string { + color: #98c379; +} +.hljs-built_in, +.hljs-title.class_, +.hljs-class .hljs-title { + color: #e6c07b; +} +.hljs-attr, .hljs-variable, .hljs-template-variable, .hljs-type, .hljs-selector-class, .hljs-selector-attr, .hljs-selector-pseudo, .hljs-number { + color: #d19a66; +} +.hljs-symbol, .hljs-bullet, .hljs-link, .hljs-meta, .hljs-selector-id, .hljs-title { + color: #61aeee; +} +.hljs-emphasis { + font-style: italic; +} +.hljs-strong { + font-weight: bold; +} +.hljs-link { + text-decoration: underline; +} diff --git a/demo/testcode.html b/demo/testcode.html index 4b5b8a4..cda794b 100644 --- a/demo/testcode.html +++ b/demo/testcode.html @@ -9,6 +9,7 @@ @@ -20,8 +21,8 @@ - -

+	
+    

       List<SObject> mylist = [SELECT Name, StreetAddress__c, COUNT(),
       (SELECT Id FROM Contacts)
       FROM Warehouse__c.Contacts__r
@@ -30,10 +31,16 @@
       ORDER BY DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi')
       LIMIT 10];
 
+      delete myAccount;
+      delete [SELECT Id FROM Account];
+
+      Integer myInt = 8 - 7++;
+
+      public List myString { get; set; }
+
       List<Opportunity> opps = [SELECT Id FROM Opportunity WHERE Id NOT IN :newRecordsMap.keySet()];
 
-      String queryText =
-				'SELECT Id, Name, AccountId, FirstName, LastName, mailingstreet, mailingcity, mailingstate, mailingpostalcode, mailingcountry, ' +
+      String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingstreet, mailingcity, mailingstate, mailingpostalcode, mailingcountry, ' +
 				'otherstreet, othercity, otherstate, otherpostalcode, othercountry, mailinglatitude, mailinglongitude, otherlatitude, otherlongitude ' +
 				'FROM Contact WHERE AccountId = :acctid ORDER BY ' +
 				String.escapeSingleQuotes(SortFullExp) +
@@ -41,7 +48,7 @@
         String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingstreet, mailingcity, mailingstate, mailingpostalcode, mailingcountry, '
     

-------NEW LANGUAGE----------

-

+    

       @IsTest
       private without sharing class myTestClass {
         myMap?.get('Id');
@@ -52,7 +59,7 @@
     

-------NEW LANGUAGE----------


 
-    Database.insert(myAccounts, AccessLevel.USER_MODE);
+    Database.insert(myAccounts, false, AccessLevel.USER_MODE);
     delete myAccount;
     delete [SELECT Id FROM Account];
 
@@ -64,6 +71,7 @@
     SPDX-License-Identifier: BSD-3-Clause
     For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
     'This is a string in a comment'
+    @throws DMLException
     */
 
     /**
@@ -552,7 +560,7 @@
   }
     

-------NEW LANGUAGE----------

-

+		

 /**
  * SHOULD BE RECOGNIZED AS JAVA
  * @author John Smith 
@@ -668,7 +676,7 @@
     Boolean ai = (Boolean) false;
     System.debug('Should not be called');
     if (1 > 5) { // wtf!?
-      Database.insert(myAccounts, AccessLevel.USER_MODE);
+      Database.insert(myAccounts, true, AccessLevel.USER_MODE);
     }
   }
 
@@ -699,7 +707,7 @@
 trigger CTrig on Custom__c (before insert){
   System.debug('inserting a record');
   upsert myRecord__c;
-  Database.upsert(myRecord__c, AccessLevel.USER_MODE);
+  Database.upsert(myRecord__c, false, AccessLevel.USER_MODE);
 }
 
     
diff --git a/dist/apex.es.min.js b/dist/apex.es.min.js index d2af04a..c300d6f 100644 --- a/dist/apex.es.min.js +++ b/dist/apex.es.min.js @@ -1,104 +1,102 @@ /*! `apex` grammar compiled for Highlight.js 11.9.0 */ var hljsGrammar=(()=>{"use strict";return e=>{ const t=e.regex,a="[a-zA-Z][a-zA-Z_0-9]*",n="@"+a,c={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/), +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=["cast","default","export","try","catch","finally","get","set","put","if","for","else","do","while","continue","break","return","throw","when"],i={ +},s=["cast","default","export","try","catch","finally","get","set","put","if","for","else","do","while","continue","break","implements","extends","return","throw","when"],o={ match:t.concat(/(?)/,/(--)/,/(\!|&&|\|\|)/,/(\*=|\/=|%=|\+=|-=)/,/(\&=|\^=|<<=|>>=|\|=)/,/(\&|~|\^|\|)/,/(\+\+)/,/(%[^%]|\*[^\/]|\/[^\/\*]|-|\+)/,/(<<|>>)/,/(<=|>=|\s(<|>)\s)/,/(==|!=)/,/=>/,/(!(?=\w))/,/(\&\&)/,/((?<=\s)(\?|:)(?=\s))/,/(\?\.)/,/(?)/,/--/,/\+\+/,/&&|\|\|/,/\*=|\/=|%=|\+=|-=/,/\&=|\^=|<<=|>>=|>>>=|\|=/,/\&|~|\^|\|/,/%[^%]|\*[^\/]|\/[^\/\*]|(?>/,/<=|>=|\s(<|>)\s/,/==|!=/,/=>/,/!(?=\w)/,/\&\&/,/(?<=\s)(\?|:)(?=\s)/,/\?\./,/(?+/, -endScope:"punctuation",contains:[{match:/)/),scope:"title.class.inherited" -},{match:t.concat(/\b/,t.either(...p),/\b\s*(?!<>)/),scope:"built_in"},{ -match:[/\b/,a,/\./,a,/(?=[,\s<])/],scope:{2:"built_in",4:"title.class.inherited" -}},{match:[/\b/,a,/(?=>)/],scope:{2:"type"}},{match:t.concat(/\b/,a,/\b(?!<)/), -scope:"title.class.inherited"}]}]},U=[C,{relevance:10, -match:/\b(with|without|inherited)\s+sharing\b/,scope:"keyword"},L,{ -begin:[/\benum\s+/,a,/\s*/,/\{/],beginScope:{1:"type",2:"type",4:"punctuation"}, -end:/[\}\n]/,endScope:"punctuation",scope:"enum_declaration",relevance:0, -contains:[E,g,A,{match:t.concat(/\b/,a,/\b/),scope:"variable.constant"}] -}].concat(M),w=[{match:[/(?<=\breturn\b)\s+/,t.either(o),/(?=\s*;)/],scope:{ -2:"literal"}},{match:[/(?<=return)/,/\s+/,a,/(?=\s*;)/],scope:{3:"variable"}},{ -match:[/(?<=return)/,/\s+/,t.lookahead(a+/\(/)],scope:{2:"title.function.invoke" -}}],f={begin:[/\[/,/\s*/,/\b(SELECT|FIND)\b/],beginScope:{1:"punctuation", -3:"keyword soql"},end:/\]/,scope:"soql",relevance:10,contains:[{ +scope:"built_in"}]}]},M={beginKeywords:"class",returnBegin:!0,end:/\{/, +endScope:"punctuation",returnEnd:!0,scope:"class_declaration",keywords:{type:r, +keyword:s},contains:[{match:[/(?<=\bclass\b)\s+/,a],scope:{2:"title.class"}},{ +returnEnd:!0,endsWithParent:!0,variants:[{beginKeywords:"implements", +end:/(\b(extends)\b)|\{/,scope:"implements block"},{beginKeywords:"extends", +end:/(\b(implements)\b)|\{/,scope:"extends block"}],contains:[{match:/\<|\>/, +scope:"punctuation"},{match:t.concat(/\b/,t.either(...p),/\b\s*(?!<>)/), +scope:"built_in"},{match:[/\b/,a,/\./,a,/(?=[,\s<])/],scope:{2:"built_in", +4:"title.class.inherited"}},{match:[/\b/,a,/(?=>)/],scope:{2:"type"}},{ +match:t.concat(/\b/,a,/\b(?!<)/),scope:"title.class.inherited"},{ +match:t.concat(/\b/,t.either(...b),/\b\s*(?!>)/),scope:"title.class.inherited"}] +}]},U=[L,{relevance:10,match:/\b(with|without|inherited)\s+sharing\b/, +scope:"keyword"},C,{begin:[/\benum\s+/,a,/\s*/,/\{/],beginScope:{1:"type", +2:"type"},end:/[\}\n]/,returnEnd:!0,scope:"enum_declaration",relevance:0, +contains:[g,T,E,{match:t.concat(/\b/,a,/\b/),scope:"variable.constant"}] +},M].concat(N),w=[{match:[/(?<=\breturn\b)\s+/,t.either(i),/(?=\s*;)/],scope:{ +2:"literal"}},{match:[/(?<=\breturn\b)/,/\s+/,a,/(?=\s*;)/],scope:{3:"variable"} +},{match:[/(?<=\breturn\b)/,/\s+/,t.lookahead(a+/\(/)],scope:{ +2:"title.function.invoke"}}],f={begin:[/\[/,/\s*/,/\b(SELECT|FIND)\b/], +beginScope:{1:"punctuation",3:"keyword soql"},end:/\]/, +endScope:"punctuation outer",scope:"soql",relevance:10,contains:[{ begin:[/\bFROM\b/,t.concat(/\s+/,a,/\b/)],beginScope:{1:"keyword",2:"type"}, scope:"from_clause",end:/(?=\]|\s)/,contains:[{match:[/(?<=\.)/,a,/\b/],scope:{ -2:"type"}},A]},{match:/\]/,scope:"punctuation",endsParent:!0},{ +2:"type"}},E]},{match:/\]/,scope:"punctuation",endsParent:!0},{ match:/\b\s*IN|=\s*:/,scope:"operator"},{ begin:t.concat(/\b/,t.either("ABOVE_OR_BELOW","ACTIVE","ADVANCED","ALL","ANY","ARRAY","AS","BY","CATEGORY","CONTAINS","CUSTOM","DATA","DIVISION","END","FIELDS","FIND","FROM","LAST","METADATA","NETWORK","ON","RETURNING","ROLLUP","ROWS","SEARCH","SELECT","SNIPPET","SORT","STANDARD","USER_MODE","WHERE",/USING\s+SCOPE\s*(Delegated|Everything|Mine|My_Territory|My_Team_Territory|Team)/,/WITH\s+SECURITY_ENFORCED/),/\b/), scope:"keyword soql",relevance:0},{ @@ -112,22 +110,23 @@ match:/(NEXT|LAST|THIS)_(90_DAY|DAY|FISCAL_QUARTER|FISCAL_YEAR|MONTH|QUARTER|WEE scope:"variable.language",relevance:10},{ match:[/(NEXT|LAST)_N_(DAY|FISCAL_QUARTER|FISCAL_YEAR|MONTH|QUARTER|WEEK|YEAR)S/,/\s*:\s*/,/\d+/], scope:{1:"variable.language",2:"operator",3:"number"},relevance:10},{ -match:[/(?<=:)/,/\s*/,a],scope:{3:"variable"}},c,I,S,A,e.APOS_STRING_MODE], -illegal:"::"},k={begin:[/\bfor\b/,/\s*\(/,a,/\s+/,a,/\s*:/],beginScope:{ -2:"punctuation",3:"type",5:"variable",6:"operator"},end:"{",contains:[E,g,f]} +match:[/(?<=:)/,/\s*/,a],scope:{3:"variable"}},c,I,A,E,e.APOS_STRING_MODE], +illegal:"::"},k={begin:[/\bfor\b\s*/,/\(/,a,/\s+/,a,/\s*:/],beginScope:{ +2:"punctuation",3:"type",5:"variable for",6:"operator"},scope:"for_loop", +end:/\)\s*\{/,endScope:"punctuation",contains:[g,T,f,I,{ +match:t.concat(a,/\b(?!\()/),scope:"variable"}],METHOD_CALL:I,PUNCTUATION:E} ;return{name:"Apex",aliases:["apex","lightning","soql"],case_insensitive:!0, disableAutodetect:!1,ignoreIllegals:!1,keywords:{$pattern:a,keyword:s, -"variable.language":["instanceof","new","super","this"],built_in:l,type:r, -literal:o,classNameAliases:{soql:"subst"}}, -illegal:["","\x3c!--","!DOCTYPE",/","<%%"], -contains:[v,R,_,g,E,O,U,[{ -match:[t.concat(/\b/,t.either(...b),/\b/),/\s*/,a,/(?=;)/],scope:{1:"built_in", -3:"variable"}},{match:t.concat(/\b/,t.either(...b),/\b/),scope:"built_in"},{ -match:[/\s+/,/(?:\bas\s+(user|system)\b\s+)?/,a,t.lookahead(";")],scope:{ -2:"built_in",3:"variable"}},{begin:t.concat(/\b/,t.either(...b),/\b/), -beginScope:"built_in",scope:"DML",contains:[D,{ -match:[t.concat("(?<=",t.either(b),")"),/\s+/,/(?:\bas\s+(user|system)\b\s+)?/,a,t.lookahead(";")], -scope:{3:"built_in",4:"variable"}},{match:t.either(b),scope:"built_in"},A]},{ +"variable.language":["instanceof","new","super","this"],built_in:b,type:r, +literal:i}, +illegal:["","\x3c!--","!DOCTYPE",/","<%%",":-"], +contains:[v,O,_,T,g,U,[{begin:t.concat(/\s\b/,t.either(...l),/\b\s/), +beginScope:"built_in",end:";|$",scope:"dml",contains:[D,{ +match:/\bas\s+(user|system)\b/,scope:"keyword"},{match:[a,/\s*;/],scope:{ +1:"variable"}},E,g,f]},{begin:[/\bDatabase\b/,/\./,a,/\s*/,/\(/],beginScope:{ +1:"built_in",3:"built_in"},end:";",scope:"database_dml", +contains:[y,m,e.APOS_STRING_MODE,T,g,{match:[/\(/,a,/,/],scope:{2:"variable"}},{ match:["AccessLevel",/\./,/(SYSTEM_MODE|USER_MODE)/],scope:{1:"built_in", -3:"keyword"}}],T,k,e.APOS_STRING_MODE,D,I,m,c,S,y,A,w,{match:/(?])/,scope:"type",relevance:8},f,o,S]}}})() +;export default hljsGrammar; \ No newline at end of file diff --git a/dist/apex.min.js b/dist/apex.min.js index a650eb6..54a75b9 100644 --- a/dist/apex.min.js +++ b/dist/apex.min.js @@ -1,104 +1,102 @@ /*! `apex` grammar compiled for Highlight.js 11.9.0 */ (()=>{var e=(()=>{"use strict";return e=>{ const t=e.regex,a="[a-zA-Z][a-zA-Z_0-9]*",n="@"+a,c={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/), +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=["cast","default","export","try","catch","finally","get","set","put","if","for","else","do","while","continue","break","return","throw","when"],i={ +},s=["cast","default","export","try","catch","finally","get","set","put","if","for","else","do","while","continue","break","implements","extends","return","throw","when"],o={ match:t.concat(/(?)/,/(--)/,/(\!|&&|\|\|)/,/(\*=|\/=|%=|\+=|-=)/,/(\&=|\^=|<<=|>>=|\|=)/,/(\&|~|\^|\|)/,/(\+\+)/,/(%[^%]|\*[^\/]|\/[^\/\*]|-|\+)/,/(<<|>>)/,/(<=|>=|\s(<|>)\s)/,/(==|!=)/,/=>/,/(!(?=\w))/,/(\&\&)/,/((?<=\s)(\?|:)(?=\s))/,/(\?\.)/,/(?)/,/--/,/\+\+/,/&&|\|\|/,/\*=|\/=|%=|\+=|-=/,/\&=|\^=|<<=|>>=|>>>=|\|=/,/\&|~|\^|\|/,/%[^%]|\*[^\/]|\/[^\/\*]|(?>/,/<=|>=|\s(<|>)\s/,/==|!=/,/=>/,/!(?=\w)/,/\&\&/,/(?<=\s)(\?|:)(?=\s)/,/\?\./,/(?+/, -endScope:"punctuation",contains:[{match:/)/),scope:"title.class.inherited" -},{match:t.concat(/\b/,t.either(...p),/\b\s*(?!<>)/),scope:"built_in"},{ -match:[/\b/,a,/\./,a,/(?=[,\s<])/],scope:{2:"built_in",4:"title.class.inherited" -}},{match:[/\b/,a,/(?=>)/],scope:{2:"type"}},{match:t.concat(/\b/,a,/\b(?!<)/), -scope:"title.class.inherited"}]}]},U=[C,{relevance:10, -match:/\b(with|without|inherited)\s+sharing\b/,scope:"keyword"},L,{ -begin:[/\benum\s+/,a,/\s*/,/\{/],beginScope:{1:"type",2:"type",4:"punctuation"}, -end:/[\}\n]/,endScope:"punctuation",scope:"enum_declaration",relevance:0, -contains:[g,E,A,{match:t.concat(/\b/,a,/\b/),scope:"variable.constant"}] -}].concat(M),w=[{match:[/(?<=\breturn\b)\s+/,t.either(o),/(?=\s*;)/],scope:{ -2:"literal"}},{match:[/(?<=return)/,/\s+/,a,/(?=\s*;)/],scope:{3:"variable"}},{ -match:[/(?<=return)/,/\s+/,t.lookahead(a+/\(/)],scope:{2:"title.function.invoke" -}}],f={begin:[/\[/,/\s*/,/\b(SELECT|FIND)\b/],beginScope:{1:"punctuation", -3:"keyword soql"},end:/\]/,scope:"soql",relevance:10,contains:[{ +scope:"built_in"}]}]},M={beginKeywords:"class",returnBegin:!0,end:/\{/, +endScope:"punctuation",returnEnd:!0,scope:"class_declaration",keywords:{type:r, +keyword:s},contains:[{match:[/(?<=\bclass\b)\s+/,a],scope:{2:"title.class"}},{ +returnEnd:!0,endsWithParent:!0,variants:[{beginKeywords:"implements", +end:/(\b(extends)\b)|\{/,scope:"implements block"},{beginKeywords:"extends", +end:/(\b(implements)\b)|\{/,scope:"extends block"}],contains:[{match:/\<|\>/, +scope:"punctuation"},{match:t.concat(/\b/,t.either(...p),/\b\s*(?!<>)/), +scope:"built_in"},{match:[/\b/,a,/\./,a,/(?=[,\s<])/],scope:{2:"built_in", +4:"title.class.inherited"}},{match:[/\b/,a,/(?=>)/],scope:{2:"type"}},{ +match:t.concat(/\b/,a,/\b(?!<)/),scope:"title.class.inherited"},{ +match:t.concat(/\b/,t.either(...b),/\b\s*(?!>)/),scope:"title.class.inherited"}] +}]},U=[L,{relevance:10,match:/\b(with|without|inherited)\s+sharing\b/, +scope:"keyword"},C,{begin:[/\benum\s+/,a,/\s*/,/\{/],beginScope:{1:"type", +2:"type"},end:/[\}\n]/,returnEnd:!0,scope:"enum_declaration",relevance:0, +contains:[g,T,E,{match:t.concat(/\b/,a,/\b/),scope:"variable.constant"}] +},M].concat(N),w=[{match:[/(?<=\breturn\b)\s+/,t.either(i),/(?=\s*;)/],scope:{ +2:"literal"}},{match:[/(?<=\breturn\b)/,/\s+/,a,/(?=\s*;)/],scope:{3:"variable"} +},{match:[/(?<=\breturn\b)/,/\s+/,t.lookahead(a+/\(/)],scope:{ +2:"title.function.invoke"}}],f={begin:[/\[/,/\s*/,/\b(SELECT|FIND)\b/], +beginScope:{1:"punctuation",3:"keyword soql"},end:/\]/, +endScope:"punctuation outer",scope:"soql",relevance:10,contains:[{ begin:[/\bFROM\b/,t.concat(/\s+/,a,/\b/)],beginScope:{1:"keyword",2:"type"}, scope:"from_clause",end:/(?=\]|\s)/,contains:[{match:[/(?<=\.)/,a,/\b/],scope:{ -2:"type"}},A]},{match:/\]/,scope:"punctuation",endsParent:!0},{ +2:"type"}},E]},{match:/\]/,scope:"punctuation",endsParent:!0},{ match:/\b\s*IN|=\s*:/,scope:"operator"},{ begin:t.concat(/\b/,t.either("ABOVE_OR_BELOW","ACTIVE","ADVANCED","ALL","ANY","ARRAY","AS","BY","CATEGORY","CONTAINS","CUSTOM","DATA","DIVISION","END","FIELDS","FIND","FROM","LAST","METADATA","NETWORK","ON","RETURNING","ROLLUP","ROWS","SEARCH","SELECT","SNIPPET","SORT","STANDARD","USER_MODE","WHERE",/USING\s+SCOPE\s*(Delegated|Everything|Mine|My_Territory|My_Team_Territory|Team)/,/WITH\s+SECURITY_ENFORCED/),/\b/), scope:"keyword soql",relevance:0},{ @@ -112,22 +110,23 @@ match:/(NEXT|LAST|THIS)_(90_DAY|DAY|FISCAL_QUARTER|FISCAL_YEAR|MONTH|QUARTER|WEE scope:"variable.language",relevance:10},{ match:[/(NEXT|LAST)_N_(DAY|FISCAL_QUARTER|FISCAL_YEAR|MONTH|QUARTER|WEEK|YEAR)S/,/\s*:\s*/,/\d+/], scope:{1:"variable.language",2:"operator",3:"number"},relevance:10},{ -match:[/(?<=:)/,/\s*/,a],scope:{3:"variable"}},c,I,S,A,e.APOS_STRING_MODE], -illegal:"::"},k={begin:[/\bfor\b/,/\s*\(/,a,/\s+/,a,/\s*:/],beginScope:{ -2:"punctuation",3:"type",5:"variable",6:"operator"},end:"{",contains:[g,E,f]} +match:[/(?<=:)/,/\s*/,a],scope:{3:"variable"}},c,I,A,E,e.APOS_STRING_MODE], +illegal:"::"},k={begin:[/\bfor\b\s*/,/\(/,a,/\s+/,a,/\s*:/],beginScope:{ +2:"punctuation",3:"type",5:"variable for",6:"operator"},scope:"for_loop", +end:/\)\s*\{/,endScope:"punctuation",contains:[g,T,f,I,{ +match:t.concat(a,/\b(?!\()/),scope:"variable"}],METHOD_CALL:I,PUNCTUATION:E} ;return{name:"Apex",aliases:["apex","lightning","soql"],case_insensitive:!0, disableAutodetect:!1,ignoreIllegals:!1,keywords:{$pattern:a,keyword:s, -"variable.language":["instanceof","new","super","this"],built_in:l,type:r, -literal:o,classNameAliases:{soql:"subst"}}, -illegal:["","\x3c!--","!DOCTYPE",/","<%%"], -contains:[v,R,_,E,g,O,U,[{ -match:[t.concat(/\b/,t.either(...b),/\b/),/\s*/,a,/(?=;)/],scope:{1:"built_in", -3:"variable"}},{match:t.concat(/\b/,t.either(...b),/\b/),scope:"built_in"},{ -match:[/\s+/,/(?:\bas\s+(user|system)\b\s+)?/,a,t.lookahead(";")],scope:{ -2:"built_in",3:"variable"}},{begin:t.concat(/\b/,t.either(...b),/\b/), -beginScope:"built_in",scope:"DML",contains:[D,{ -match:[t.concat("(?<=",t.either(b),")"),/\s+/,/(?:\bas\s+(user|system)\b\s+)?/,a,t.lookahead(";")], -scope:{3:"built_in",4:"variable"}},{match:t.either(b),scope:"built_in"},A]},{ +"variable.language":["instanceof","new","super","this"],built_in:b,type:r, +literal:i}, +illegal:["","\x3c!--","!DOCTYPE",/","<%%",":-"], +contains:[v,O,_,T,g,U,[{begin:t.concat(/\s\b/,t.either(...l),/\b\s/), +beginScope:"built_in",end:";|$",scope:"dml",contains:[D,{ +match:/\bas\s+(user|system)\b/,scope:"keyword"},{match:[a,/\s*;/],scope:{ +1:"variable"}},E,g,f]},{begin:[/\bDatabase\b/,/\./,a,/\s*/,/\(/],beginScope:{ +1:"built_in",3:"built_in"},end:";",scope:"database_dml", +contains:[y,m,e.APOS_STRING_MODE,T,g,{match:[/\(/,a,/,/],scope:{2:"variable"}},{ match:["AccessLevel",/\./,/(SYSTEM_MODE|USER_MODE)/],scope:{1:"built_in", -3:"keyword"}}],T,k,e.APOS_STRING_MODE,D,I,m,c,S,y,A,w,{match:/(?])/,scope:"type",relevance:8},f,o,S]}}})() +;hljs.registerLanguage("apex",e)})(); \ No newline at end of file diff --git a/src/languages/apex.js b/src/languages/apex.js index d34487d..cbca50b 100644 --- a/src/languages/apex.js +++ b/src/languages/apex.js @@ -19,10 +19,11 @@ export default function (hljs) { /\b(\d{4}\-\d{2}\-\d{2})\b/, //date /\b0(x|X)[0-9a-fA-F_]+(U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?\b/, //hex /\b0(b|B)[01_]+(U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?\b/, //binary - /\b([0-9_]+)?\.[0-9_]+((e|E)[0-9]+)?(F|f|D|d|M|m)?\b/, //decimal - /\b[0-9_]+(e|E)[0-9_]+(F|f|D|d|M|m)?\b/, //decimal - /\b[0-9_]+(F|f|D|d|M|m)\b/, //decimal - /\b[0-9_]+(U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?\b/ //decimal + /\b([0-9]+)?\.[0-9]+((e|E)[0-9]+)?(F|f|D|d|M|m)?\b/, //decimal + /(-?)\b[0-9]+(e|E)[0-9]+(F|f|D|d|M|m)?\b/, //decimal + /(-?)\b[0-9]+(F|f|D|d|M|m)\b/, //decimal + /(-?)\b[0-9]+(U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?\b/, //decimal + /(-?)(\b0[0-9]+|(\b\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)/ // C_NUMBER_MODE ), relevance: 0 }; @@ -49,17 +50,15 @@ export default function (hljs) { 'continue', 'break', + 'implements', + 'extends', + 'return', 'throw', 'when' ]; - const LANGUAGE_VARS = [ - 'instanceof', - 'new', - 'super', - 'this' - ]; + const LANGUAGE_VARS = ['instanceof', 'new', 'super', 'this']; // keyword const STORAGE_MODIFIER_LIST = [ @@ -115,17 +114,6 @@ export default function (hljs) { 'float|0' ]; - const BUILT_INS = [ - 'start', - 'execute', - 'finish', - 'schedulable|10', - 'batchable|10', - 'queueable|10', - 'comparable|10', - 'callable|10' - ]; - const DMLS = [ 'insert', 'update', @@ -136,6 +124,19 @@ export default function (hljs) { 'convertLead' ]; + const BUILT_INS = [].concat(...[ + 'start', + 'execute', + 'finish', + 'schedulable|10', + 'batchable|10', + 'queueable|10', + 'comparable|10', + 'callable|10' + ]).concat(...DMLS); + + + // Extraneous for now - will be useful if we go this route BUT will need more maintenance /* const APEX_ANNOTATIONS = [ '@AuraEnabled', @@ -312,6 +313,12 @@ export default function (hljs) { 'WebServiceMock' ]; + const LITERAL_REGEX = { + match: regex.concat(/\b/, regex.either(...LITERALS), /\b\s*(?=[,)])/), + scope: 'literal regex', + relevance: 0 + }; + const NAMESPACES = [ // * SYSTEM ENUMS W/WO SYSTEM SPECIFIED { @@ -323,31 +330,34 @@ export default function (hljs) { APEX_IDENT_RE ], scope: { - 1: 'built_in', - /* 2: 'punctuation', */ 3: 'built_in', - /* 4:'punctuation', */ 5: 'variable.constant' + 1: 'built_in' /* 2: 'punctuation', */, + 3: 'built_in' /* 4:'punctuation', */, + 5: 'variable.constant' }, relevance: 10 }, { - match: [regex.concat(/\b/, regex.either(...SYSTEM_ENUMS)), /\./, APEX_IDENT_RE, /\b(?![\.\(])/], + match: [ + regex.concat(/\b/, regex.either(...SYSTEM_ENUMS)), + /\./, + APEX_IDENT_RE, + /\b(?![\.\(])/ + ], // TODO: Find a better scope for the enum value scope: { 1: 'built_in', 3: 'variable.constant' }, relevance: 0 }, - // ANY USE OF SYSTEM BASE + // ANY USE OF SYSTEM (or other Namespace) BASE { - match: [/\bSystem/, /\./, regex.concat('\(\?=', APEX_IDENT_RE, '\\\.\)' ) ], - scope: { 1: 'built_in', /* 2: 'punctuation', 3: 'title.class'*/ }, + match: [regex.either(...NAMESPACE_LIST), /\./, regex.concat('(?=', APEX_IDENT_RE, '\\.)')], + scope: { 1: 'built_in' }, relevance: 0 }, { match: [ regex.concat(/\b/, regex.either(...NAMESPACE_LIST)), /\./, - regex.concat( '(?=', APEX_IDENT_RE, '\\s*\\()' ), - /* APEX_IDENT_RE, - /(?=\s*\()/ */ + regex.concat('(?=', APEX_IDENT_RE, '\\s*\\()') ], scope: { 1: 'built_in', @@ -356,7 +366,7 @@ export default function (hljs) { relevance: 10 }, { - match: [/\b/, regex.either(...NAMESPACE_LIST), /(?!\.)/], + match: [/\b/, regex.either(...NAMESPACE_LIST), /\b(?!\.)/], scope: { 2: 'built_in' } }, { @@ -373,12 +383,12 @@ export default function (hljs) { { match: [/\b/, regex.either(...SYSTEM_CLASSES), /(?=\.)/], scope: { 2: 'title.class' }, - relevance: 9 + relevance: 4 }, { match: [/\b/, regex.either(...SYSTEM_INTERFACES), /\b/], scope: { 2: 'title.class.inherited' }, - relevance: 10 + relevance: 8 } ]; @@ -389,32 +399,34 @@ export default function (hljs) { const OPERATOR_REGEX = [ //=/, - /(?<=')\s*\+/, // string concat before - /\+(?=\s*')/, // string concat after - /(?)/, - - /(--)/, // decrement - /(\!|&&|\|\|)/, // logical - /(\*=|\/=|%=|\+=|-=)/, // assignment.compound - /(\&=|\^=|<<=|>>=|\|=)/, // assignment.compound.bitwise - /(\&|~|\^|\|)/, // bitwise - /(\+\+)/, // increment - //(\=)/, // assignment - /(%[^%]|\*[^\/]|\/[^\/\*]|-|\+)/, // arithmetic - /(<<|>>)/, // bitwise.shift - /(<=|>=|\s(<|>)\s)/, // relational - /(==|!=)/, // comparison - /=>/, // map assign - /(!(?=\w))/, // negator - /(\&\&)/, - /((?<=\s)(\?|:)(?=\s))/, // standalone ? or : (ternary operator?) + //(?<=')\s*\+/, // string concat before + //\+(?=\s*')/, // string concat after + /(?)/, // assignment + ///(\=/, // assignment + + /--/, // decrement + /\+\+/, // increment + /&&|\|\|/, // logical + /\*=|\/=|%=|\+=|-=/, // assignment.compound + /\&=|\^=|<<=|>>=|>>>=|\|=/, // assignment.compound.bitwise + /\&|~|\^|\|/, // bitwise - /(\?\.)/, // null-safe operator - /(?>/, // bitwise.shift + /<=|>=|\s(<|>)\s/, // relational + /==|!=/, // comparison + /=>/, // map assign + /!(?=\w)/, // negator + /\&\&/, + /(?<=\s)(\?|:)(?=\s)/, // standalone ? or : (ternary operator?) + + /\?\./, // null-safe operator + /(?)/), - scope: 'title.class.inherited' + match: /\<|\>/, + scope: 'punctuation' }, { - match: regex.concat(/\b/, regex.either(...NAMESPACE_LIST), /\b\s*(?!<>)/), + match: regex.concat( + /\b/, + regex.either(...NAMESPACE_LIST), + /\b\s*(?!<>)/ + ), scope: 'built_in' }, { @@ -864,21 +893,25 @@ export default function (hljs) { scope: { 2: 'built_in', 4: 'title.class.inherited' } }, /* { - match: regex.concat(/[^\.]/, APEX_IDENT_RE, /(?=[,\s<])/), - scope: { 2: 'title.class.inherited' } - }, */ + match: regex.concat(/[^\.]/, APEX_IDENT_RE, /(?=[,\s<])/), + scope: { 2: 'title.class.inherited' } + }, */ { // collection type match: [/\b/, APEX_IDENT_RE, /(?=>)/], - scope: { 2: 'type' //, 3: 'punctuation' - } + scope: { + 2: 'type' //, 3: 'punctuation' + } }, - { + { //(?!implements|extends)\s+ match: regex.concat(/\b/, APEX_IDENT_RE, /\b(?!<)/), scope: 'title.class.inherited' - } + }, + { + match: regex.concat(/\b/, regex.either(...BUILT_INS), /\b\s*(?!>)/), + scope: 'title.class.inherited' + }, ] - } ] }; @@ -888,10 +921,11 @@ export default function (hljs) { beginScope: { 1: 'type', 2: 'type', - 4: 'punctuation' + //4: 'punctuation' }, end: /[\}\n]/, - endScope: 'punctuation', + returnEnd: true, + //endScope: 'punctuation', scope: 'enum_declaration', relevance: 0, contains: [ @@ -911,31 +945,29 @@ export default function (hljs) { scope: 'keyword' }; - /* const CONSTRUCTOR_DECLARATION = [ + // commented for now - too easy to overlap with method_call + const CONSTRUCTOR_DECLARATION = [ { - // Constructor - // Matches public/private, methodname, then parens and a curly bracket - - begin: [/(?<=(public|private))/, /\s+/, APEX_IDENT_RE, /(?=\s*\()/], // /(?=\s*\()/], - beginScope: { - 3: 'constructor' - }, - end: /\)\s*{/, - contains: [PARAMS] - } - ]; */ - + // Constructor + // Matches public/private, methodname, then parens and a curly bracket + begin: [/(?<=(public|private))\s+/, APEX_IDENT_RE, /(?=\s*\()/], // /(?=\s*\()/], + beginScope: { + 2: 'constructor' + }, + end: /\{/, + contains: [PARAMS] + } + ]; const DECLARATIONS = [ TRIGGER_DECLARATION, CLASS_SHARING, TRIGGER_CONTEXT_DECLARATION, - ENUM_DECLARATION + ENUM_DECLARATION, //CONSTRUCTOR_DECLARATION, - ].concat(CLASS_DECLARATION); - - + CLASS_DECLARATION + ].concat(PROPERTY_DECLARATION); const RETURNS = [ { @@ -945,28 +977,28 @@ export default function (hljs) { } }, { - match: [/(?<=return)/, /\s+/, APEX_IDENT_RE, /(?=\s*;)/], + match: [/(?<=\breturn\b)/, /\s+/, APEX_IDENT_RE, /(?=\s*;)/], scope: { 3: 'variable' } }, { - match: [/(?<=return)/, /\s+/, regex.lookahead(APEX_IDENT_RE + /\(/)], + match: [/(?<=\breturn\b)/, /\s+/, regex.lookahead(APEX_IDENT_RE + /\(/)], //returnBegin: true, //end: /(?=\))/, scope: { 2: 'title.function.invoke' - }, + } //contains: [METHOD_CALL, PARAMS] } // * RETURN NEW OBJECT - NO PARAMS BY DEFAULT ]; - const SALESFORCE_ID = { - match: /(?])/, scope: 'type', relevance: 8 - }; + }; /** * SOQL SECTION @@ -1082,7 +1114,7 @@ export default function (hljs) { beginScope: { 1: 'punctuation', 3: 'keyword soql' }, //returnBegin: true, end: /\]/, - //endScope: 'punctuation', //outer + endScope: 'punctuation outer', //returnEnd: true, scope: 'soql', relevance: 10, @@ -1165,79 +1197,90 @@ export default function (hljs) { }; const FOR_LOOP = { - begin: [/\bfor\b/, /\s*\(/, APEX_IDENT_RE, /\s+/, APEX_IDENT_RE, /\s*:/], + begin: [/\bfor\b\s*/, /\(/, APEX_IDENT_RE, /\s+/, APEX_IDENT_RE, /\s*:/], beginScope: { //1: 'keyword', 2: 'punctuation', 3: 'type', - 5: 'variable', + 5: 'variable for', 6: 'operator' }, - end: '{', - contains: [COMMENT_LINE, COMMENT_BLOCK, SOQL_QUERY] + scope: 'for_loop', + end: /\)\s*\{/, + endScope: 'punctuation', + + contains: [COMMENT_LINE, COMMENT_BLOCK, SOQL_QUERY, METHOD_CALL, + { + match: regex.concat(APEX_IDENT_RE, /\b(?!\()/), + scope: 'variable' + }], + METHOD_CALL, + PUNCTUATION + }; // TODO: Do DMLs const DML_OPERATIONS = [ - { - // delete myAccount; - match: [ - regex.concat(/\b/, regex.either(...DMLS), /\b/), - /\s*/, - APEX_IDENT_RE, - /(?=;)/ - ], - scope: { 1: 'built_in', 3: 'variable' } - }, - { - match: regex.concat(/\b/, regex.either(...DMLS), /\b/), - scope: 'built_in' - }, - { - match: [ - /\s+/, - /(?:\bas\s+(user|system)\b\s+)?/, - APEX_IDENT_RE, - regex.lookahead(';') - ], - scope: { 2: 'built_in', 3: 'variable' } - }, /* * DML types * naked - insert a; * */ { - begin: regex.concat(/\b/, regex.either(...DMLS), /\b/), + begin: + regex.concat(/\s\b/, regex.either(...DMLS), /\b\s/), //returnBegin: true, beginScope: 'built_in', - scope: 'DML', + end: ';|$', + //endScope: 'punctuation', + scope: 'dml', contains: [ INSTANTIATE, { - match: [ - regex.concat('(?<=', regex.either(DMLS), ')'), - /\s+/, - /(?:\bas\s+(user|system)\b\s+)?/, - APEX_IDENT_RE, - regex.lookahead(';') - ], - scope: { 3: 'built_in', 4: 'variable' } + match: /\bas\s+(user|system)\b/, + scope: 'keyword' }, { - match: regex.either(DMLS), - scope: 'built_in' + match: [APEX_IDENT_RE, /\s*;/], + scope: {1: 'variable'} }, - PUNCTUATION + PUNCTUATION, + COMMENT_LINE, + SOQL_QUERY ] }, + /* + * DML types + * Database - Database.insert( ); + * + */ { - // TODO: Pick better scopes here - match: ['AccessLevel', /\./, /(SYSTEM_MODE|USER_MODE)/], - scope: { - 1: 'built_in', - 3: 'keyword' - } + begin: [/\bDatabase\b/,/\./, APEX_IDENT_RE, /\s*/, /\(/], + beginScope: { 1: 'built_in', 3: 'built_in'}, + end: ';', + //endScope: 'punctuation', + scope: 'database_dml', + contains: [ + + PARAMS, LITERAL_REGEX, hljs.APOS_STRING_MODE, COMMENT_BLOCK, COMMENT_LINE,{ + match: [/\(/, APEX_IDENT_RE,/,/], + scope: {2: 'variable'} + },{ + // TODO: Pick better scopes here + match: ['AccessLevel', /\./, /(SYSTEM_MODE|USER_MODE)/], + scope: { + 1: 'built_in', + 3: 'keyword' + } + }, + /* { + start: /\(/, + end: /\)/, + scope: 'dml params', + endsWithParent: true, + contains: [PARAMS, LITERAL_REGEX, hljs.APOS_STRING_MODE, COMMENT_BLOCK, COMMENT_LINE ] + } */ + ] } ]; @@ -1277,6 +1320,8 @@ export default function (hljs) { '#endif', /\w::\w/, /(SELECT|RETURNING)\s+\*/, + /END\s+LOOP/, + /CREATE\s+FUNCTION/, /\bint\b/, /import\s+\w+\s+=\s+require\("\w+"\)/, '/^include\b/', @@ -1284,14 +1329,17 @@ export default function (hljs) { /\w+\s+=\s+"\S*";/, /\/include\//, /\Anamespace\b/, - /\bend\.\n/, - /\bend\n/, + /\bend(\.)?\n/, '"""', /\+\+\+/, /<%/, '<%#', '%%>', - '<%%' + '<%%', + ':-', + //\bmergesort\(/, + //\bvar\s+env\b/, + //\bdef\b\s\W:/ // /"[^"]+"/, // Quote_string_mode // /@\w+\[\w+\]/ //moonscript ]; @@ -1308,11 +1356,7 @@ export default function (hljs) { 'variable.language': LANGUAGE_VARS, built_in: BUILT_INS, type: TYPES, - literal: LITERALS, - //operator: OPERATOR_REGEX, - classNameAliases: { - soql: 'subst' - } + literal: LITERALS }, illegal: ILLEGALS, contains: [ @@ -1320,20 +1364,18 @@ export default function (hljs) { ASSIGNMENTS, COLLECTION_DECLARATION, COMMENT_BLOCK, - COMMENT_LINE, - CUSTOM_METADATA, + COMMENT_LINE, + //CUSTOM_METADATA, DECLARATIONS, DML_OPERATIONS, EXCEPTION, FOR_LOOP, hljs.APOS_STRING_MODE, INSTANTIATE, - //KEYWORDS, METHOD_CALL, NAMESPACES, NUMBERS, OPERATORS, - PROPERTIES, PUNCTUATION, RETURNS, SALESFORCE_ID, diff --git a/test/markup/apex/apexcode.txt b/test/markup/apex/apexcode.txt index b370c9b..da78027 100644 --- a/test/markup/apex/apexcode.txt +++ b/test/markup/apex/apexcode.txt @@ -5,11 +5,11 @@ public with sharing class L2Char implements Database.batchable { public static final String ERROR = 0x0001; - @InvocableApex(label='my invocable') - public void moveTo( - integer x, - integer y, - integer z + @InvocableMethod(label='my invocable') + public static void moveTo( + Integer x, + Integer y, + Integer z ) { @@ -18,8 +18,8 @@ public with sharing class L2Char implements Database.batchable { insert a; Boolean ai = (Boolean) false; System.debug('Should not be called'); - if (1 > 5) { // wtf!? - Database.insert(myAccounts); + if (1 > 5 && !Test.isRunningTest()) { // wtf!? + Database.insert(myAccounts, false); } } } @@ -33,7 +33,8 @@ private static void makeData(Boolean a){ } } -private testMethod void testme(){ +@isTest +private static void testme(){ System.assert(true); }