6373ffeee52d7649fd4d155b198644b2.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  2. var oop = require("../lib/oop");
  3. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4. var DocCommentHighlightRules = function () {
  5. this.$rules = {
  6. "start": [{
  7. token: "comment.doc.tag",
  8. regex: "@[\\w\\d_]+" // TODO: fix email addresses
  9. },
  10. DocCommentHighlightRules.getTagRule(),
  11. {
  12. defaultToken: "comment.doc",
  13. caseInsensitive: true
  14. }]
  15. };
  16. };
  17. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  18. DocCommentHighlightRules.getTagRule = function (start) {
  19. return {
  20. token: "comment.doc.tag.storage.type",
  21. regex: "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  22. };
  23. };
  24. DocCommentHighlightRules.getStartRule = function (start) {
  25. return {
  26. token: "comment.doc",
  27. regex: "\\/\\*(?=\\*)",
  28. next: start
  29. };
  30. };
  31. DocCommentHighlightRules.getEndRule = function (start) {
  32. return {
  33. token: "comment.doc",
  34. regex: "\\*\\/",
  35. next: start
  36. };
  37. };
  38. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  39. });
  40. ace.define("ace/mode/apex_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules","ace/mode/doc_comment_highlight_rules"], function(require, exports, module){"use strict";
  41. var oop = require("../lib/oop");
  42. var TextHighlightRules = require("../mode/text_highlight_rules").TextHighlightRules;
  43. var DocCommentHighlightRules = require("../mode/doc_comment_highlight_rules").DocCommentHighlightRules;
  44. var ApexHighlightRules = function () {
  45. var mainKeywordMapper = this.createKeywordMapper({
  46. "variable.language": "activate|any|autonomous|begin|bigdecimal|byte|cast|char|collect|const"
  47. + "|end|exit|export|float|goto|group|having|hint|import|inner|into|join|loop|number|object|of|outer"
  48. + "|parallel|pragma|retrieve|returning|search|short|stat|synchronized|then|this_month"
  49. + "|transaction|type|when",
  50. "keyword": "private|protected|public|native|synchronized|abstract|threadsafe|transient|static|final"
  51. + "|and|array|as|asc|break|bulk|by|catch|class|commit|continue|convertcurrency"
  52. + "|delete|desc|do|else|enum|extends|false|final|finally|for|from|future|global"
  53. + "|if|implements|in|insert|instanceof|interface|last_90_days|last_month"
  54. + "|last_n_days|last_week|like|limit|list|map|merge|new|next_90_days|next_month|next_n_days"
  55. + "|next_week|not|null|nulls|on|or|override|package|return"
  56. + "|rollback|savepoint|select|set|sort|super|testmethod|this|this_week|throw|today"
  57. + "|tolabel|tomorrow|trigger|true|try|undelete|update|upsert|using|virtual|webservice"
  58. + "|where|while|yesterday|switch|case|default",
  59. "storage.type": "def|boolean|byte|char|short|int|float|pblob|date|datetime|decimal|double|id|integer|long|string|time|void|blob|Object",
  60. "constant.language": "true|false|null|after|before|count|excludes|first|includes|last|order|sharing|with",
  61. "support.function": "system|apex|label|apexpages|userinfo|schema"
  62. }, "identifier", true);
  63. function keywordMapper(value) {
  64. if (value.slice(-3) == "__c")
  65. return "support.function";
  66. return mainKeywordMapper(value);
  67. }
  68. function string(start, options) {
  69. return {
  70. regex: start + (options.multiline ? "" : "(?=.)"),
  71. token: "string.start",
  72. next: [{
  73. regex: options.escape,
  74. token: "character.escape"
  75. }, {
  76. regex: options.error,
  77. token: "error.invalid"
  78. }, {
  79. regex: start + (options.multiline ? "" : "|$"),
  80. token: "string.end",
  81. next: options.next || "start"
  82. }, {
  83. defaultToken: "string"
  84. }]
  85. };
  86. }
  87. function comments() {
  88. return [{
  89. token: "comment",
  90. regex: "\\/\\/(?=.)",
  91. next: [
  92. DocCommentHighlightRules.getTagRule(),
  93. { token: "comment", regex: "$|^", next: "start" },
  94. { defaultToken: "comment", caseInsensitive: true }
  95. ]
  96. },
  97. DocCommentHighlightRules.getStartRule("doc-start"),
  98. {
  99. token: "comment",
  100. regex: /\/\*/,
  101. next: [
  102. DocCommentHighlightRules.getTagRule(),
  103. { token: "comment", regex: "\\*\\/", next: "start" },
  104. { defaultToken: "comment", caseInsensitive: true }
  105. ]
  106. }
  107. ];
  108. }
  109. this.$rules = {
  110. start: [
  111. string("'", {
  112. escape: /\\[nb'"\\]/,
  113. error: /\\./,
  114. multiline: false
  115. }),
  116. comments("c"),
  117. {
  118. type: "decoration",
  119. token: [
  120. "meta.package.apex",
  121. "keyword.other.package.apex",
  122. "meta.package.apex",
  123. "storage.modifier.package.apex",
  124. "meta.package.apex",
  125. "punctuation.terminator.apex"
  126. ],
  127. regex: /^(\s*)(package)\b(?:(\s*)([^ ;$]+)(\s*)((?:;)?))?/
  128. }, {
  129. regex: /@[a-zA-Z_$][a-zA-Z_$\d\u0080-\ufffe]*/,
  130. token: "constant.language"
  131. },
  132. {
  133. regex: /[a-zA-Z_$][a-zA-Z_$\d\u0080-\ufffe]*/,
  134. token: keywordMapper
  135. },
  136. {
  137. regex: "`#%",
  138. token: "error.invalid"
  139. }, {
  140. token: "constant.numeric",
  141. regex: /[+-]?\d+(?:(?:\.\d*)?(?:[LlDdEe][+-]?\d+)?)\b|\.\d+[LlDdEe]/
  142. }, {
  143. token: "keyword.operator",
  144. regex: /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
  145. next: "start"
  146. }, {
  147. token: "punctuation.operator",
  148. regex: /[?:,;.]/,
  149. next: "start"
  150. }, {
  151. token: "paren.lparen",
  152. regex: /[\[]/,
  153. next: "maybe_soql",
  154. merge: false
  155. }, {
  156. token: "paren.lparen",
  157. regex: /[\[({]/,
  158. next: "start",
  159. merge: false
  160. }, {
  161. token: "paren.rparen",
  162. regex: /[\])}]/,
  163. merge: false
  164. }
  165. ],
  166. maybe_soql: [{
  167. regex: /\s+/,
  168. token: "text"
  169. }, {
  170. regex: /(SELECT|FIND)\b/,
  171. token: "keyword",
  172. caseInsensitive: true,
  173. next: "soql"
  174. }, {
  175. regex: "",
  176. token: "none",
  177. next: "start"
  178. }],
  179. soql: [{
  180. regex: "(:?ASC|BY|CATEGORY|CUBE|DATA|DESC|END|FIND|FIRST|FOR|FROM|GROUP|HAVING|IN|LAST"
  181. + "|LIMIT|NETWORK|NULLS|OFFSET|ORDER|REFERENCE|RETURNING|ROLLUP|SCOPE|SELECT"
  182. + "|SNIPPET|TRACKING|TYPEOF|UPDATE|USING|VIEW|VIEWSTAT|WHERE|WITH|AND|OR)\\b",
  183. token: "keyword",
  184. caseInsensitive: true
  185. }, {
  186. regex: "(:?target_length|toLabel|convertCurrency|count|Contact|Account|User|FIELDS)\\b",
  187. token: "support.function",
  188. caseInsensitive: true
  189. }, {
  190. token: "paren.rparen",
  191. regex: /[\]]/,
  192. next: "start",
  193. merge: false
  194. },
  195. string("'", {
  196. escape: /\\[nb'"\\]/,
  197. error: /\\./,
  198. multiline: false,
  199. next: "soql"
  200. }),
  201. string('"', {
  202. escape: /\\[nb'"\\]/,
  203. error: /\\./,
  204. multiline: false,
  205. next: "soql"
  206. }),
  207. {
  208. regex: /\\./,
  209. token: "character.escape"
  210. },
  211. {
  212. regex: /[\?\&\|\!\{\}\[\]\(\)\^\~\*\:\"\'\+\-\,\.=\\\/]/,
  213. token: "keyword.operator"
  214. }],
  215. "log-start": [{
  216. token: "timestamp.invisible",
  217. regex: /^[\d:.() ]+\|/,
  218. next: "log-header"
  219. }, {
  220. token: "timestamp.invisible",
  221. regex: /^ (Number of|Maximum)[^:]*:/,
  222. next: "log-comment"
  223. }, {
  224. token: "invisible",
  225. regex: /^Execute Anonymous:/,
  226. next: "log-comment"
  227. }, {
  228. defaultToken: "text"
  229. }],
  230. "log-comment": [{
  231. token: "log-comment",
  232. regex: /.*$/,
  233. next: "log-start"
  234. }],
  235. "log-header": [{
  236. token: "timestamp.invisible",
  237. regex: /((USER_DEBUG|\[\d+\]|DEBUG)\|)+/
  238. },
  239. {
  240. token: "keyword",
  241. regex: "(?:EXECUTION_FINISHED|EXECUTION_STARTED|CODE_UNIT_STARTED"
  242. + "|CUMULATIVE_LIMIT_USAGE|LIMIT_USAGE_FOR_NS"
  243. + "|CUMULATIVE_LIMIT_USAGE_END|CODE_UNIT_FINISHED)"
  244. }, {
  245. regex: "",
  246. next: "log-start"
  247. }]
  248. };
  249. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
  250. this.normalizeRules();
  251. };
  252. oop.inherits(ApexHighlightRules, TextHighlightRules);
  253. exports.ApexHighlightRules = ApexHighlightRules;
  254. });
  255. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
  256. var oop = require("../../lib/oop");
  257. var Range = require("../../range").Range;
  258. var BaseFoldMode = require("./fold_mode").FoldMode;
  259. var FoldMode = exports.FoldMode = function (commentRegex) {
  260. if (commentRegex) {
  261. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  262. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  263. }
  264. };
  265. oop.inherits(FoldMode, BaseFoldMode);
  266. (function () {
  267. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  268. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  269. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  270. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  271. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  272. this._getFoldWidgetBase = this.getFoldWidget;
  273. this.getFoldWidget = function (session, foldStyle, row) {
  274. var line = session.getLine(row);
  275. if (this.singleLineBlockCommentRe.test(line)) {
  276. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  277. return "";
  278. }
  279. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  280. if (!fw && this.startRegionRe.test(line))
  281. return "start"; // lineCommentRegionStart
  282. return fw;
  283. };
  284. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  285. var line = session.getLine(row);
  286. if (this.startRegionRe.test(line))
  287. return this.getCommentRegionBlock(session, line, row);
  288. var match = line.match(this.foldingStartMarker);
  289. if (match) {
  290. var i = match.index;
  291. if (match[1])
  292. return this.openingBracketBlock(session, match[1], row, i);
  293. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  294. if (range && !range.isMultiLine()) {
  295. if (forceMultiline) {
  296. range = this.getSectionRange(session, row);
  297. }
  298. else if (foldStyle != "all")
  299. range = null;
  300. }
  301. return range;
  302. }
  303. if (foldStyle === "markbegin")
  304. return;
  305. var match = line.match(this.foldingStopMarker);
  306. if (match) {
  307. var i = match.index + match[0].length;
  308. if (match[1])
  309. return this.closingBracketBlock(session, match[1], row, i);
  310. return session.getCommentFoldRange(row, i, -1);
  311. }
  312. };
  313. this.getSectionRange = function (session, row) {
  314. var line = session.getLine(row);
  315. var startIndent = line.search(/\S/);
  316. var startRow = row;
  317. var startColumn = line.length;
  318. row = row + 1;
  319. var endRow = row;
  320. var maxRow = session.getLength();
  321. while (++row < maxRow) {
  322. line = session.getLine(row);
  323. var indent = line.search(/\S/);
  324. if (indent === -1)
  325. continue;
  326. if (startIndent > indent)
  327. break;
  328. var subRange = this.getFoldWidgetRange(session, "all", row);
  329. if (subRange) {
  330. if (subRange.start.row <= startRow) {
  331. break;
  332. }
  333. else if (subRange.isMultiLine()) {
  334. row = subRange.end.row;
  335. }
  336. else if (startIndent == indent) {
  337. break;
  338. }
  339. }
  340. endRow = row;
  341. }
  342. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  343. };
  344. this.getCommentRegionBlock = function (session, line, row) {
  345. var startColumn = line.search(/\s*$/);
  346. var maxRow = session.getLength();
  347. var startRow = row;
  348. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  349. var depth = 1;
  350. while (++row < maxRow) {
  351. line = session.getLine(row);
  352. var m = re.exec(line);
  353. if (!m)
  354. continue;
  355. if (m[1])
  356. depth--;
  357. else
  358. depth++;
  359. if (!depth)
  360. break;
  361. }
  362. var endRow = row;
  363. if (endRow > startRow) {
  364. return new Range(startRow, startColumn, endRow, line.length);
  365. }
  366. };
  367. }).call(FoldMode.prototype);
  368. });
  369. ace.define("ace/mode/apex",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/apex_highlight_rules","ace/mode/folding/cstyle","ace/mode/behaviour/cstyle"], function(require, exports, module){/* caption: Apex; extensions: apex,cls,trigger,tgr */
  370. "use strict";
  371. var oop = require("../lib/oop");
  372. var TextMode = require("../mode/text").Mode;
  373. var ApexHighlightRules = require("./apex_highlight_rules").ApexHighlightRules;
  374. var FoldMode = require("../mode/folding/cstyle").FoldMode;
  375. var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour;
  376. function ApexMode() {
  377. TextMode.call(this);
  378. this.HighlightRules = ApexHighlightRules;
  379. this.foldingRules = new FoldMode();
  380. this.$behaviour = new CstyleBehaviour();
  381. }
  382. oop.inherits(ApexMode, TextMode);
  383. ApexMode.prototype.lineCommentStart = "//";
  384. ApexMode.prototype.blockComment = {
  385. start: "/*",
  386. end: "*/"
  387. };
  388. exports.Mode = ApexMode;
  389. }); (function() {
  390. ace.require(["ace/mode/apex"], function(m) {
  391. if (typeof module == "object" && typeof exports == "object" && module) {
  392. module.exports = m;
  393. }
  394. });
  395. })();