source: node_modules/refractor/lang/apex.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 3.1 KB
Line 
1'use strict'
2var refractorSql = require('./sql.js')
3module.exports = apex
4apex.displayName = 'apex'
5apex.aliases = []
6function apex(Prism) {
7 Prism.register(refractorSql)
8 ;(function (Prism) {
9 var keywords =
10 /\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
11 var className =
12 /\b(?:(?=[a-z_]\w*\s*[<\[])|(?!<keyword>))[A-Z_]\w*(?:\s*\.\s*[A-Z_]\w*)*\b(?:\s*(?:\[\s*\]|<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>))*/.source.replace(
13 /<keyword>/g,
14 function () {
15 return keywords.source
16 }
17 )
18 /** @param {string} pattern */
19 function insertClassName(pattern) {
20 return RegExp(
21 pattern.replace(/<CLASS-NAME>/g, function () {
22 return className
23 }),
24 'i'
25 )
26 }
27 var classNameInside = {
28 keyword: keywords,
29 punctuation: /[()\[\]{};,:.<>]/
30 }
31 Prism.languages.apex = {
32 comment: Prism.languages.clike.comment,
33 string: Prism.languages.clike.string,
34 sql: {
35 pattern: /((?:[=,({:]|\breturn)\s*)\[[^\[\]]*\]/i,
36 lookbehind: true,
37 greedy: true,
38 alias: 'language-sql',
39 inside: Prism.languages.sql
40 },
41 annotation: {
42 pattern: /@\w+\b/,
43 alias: 'punctuation'
44 },
45 'class-name': [
46 {
47 pattern: insertClassName(
48 /(\b(?:class|enum|extends|implements|instanceof|interface|new|trigger\s+\w+\s+on)\s+)<CLASS-NAME>/
49 .source
50 ),
51 lookbehind: true,
52 inside: classNameInside
53 },
54 {
55 // cast
56 pattern: insertClassName(
57 /(\(\s*)<CLASS-NAME>(?=\s*\)\s*[\w(])/.source
58 ),
59 lookbehind: true,
60 inside: classNameInside
61 },
62 {
63 // variable/parameter declaration and return types
64 pattern: insertClassName(/<CLASS-NAME>(?=\s*\w+\s*[;=,(){:])/.source),
65 inside: classNameInside
66 }
67 ],
68 trigger: {
69 pattern: /(\btrigger\s+)\w+\b/i,
70 lookbehind: true,
71 alias: 'class-name'
72 },
73 keyword: keywords,
74 function: /\b[a-z_]\w*(?=\s*\()/i,
75 boolean: /\b(?:false|true)\b/i,
76 number: /(?:\B\.\d+|\b\d+(?:\.\d+|L)?)\b/i,
77 operator:
78 /[!=](?:==?)?|\?\.?|&&|\|\||--|\+\+|[-+*/^&|]=?|:|<<?=?|>{1,3}=?/,
79 punctuation: /[()\[\]{};,.]/
80 }
81 })(Prism)
82}
Note: See TracBrowser for help on using the repository browser.