1 | (function (Prism) {
|
---|
2 |
|
---|
3 | var keywords = /\b(?:(?:after|before)(?=\s+[a-z])|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|get(?=\s*[{};])|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|(?:inherited|with|without)\s+sharing)\b/i;
|
---|
4 |
|
---|
5 | var className = /\b(?:(?=[a-z_]\w*\s*[<\[])|(?!<keyword>))[A-Z_]\w*(?:\s*\.\s*[A-Z_]\w*)*\b(?:\s*(?:\[\s*\]|<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>))*/.source
|
---|
6 | .replace(/<keyword>/g, function () { return keywords.source; });
|
---|
7 | /** @param {string} pattern */
|
---|
8 | function insertClassName(pattern) {
|
---|
9 | return RegExp(pattern.replace(/<CLASS-NAME>/g, function () { return className; }), 'i');
|
---|
10 | }
|
---|
11 |
|
---|
12 | var classNameInside = {
|
---|
13 | 'keyword': keywords,
|
---|
14 | 'punctuation': /[()\[\]{};,:.<>]/
|
---|
15 | };
|
---|
16 |
|
---|
17 | Prism.languages.apex = {
|
---|
18 | 'comment': Prism.languages.clike.comment,
|
---|
19 | 'string': Prism.languages.clike.string,
|
---|
20 | 'sql': {
|
---|
21 | pattern: /((?:[=,({:]|\breturn)\s*)\[[^\[\]]*\]/i,
|
---|
22 | lookbehind: true,
|
---|
23 | greedy: true,
|
---|
24 | alias: 'language-sql',
|
---|
25 | inside: Prism.languages.sql
|
---|
26 | },
|
---|
27 |
|
---|
28 | 'annotation': {
|
---|
29 | pattern: /@\w+\b/,
|
---|
30 | alias: 'punctuation'
|
---|
31 | },
|
---|
32 | 'class-name': [
|
---|
33 | {
|
---|
34 | pattern: insertClassName(/(\b(?:class|enum|extends|implements|instanceof|interface|new|trigger\s+\w+\s+on)\s+)<CLASS-NAME>/.source),
|
---|
35 | lookbehind: true,
|
---|
36 | inside: classNameInside
|
---|
37 | },
|
---|
38 | {
|
---|
39 | // cast
|
---|
40 | pattern: insertClassName(/(\(\s*)<CLASS-NAME>(?=\s*\)\s*[\w(])/.source),
|
---|
41 | lookbehind: true,
|
---|
42 | inside: classNameInside
|
---|
43 | },
|
---|
44 | {
|
---|
45 | // variable/parameter declaration and return types
|
---|
46 | pattern: insertClassName(/<CLASS-NAME>(?=\s*\w+\s*[;=,(){:])/.source),
|
---|
47 | inside: classNameInside
|
---|
48 | }
|
---|
49 | ],
|
---|
50 | 'trigger': {
|
---|
51 | pattern: /(\btrigger\s+)\w+\b/i,
|
---|
52 | lookbehind: true,
|
---|
53 | alias: 'class-name'
|
---|
54 | },
|
---|
55 | 'keyword': keywords,
|
---|
56 | 'function': /\b[a-z_]\w*(?=\s*\()/i,
|
---|
57 |
|
---|
58 | 'boolean': /\b(?:false|true)\b/i,
|
---|
59 |
|
---|
60 | 'number': /(?:\B\.\d+|\b\d+(?:\.\d+|L)?)\b/i,
|
---|
61 | 'operator': /[!=](?:==?)?|\?\.?|&&|\|\||--|\+\+|[-+*/^&|]=?|:|<<?=?|>{1,3}=?/,
|
---|
62 | 'punctuation': /[()\[\]{};,.]/
|
---|
63 | };
|
---|
64 |
|
---|
65 | }(Prism));
|
---|