From 42e040424a166374f615a590eacef30ac055fd9e Mon Sep 17 00:00:00 2001 From: David Schach Date: Sat, 28 Oct 2023 10:05:26 -0700 Subject: [PATCH] progress --- demo/testcode.html | 189 +++------------ dist/apex.es.min.js | 179 +++++++------- dist/apex.min.js | 179 +++++++------- src/languages/apex.js | 532 +++++++++++++++++++++--------------------- 4 files changed, 473 insertions(+), 606 deletions(-) diff --git a/demo/testcode.html b/demo/testcode.html index 5df6f86..dd3dea4 100644 --- a/demo/testcode.html +++ b/demo/testcode.html @@ -23,13 +23,7 @@

-      List<SObject> mylist = [SELECT Name, StreetAddress__c, COUNT(),
-      (SELECT Id FROM Contacts)
-      FROM Warehouse__c.Contacts__r
-      WHERE DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') < 20 
-      AND Date__kav NOT IN LAST_N_DAYS:80
-      ORDER BY DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi')
-      LIMIT 10];
+      
 
       delete myAccount;
       Account a;
@@ -42,30 +36,30 @@
 
       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, ' +
-				'otherstreet, othercity, otherstate, otherpostalcode, othercountry, mailinglatitude, mailinglongitude, otherlatitude, otherlongitude ' +
-				'FROM Contact WHERE AccountId = :acctid ORDER BY ' +
-				String.escapeSingleQuotes(SortFullExp) +
-				' NULLS LAST LIMIT 1000';
-        String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingstreet, mailingcity, mailingstate, mailingpostalcode, mailingcountry, '
+      
+      String queryText = 'SELECT Id, Name, ';
+      acctid = System.currentPageReference().getParameters().get('Id');
+      System.assert(true);
+      System.requestVersion();
     
-

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

+

-------NEW_CODEBLOCK----------


       @IsTest
       private without sharing class myTestClass {
         myMap?.get('Id');
       }
       System.URL.getCurrentRequestUrl();
-      System.getCurrentRequestUrl();
+      URL.getCurrentRequestUrl();
 
       public List<SelectOption> recordTypes { get; private set; }
     
-

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

+

-------NEW_CODEBLOCK----------


 
     Database.insert(myAccounts, false, AccessLevel.USER_MODE);
     delete myAccount;
     delete [SELECT Id FROM Account];
+    myAcct = (Account)myacct;
 
     public String myString { get; set; }
 
@@ -78,6 +72,19 @@
     @throws DMLException
     */
 
+    List<SObject> mylist = [SELECT Name, StreetAddress__c, COUNT(),
+      (SELECT Id FROM Contacts)
+      FROM Warehouse__c.Contacts__r
+      WHERE DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') < 20 
+      AND Date__kav NOT IN LAST_N_DAYS:80
+      ORDER BY DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi')
+      LIMIT 10];
+
+    String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingcountry, ' +
+				'FROM Contact WHERE AccountId = :acctid ORDER BY ' +
+				String.escapeSingleQuotes(SortFullExp) +
+				' NULLS LAST LIMIT 1000';
+
     /**
      * @author {@link [David Schach](https://github.com/dschach)}
      * @group Visualforce
@@ -87,10 +94,6 @@
 
       public enum Season {WINTER, SPRING, SUMMER, FALL}
      
-      /**
-       * Extension Constructor
-       * @param stdController `ActionPlan__c` Standard Controller
-       */
       public ActionPlanDetailController(ApexPages.StandardController stdController, Integer x, Double y) {
         Map<Id, Map<String, Wrapper>> renew = new Map<Id, Map<String, SObject>>();
         if (!Test.isRunningTest() && false) {
@@ -100,11 +103,7 @@
         actionPlan = (ActionPlan__c) stdController.getRecord();
         truestory = req.setHeader('X-Password', '{!$Credential.Password}');
       }
-    
-      /**
-       * Action on page load to ensure custom setting is created
-       * @return   `PageReference` null (required for page actions method)
-       */
+
       public PageReference onLoad() {
         ActionPlansUtilities.onPageLoad();
         return null;
@@ -112,6 +111,7 @@
     
       /**
        * Deletes the current Action Plan loaded and redirects to the AP List
+       * @return   `PageReference` null (required for page actions method)
        * @return `PageReference` Page to go to after deleting `ActionPlan__c`
        */
       public PageReference deletePlan() {
@@ -234,24 +234,6 @@
         return false;
       }
     
-      /**
-       * The label of the Action Plan's parent record SObject
-       * @return  `String` Label of the object related to this Action Plan
-       */
-      public String getRelatedObjectLabel() {
-        String objLabel = '';
-    
-        for (String f : ActionPlansUtilities.getCustomRelationshipFields()) {
-          if (actionPlan.get(f) != null) {
-            Id objId = (Id) actionPlan.get(f);
-            Schema.DescribeSObjectResult dsr = objId.getSObjectType().getDescribe();
-            objLabel = dsr.getLabel();
-            break;
-          }
-        }
-        return objLabel;
-      }
-    
       /**
        * The name of the parent record - show a different field based on SObject Type
        * @return  `String` name of the object related to this Action Plan
@@ -286,21 +268,6 @@
         }
       }
     
-      /**
-       * Convert AP Task Record Type Id to Record Type Name
-       * @return Record Type Name
-       */
-      public String getRecordTypeName() {
-        String toReturn = '';
-        if (ActionPlansUtilities.taskUsesRecordTypes) {
-          Map<Id, Schema.RecordTypeInfo> rtMapById = Task.SObjectType.getDescribe().getRecordTypeInfosById();
-          if (!rtMapById.isEmpty() && rtMapById.containsKey(actionPlan.TaskRecordTypeID__c)) {
-            return rtMapById.get(actionPlan.TaskRecordTypeID__c).getName();
-          }
-        }
-        return toReturn;
-      }
-    
       /**
        * If we have no share object, we don't need to show a Share button
        * @author {@link [David Schach](https://github.com/dschach)}
@@ -309,16 +276,6 @@
       public Boolean getCanShare() {
         return ActionPlansUtilities.canShareRecord(actionPlan.Id, actionPlan.OwnerId);
       }
-    
-      /**
-       * Does the user have permission to transfer? We query `UserRecordAccess` to find out.
-       * @author {@link [David Schach](https://github.com/dschach)}
-       * @return   `Boolean` yes/no
-       */
-      public Boolean getCanTransfer() {
-        return ActionPlansUtilities.getCanTransfer(actionPlan.Id);
-      }
-    }
 
   @SuppressWarnings('PMD.AvoidGlobalModifier')
   /**
@@ -343,23 +300,10 @@
         SELECT
           Id,
           Description__c,
-          Name,
-          OwnerId,
-          SkipDay__c,
-          SkipWeekends__c,
           TaskRecordTypeID__c,
           (
             SELECT
               Type__c,
-              Name,
-              User__c,
-              User__r.Name,
-              Id,
-              DaysFromStart__c,
-              Action_Plan_Template__c,
-              TController__r.Subject__c,
-              Minutes_Reminder__c,
-              TaskIndex__c,
               Action_Plan_Template__r.TaskRecordTypeID__c
             FROM aptTasks__r
             ORDER BY TaskIndex__c ASC
@@ -376,19 +320,12 @@
         templateNameOrIdToTemplate.put(apt.Id, apt);
       }
 
-      Set<Id> relatedIDs = new Set<Id>();
-
       for (CreateActionPlanRequest r : requests) {
         relatedIDs.add(r.relatedRecordID);
       }
 
       Map<Id, ActionPlan__c> actionPlansToInsert = new Map<Id, ActionPlan__c>();
 
-    
-      if (actionPlansToInsert.isEmpty()) {
-        return resultIDs;
-      }
-
       insert actionPlansToInsert.values();
 
       Map<String, APTask__c> planTaskIndexToTask = new Map<String, APTask__c>();
@@ -400,36 +337,18 @@
 
         ActionPlan__c ap = actionPlansToInsert.get(r.relatedRecordID);
 
-        ActionPlanTemplate__c actionPlanTemplate = templateNameOrIdToTemplate.get(r.templateNameOrID);
-
         for (APTemplateTask__c aptTask : actionPlanTemplate.aptTasks__r) {
           APTask__c apTask = new APTask__c();
           apTask.User__c = ActionPlansBuilderUtilities.getAPTaskTemplateUser(ap, relObjectOwners, aptTask.User__c);
-          apTask.DaysFromStart__c = aptTask.DaysFromStart__c;
-          apTask.Comments__c = aptTask.Comments__c;
-          apTask.Minutes_Reminder__c = aptTask.Minutes_Reminder__c;
           apTask.SendEmail__c = aptTask.SendEmail__c;
 
-          apTask.Action_Plan__c = ap.Id;
-
           apTask.Status__c = ActionPlansUtilities.getTaskRecordTypeStatusDefaultValues().get(ActionPlansUtilities.getDefaultTaskRecordTypeId());
 
-          if (apTask.Dependent__c != null && apTask.Dependent__c != 'None') {
-            apTask.ActivityDate__c = null;
+          // create due date, calculate the due date of the tasks for skip weekends feature
+          if (ap.SkipWeekends__c == true && ap.SkipDay__c != null) {
+            apTask.ActivityDate__c = ActionPlansUtilities.adjustTaskDueDate(ap.StartDate__c, apTask.DaysFromStart__c.intValue(), ap.SkipDay__c);
           } else {
-            apTask.Controller__c = null;
-
-            //set dependency taskId to none if none was selected
-            if (apTask.Dependent__c == null) {
-              apTask.Dependent__c = 'None';
-            }
-
-            // create due date, calculate the due date of the tasks for skip weekends feature
-            if (ap.SkipWeekends__c == true && ap.SkipDay__c != null) {
-              apTask.ActivityDate__c = ActionPlansUtilities.adjustTaskDueDate(ap.StartDate__c, apTask.DaysFromStart__c.intValue(), ap.SkipDay__c);
-            } else {
-              apTask.ActivityDate__c = ap.StartDate__c.addDays(apTask.DaysFromStart__c.intValue());
-            }
+            apTask.ActivityDate__c = ap.StartDate__c.addDays(apTask.DaysFromStart__c.intValue());
           }
           planTaskIndexToTask.put(ap.Id + '' + apTask.TaskIndex__c, apTask);
         }
@@ -437,19 +356,6 @@
 
       Database.insert(new planTaskIndexToTask.values());
 
-      // Now we have to update with the controlling/dependent task IDs
-
-      List<APTask__c> dependentTasksToUpdate = new List<APTask__c>();
-
-      for (APTask__c apTask : planTaskIndexToTask.values()) {
-        String actionPlanPlusIndex = apTask.Action_Plan__c + '' + apTask.Dependent__c;
-
-        if (planTaskIndexToTask.containsKey(actionPlanPlusIndex)) {
-          apTask.Controller__c = planTaskIndexToTask.get(actionPlanPlusIndex).Id;
-          dependentTasksToUpdate.add(apTask);
-        }
-      }
-
       Database.update(dependentTasksToUpdate);
 
       List<Task> myTasksWithOutEmail = new List<Task>();
@@ -468,8 +374,6 @@
         ActionPlan__c insertedAP;
         // check if task exists already
         Task t = new Task();
-        t.Subject = apTask.Subject__c;
-        t.Priority = apTask.Priority__c;
         t.OwnerId = apTask.User__c;
         t.TaskAPTask__c = apTask.Id;
 
@@ -497,35 +401,17 @@
           String f = s;
           if (
             !f.equalsIgnoreCase(ActionPlansUtilities.namespacePrefix + 'Contact__c') &&
-            !f.equalsIgnoreCase(ActionPlansUtilities.namespacePrefix + 'Lead__c') &&
             insertedAP.get(f) != null
           ) {
             t.WhatId = (Id) insertedAP.get(f);
             break;
           }
         }
-
-        if (t.Id == null) {
-          t.Status = apTask.Status__c;
-        }
-        t.ActivityDate = apTask.ActivityDate__c;
-
-        if (apTask.Dependent__c == 'None') {
-          if (apTask.SendEmail__c == true) {
-            myNewTasksWithEmail.add(t);
-          } else {
-            myTasksWithOutEmail.add(t);
-          }
-        }
       }
 
       Database.DMLOptions dmlo1 = new Database.DMLOptions();
       dmlo1.EmailHeader.triggerUserEmail = true;
 
-      if (myTasksWithOutEmail.size() > 0) {
-        Database.insert(myTasksWithOutEmail, dmlo2);
-      }
-
       Set<Id> relObjectIDs = new Set<Id>();
       for (ActionPlan__c ap : actionPlansToInsert.values()) {
         relObjectIDs.add(ap.Id);
@@ -562,7 +448,7 @@
   
   }
     
-

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

+

-------NEW_CODEBLOCK----------


 /**
  * SHOULD BE RECOGNIZED AS JAVA
@@ -583,13 +469,11 @@
 }
       
     
-

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

+

-------NEW_CODEBLOCK----------


 public without sharing class AccountSampleTriggerHandler extends Database.schedulable, TriggerHandler, Database.Batchable<SObject> {
   private List<Account> newRecords;
-  private List<Account> oldRecords;
   private Map<Id, Account> newRecordsMap;
-  private Map<Id, Account> oldRecordsMap;
 
   switch on context {
     when 'BEFORE_INSERT' {
@@ -611,12 +495,10 @@
     */
   public AccountSampleTriggerHandler(CustomType a, String className) {
     this.newRecords = (List<Account>) Trigger.new;
-    this.oldRecords = (List<Account>) Trigger.old;
     this.newRecordsMap = (Map<Id, Account>) Trigger.newMap;
-    this.oldRecordsMap = (Map<Id, Account>) Trigger.oldMap;
   }
 
-  public override sobject beforeInsert() {
+  public override sobject beforeInsert(String a, APTask__c b, DateTime c) {
     method1();
   }
 
@@ -624,7 +506,7 @@
 
   private void method1() {
     for (Account a : newRecords) {
-      a.Name = a.Name.toUpperCase();
+      a.Name = a.Name.toUpperCase(a, b, c);
       a.Name = new FooBar();
     }
   }
@@ -649,9 +531,7 @@
   }
 }
 
-public without sharing class AccountSampleTriggerHandler extends Database.schedulable, Batchable<SObject> {
-
-}
+public without sharing class AccountSampleTriggerHandler extends Database.schedulable, Batchable<SObject> {}
 
 public virtual class Marker {
   public virtual void write() {
@@ -713,7 +593,6 @@
   upsert myRecord__c;
   Database.upsert(myRecord__c, false, AccessLevel.USER_MODE);
 }
-
     
diff --git a/dist/apex.es.min.js b/dist/apex.es.min.js index ae81167..2e1c901 100644 --- a/dist/apex.es.min.js +++ b/dist/apex.es.min.js @@ -1,94 +1,90 @@ /*! `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", +const t=e.regex,n="[a-zA-Z][a-zA-Z_0-9]*",a="@"+n,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/,/(-?)(\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","implements","extends","return","throw","when"],o=["false","true","null"],i=["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|10","selectoption|10","short|0","sobject|10","string|0","time|0","void|0","float|0"],r=["insert","update","upsert|8","delete","undelete","merge","convertLead|8"],l=[].concat("start","execute","finish","schedulable|10","batchable|10","queueable|10","comparable|10","callable|10").concat(...r),b=["ApexPages","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"],p=["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","Schema","Search","Security","SelectOption","Site","SObject","SObjectAccessDecision","StaticResourceCalloutMock","Test","TimeZone","Type","URL","UserInfo","UserManagement","Version","WebServiceCallout","XmlStreamReader","XmlStreamWriter"],u=["AccessType","DomainType","JSONToken","LoggingLevel","Quiddity","TriggerOperation"],d={ +},s=["try","catch","finally","get","set","put","if","for","else","do","while","continue","break","implements","extends","return","throw","when","new"],o=["false","true","null"],i=["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|10","selectoption|10","short|0","sobject|10","string|0","time|0","void|0","float|0","id"],r=["insert","update","upsert","delete","undelete","merge","convertLead"],l=["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","Search","Sfc","Sfdc_Checkout","sfdc_surveys","Site","Support","TerritoryMgmt","TxnSecurity","UserProvisioning","VisualEditor","Wave"],b=["AccessType","DomainType","JSONToken","LoggingLevel","Quiddity","TriggerOperation"],p=[].concat(...l).concat(...r),d={ match:t.concat(/\b/,t.either(...o),/\b\s*(?=[,)])/),scope:"literal regex", -relevance:0},m=[{match:[/\bSystem/,/\./,t.either(...u),/\./,a],scope:{ -1:"built_in",3:"built_in",5:"variable.constant"},relevance:9},{ -match:[t.concat(/\b/,t.either(...u)),/\./,a,/\b(?![\.\(])/],scope:{1:"built_in", -3:"variable.constant"},relevance:0},{ -match:[t.either(...b),/\./,t.concat("(?=",a,"\\.)")],scope:{1:"built_in"}},{ -match:[t.concat(/\b/,t.either(...b)),/\./,t.concat("(?=",a,"\\s*\\()")],scope:{ -1:"built_in",3:"title.function.invoked"},relevance:10},{ -match:[/\b/,t.either(...b),/\b(?!\.)/],scope:{2:"built_in"}},{ -match:[t.concat(/\b/,"(?<=",t.either(...p),")."),a,/(?=\()/],scope:{ -2:"title.class",4:"title.function.invoke"},relevance:4},{ -match:[/\b/,t.either(...p),/(?=\.)/],scope:{2:"title.class"},relevance:4}],E={ -match:[/\bswitch\s+on\s+/,a],scope:{1:"keyword",2:"variable"}},A={ -match:t.concat(t.either(/(?)/,/--/,/\+\+/,/&&|\|\|/,/\*=|\/=|%=|\+=|-=/,/\&=|\^=|<<=|>>=|>>>=|\|=/,/\&|~|\^|\|/,/%[^%]|\*[^\/]|\/[^\/\*]|(?>/,/<=|>=|\s(<|>)\s/,/==|!=/,/=>/,/!(?=\w)/,/\&\&/,/(?<=\s)(\?|:)(?=\s)/,/\?\./,/(?+/, -endScope:"punctuation",contains:[{match:/)/,/--/,/\+\+/,/&&|\|\|/,/\*=|\/=|%=|\+=|-=/,/\&=|\^=|<<=|>>=|>>>=|\|=/,/\&|~|\^|\|/,/%[^%]|\*[^\/]|\/[^\/\*]|(?>/,/<=|>=|\s(<|>)\s/,/==|!=/,/=>/,/!(?=\w)/,/\&\&/,/(?<=\s)(\?|:)(?=\s)/,/\?\./,/(?+/,contains:[g,{ +match:t.concat(/\b/,n,/\b/),scope:"type"}],relevance:10},{ +match:[n,/\[/,/\d*/,/\]/],scope:{1:"type",3:"number"},contains:[g],relevance:0 +}],O={ +match:[/\bTrigger/,/\./,/(isExecuting|isInsert|isUpdate|isDelete|isBefore|isAfter|isUndelete|new|newMap|old|oldMap|size|operationType)\b/], +scope:{1:"built_in",3:"keyword"},relevance:10},_=[{ +match:[/\bSystem/,/\./,t.either(...b),/\./,n,/\b(?!\()/],scope:{1:"built_in", +3:"built_in",5:"variable.constant"},relevance:9},{ +match:[t.concat(/\b/,t.either(...b)),/\./,n,/\b(?![\.\(])/],scope:{1:"built_in", +3:"variable.constant"},relevance:0},{match:/\bSystem(?=\.System\.)/, +scope:"built_in"},{match:[/\bSystem/,/\./,n,t.lookahead(/[\.\(\s]/)],scope:{ +1:"built_in",3:"keyword"}},{ +match:[/\b/,t.either("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","Schema","Search","Security","SelectOption","Site","SObject","SObjectAccessDecision","StaticResourceCalloutMock","Test","TimeZone","Type","URL","UserInfo","UserManagement","Version","WebServiceCallout","XmlStreamReader","XmlStreamWriter"),/\b\./,n,t.lookahead(/[\.\(\s]/)], +scope:{2:"built_in",4:"keyword"}},{ +match:t.concat(t.either(...l),t.lookahead(/\./)),scope:"built_in"}],v={ +scope:"params",begin:/\(/,beginScope:"punctuation",end:/\)/, +endScope:"punctuation",endsParent:!0,relevance:0,keywords:{keyword:s}, +contains:[c,e.APOS_STRING_MODE,u,m,S,R,d,O,_,c,"self",{ +match:[/(?<=[,\(])\s*(?!Trigger)/,n,/\./,n,/\s*(?=[,)])/],scope:{}},{ +match:t.concat(t.concat(/\b/,n),t.lookahead(t.concat(/\s+/,n,/\s*[,)]/))), +scope:"type"},{match:t.concat(n,/(?=\s*[,)])/)}]} +;t.concat(/(?!return)\b/,n),t.concat(/\s+(?!get|set)/,n), +t.concat(/\b/,n,/__(c|pc|r|b|e|mdt|x|share|kav|ka|history|del|s)/,/\b/) +;const N=[{begin:[/\bnew\b/,/\s+/,n,/\s*(?=\()/],beginScope:{3:"title.class"}, +end:/\)/,returnEnd:!0,scope:"instantiate",contains:[v,u,g],illegal:":", +relevance:0}],y={end:/(?=\)\s*[^{])/,returnEnd:!0,relevance:0,variants:[{ +begin:t.concat(n,/(?=\()/),beginScope:"title.function solo"},{ +begin:[t.concat("(?!",t.either([].concat(...l,["System"])),")",n),/\./,t.concat(n,/(?=\()/)], +beginScope:{1:"title.class nonsystem",3:"title.function.invoke"}}], +contains:[u,m,e.APOS_STRING_MODE,v,N,"self"],relevance:0},D={ +begin:[/\btrigger/,/\s+/,n,/\s+/,"on",/\s+/,n],beginScope:{1:"keyword", +3:"title.class",5:"operator",7:"title.class"},end:/(?=\{)/,returnEnd:!0, +scope:"trigger_declaration",contains:[u,m,{begin:/\(/,end:/\)/, +scope:"trigger_params",contains:[{ match:/\b(before|after)\s+(insert|update|delete|merge|undelete)\b/, -scope:"built_in"}]}]},y={begin:/\bclass\b/,beginScope:"keyword",end:/\{/, +scope:"built_in"}]}]},I={begin:/\bclass\b/,beginScope:"keyword",end:/\{/, endScope:"punctuation",scope:"class_declaration",keywords:{type:i,keyword:s}, -contains:[m,{match:[/(?<=\bclass\b)\s+/,a],scope:{2:"title.class"}},{ +contains:[_,{match:[/(?<=\bclass\b)\s+/,n],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:[m,{match:/\<|\>/, -scope:"punctuation"},{match:t.concat(/\b/,t.either(...b),/\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(...l),/\b\s*(?!>)/),scope:"title.class.inherited"}] -}]},L={begin:[/\benum\s+/,a,/\s*/,/\{/],beginScope:{1:"type",2:"type"}, -end:/[\}\n]/,returnEnd:!0,scope:"enum_declaration",relevance:0,contains:[S,g,h,{ -match:t.concat(/\b/,a,/\b/),scope:"variable.constant"}]},C=[].concat(I,{ -relevance:10,match:/\b(with|without|inherited)\s+sharing\b/,scope:"keyword"},{ -match:[/\bTrigger/,/\./,/(isExecuting|isInsert|isUpdate|isDelete|isBefore|isAfter|isUndelete|new|newMap|old|oldMap|size|operationType)\b/], -scope:{1:"built_in",3:"keyword"},relevance:10},L,[{ -begin:[/(public|private|protected)\s+/,a,/(?=\s*\()/],beginScope:{1:"keyword", -2:"constructor"},end:/\{/,contains:[O,h]}],y),M=[{ +end:/(\b(implements)\b)|\{/,scope:"extends block"}],contains:[_,{ +match:t.concat(/\b/,t.either(...l),/\b\s*(?!<>)/),scope:"built_in"},{ +match:[/\b/,n,/\./,n,/(?=[,\s<])/],scope:{2:"built_in",4:"title.class.inherited" +}},{match:[/\b/,n,/(?=>)/],scope:{2:"type"}},{match:t.concat(/\b/,n,/\b(?!<)/), +scope:"title.class.inherited"},{ +match:t.concat(/\b/,t.either("schedulable","batchable","queueable","comparable","callable"),/\b\s*(?!>)/), +scope:"title.class.inherited",relevance:8}]}]},L={ +begin:[/\benum\s+/,n,/\s*/,/\{/],beginScope:{1:"type",2:"type"},end:/[\}\n]/, +returnEnd:!0,scope:"enum_declaration",relevance:0,contains:[u,m,g,{ +match:t.concat(/\b/,n,/\b/),scope:"variable.constant"}]},C=[].concat(D,{ +relevance:10,match:/\b(with|without|inherited)\s+sharing\b/,scope:"keyword" +},O,L,[{begin:[/(public|private|protected)\s+/,n,/(?=\s*\()/],beginScope:{ +1:"keyword",2:"constructor"},end:/\{/,contains:[v,g]}],I),M=[{ match:[/\breturn\b\s+/,t.either(o)],scope:{2:"literal"}},{ -match:[/\breturn\s+(?!(true|false|null))/,a,";"],scope:{2:"variable"}},{ -match:[/\breturn\b/,/\s+/,t.lookahead(a+/\(/)],scope:{2:"title.function.invoke"} -}],U={begin:[/\[/,/\s*/,/\b(SELECT|FIND)\b/],beginScope:{1:"punctuation", +match:[/\breturn\s+(?!(true|false|null))/,n,";"],scope:{2:"variable"}},{ +match:[/\breturn\b/,/\s+/,t.lookahead(n+/\(/)],scope:{2:"title.function"}}],w={ +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:{ +relevance:10,contains:[{begin:[/\bFROM\b/,t.concat(/\s+/,n,/\b/)],beginScope:{ 1:"keyword",2:"type"},scope:"from_clause",end:/(?=\]|\s)/,contains:[{ -match:[/(?<=\.)/,a,/\b/],scope:{2:"type"}},h]},{match:/\]/,scope:"punctuation", +match:[/(?<=\.)/,n,/\b/],scope:{2:"type"}},g]},{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},{ @@ -102,24 +98,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,D,A,h,e.APOS_STRING_MODE], -illegal:"::"},f={begin:[/\bfor\b\s*/,/\(/,a,/\s+/,a,/\s*:/],beginScope:{ -3:"type",5:"variable for",6:"operator"},scope:"for_loop",end:[/\)\s*\{/], -endScope:{1:"punctuation"},contains:[S,g,U,D,{match:t.concat(a,/\b(?!\()/), -scope:"variable"}],METHOD_CALL:D,PUNCTUATION_RE:h,OPERATOR_RE:A},w=[{ -begin:t.concat(/\s\b/,t.either(...r),/\b\s/),beginScope:"built_in",end:/;|$/, -scope:"dml",contains:[N,{match:/\bas\s+(user|system)\b/,scope:"keyword"},{ -match:[a,/\s*;/],scope:{1:"variable"}},h,S,U]},{ -begin:[/\bDatabase\b/,/\./,a,/\s*/,t.lookahead(/\(/)],beginScope:{1:"built_in", -3:"built_in"},end:";",scope:"database_dml", -contains:[O,d,e.APOS_STRING_MODE,g,S,{match:[/\(/,a,/,/],scope:{2:"variable"}},{ +match:[/(?<=:)/,/\s*/,n],scope:{3:"variable"}},c,y,S,e.APOS_STRING_MODE], +illegal:"::"},U={begin:[/\bfor\b\s*/,/\(/,n,/\s+/,n,/\s*/,/:/],beginScope:{ +3:"type",5:"variable for",7:"operator"},end:[/\{/],endScope:{1:"punctuation"}, +contains:[u,m,w,y,{match:t.concat(n,/\b(?!\()/),scope:"variable"},{match:/\{/, +endsParent:!0},y,g,S,c]},f=[{begin:t.concat(/\s\b/,t.either(...r),/\b\s/), +beginScope:"built_in",end:/;|$/,scope:"dml",contains:[N,{ +match:/\bas\s+(user|system)\b/,scope:"keyword"},{match:[n,/\s*;/],scope:{ +1:"variable"}},g,u,w,c,S]},{ +begin:[/\bDatabase\b/,/\./,n,/\s*/,t.lookahead(/\(/)],beginScope:{1:"built_in", +3:"title.function.invoke"},end:";",scope:"database_dml", +contains:[v,d,e.APOS_STRING_MODE,m,u,{match:[/\(/,n,/,/],scope:{2:"variable"}},{ match:["AccessLevel",/\./,/(SYSTEM_MODE|USER_MODE)/],scope:{1:"built_in", 3:"keyword"}}]}];return{name:"Apex",aliases:["apex","lightning","soql"], -case_insensitive:!0,disableAutodetect:!1,ignoreIllegals:!1,keywords:{$pattern:a, +case_insensitive:!0,disableAutodetect:!1,ignoreIllegals:!1,keywords:{ +$pattern:t.concat(/\b/,n,/\.?/), keyword:s.concat("abstract","final","global","interface","override","private","protected","public","static","testMethod","transient","virtual","webservice"), -"variable.language":["instanceof","new","super","this"],built_in:l,type:i, -literal:o}, +"variable.language":["instanceof","super","this"],built_in:p,type:i,literal:o}, illegal:["","\x3c!--","!DOCTYPE",/","<%%",":-",/\bmergesort\(/,/\bvar\s+env\b/,/\bdef\b\s\W:/,/"[^"]+"/], -contains:[T,_,v,g,S,C,w,R,f,e.APOS_STRING_MODE,N,D,m,c,A,h,M,{ -match:/(?])/,scope:"type",relevance:8},U,E]}}})() +contains:[h,R,m,u,C,f,T,U,e.APOS_STRING_MODE,N,y,_,c,S,g,M,w,E]}}})() ;export default hljsGrammar; \ No newline at end of file diff --git a/dist/apex.min.js b/dist/apex.min.js index b3f917a..85ee373 100644 --- a/dist/apex.min.js +++ b/dist/apex.min.js @@ -1,94 +1,90 @@ /*! `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", +const t=e.regex,n="[a-zA-Z][a-zA-Z_0-9]*",a="@"+n,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/,/(-?)(\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","implements","extends","return","throw","when"],o=["false","true","null"],i=["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|10","selectoption|10","short|0","sobject|10","string|0","time|0","void|0","float|0"],r=["insert","update","upsert|8","delete","undelete","merge","convertLead|8"],l=[].concat("start","execute","finish","schedulable|10","batchable|10","queueable|10","comparable|10","callable|10").concat(...r),b=["ApexPages","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"],p=["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","Schema","Search","Security","SelectOption","Site","SObject","SObjectAccessDecision","StaticResourceCalloutMock","Test","TimeZone","Type","URL","UserInfo","UserManagement","Version","WebServiceCallout","XmlStreamReader","XmlStreamWriter"],u=["AccessType","DomainType","JSONToken","LoggingLevel","Quiddity","TriggerOperation"],d={ +},s=["try","catch","finally","get","set","put","if","for","else","do","while","continue","break","implements","extends","return","throw","when","new"],o=["false","true","null"],i=["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|10","selectoption|10","short|0","sobject|10","string|0","time|0","void|0","float|0","id"],r=["insert","update","upsert","delete","undelete","merge","convertLead"],l=["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","Search","Sfc","Sfdc_Checkout","sfdc_surveys","Site","Support","TerritoryMgmt","TxnSecurity","UserProvisioning","VisualEditor","Wave"],b=["AccessType","DomainType","JSONToken","LoggingLevel","Quiddity","TriggerOperation"],p=[].concat(...l).concat(...r),d={ match:t.concat(/\b/,t.either(...o),/\b\s*(?=[,)])/),scope:"literal regex", -relevance:0},m=[{match:[/\bSystem/,/\./,t.either(...u),/\./,a],scope:{ -1:"built_in",3:"built_in",5:"variable.constant"},relevance:9},{ -match:[t.concat(/\b/,t.either(...u)),/\./,a,/\b(?![\.\(])/],scope:{1:"built_in", -3:"variable.constant"},relevance:0},{ -match:[t.either(...b),/\./,t.concat("(?=",a,"\\.)")],scope:{1:"built_in"}},{ -match:[t.concat(/\b/,t.either(...b)),/\./,t.concat("(?=",a,"\\s*\\()")],scope:{ -1:"built_in",3:"title.function.invoked"},relevance:10},{ -match:[/\b/,t.either(...b),/\b(?!\.)/],scope:{2:"built_in"}},{ -match:[t.concat(/\b/,"(?<=",t.either(...p),")."),a,/(?=\()/],scope:{ -2:"title.class",4:"title.function.invoke"},relevance:4},{ -match:[/\b/,t.either(...p),/(?=\.)/],scope:{2:"title.class"},relevance:4}],E={ -match:[/\bswitch\s+on\s+/,a],scope:{1:"keyword",2:"variable"}},A={ -match:t.concat(t.either(/(?)/,/--/,/\+\+/,/&&|\|\|/,/\*=|\/=|%=|\+=|-=/,/\&=|\^=|<<=|>>=|>>>=|\|=/,/\&|~|\^|\|/,/%[^%]|\*[^\/]|\/[^\/\*]|(?>/,/<=|>=|\s(<|>)\s/,/==|!=/,/=>/,/!(?=\w)/,/\&\&/,/(?<=\s)(\?|:)(?=\s)/,/\?\./,/(?+/, -endScope:"punctuation",contains:[{match:/)/,/--/,/\+\+/,/&&|\|\|/,/\*=|\/=|%=|\+=|-=/,/\&=|\^=|<<=|>>=|>>>=|\|=/,/\&|~|\^|\|/,/%[^%]|\*[^\/]|\/[^\/\*]|(?>/,/<=|>=|\s(<|>)\s/,/==|!=/,/=>/,/!(?=\w)/,/\&\&/,/(?<=\s)(\?|:)(?=\s)/,/\?\./,/(?+/,contains:[g,{ +match:t.concat(/\b/,n,/\b/),scope:"type"}],relevance:10},{ +match:[n,/\[/,/\d*/,/\]/],scope:{1:"type",3:"number"},contains:[g],relevance:0 +}],O={ +match:[/\bTrigger/,/\./,/(isExecuting|isInsert|isUpdate|isDelete|isBefore|isAfter|isUndelete|new|newMap|old|oldMap|size|operationType)\b/], +scope:{1:"built_in",3:"keyword"},relevance:10},_=[{ +match:[/\bSystem/,/\./,t.either(...b),/\./,n,/\b(?!\()/],scope:{1:"built_in", +3:"built_in",5:"variable.constant"},relevance:9},{ +match:[t.concat(/\b/,t.either(...b)),/\./,n,/\b(?![\.\(])/],scope:{1:"built_in", +3:"variable.constant"},relevance:0},{match:/\bSystem(?=\.System\.)/, +scope:"built_in"},{match:[/\bSystem/,/\./,n,t.lookahead(/[\.\(\s]/)],scope:{ +1:"built_in",3:"keyword"}},{ +match:[/\b/,t.either("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","Schema","Search","Security","SelectOption","Site","SObject","SObjectAccessDecision","StaticResourceCalloutMock","Test","TimeZone","Type","URL","UserInfo","UserManagement","Version","WebServiceCallout","XmlStreamReader","XmlStreamWriter"),/\b\./,n,t.lookahead(/[\.\(\s]/)], +scope:{2:"built_in",4:"keyword"}},{ +match:t.concat(t.either(...l),t.lookahead(/\./)),scope:"built_in"}],v={ +scope:"params",begin:/\(/,beginScope:"punctuation",end:/\)/, +endScope:"punctuation",endsParent:!0,relevance:0,keywords:{keyword:s}, +contains:[c,e.APOS_STRING_MODE,u,m,S,R,d,O,_,c,"self",{ +match:[/(?<=[,\(])\s*(?!Trigger)/,n,/\./,n,/\s*(?=[,)])/],scope:{}},{ +match:t.concat(t.concat(/\b/,n),t.lookahead(t.concat(/\s+/,n,/\s*[,)]/))), +scope:"type"},{match:t.concat(n,/(?=\s*[,)])/)}]} +;t.concat(/(?!return)\b/,n),t.concat(/\s+(?!get|set)/,n), +t.concat(/\b/,n,/__(c|pc|r|b|e|mdt|x|share|kav|ka|history|del|s)/,/\b/) +;const N=[{begin:[/\bnew\b/,/\s+/,n,/\s*(?=\()/],beginScope:{3:"title.class"}, +end:/\)/,returnEnd:!0,scope:"instantiate",contains:[v,u,g],illegal:":", +relevance:0}],y={end:/(?=\)\s*[^{])/,returnEnd:!0,relevance:0,variants:[{ +begin:t.concat(n,/(?=\()/),beginScope:"title.function solo"},{ +begin:[t.concat("(?!",t.either([].concat(...l,["System"])),")",n),/\./,t.concat(n,/(?=\()/)], +beginScope:{1:"title.class nonsystem",3:"title.function.invoke"}}], +contains:[u,m,e.APOS_STRING_MODE,v,N,"self"],relevance:0},D={ +begin:[/\btrigger/,/\s+/,n,/\s+/,"on",/\s+/,n],beginScope:{1:"keyword", +3:"title.class",5:"operator",7:"title.class"},end:/(?=\{)/,returnEnd:!0, +scope:"trigger_declaration",contains:[u,m,{begin:/\(/,end:/\)/, +scope:"trigger_params",contains:[{ match:/\b(before|after)\s+(insert|update|delete|merge|undelete)\b/, -scope:"built_in"}]}]},y={begin:/\bclass\b/,beginScope:"keyword",end:/\{/, +scope:"built_in"}]}]},I={begin:/\bclass\b/,beginScope:"keyword",end:/\{/, endScope:"punctuation",scope:"class_declaration",keywords:{type:i,keyword:s}, -contains:[m,{match:[/(?<=\bclass\b)\s+/,a],scope:{2:"title.class"}},{ +contains:[_,{match:[/(?<=\bclass\b)\s+/,n],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:[m,{match:/\<|\>/, -scope:"punctuation"},{match:t.concat(/\b/,t.either(...b),/\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(...l),/\b\s*(?!>)/),scope:"title.class.inherited"}] -}]},L={begin:[/\benum\s+/,a,/\s*/,/\{/],beginScope:{1:"type",2:"type"}, -end:/[\}\n]/,returnEnd:!0,scope:"enum_declaration",relevance:0,contains:[h,g,S,{ -match:t.concat(/\b/,a,/\b/),scope:"variable.constant"}]},C=[].concat(I,{ -relevance:10,match:/\b(with|without|inherited)\s+sharing\b/,scope:"keyword"},{ -match:[/\bTrigger/,/\./,/(isExecuting|isInsert|isUpdate|isDelete|isBefore|isAfter|isUndelete|new|newMap|old|oldMap|size|operationType)\b/], -scope:{1:"built_in",3:"keyword"},relevance:10},L,[{ -begin:[/(public|private|protected)\s+/,a,/(?=\s*\()/],beginScope:{1:"keyword", -2:"constructor"},end:/\{/,contains:[O,S]}],y),M=[{ +end:/(\b(implements)\b)|\{/,scope:"extends block"}],contains:[_,{ +match:t.concat(/\b/,t.either(...l),/\b\s*(?!<>)/),scope:"built_in"},{ +match:[/\b/,n,/\./,n,/(?=[,\s<])/],scope:{2:"built_in",4:"title.class.inherited" +}},{match:[/\b/,n,/(?=>)/],scope:{2:"type"}},{match:t.concat(/\b/,n,/\b(?!<)/), +scope:"title.class.inherited"},{ +match:t.concat(/\b/,t.either("schedulable","batchable","queueable","comparable","callable"),/\b\s*(?!>)/), +scope:"title.class.inherited",relevance:8}]}]},L={ +begin:[/\benum\s+/,n,/\s*/,/\{/],beginScope:{1:"type",2:"type"},end:/[\}\n]/, +returnEnd:!0,scope:"enum_declaration",relevance:0,contains:[u,m,g,{ +match:t.concat(/\b/,n,/\b/),scope:"variable.constant"}]},C=[].concat(D,{ +relevance:10,match:/\b(with|without|inherited)\s+sharing\b/,scope:"keyword" +},O,L,[{begin:[/(public|private|protected)\s+/,n,/(?=\s*\()/],beginScope:{ +1:"keyword",2:"constructor"},end:/\{/,contains:[v,g]}],I),M=[{ match:[/\breturn\b\s+/,t.either(o)],scope:{2:"literal"}},{ -match:[/\breturn\s+(?!(true|false|null))/,a,";"],scope:{2:"variable"}},{ -match:[/\breturn\b/,/\s+/,t.lookahead(a+/\(/)],scope:{2:"title.function.invoke"} -}],U={begin:[/\[/,/\s*/,/\b(SELECT|FIND)\b/],beginScope:{1:"punctuation", +match:[/\breturn\s+(?!(true|false|null))/,n,";"],scope:{2:"variable"}},{ +match:[/\breturn\b/,/\s+/,t.lookahead(n+/\(/)],scope:{2:"title.function"}}],w={ +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:{ +relevance:10,contains:[{begin:[/\bFROM\b/,t.concat(/\s+/,n,/\b/)],beginScope:{ 1:"keyword",2:"type"},scope:"from_clause",end:/(?=\]|\s)/,contains:[{ -match:[/(?<=\.)/,a,/\b/],scope:{2:"type"}},S]},{match:/\]/,scope:"punctuation", +match:[/(?<=\.)/,n,/\b/],scope:{2:"type"}},g]},{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},{ @@ -102,24 +98,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,D,A,S,e.APOS_STRING_MODE], -illegal:"::"},f={begin:[/\bfor\b\s*/,/\(/,a,/\s+/,a,/\s*:/],beginScope:{ -3:"type",5:"variable for",6:"operator"},scope:"for_loop",end:[/\)\s*\{/], -endScope:{1:"punctuation"},contains:[h,g,U,D,{match:t.concat(a,/\b(?!\()/), -scope:"variable"}],METHOD_CALL:D,PUNCTUATION_RE:S,OPERATOR_RE:A},w=[{ -begin:t.concat(/\s\b/,t.either(...r),/\b\s/),beginScope:"built_in",end:/;|$/, -scope:"dml",contains:[N,{match:/\bas\s+(user|system)\b/,scope:"keyword"},{ -match:[a,/\s*;/],scope:{1:"variable"}},S,h,U]},{ -begin:[/\bDatabase\b/,/\./,a,/\s*/,t.lookahead(/\(/)],beginScope:{1:"built_in", -3:"built_in"},end:";",scope:"database_dml", -contains:[O,d,e.APOS_STRING_MODE,g,h,{match:[/\(/,a,/,/],scope:{2:"variable"}},{ +match:[/(?<=:)/,/\s*/,n],scope:{3:"variable"}},c,y,S,e.APOS_STRING_MODE], +illegal:"::"},U={begin:[/\bfor\b\s*/,/\(/,n,/\s+/,n,/\s*/,/:/],beginScope:{ +3:"type",5:"variable for",7:"operator"},end:[/\{/],endScope:{1:"punctuation"}, +contains:[u,m,w,y,{match:t.concat(n,/\b(?!\()/),scope:"variable"},{match:/\{/, +endsParent:!0},y,g,S,c]},f=[{begin:t.concat(/\s\b/,t.either(...r),/\b\s/), +beginScope:"built_in",end:/;|$/,scope:"dml",contains:[N,{ +match:/\bas\s+(user|system)\b/,scope:"keyword"},{match:[n,/\s*;/],scope:{ +1:"variable"}},g,u,w,c,S]},{ +begin:[/\bDatabase\b/,/\./,n,/\s*/,t.lookahead(/\(/)],beginScope:{1:"built_in", +3:"title.function.invoke"},end:";",scope:"database_dml", +contains:[v,d,e.APOS_STRING_MODE,m,u,{match:[/\(/,n,/,/],scope:{2:"variable"}},{ match:["AccessLevel",/\./,/(SYSTEM_MODE|USER_MODE)/],scope:{1:"built_in", 3:"keyword"}}]}];return{name:"Apex",aliases:["apex","lightning","soql"], -case_insensitive:!0,disableAutodetect:!1,ignoreIllegals:!1,keywords:{$pattern:a, +case_insensitive:!0,disableAutodetect:!1,ignoreIllegals:!1,keywords:{ +$pattern:t.concat(/\b/,n,/\.?/), keyword:s.concat("abstract","final","global","interface","override","private","protected","public","static","testMethod","transient","virtual","webservice"), -"variable.language":["instanceof","new","super","this"],built_in:l,type:i, -literal:o}, +"variable.language":["instanceof","super","this"],built_in:p,type:i,literal:o}, illegal:["","\x3c!--","!DOCTYPE",/","<%%",":-",/\bmergesort\(/,/\bvar\s+env\b/,/\bdef\b\s\W:/,/"[^"]+"/], -contains:[T,_,v,g,h,C,w,R,f,e.APOS_STRING_MODE,N,D,m,c,A,S,M,{ -match:/(?])/,scope:"type",relevance:8},U,E]}}})() +contains:[h,R,m,u,C,f,T,U,e.APOS_STRING_MODE,N,y,_,c,S,g,M,w,E]}}})() ;hljs.registerLanguage("apex",e)})(); \ No newline at end of file diff --git a/src/languages/apex.js b/src/languages/apex.js index 0b2fd68..16363d2 100644 --- a/src/languages/apex.js +++ b/src/languages/apex.js @@ -29,10 +29,6 @@ export default function (hljs) { }; const MAIN_KEYWORD_LIST = [ - 'cast', - 'default', - 'export', - 'try', 'catch', 'finally', @@ -55,10 +51,12 @@ export default function (hljs) { 'return', 'throw', - 'when' + 'when', + + 'new', ]; - const LANGUAGE_VAR_LIST = ['instanceof', 'new', 'super', 'this']; + const LANGUAGE_VAR_LIST = ['instanceof', 'super', 'this']; // keyword const STORAGE_MODIFIER_LIST = [ @@ -101,36 +99,32 @@ export default function (hljs) { 'string|0', 'time|0', 'void|0', - 'float|0' + 'float|0', + 'id' ]; const DMLS = [ 'insert', 'update', - 'upsert|8', + 'upsert', 'delete', 'undelete', 'merge', - 'convertLead|8' + 'convertLead' ]; - const BUILT_INS = [] - .concat( - ...[ - 'start', - 'execute', - 'finish', - 'schedulable|10', - 'batchable|10', - 'queueable|10', - 'comparable|10', - 'callable|10' - ] - ) - .concat(...DMLS); + + + const SYSTEM_INTERFACES = [ + 'schedulable', + 'batchable', + 'queueable', + 'comparable', + 'callable' + ]; const NAMESPACE_LIST = [ - 'ApexPages', + //'ApexPages', 'AppLauncher', 'Approval', 'Auth', @@ -158,14 +152,14 @@ export default function (hljs) { 'QuickAction', 'Reports', 'RichMessageing', - 'Schema', + //'Schema', 'Search', 'Sfc', 'Sfdc_Checkout', 'sfdc_surveys', 'Site', 'Support', - 'System', + //'System', // remove System so we handle it separately 'TerritoryMgmt', 'TxnSecurity', 'UserProvisioning', @@ -173,6 +167,7 @@ export default function (hljs) { 'Wave' ]; + // TODO: Check if these are necessary const SYSTEM_CLASSES = [ 'AccessLevel', 'Address', @@ -258,83 +253,72 @@ export default function (hljs) { 'JSONToken', 'LoggingLevel', 'Quiddity', - 'TriggerOperation' + 'TriggerOperation', ]; + const BUILT_INS = [] + .concat( ...NAMESPACE_LIST ) + .concat(...DMLS); + const LITERAL_RE = { match: regex.concat(/\b/, regex.either(...LITERALS), /\b\s*(?=[,)])/), scope: 'literal regex', relevance: 0 }; - const NAMESPACES = [ - // * SYSTEM ENUMS W/WO SYSTEM SPECIFIED - { - match: [ - /\bSystem/, - /\./, - regex.either(...SYSTEM_ENUMS), - /\./, - APEX_IDENT_RE - ], - scope: { - 1: 'built_in' /* 2: 'punctuation', */, - 3: 'built_in' /* 4:'punctuation', */, - 5: 'variable.constant' + const COMMENT_LINE = hljs.COMMENT('//', /[$\n]/, { + relevance: 0 + }); + + const COMMENT_BLOCK = hljs.COMMENT('/\\*', '\\*/', { + relevance: 0, + contains: [ + { + begin: /\[/, + end: '\\]\\(', + excludeBegin: true, + returnEnd: true, + //returnBegin: true, + scope: 'symbol' + }, + { + begin: '\\]\\(', + end: '\\)', + excludeBegin: true, + excludeEnd: true, + scope: 'link' + }, + { + // eat up @'s in emails to prevent them to be recognized as doctags + begin: /\w+@/, + relevance: 0 }, - relevance: 9 - }, - { - 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 (or other Namespace) BASE - { - match: [ - regex.either(...NAMESPACE_LIST), - /\./, - regex.concat('(?=', APEX_IDENT_RE, '\\.)') - ], - scope: { 1: 'built_in' } - }, - { - match: [ - regex.concat(/\b/, regex.either(...NAMESPACE_LIST)), - /\./, - regex.concat('(?=', APEX_IDENT_RE, '\\s*\\()') - ], - scope: { - 1: 'built_in', - /* 2: 'punctuation', */ 3: 'title.function.invoked' + { + match: [/@(?:exception|throws)/, /\s+/, APEX_IDENT_RE], + scope: { 1: 'doctag', 3: 'title.class' } }, - relevance: 10 - }, - { - match: [/\b/, regex.either(...NAMESPACE_LIST), /\b(?!\.)/], - scope: { 2: 'built_in' } - }, - { - match: [ - regex.concat(/\b/, '(?<=', regex.either(...SYSTEM_CLASSES), ').'), - APEX_IDENT_RE, - /(?=\()/ - ], - scope: { 2: 'title.class', 4: 'title.function.invoke' }, - relevance: 4 - }, - { - match: [/\b/, regex.either(...SYSTEM_CLASSES), /(?=\.)/], - scope: { 2: 'title.class' }, - relevance: 4 - } - ]; + { + begin: /@[A-Za-z_]+\s/, + scope: 'doctag' + }, + { + begin: '`', + end: '`', + excludeBegin: true, + excludeEnd: true, + scope: 'code', + contains: [hljs.BACKSLASH_ESCAPE], + relevance: 0 + }, + hljs.inherit(hljs.APOS_STRING_MODE, { scope: 'meta string' }), + { + match: regex.concat(/(?<=@param)/, /\s+/, APEX_IDENT_RE), + scope: 'variable', + } + ] + }); + + const SWITCH_STATEMENT = { match: [/\bswitch\s+on\s+/, APEX_IDENT_RE], @@ -342,19 +326,13 @@ export default function (hljs) { }; const OPERATOR_LIST = [ - //=/, - //(?<=')\s*\+/, // string concat before - //\+(?=\s*')/, // string concat after /(?)/, // assignment - ///(\=/, // assignment - /--/, // decrement /\+\+/, // increment /&&|\|\|/, // logical /\*=|\/=|%=|\+=|-=/, // assignment.compound /\&=|\^=|<<=|>>=|>>>=|\|=/, // assignment.compound.bitwise /\&|~|\^|\|/, // bitwise - /%[^%]|\*[^\/]|\/[^\/\*]|(?>/, // bitwise.shift /<=|>=|\s(<|>)\s/, // relational @@ -363,24 +341,22 @@ export default function (hljs) { /!(?=\w)/, // negator /\&\&/, /(?<=\s)(\?|:)(?=\s)/, // standalone ? or : (ternary operator?) - /\?\./, // null-safe operator /(?+/, - endScope: 'punctuation', + //endScope: 'punctuation', contains: [ - { - match: //, scope: 'punctuation' - }, + }, */ { match: regex.concat( /\b/, @@ -794,8 +785,9 @@ export default function (hljs) { scope: 'title.class.inherited' }, { - match: regex.concat(/\b/, regex.either(...BUILT_INS), /\b\s*(?!>)/), - scope: 'title.class.inherited' + match: regex.concat(/\b/, regex.either(...SYSTEM_INTERFACES), /\b\s*(?!>)/), + scope: 'title.class.inherited', + relevance: 8 } ] } @@ -829,7 +821,6 @@ export default function (hljs) { scope: 'keyword' }; - // commented for now - too easy to overlap with method_call const CONSTRUCTOR_DECLARATION = [ { // Constructor @@ -873,13 +864,14 @@ export default function (hljs) { //returnBegin: true, //end: /(?=\))/, scope: { - 2: 'title.function.invoke' + 2: 'title.function' } //contains: [METHOD_CALL, PARAMS] } // * RETURN NEW OBJECT - NO PARAMS BY DEFAULT ]; + // may not need const SALESFORCE_ID = { match: /(?])/, scope: 'type', @@ -1076,23 +1068,22 @@ export default function (hljs) { NUMBERS, METHOD_CALL, OPERATOR_RE, - PUNCTUATION_RE, hljs.APOS_STRING_MODE ], illegal: '::' }; 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 for', - 6: 'operator' + 7: 'operator' }, - scope: 'for_loop', - end: [/\)\s*\{/], + //scope: 'for_loop', + end: [/\{/], endScope: { 1: 'punctuation' }, //returnEnd: true, //endScope: 'punctuation', @@ -1105,11 +1096,16 @@ export default function (hljs) { { match: regex.concat(APEX_IDENT_RE, /\b(?!\()/), scope: 'variable' - } - ], - METHOD_CALL, - PUNCTUATION_RE, - OPERATOR_RE + }, + { + match: /\{/, + endsParent: true, + }, + METHOD_CALL, + PUNCTUATION_RE, + OPERATOR_RE, + NUMBERS + ] }; // TODO: Do DMLs @@ -1138,7 +1134,9 @@ export default function (hljs) { }, PUNCTUATION_RE, COMMENT_LINE, - SOQL_QUERY + SOQL_QUERY, + NUMBERS, + OPERATOR_RE ] }, /* @@ -1154,7 +1152,7 @@ export default function (hljs) { /\s*/, regex.lookahead(/\(/) ], - beginScope: { 1: 'built_in', 3: 'built_in' }, + beginScope: { 1: 'built_in', 3: 'title.function.invoke' }, end: ';', //endScope: 'punctuation', scope: 'database_dml', @@ -1254,7 +1252,7 @@ export default function (hljs) { disableAutodetect: false, ignoreIllegals: false, keywords: { - $pattern: APEX_IDENT_RE, + $pattern: regex.concat(/\b/,APEX_IDENT_RE, /\.?/), keyword: MAIN_KEYWORD_LIST.concat(...STORAGE_MODIFIER_LIST), 'variable.language': LANGUAGE_VAR_LIST, built_in: BUILT_INS, @@ -1264,7 +1262,7 @@ export default function (hljs) { illegal: ILLEGALS, contains: [ ANNOTATIONS, - ASSIGNMENTS, + //, COLLECTION_DECLARATION, COMMENT_BLOCK, COMMENT_LINE, @@ -1281,7 +1279,7 @@ export default function (hljs) { OPERATOR_RE, PUNCTUATION_RE, RETURNS, - SALESFORCE_ID, + //SALESFORCE_ID, SOQL_QUERY, SWITCH_STATEMENT ]