apex.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.31.1(337587859b1c171314b40503171188b6cea6a32a)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. // src/basic-languages/apex/apex.ts
  8. var conf = {
  9. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
  10. comments: {
  11. lineComment: "//",
  12. blockComment: ["/*", "*/"]
  13. },
  14. brackets: [
  15. ["{", "}"],
  16. ["[", "]"],
  17. ["(", ")"]
  18. ],
  19. autoClosingPairs: [
  20. { open: "{", close: "}" },
  21. { open: "[", close: "]" },
  22. { open: "(", close: ")" },
  23. { open: '"', close: '"' },
  24. { open: "'", close: "'" }
  25. ],
  26. surroundingPairs: [
  27. { open: "{", close: "}" },
  28. { open: "[", close: "]" },
  29. { open: "(", close: ")" },
  30. { open: '"', close: '"' },
  31. { open: "'", close: "'" },
  32. { open: "<", close: ">" }
  33. ],
  34. folding: {
  35. markers: {
  36. start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))"),
  37. end: new RegExp("^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))")
  38. }
  39. }
  40. };
  41. var keywords = [
  42. "abstract",
  43. "activate",
  44. "and",
  45. "any",
  46. "array",
  47. "as",
  48. "asc",
  49. "assert",
  50. "autonomous",
  51. "begin",
  52. "bigdecimal",
  53. "blob",
  54. "boolean",
  55. "break",
  56. "bulk",
  57. "by",
  58. "case",
  59. "cast",
  60. "catch",
  61. "char",
  62. "class",
  63. "collect",
  64. "commit",
  65. "const",
  66. "continue",
  67. "convertcurrency",
  68. "decimal",
  69. "default",
  70. "delete",
  71. "desc",
  72. "do",
  73. "double",
  74. "else",
  75. "end",
  76. "enum",
  77. "exception",
  78. "exit",
  79. "export",
  80. "extends",
  81. "false",
  82. "final",
  83. "finally",
  84. "float",
  85. "for",
  86. "from",
  87. "future",
  88. "get",
  89. "global",
  90. "goto",
  91. "group",
  92. "having",
  93. "hint",
  94. "if",
  95. "implements",
  96. "import",
  97. "in",
  98. "inner",
  99. "insert",
  100. "instanceof",
  101. "int",
  102. "interface",
  103. "into",
  104. "join",
  105. "last_90_days",
  106. "last_month",
  107. "last_n_days",
  108. "last_week",
  109. "like",
  110. "limit",
  111. "list",
  112. "long",
  113. "loop",
  114. "map",
  115. "merge",
  116. "native",
  117. "new",
  118. "next_90_days",
  119. "next_month",
  120. "next_n_days",
  121. "next_week",
  122. "not",
  123. "null",
  124. "nulls",
  125. "number",
  126. "object",
  127. "of",
  128. "on",
  129. "or",
  130. "outer",
  131. "override",
  132. "package",
  133. "parallel",
  134. "pragma",
  135. "private",
  136. "protected",
  137. "public",
  138. "retrieve",
  139. "return",
  140. "returning",
  141. "rollback",
  142. "savepoint",
  143. "search",
  144. "select",
  145. "set",
  146. "short",
  147. "sort",
  148. "stat",
  149. "static",
  150. "strictfp",
  151. "super",
  152. "switch",
  153. "synchronized",
  154. "system",
  155. "testmethod",
  156. "then",
  157. "this",
  158. "this_month",
  159. "this_week",
  160. "throw",
  161. "throws",
  162. "today",
  163. "tolabel",
  164. "tomorrow",
  165. "transaction",
  166. "transient",
  167. "trigger",
  168. "true",
  169. "try",
  170. "type",
  171. "undelete",
  172. "update",
  173. "upsert",
  174. "using",
  175. "virtual",
  176. "void",
  177. "volatile",
  178. "webservice",
  179. "when",
  180. "where",
  181. "while",
  182. "yesterday"
  183. ];
  184. var uppercaseFirstLetter = (lowercase) => lowercase.charAt(0).toUpperCase() + lowercase.substr(1);
  185. var keywordsWithCaseVariations = [];
  186. keywords.forEach((lowercase) => {
  187. keywordsWithCaseVariations.push(lowercase);
  188. keywordsWithCaseVariations.push(lowercase.toUpperCase());
  189. keywordsWithCaseVariations.push(uppercaseFirstLetter(lowercase));
  190. });
  191. var language = {
  192. defaultToken: "",
  193. tokenPostfix: ".apex",
  194. keywords: keywordsWithCaseVariations,
  195. operators: [
  196. "=",
  197. ">",
  198. "<",
  199. "!",
  200. "~",
  201. "?",
  202. ":",
  203. "==",
  204. "<=",
  205. ">=",
  206. "!=",
  207. "&&",
  208. "||",
  209. "++",
  210. "--",
  211. "+",
  212. "-",
  213. "*",
  214. "/",
  215. "&",
  216. "|",
  217. "^",
  218. "%",
  219. "<<",
  220. ">>",
  221. ">>>",
  222. "+=",
  223. "-=",
  224. "*=",
  225. "/=",
  226. "&=",
  227. "|=",
  228. "^=",
  229. "%=",
  230. "<<=",
  231. ">>=",
  232. ">>>="
  233. ],
  234. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  235. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  236. digits: /\d+(_+\d+)*/,
  237. octaldigits: /[0-7]+(_+[0-7]+)*/,
  238. binarydigits: /[0-1]+(_+[0-1]+)*/,
  239. hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
  240. tokenizer: {
  241. root: [
  242. [
  243. /[a-z_$][\w$]*/,
  244. {
  245. cases: {
  246. "@keywords": { token: "keyword.$0" },
  247. "@default": "identifier"
  248. }
  249. }
  250. ],
  251. [
  252. /[A-Z][\w\$]*/,
  253. {
  254. cases: {
  255. "@keywords": { token: "keyword.$0" },
  256. "@default": "type.identifier"
  257. }
  258. }
  259. ],
  260. { include: "@whitespace" },
  261. [/[{}()\[\]]/, "@brackets"],
  262. [/[<>](?!@symbols)/, "@brackets"],
  263. [
  264. /@symbols/,
  265. {
  266. cases: {
  267. "@operators": "delimiter",
  268. "@default": ""
  269. }
  270. }
  271. ],
  272. [/@\s*[a-zA-Z_\$][\w\$]*/, "annotation"],
  273. [/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, "number.float"],
  274. [/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, "number.float"],
  275. [/(@digits)[fFdD]/, "number.float"],
  276. [/(@digits)[lL]?/, "number"],
  277. [/[;,.]/, "delimiter"],
  278. [/"([^"\\]|\\.)*$/, "string.invalid"],
  279. [/'([^'\\]|\\.)*$/, "string.invalid"],
  280. [/"/, "string", '@string."'],
  281. [/'/, "string", "@string.'"],
  282. [/'[^\\']'/, "string"],
  283. [/(')(@escapes)(')/, ["string", "string.escape", "string"]],
  284. [/'/, "string.invalid"]
  285. ],
  286. whitespace: [
  287. [/[ \t\r\n]+/, ""],
  288. [/\/\*\*(?!\/)/, "comment.doc", "@apexdoc"],
  289. [/\/\*/, "comment", "@comment"],
  290. [/\/\/.*$/, "comment"]
  291. ],
  292. comment: [
  293. [/[^\/*]+/, "comment"],
  294. [/\*\//, "comment", "@pop"],
  295. [/[\/*]/, "comment"]
  296. ],
  297. apexdoc: [
  298. [/[^\/*]+/, "comment.doc"],
  299. [/\*\//, "comment.doc", "@pop"],
  300. [/[\/*]/, "comment.doc"]
  301. ],
  302. string: [
  303. [/[^\\"']+/, "string"],
  304. [/@escapes/, "string.escape"],
  305. [/\\./, "string.escape.invalid"],
  306. [
  307. /["']/,
  308. {
  309. cases: {
  310. "$#==$S2": { token: "string", next: "@pop" },
  311. "@default": "string"
  312. }
  313. }
  314. ]
  315. ]
  316. }
  317. };
  318. export {
  319. conf,
  320. language
  321. };