Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-apex.js

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