Added support for Apex (#2622)
This commit is contained in:
parent
a5107d5c28
commit
f0e2b70e23
File diff suppressed because one or more lines are too long
|
@ -112,6 +112,11 @@
|
|||
"title": "Apache Configuration",
|
||||
"owner": "GuiTeK"
|
||||
},
|
||||
"apex": {
|
||||
"title": "Apex",
|
||||
"require": ["clike", "sql"],
|
||||
"owner": "RunDevelopment"
|
||||
},
|
||||
"apl": {
|
||||
"title": "APL",
|
||||
"owner": "ngn"
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
(function (Prism) {
|
||||
|
||||
var keywords = /\b(?:abstract|activate|and|any|array|as|asc|autonomous|begin|bigdecimal|blob|boolean|break|bulk|by|byte|case|cast|catch|char|class|collect|commit|const|continue|currency|date|datetime|decimal|default|delete|desc|do|double|else|end|enum|exception|exit|export|extends|final|finally|float|for|from|global|goto|group|having|hint|if|implements|import|in|inner|insert|instanceof|int|integer|interface|into|join|like|limit|list|long|loop|map|merge|new|not|null|nulls|number|object|of|on|or|outer|override|package|parallel|pragma|private|protected|public|retrieve|return|rollback|select|set|short|sObject|sort|static|string|super|switch|synchronized|system|testmethod|then|this|throw|time|transaction|transient|trigger|try|undelete|update|upsert|using|virtual|void|webservice|when|where|while|get(?=\s*[{};])|(?:after|before)(?=\s+[a-z])|(?:inherited|with|without)\s+sharing)\b/i;
|
||||
|
||||
var className = /\b(?:(?=[a-z_]\w*\s*[<\[])|(?!<keyword>))[A-Z_]\w*(?:\s*\.\s*[A-Z_]\w*)*\b(?:\s*(?:\[\s*\]|<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>))*/.source
|
||||
.replace(/<keyword>/g, function () { return keywords.source; });
|
||||
/** @param {string} pattern */
|
||||
function insertClassName(pattern) {
|
||||
return RegExp(pattern.replace(/<CLASS-NAME>/g, function () { return className; }), 'i');
|
||||
}
|
||||
|
||||
var classNameInside = {
|
||||
'keyword': keywords,
|
||||
'punctuation': /[()\[\]{};,:.<>]/
|
||||
};
|
||||
|
||||
Prism.languages.apex = {
|
||||
'comment': Prism.languages.clike.comment,
|
||||
'string': Prism.languages.clike.string,
|
||||
'sql': {
|
||||
pattern: /((?:[=,({:]|\breturn)\s*)\[[^\[\]]*\]/i,
|
||||
lookbehind: true,
|
||||
greedy: true,
|
||||
alias: 'language-sql',
|
||||
inside: Prism.languages.sql
|
||||
},
|
||||
|
||||
'annotation': {
|
||||
pattern: /@\w+\b/,
|
||||
alias: 'punctuation'
|
||||
},
|
||||
'class-name': [
|
||||
{
|
||||
pattern: insertClassName(/(\b(?:class|enum|extends|implements|instanceof|interface|new|trigger\s+\w+\s+on)\s+)<CLASS-NAME>/.source),
|
||||
lookbehind: true,
|
||||
inside: classNameInside
|
||||
},
|
||||
{
|
||||
// cast
|
||||
pattern: insertClassName(/(\(\s*)<CLASS-NAME>(?=\s*\)\s*[\w(])/.source),
|
||||
lookbehind: true,
|
||||
inside: classNameInside
|
||||
},
|
||||
{
|
||||
// variable/parameter declaration and return types
|
||||
pattern: insertClassName(/<CLASS-NAME>(?=\s*\w+\s*[;=,(){:])/.source),
|
||||
inside: classNameInside
|
||||
}
|
||||
],
|
||||
'trigger': {
|
||||
pattern: /(\btrigger\s+)\w+\b/i,
|
||||
lookbehind: true,
|
||||
alias: 'class-name'
|
||||
},
|
||||
'keyword': keywords,
|
||||
'function': /\b[a-z_]\w*(?=\s*\()/i,
|
||||
|
||||
'boolean': /\b(?:false|true)\b/i,
|
||||
|
||||
'number': /(?:\B\.\d+|\b\d+(?:\.\d+|L)?)\b/i,
|
||||
'operator': /[!=](?:==?)?|\?\.?|&&|\|\||--|\+\+|[-+*/^&|]=?|:|<<?=?|>{1,3}=?/,
|
||||
'punctuation': /[()\[\]{};,.]/
|
||||
};
|
||||
|
||||
})(Prism);
|
|
@ -0,0 +1 @@
|
|||
!function(e){var t=/\b(?:abstract|activate|and|any|array|as|asc|autonomous|begin|bigdecimal|blob|boolean|break|bulk|by|byte|case|cast|catch|char|class|collect|commit|const|continue|currency|date|datetime|decimal|default|delete|desc|do|double|else|end|enum|exception|exit|export|extends|final|finally|float|for|from|global|goto|group|having|hint|if|implements|import|in|inner|insert|instanceof|int|integer|interface|into|join|like|limit|list|long|loop|map|merge|new|not|null|nulls|number|object|of|on|or|outer|override|package|parallel|pragma|private|protected|public|retrieve|return|rollback|select|set|short|sObject|sort|static|string|super|switch|synchronized|system|testmethod|then|this|throw|time|transaction|transient|trigger|try|undelete|update|upsert|using|virtual|void|webservice|when|where|while|get(?=\s*[{};])|(?:after|before)(?=\s+[a-z])|(?:inherited|with|without)\s+sharing)\b/i,n="\\b(?:(?=[a-z_]\\w*\\s*[<\\[])|(?!<keyword>))[A-Z_]\\w*(?:\\s*\\.\\s*[A-Z_]\\w*)*\\b(?:\\s*(?:\\[\\s*\\]|<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>))*".replace(/<keyword>/g,function(){return t.source});function i(e){return RegExp(e.replace(/<CLASS-NAME>/g,function(){return n}),"i")}var a={keyword:t,punctuation:/[()\[\]{};,:.<>]/};e.languages.apex={comment:e.languages.clike.comment,string:e.languages.clike.string,sql:{pattern:/((?:[=,({:]|\breturn)\s*)\[[^\[\]]*\]/i,lookbehind:!0,greedy:!0,alias:"language-sql",inside:e.languages.sql},annotation:{pattern:/@\w+\b/,alias:"punctuation"},"class-name":[{pattern:i("(\\b(?:class|enum|extends|implements|instanceof|interface|new|trigger\\s+\\w+\\s+on)\\s+)<CLASS-NAME>"),lookbehind:!0,inside:a},{pattern:i("(\\(\\s*)<CLASS-NAME>(?=\\s*\\)\\s*[\\w(])"),lookbehind:!0,inside:a},{pattern:i("<CLASS-NAME>(?=\\s*\\w+\\s*[;=,(){:])"),inside:a}],trigger:{pattern:/(\btrigger\s+)\w+\b/i,lookbehind:!0,alias:"class-name"},keyword:t,function:/\b[a-z_]\w*(?=\s*\()/i,boolean:/\b(?:false|true)\b/i,number:/(?:\B\.\d+|\b\d+(?:\.\d+|L)?)\b/i,operator:/[!=](?:==?)?|\?\.?|&&|\|\||--|\+\+|[-+*/^&|]=?|:|<<?=?|>{1,3}=?/,punctuation:/[()\[\]{};,.]/}}(Prism);
|
|
@ -0,0 +1,152 @@
|
|||
<h2>Full example</h2>
|
||||
<pre><code>// source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_shopping_cart_example_code.htm
|
||||
|
||||
trigger calculate on Item__c (after insert, after update, after delete) {
|
||||
|
||||
// Use a map because it doesn't allow duplicate values
|
||||
|
||||
Map<ID, Shipping_Invoice__C> updateMap = new Map<ID, Shipping_Invoice__C>();
|
||||
|
||||
// Set this integer to -1 if we are deleting
|
||||
Integer subtract ;
|
||||
|
||||
// Populate the list of items based on trigger type
|
||||
List<Item__c> itemList;
|
||||
if(trigger.isInsert || trigger.isUpdate){
|
||||
itemList = Trigger.new;
|
||||
subtract = 1;
|
||||
}
|
||||
else if(trigger.isDelete)
|
||||
{
|
||||
// Note -- there is no trigger.new in delete
|
||||
itemList = trigger.old;
|
||||
subtract = -1;
|
||||
}
|
||||
|
||||
// Access all the information we need in a single query
|
||||
// rather than querying when we need it.
|
||||
// This is a best practice for bulkifying requests
|
||||
|
||||
set<Id> AllItems = new set<id>();
|
||||
|
||||
for(item__c i :itemList){
|
||||
// Assert numbers are not negative.
|
||||
// None of the fields would make sense with a negative value
|
||||
|
||||
System.assert(i.quantity__c > 0, 'Quantity must be positive');
|
||||
System.assert(i.weight__c >= 0, 'Weight must be non-negative');
|
||||
System.assert(i.price__c >= 0, 'Price must be non-negative');
|
||||
|
||||
// If there is a duplicate Id, it won't get added to a set
|
||||
AllItems.add(i.Shipping_Invoice__C);
|
||||
}
|
||||
|
||||
// Accessing all shipping invoices associated with the items in the trigger
|
||||
List<Shipping_Invoice__C> AllShippingInvoices = [SELECT Id, ShippingDiscount__c,
|
||||
SubTotal__c, TotalWeight__c, Tax__c, GrandTotal__c
|
||||
FROM Shipping_Invoice__C WHERE Id IN :AllItems];
|
||||
|
||||
// Take the list we just populated and put it into a Map.
|
||||
// This will make it easier to look up a shipping invoice
|
||||
// because you must iterate a list, but you can use lookup for a map,
|
||||
Map<ID, Shipping_Invoice__C> SIMap = new Map<ID, Shipping_Invoice__C>();
|
||||
|
||||
for(Shipping_Invoice__C sc : AllShippingInvoices)
|
||||
{
|
||||
SIMap.put(sc.id, sc);
|
||||
}
|
||||
|
||||
// Process the list of items
|
||||
if(Trigger.isUpdate)
|
||||
{
|
||||
// Treat updates like a removal of the old item and addition of the
|
||||
// revised item rather than figuring out the differences of each field
|
||||
// and acting accordingly.
|
||||
// Note updates have both trigger.new and trigger.old
|
||||
for(Integer x = 0; x < Trigger.old.size(); x++)
|
||||
{
|
||||
Shipping_Invoice__C myOrder;
|
||||
myOrder = SIMap.get(trigger.old[x].Shipping_Invoice__C);
|
||||
|
||||
// Decrement the previous value from the subtotal and weight.
|
||||
myOrder.SubTotal__c -= (trigger.old[x].price__c *
|
||||
trigger.old[x].quantity__c);
|
||||
myOrder.TotalWeight__c -= (trigger.old[x].weight__c *
|
||||
trigger.old[x].quantity__c);
|
||||
|
||||
// Increment the new subtotal and weight.
|
||||
myOrder.SubTotal__c += (trigger.new[x].price__c *
|
||||
trigger.new[x].quantity__c);
|
||||
myOrder.TotalWeight__c += (trigger.new[x].weight__c *
|
||||
trigger.new[x].quantity__c);
|
||||
}
|
||||
|
||||
for(Shipping_Invoice__C myOrder : AllShippingInvoices)
|
||||
{
|
||||
|
||||
// Set tax rate to 9.25% Please note, this is a simple example.
|
||||
// Generally, you would never hard code values.
|
||||
// Leveraging Custom Settings for tax rates is a best practice.
|
||||
// See Custom Settings in the Apex Developer Guide
|
||||
// for more information.
|
||||
myOrder.Tax__c = myOrder.Subtotal__c * .0925;
|
||||
|
||||
// Reset the shipping discount
|
||||
myOrder.ShippingDiscount__c = 0;
|
||||
|
||||
// Set shipping rate to 75 cents per pound.
|
||||
// Generally, you would never hard code values.
|
||||
// Leveraging Custom Settings for the shipping rate is a best practice.
|
||||
// See Custom Settings in the Apex Developer Guide
|
||||
// for more information.
|
||||
myOrder.Shipping__c = (myOrder.totalWeight__c * .75);
|
||||
myOrder.GrandTotal__c = myOrder.SubTotal__c + myOrder.tax__c +
|
||||
myOrder.Shipping__c;
|
||||
updateMap.put(myOrder.id, myOrder);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(Item__c itemToProcess : itemList)
|
||||
{
|
||||
Shipping_Invoice__C myOrder;
|
||||
|
||||
// Look up the correct shipping invoice from the ones we got earlier
|
||||
myOrder = SIMap.get(itemToProcess.Shipping_Invoice__C);
|
||||
myOrder.SubTotal__c += (itemToProcess.price__c *
|
||||
itemToProcess.quantity__c * subtract);
|
||||
myOrder.TotalWeight__c += (itemToProcess.weight__c *
|
||||
itemToProcess.quantity__c * subtract);
|
||||
}
|
||||
|
||||
for(Shipping_Invoice__C myOrder : AllShippingInvoices)
|
||||
{
|
||||
|
||||
// Set tax rate to 9.25% Please note, this is a simple example.
|
||||
// Generally, you would never hard code values.
|
||||
// Leveraging Custom Settings for tax rates is a best practice.
|
||||
// See Custom Settings in the Apex Developer Guide
|
||||
// for more information.
|
||||
myOrder.Tax__c = myOrder.Subtotal__c * .0925;
|
||||
|
||||
// Reset shipping discount
|
||||
myOrder.ShippingDiscount__c = 0;
|
||||
|
||||
// Set shipping rate to 75 cents per pound.
|
||||
// Generally, you would never hard code values.
|
||||
// Leveraging Custom Settings for the shipping rate is a best practice.
|
||||
// See Custom Settings in the Apex Developer Guide
|
||||
// for more information.
|
||||
myOrder.Shipping__c = (myOrder.totalWeight__c * .75);
|
||||
myOrder.GrandTotal__c = myOrder.SubTotal__c + myOrder.tax__c +
|
||||
myOrder.Shipping__c;
|
||||
|
||||
updateMap.put(myOrder.id, myOrder);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Only use one DML update at the end.
|
||||
// This minimizes the number of DML requests generated from this trigger.
|
||||
update updateMap.values();
|
||||
}</code></pre>
|
|
@ -11,6 +11,10 @@
|
|||
var lang_dependencies = /*dependencies_placeholder[*/{
|
||||
"javascript": "clike",
|
||||
"actionscript": "javascript",
|
||||
"apex": [
|
||||
"clike",
|
||||
"sql"
|
||||
],
|
||||
"arduino": "cpp",
|
||||
"aspnet": [
|
||||
"markup",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,16 @@
|
|||
@Future
|
||||
@IsTest
|
||||
@isTest(SeeAllData=true)
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["annotation", "@Future"],
|
||||
["annotation", "@IsTest"],
|
||||
["annotation", "@isTest"],
|
||||
["punctuation", "("],
|
||||
"SeeAllData",
|
||||
["operator", "="],
|
||||
["boolean", "true"],
|
||||
["punctuation", ")"]
|
||||
]
|
|
@ -0,0 +1,9 @@
|
|||
true
|
||||
false
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["boolean", "true"],
|
||||
["boolean", "false"]
|
||||
]
|
|
@ -0,0 +1,334 @@
|
|||
Integer i;
|
||||
Integer i = (Integer)obj;
|
||||
Integer[] myInts = new Integer[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
Object obj = new MyApexClass();
|
||||
list<Item__c> itemList;
|
||||
List<List<Set<Integer>>> my_list_2 = new List<List<Set<Integer>>>();
|
||||
Map<ID, Shipping_Invoice__C> updateMap = new Map<ID, Shipping_Invoice__C>();
|
||||
set<Id> AllItems = new set<id>();
|
||||
|
||||
public Season getSouthernHemisphereSeason(season northernHemisphereSeason) {}
|
||||
|
||||
for(Shipping_Invoice__C sc : AllShippingInvoices){}
|
||||
public static Integer calculate() {}
|
||||
|
||||
if (sobject instanceof Account) {
|
||||
Account a = (Account) sobject;
|
||||
}
|
||||
|
||||
public class myOuterClass {}
|
||||
public enum MyEnumClass { X, Y }
|
||||
public class YellowMarker extends Marker {}
|
||||
interface MySecondInterface extends MyInterface {}
|
||||
public virtual class InnerClass implements MySecondInterface {}
|
||||
|
||||
|
||||
class Foo {
|
||||
List<Account> accs {get; set;}
|
||||
Integer i {get; set;}
|
||||
}
|
||||
|
||||
|
||||
public with sharing class sharingClass {}
|
||||
public without sharing class noSharing {}
|
||||
public inherited sharing class InheritedSharingClass{}
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["keyword", "Integer"],
|
||||
" i",
|
||||
["punctuation", ";"],
|
||||
["keyword", "Integer"],
|
||||
" i ",
|
||||
["operator", "="],
|
||||
["punctuation", "("],
|
||||
["keyword", "Integer"],
|
||||
["punctuation", ")"],
|
||||
"obj",
|
||||
["punctuation", ";"],
|
||||
["class-name", [
|
||||
["keyword", "Integer"],
|
||||
["punctuation", "["],
|
||||
["punctuation", "]"]
|
||||
]],
|
||||
" myInts ",
|
||||
["operator", "="],
|
||||
["keyword", "new"],
|
||||
["class-name", [
|
||||
["keyword", "Integer"],
|
||||
["punctuation", "["],
|
||||
["punctuation", "]"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["number", "1"],
|
||||
["punctuation", ","],
|
||||
["number", "2"],
|
||||
["punctuation", ","],
|
||||
["number", "3"],
|
||||
["punctuation", ","],
|
||||
["number", "4"],
|
||||
["punctuation", ","],
|
||||
["number", "5"],
|
||||
["punctuation", ","],
|
||||
["number", "6"],
|
||||
["punctuation", ","],
|
||||
["number", "7"],
|
||||
["punctuation", ","],
|
||||
["number", "8"],
|
||||
["punctuation", ","],
|
||||
["number", "9"],
|
||||
["punctuation", ","],
|
||||
["number", "10"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "Object"],
|
||||
" obj ",
|
||||
["operator", "="],
|
||||
["keyword", "new"],
|
||||
["class-name", [
|
||||
"MyApexClass"
|
||||
]],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["punctuation", ";"],
|
||||
["class-name", [
|
||||
["keyword", "list"],
|
||||
["punctuation", "<"],
|
||||
"Item__c",
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
" itemList",
|
||||
["punctuation", ";"],
|
||||
["class-name", [
|
||||
["keyword", "List"],
|
||||
["punctuation", "<"],
|
||||
["keyword", "List"],
|
||||
["punctuation", "<"],
|
||||
["keyword", "Set"],
|
||||
["punctuation", "<"],
|
||||
["keyword", "Integer"],
|
||||
["punctuation", ">"],
|
||||
["punctuation", ">"],
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
" my_list_2 ",
|
||||
["operator", "="],
|
||||
["keyword", "new"],
|
||||
["class-name", [
|
||||
["keyword", "List"],
|
||||
["punctuation", "<"],
|
||||
["keyword", "List"],
|
||||
["punctuation", "<"],
|
||||
["keyword", "Set"],
|
||||
["punctuation", "<"],
|
||||
["keyword", "Integer"],
|
||||
["punctuation", ">"],
|
||||
["punctuation", ">"],
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["punctuation", ";"],
|
||||
["class-name", [
|
||||
["keyword", "Map"],
|
||||
["punctuation", "<"],
|
||||
"ID",
|
||||
["punctuation", ","],
|
||||
" Shipping_Invoice__C",
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
" updateMap ",
|
||||
["operator", "="],
|
||||
["keyword", "new"],
|
||||
["class-name", [
|
||||
["keyword", "Map"],
|
||||
["punctuation", "<"],
|
||||
"ID",
|
||||
["punctuation", ","],
|
||||
" Shipping_Invoice__C",
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["punctuation", ";"],
|
||||
["class-name", [
|
||||
["keyword", "set"],
|
||||
["punctuation", "<"],
|
||||
"Id",
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
" AllItems ",
|
||||
["operator", "="],
|
||||
["keyword", "new"],
|
||||
["class-name", [
|
||||
["keyword", "set"],
|
||||
["punctuation", "<"],
|
||||
"id",
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["punctuation", ";"],
|
||||
|
||||
["keyword", "public"],
|
||||
["class-name", [
|
||||
"Season"
|
||||
]],
|
||||
["function", "getSouthernHemisphereSeason"],
|
||||
["punctuation", "("],
|
||||
["class-name", [
|
||||
"season"
|
||||
]],
|
||||
" northernHemisphereSeason",
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["keyword", "for"],
|
||||
["punctuation", "("],
|
||||
["class-name", [
|
||||
"Shipping_Invoice__C"
|
||||
]],
|
||||
" sc ",
|
||||
["operator", ":"],
|
||||
" AllShippingInvoices",
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "public"],
|
||||
["keyword", "static"],
|
||||
["keyword", "Integer"],
|
||||
["function", "calculate"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["keyword", "if"],
|
||||
["punctuation", "("],
|
||||
["keyword", "sobject"],
|
||||
["keyword", "instanceof"],
|
||||
["class-name", [
|
||||
"Account"
|
||||
]],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["class-name", [
|
||||
"Account"
|
||||
]],
|
||||
" a ",
|
||||
["operator", "="],
|
||||
["punctuation", "("],
|
||||
["class-name", [
|
||||
"Account"
|
||||
]],
|
||||
["punctuation", ")"],
|
||||
["keyword", "sobject"],
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["keyword", "public"],
|
||||
["keyword", "class"],
|
||||
["class-name", [
|
||||
"myOuterClass"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "public"],
|
||||
["keyword", "enum"],
|
||||
["class-name", [
|
||||
"MyEnumClass"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
" X",
|
||||
["punctuation", ","],
|
||||
" Y ",
|
||||
["punctuation", "}"],
|
||||
["keyword", "public"],
|
||||
["keyword", "class"],
|
||||
["class-name", [
|
||||
"YellowMarker"
|
||||
]],
|
||||
["keyword", "extends"],
|
||||
["class-name", [
|
||||
"Marker"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "interface"],
|
||||
["class-name", [
|
||||
"MySecondInterface"
|
||||
]],
|
||||
["keyword", "extends"],
|
||||
["class-name", [
|
||||
"MyInterface"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "public"],
|
||||
["keyword", "virtual"],
|
||||
["keyword", "class"],
|
||||
["class-name", [
|
||||
"InnerClass"
|
||||
]],
|
||||
["keyword", "implements"],
|
||||
["class-name", [
|
||||
"MySecondInterface"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["keyword", "class"],
|
||||
["class-name", [
|
||||
"Foo"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["class-name", [
|
||||
["keyword", "List"],
|
||||
["punctuation", "<"],
|
||||
"Account",
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
" accs ",
|
||||
["punctuation", "{"],
|
||||
["keyword", "get"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "set"],
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "Integer"],
|
||||
" i ",
|
||||
["punctuation", "{"],
|
||||
["keyword", "get"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "set"],
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["keyword", "public"],
|
||||
["keyword", "with sharing"],
|
||||
["keyword", "class"],
|
||||
["class-name", [
|
||||
"sharingClass"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "public"],
|
||||
["keyword", "without sharing"],
|
||||
["keyword", "class"],
|
||||
["class-name", [
|
||||
"noSharing"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "public"],
|
||||
["keyword", "inherited sharing"],
|
||||
["keyword", "class"],
|
||||
["class-name", [
|
||||
"InheritedSharingClass"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"]
|
||||
]
|
|
@ -0,0 +1,11 @@
|
|||
// comment
|
||||
/*
|
||||
comment
|
||||
*/
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["comment", "// comment"],
|
||||
["comment", "/*\r\ncomment\r\n*/"]
|
||||
]
|
|
@ -0,0 +1,15 @@
|
|||
0
|
||||
123
|
||||
.123
|
||||
21.3
|
||||
123L
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["number", "0"],
|
||||
["number", "123"],
|
||||
["number", ".123"],
|
||||
["number", "21.3"],
|
||||
["number", "123L"]
|
||||
]
|
|
@ -0,0 +1,64 @@
|
|||
=
|
||||
|
||||
+= *= -= /=
|
||||
|= &= <<= >>= >>>=
|
||||
|
||||
? :
|
||||
|
||||
&& ||
|
||||
== === < > <= >= != !==
|
||||
|
||||
+ - * / !
|
||||
++ --
|
||||
& |
|
||||
^ ^=
|
||||
<< >> >>>
|
||||
|
||||
?.
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["operator", "="],
|
||||
|
||||
["operator", "+="],
|
||||
["operator", "*="],
|
||||
["operator", "-="],
|
||||
["operator", "/="],
|
||||
["operator", "|="],
|
||||
["operator", "&="],
|
||||
["operator", "<<="],
|
||||
["operator", ">>="],
|
||||
["operator", ">>>="],
|
||||
|
||||
["operator", "?"],
|
||||
["operator", ":"],
|
||||
|
||||
["operator", "&&"],
|
||||
["operator", "||"],
|
||||
["operator", "=="],
|
||||
["operator", "==="],
|
||||
["operator", "<"],
|
||||
["operator", ">"],
|
||||
["operator", "<="],
|
||||
["operator", ">="],
|
||||
["operator", "!="],
|
||||
["operator", "!=="],
|
||||
|
||||
["operator", "+"],
|
||||
["operator", "-"],
|
||||
["operator", "*"],
|
||||
["operator", "/"],
|
||||
["operator", "!"],
|
||||
["operator", "++"],
|
||||
["operator", "--"],
|
||||
["operator", "&"],
|
||||
["operator", "|"],
|
||||
["operator", "^"],
|
||||
["operator", "^="],
|
||||
["operator", "<<"],
|
||||
["operator", ">>"],
|
||||
["operator", ">>>"],
|
||||
|
||||
["operator", "?."]
|
||||
]
|
|
@ -0,0 +1,16 @@
|
|||
( ) [ ] { }
|
||||
. , ;
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "["],
|
||||
["punctuation", "]"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", "."],
|
||||
["punctuation", ","],
|
||||
["punctuation", ";"]
|
||||
]
|
|
@ -0,0 +1,48 @@
|
|||
b = [SELECT Price__c FROM Book__c WHERE Id =:b.Id];
|
||||
return [SELECT Name FROM Contact];
|
||||
|
||||
// don't capture array indexing
|
||||
a[0].Name = 'Acme';
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
"b ",
|
||||
["operator", "="],
|
||||
["sql", [
|
||||
["punctuation", "["],
|
||||
["keyword", "SELECT"],
|
||||
" Price__c ",
|
||||
["keyword", "FROM"],
|
||||
" Book__c ",
|
||||
["keyword", "WHERE"],
|
||||
" Id ",
|
||||
["operator", "="],
|
||||
":b",
|
||||
["punctuation", "."],
|
||||
"Id",
|
||||
["punctuation", "]"]
|
||||
]],
|
||||
["punctuation", ";"],
|
||||
["keyword", "return"],
|
||||
["sql", [
|
||||
["punctuation", "["],
|
||||
["keyword", "SELECT"],
|
||||
" Name ",
|
||||
["keyword", "FROM"],
|
||||
" Contact",
|
||||
["punctuation", "]"]
|
||||
]],
|
||||
["punctuation", ";"],
|
||||
|
||||
["comment", "// don't capture array indexing"],
|
||||
"\r\na",
|
||||
["punctuation", "["],
|
||||
["number", "0"],
|
||||
["punctuation", "]"],
|
||||
["punctuation", "."],
|
||||
"Name ",
|
||||
["operator", "="],
|
||||
["string", "'Acme'"],
|
||||
["punctuation", ";"]
|
||||
]
|
|
@ -0,0 +1,13 @@
|
|||
''
|
||||
' '
|
||||
'\''
|
||||
'foo\nbar'
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["string", "''"],
|
||||
["string", "' '"],
|
||||
["string", "'\\''"],
|
||||
["string", "'foo\\nbar'"]
|
||||
]
|
|
@ -0,0 +1,39 @@
|
|||
trigger HelloWorldTrigger on Book__c (before insert) {}
|
||||
|
||||
trigger T1 on Account (before delete, after delete, after undelete) {}
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["keyword", "trigger"],
|
||||
["trigger", "HelloWorldTrigger"],
|
||||
["keyword", "on"],
|
||||
["class-name", [
|
||||
"Book__c"
|
||||
]],
|
||||
["punctuation", "("],
|
||||
["keyword", "before"],
|
||||
["keyword", "insert"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["keyword", "trigger"],
|
||||
["trigger", "T1"],
|
||||
["keyword", "on"],
|
||||
["class-name", [
|
||||
"Account"
|
||||
]],
|
||||
["punctuation", "("],
|
||||
["keyword", "before"],
|
||||
["keyword", "delete"],
|
||||
["punctuation", ","],
|
||||
["keyword", "after"],
|
||||
["keyword", "delete"],
|
||||
["punctuation", ","],
|
||||
["keyword", "after"],
|
||||
["keyword", "undelete"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"]
|
||||
]
|
Loading…
Reference in New Issue