Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/xml_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 XmlHighlightRules = function (normalize) {
5 var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*";
6 this.$rules = {
7 start: [
8 { token: "string.cdata.xml", regex: "<\\!\\[CDATA\\[", next: "cdata" },
9 {
10 token: ["punctuation.instruction.xml", "keyword.instruction.xml"],
11 regex: "(<\\?)(" + tagRegex + ")", next: "processing_instruction"
12 },
13 { token: "comment.start.xml", regex: "<\\!--", next: "comment" },
14 {
15 token: ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
16 regex: "(<\\!)(DOCTYPE)(?=[\\s])", next: "doctype", caseInsensitive: true
17 },
18 { include: "tag" },
19 { token: "text.end-tag-open.xml", regex: "</" },
20 { token: "text.tag-open.xml", regex: "<" },
21 { include: "reference" },
22 { defaultToken: "text.xml" }
23 ],
24 processing_instruction: [{
25 token: "entity.other.attribute-name.decl-attribute-name.xml",
26 regex: tagRegex
27 }, {
28 token: "keyword.operator.decl-attribute-equals.xml",
29 regex: "="
30 }, {
31 include: "whitespace"
32 }, {
33 include: "string"
34 }, {
35 token: "punctuation.xml-decl.xml",
36 regex: "\\?>",
37 next: "start"
38 }],
39 doctype: [
40 { include: "whitespace" },
41 { include: "string" },
42 { token: "xml-pe.doctype.xml", regex: ">", next: "start" },
43 { token: "xml-pe.xml", regex: "[-_a-zA-Z0-9:]+" },
44 { token: "punctuation.int-subset", regex: "\\[", push: "int_subset" }
45 ],
46 int_subset: [{
47 token: "text.xml",
48 regex: "\\s+"
49 }, {
50 token: "punctuation.int-subset.xml",
51 regex: "]",
52 next: "pop"
53 }, {
54 token: ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
55 regex: "(<\\!)(" + tagRegex + ")",
56 push: [{
57 token: "text",
58 regex: "\\s+"
59 },
60 {
61 token: "punctuation.markup-decl.xml",
62 regex: ">",
63 next: "pop"
64 },
65 { include: "string" }]
66 }],
67 cdata: [
68 { token: "string.cdata.xml", regex: "\\]\\]>", next: "start" },
69 { token: "text.xml", regex: "\\s+" },
70 { token: "text.xml", regex: "(?:[^\\]]|\\](?!\\]>))+" }
71 ],
72 comment: [
73 { token: "comment.end.xml", regex: "-->", next: "start" },
74 { defaultToken: "comment.xml" }
75 ],
76 reference: [{
77 token: "constant.language.escape.reference.xml",
78 regex: "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
79 }],
80 attr_reference: [{
81 token: "constant.language.escape.reference.attribute-value.xml",
82 regex: "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
83 }],
84 tag: [{
85 token: ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
86 regex: "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
87 next: [
88 { include: "attributes" },
89 { token: "meta.tag.punctuation.tag-close.xml", regex: "/?>", next: "start" }
90 ]
91 }],
92 tag_whitespace: [
93 { token: "text.tag-whitespace.xml", regex: "\\s+" }
94 ],
95 whitespace: [
96 { token: "text.whitespace.xml", regex: "\\s+" }
97 ],
98 string: [{
99 token: "string.xml",
100 regex: "'",
101 push: [
102 { token: "string.xml", regex: "'", next: "pop" },
103 { defaultToken: "string.xml" }
104 ]
105 }, {
106 token: "string.xml",
107 regex: '"',
108 push: [
109 { token: "string.xml", regex: '"', next: "pop" },
110 { defaultToken: "string.xml" }
111 ]
112 }],
113 attributes: [{
114 token: "entity.other.attribute-name.xml",
115 regex: tagRegex
116 }, {
117 token: "keyword.operator.attribute-equals.xml",
118 regex: "="
119 }, {
120 include: "tag_whitespace"
121 }, {
122 include: "attribute_value"
123 }],
124 attribute_value: [{
125 token: "string.attribute-value.xml",
126 regex: "'",
127 push: [
128 { token: "string.attribute-value.xml", regex: "'", next: "pop" },
129 { include: "attr_reference" },
130 { defaultToken: "string.attribute-value.xml" }
131 ]
132 }, {
133 token: "string.attribute-value.xml",
134 regex: '"',
135 push: [
136 { token: "string.attribute-value.xml", regex: '"', next: "pop" },
137 { include: "attr_reference" },
138 { defaultToken: "string.attribute-value.xml" }
139 ]
140 }]
141 };
142 if (this.constructor === XmlHighlightRules)
143 this.normalizeRules();
144 };
145 (function () {
146 this.embedTagRules = function (HighlightRules, prefix, tag) {
147 this.$rules.tag.unshift({
148 token: ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
149 regex: "(<)(" + tag + "(?=\\s|>|$))",
150 next: [
151 { include: "attributes" },
152 { token: "meta.tag.punctuation.tag-close.xml", regex: "/?>", next: prefix + "start" }
153 ]
154 });
155 this.$rules[tag + "-end"] = [
156 { include: "attributes" },
157 { token: "meta.tag.punctuation.tag-close.xml", regex: "/?>", next: "start",
158 onMatch: function (value, currentState, stack) {
159 stack.splice(0);
160 return this.token;
161 } }
162 ];
163 this.embedRules(HighlightRules, prefix, [{
164 token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
165 regex: "(</)(" + tag + "(?=\\s|>|$))",
166 next: tag + "-end"
167 }, {
168 token: "string.cdata.xml",
169 regex: "<\\!\\[CDATA\\["
170 }, {
171 token: "string.cdata.xml",
172 regex: "\\]\\]>"
173 }]);
174 };
175 }).call(TextHighlightRules.prototype);
176 oop.inherits(XmlHighlightRules, TextHighlightRules);
177 exports.XmlHighlightRules = XmlHighlightRules;
178
179 });
180
181 ace.define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module){"use strict";
182 var oop = require("../../lib/oop");
183 var Behaviour = require("../behaviour").Behaviour;
184 var TokenIterator = require("../../token_iterator").TokenIterator;
185 var lang = require("../../lib/lang");
186 function is(token, type) {
187 return token && token.type.lastIndexOf(type + ".xml") > -1;
188 }
189 var XmlBehaviour = function () {
190 this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
191 if (text == '"' || text == "'") {
192 var quote = text;
193 var selected = session.doc.getTextRange(editor.getSelectionRange());
194 if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
195 return {
196 text: quote + selected + quote,
197 selection: false
198 };
199 }
200 var cursor = editor.getCursorPosition();
201 var line = session.doc.getLine(cursor.row);
202 var rightChar = line.substring(cursor.column, cursor.column + 1);
203 var iterator = new TokenIterator(session, cursor.row, cursor.column);
204 var token = iterator.getCurrentToken();
205 if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
206 return {
207 text: "",
208 selection: [1, 1]
209 };
210 }
211 if (!token)
212 token = iterator.stepBackward();
213 if (!token)
214 return;
215 while (is(token, "tag-whitespace") || is(token, "whitespace")) {
216 token = iterator.stepBackward();
217 }
218 var rightSpace = !rightChar || rightChar.match(/\s/);
219 if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
220 return {
221 text: quote + quote,
222 selection: [1, 1]
223 };
224 }
225 }
226 });
227 this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
228 var selected = session.doc.getTextRange(range);
229 if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
230 var line = session.doc.getLine(range.start.row);
231 var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
232 if (rightChar == selected) {
233 range.end.column++;
234 return range;
235 }
236 }
237 });
238 this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
239 if (text == '>') {
240 var position = editor.getSelectionRange().start;
241 var iterator = new TokenIterator(session, position.row, position.column);
242 var token = iterator.getCurrentToken() || iterator.stepBackward();
243 if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
244 return;
245 if (is(token, "reference.attribute-value"))
246 return;
247 if (is(token, "attribute-value")) {
248 var tokenEndColumn = iterator.getCurrentTokenColumn() + token.value.length;
249 if (position.column < tokenEndColumn)
250 return;
251 if (position.column == tokenEndColumn) {
252 var nextToken = iterator.stepForward();
253 if (nextToken && is(nextToken, "attribute-value"))
254 return;
255 iterator.stepBackward();
256 }
257 }
258 if (/^\s*>/.test(session.getLine(position.row).slice(position.column)))
259 return;
260 while (!is(token, "tag-name")) {
261 token = iterator.stepBackward();
262 if (token.value == "<") {
263 token = iterator.stepForward();
264 break;
265 }
266 }
267 var tokenRow = iterator.getCurrentTokenRow();
268 var tokenColumn = iterator.getCurrentTokenColumn();
269 if (is(iterator.stepBackward(), "end-tag-open"))
270 return;
271 var element = token.value;
272 if (tokenRow == position.row)
273 element = element.substring(0, position.column - tokenColumn);
274 if (this.voidElements.hasOwnProperty(element.toLowerCase()))
275 return;
276 return {
277 text: ">" + "</" + element + ">",
278 selection: [1, 1]
279 };
280 }
281 });
282 this.add("autoindent", "insertion", function (state, action, editor, session, text) {
283 if (text == "\n") {
284 var cursor = editor.getCursorPosition();
285 var line = session.getLine(cursor.row);
286 var iterator = new TokenIterator(session, cursor.row, cursor.column);
287 var token = iterator.getCurrentToken();
288 if (token && token.type.indexOf("tag-close") !== -1) {
289 if (token.value == "/>")
290 return;
291 while (token && token.type.indexOf("tag-name") === -1) {
292 token = iterator.stepBackward();
293 }
294 if (!token) {
295 return;
296 }
297 var tag = token.value;
298 var row = iterator.getCurrentTokenRow();
299 token = iterator.stepBackward();
300 if (!token || token.type.indexOf("end-tag") !== -1) {
301 return;
302 }
303 if (this.voidElements && !this.voidElements[tag]) {
304 var nextToken = session.getTokenAt(cursor.row, cursor.column + 1);
305 var line = session.getLine(row);
306 var nextIndent = this.$getIndent(line);
307 var indent = nextIndent + session.getTabString();
308 if (nextToken && nextToken.value === "</") {
309 return {
310 text: "\n" + indent + "\n" + nextIndent,
311 selection: [1, indent.length, 1, indent.length]
312 };
313 }
314 else {
315 return {
316 text: "\n" + indent
317 };
318 }
319 }
320 }
321 }
322 });
323 };
324 oop.inherits(XmlBehaviour, Behaviour);
325 exports.XmlBehaviour = XmlBehaviour;
326
327 });
328
329 ace.define("ace/mode/folding/xml",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
330 var oop = require("../../lib/oop");
331 var Range = require("../../range").Range;
332 var BaseFoldMode = require("./fold_mode").FoldMode;
333 var FoldMode = exports.FoldMode = function (voidElements, optionalEndTags) {
334 BaseFoldMode.call(this);
335 this.voidElements = voidElements || {};
336 this.optionalEndTags = oop.mixin({}, this.voidElements);
337 if (optionalEndTags)
338 oop.mixin(this.optionalEndTags, optionalEndTags);
339 };
340 oop.inherits(FoldMode, BaseFoldMode);
341 var Tag = function () {
342 this.tagName = "";
343 this.closing = false;
344 this.selfClosing = false;
345 this.start = { row: 0, column: 0 };
346 this.end = { row: 0, column: 0 };
347 };
348 function is(token, type) {
349 return token.type.lastIndexOf(type + ".xml") > -1;
350 }
351 (function () {
352 this.getFoldWidget = function (session, foldStyle, row) {
353 var tag = this._getFirstTagInLine(session, row);
354 if (!tag)
355 return this.getCommentFoldWidget(session, row);
356 if (tag.closing || (!tag.tagName && tag.selfClosing))
357 return foldStyle === "markbeginend" ? "end" : "";
358 if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
359 return "";
360 if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
361 return "";
362 return "start";
363 };
364 this.getCommentFoldWidget = function (session, row) {
365 if (/comment/.test(session.getState(row)) && /<!-/.test(session.getLine(row)))
366 return "start";
367 return "";
368 };
369 this._getFirstTagInLine = function (session, row) {
370 var tokens = session.getTokens(row);
371 var tag = new Tag();
372 for (var i = 0; i < tokens.length; i++) {
373 var token = tokens[i];
374 if (is(token, "tag-open")) {
375 tag.end.column = tag.start.column + token.value.length;
376 tag.closing = is(token, "end-tag-open");
377 token = tokens[++i];
378 if (!token)
379 return null;
380 tag.tagName = token.value;
381 tag.end.column += token.value.length;
382 for (i++; i < tokens.length; i++) {
383 token = tokens[i];
384 tag.end.column += token.value.length;
385 if (is(token, "tag-close")) {
386 tag.selfClosing = token.value == '/>';
387 break;
388 }
389 }
390 return tag;
391 }
392 else if (is(token, "tag-close")) {
393 tag.selfClosing = token.value == '/>';
394 return tag;
395 }
396 tag.start.column += token.value.length;
397 }
398 return null;
399 };
400 this._findEndTagInLine = function (session, row, tagName, startColumn) {
401 var tokens = session.getTokens(row);
402 var column = 0;
403 for (var i = 0; i < tokens.length; i++) {
404 var token = tokens[i];
405 column += token.value.length;
406 if (column < startColumn)
407 continue;
408 if (is(token, "end-tag-open")) {
409 token = tokens[i + 1];
410 if (token && token.value == tagName)
411 return true;
412 }
413 }
414 return false;
415 };
416 this.getFoldWidgetRange = function (session, foldStyle, row) {
417 var tags = session.getMatchingTags({ row: row, column: 0 });
418 if (tags) {
419 return new Range(tags.openTag.end.row, tags.openTag.end.column, tags.closeTag.start.row, tags.closeTag.start.column);
420 }
421 else {
422 return this.getCommentFoldWidget(session, row)
423 && session.getCommentFoldRange(row, session.getLine(row).length);
424 }
425 };
426 }).call(FoldMode.prototype);
427
428 });
429
430 ace.define("ace/mode/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/xml_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/xml","ace/worker/worker_client"], function(require, exports, module){"use strict";
431 var oop = require("../lib/oop");
432 var lang = require("../lib/lang");
433 var TextMode = require("./text").Mode;
434 var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
435 var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
436 var XmlFoldMode = require("./folding/xml").FoldMode;
437 var WorkerClient = require("../worker/worker_client").WorkerClient;
438 var Mode = function () {
439 this.HighlightRules = XmlHighlightRules;
440 this.$behaviour = new XmlBehaviour();
441 this.foldingRules = new XmlFoldMode();
442 };
443 oop.inherits(Mode, TextMode);
444 (function () {
445 this.voidElements = lang.arrayToMap([]);
446 this.blockComment = { start: "<!--", end: "-->" };
447 this.createWorker = function (session) {
448 var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
449 worker.attachToDocument(session.getDocument());
450 worker.on("error", function (e) {
451 session.setAnnotations(e.data);
452 });
453 worker.on("terminate", function () {
454 session.clearAnnotations();
455 });
456 return worker;
457 };
458 this.$id = "ace/mode/xml";
459 }).call(Mode.prototype);
460 exports.Mode = Mode;
461
462 });
463
464 ace.define("ace/mode/jsdoc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
465 var oop = require("../lib/oop");
466 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
467 var JsDocCommentHighlightRules = function () {
468 this.$rules = {
469 "start": [
470 {
471 token: ["comment.doc.tag", "comment.doc.text", "lparen.doc"],
472 regex: "(@(?:param|member|typedef|property|namespace|var|const|callback))(\\s*)({)",
473 push: [
474 {
475 token: "lparen.doc",
476 regex: "{",
477 push: [
478 {
479 include: "doc-syntax"
480 }, {
481 token: "rparen.doc",
482 regex: "}|(?=$)",
483 next: "pop"
484 }
485 ]
486 }, {
487 token: ["rparen.doc", "text.doc", "variable.parameter.doc", "lparen.doc", "variable.parameter.doc", "rparen.doc"],
488 regex: /(})(\s*)(?:([\w=:\/\.]+)|(?:(\[)([\w=:\/\.]+)(\])))/,
489 next: "pop"
490 }, {
491 token: "rparen.doc",
492 regex: "}|(?=$)",
493 next: "pop"
494 }, {
495 include: "doc-syntax"
496 }, {
497 defaultToken: "text.doc"
498 }
499 ]
500 }, {
501 token: ["comment.doc.tag", "text.doc", "lparen.doc"],
502 regex: "(@(?:returns?|yields|type|this|suppress|public|protected|private|package|modifies|"
503 + "implements|external|exception|throws|enum|define|extends))(\\s*)({)",
504 push: [
505 {
506 token: "lparen.doc",
507 regex: "{",
508 push: [
509 {
510 include: "doc-syntax"
511 }, {
512 token: "rparen.doc",
513 regex: "}|(?=$)",
514 next: "pop"
515 }
516 ]
517 }, {
518 token: "rparen.doc",
519 regex: "}|(?=$)",
520 next: "pop"
521 }, {
522 include: "doc-syntax"
523 }, {
524 defaultToken: "text.doc"
525 }
526 ]
527 }, {
528 token: ["comment.doc.tag", "text.doc", "variable.parameter.doc"],
529 regex: "(@(?:alias|memberof|instance|module|name|lends|namespace|external|this|template|"
530 + "requires|param|implements|function|extends|typedef|mixes|constructor|var|"
531 + "memberof\\!|event|listens|exports|class|constructs|interface|emits|fires|"
532 + "throws|const|callback|borrows|augments))(\\s+)(\\w[\\w#\.:\/~\"\\-]*)?"
533 }, {
534 token: ["comment.doc.tag", "text.doc", "variable.parameter.doc"],
535 regex: "(@method)(\\s+)(\\w[\\w\.\\(\\)]*)"
536 }, {
537 token: "comment.doc.tag",
538 regex: "@access\\s+(?:private|public|protected)"
539 }, {
540 token: "comment.doc.tag",
541 regex: "@kind\\s+(?:class|constant|event|external|file|function|member|mixin|module|namespace|typedef)"
542 }, {
543 token: "comment.doc.tag",
544 regex: "@\\w+(?=\\s|$)"
545 },
546 JsDocCommentHighlightRules.getTagRule(),
547 {
548 defaultToken: "comment.doc",
549 caseInsensitive: true
550 }
551 ],
552 "doc-syntax": [{
553 token: "operator.doc",
554 regex: /[|:]/
555 }, {
556 token: "paren.doc",
557 regex: /[\[\]]/
558 }]
559 };
560 this.normalizeRules();
561 };
562 oop.inherits(JsDocCommentHighlightRules, TextHighlightRules);
563 JsDocCommentHighlightRules.getTagRule = function (start) {
564 return {
565 token: "comment.doc.tag.storage.type",
566 regex: "\\b(?:TODO|FIXME|XXX|HACK)\\b"
567 };
568 };
569 JsDocCommentHighlightRules.getStartRule = function (start) {
570 return {
571 token: "comment.doc", // doc comment
572 regex: "\\/\\*(?=\\*)",
573 next: start
574 };
575 };
576 JsDocCommentHighlightRules.getEndRule = function (start) {
577 return {
578 token: "comment.doc", // closing comment
579 regex: "\\*\\/",
580 next: start
581 };
582 };
583 exports.JsDocCommentHighlightRules = JsDocCommentHighlightRules;
584
585 });
586
587 ace.define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/jsdoc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
588 var oop = require("../lib/oop");
589 var DocCommentHighlightRules = require("./jsdoc_comment_highlight_rules").JsDocCommentHighlightRules;
590 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
591 var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
592 var JavaScriptHighlightRules = function (options) {
593 var keywordMapper = this.createKeywordMapper({
594 "variable.language": "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|Symbol|" + // Constructors
595 "Namespace|QName|XML|XMLList|" + // E4X
596 "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
597 "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
598 "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
599 "SyntaxError|TypeError|URIError|" +
600 "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
601 "isNaN|parseFloat|parseInt|" +
602 "JSON|Math|" + // Other
603 "this|arguments|prototype|window|document", // Pseudo
604 "keyword": "const|yield|import|get|set|async|await|" +
605 "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
606 "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
607 "__parent__|__count__|escape|unescape|with|__proto__|" +
608 "class|enum|extends|super|export|implements|private|public|interface|package|protected|static|constructor",
609 "storage.type": "const|let|var|function",
610 "constant.language": "null|Infinity|NaN|undefined",
611 "support.function": "alert",
612 "constant.language.boolean": "true|false"
613 }, "identifier");
614 var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
615 var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
616 "u[0-9a-fA-F]{4}|" + // unicode
617 "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
618 "[0-2][0-7]{0,2}|" + // oct
619 "3[0-7][0-7]?|" + // oct
620 "[4-7][0-7]?|" + //oct
621 ".)";
622 this.$rules = {
623 "no_regex": [
624 DocCommentHighlightRules.getStartRule("doc-start"),
625 comments("no_regex"),
626 {
627 token: "string",
628 regex: "'(?=.)",
629 next: "qstring"
630 }, {
631 token: "string",
632 regex: '"(?=.)',
633 next: "qqstring"
634 }, {
635 token: "constant.numeric", // hexadecimal, octal and binary
636 regex: /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
637 }, {
638 token: "constant.numeric", // decimal integers and floats
639 regex: /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
640 }, {
641 token: [
642 "storage.type", "punctuation.operator", "support.function",
643 "punctuation.operator", "entity.name.function", "text", "keyword.operator"
644 ],
645 regex: "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe + ")(\\s*)(=)",
646 next: "function_arguments"
647 }, {
648 token: [
649 "storage.type", "punctuation.operator", "entity.name.function", "text",
650 "keyword.operator", "text", "storage.type", "text", "paren.lparen"
651 ],
652 regex: "(" + identifierRe + ")(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)(function\\*?)(\\s*)(\\()",
653 next: "function_arguments"
654 }, {
655 token: [
656 "entity.name.function", "text", "keyword.operator", "text", "storage.type",
657 "text", "paren.lparen"
658 ],
659 regex: "(" + identifierRe + ")(\\s*)(=)(\\s*)(function\\*?)(\\s*)(\\()",
660 next: "function_arguments"
661 }, {
662 token: [
663 "storage.type", "punctuation.operator", "entity.name.function", "text",
664 "keyword.operator", "text",
665 "storage.type", "text", "entity.name.function", "text", "paren.lparen"
666 ],
667 regex: "(" + identifierRe + ")(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)(function\\*?)(\\s+)(\\w+)(\\s*)(\\()",
668 next: "function_arguments"
669 }, {
670 token: [
671 "storage.type", "text", "entity.name.function", "text", "paren.lparen"
672 ],
673 regex: "(function\\*?)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
674 next: "function_arguments"
675 }, {
676 token: [
677 "entity.name.function", "text", "punctuation.operator",
678 "text", "storage.type", "text", "paren.lparen"
679 ],
680 regex: "(" + identifierRe + ")(\\s*)(:)(\\s*)(function\\*?)(\\s*)(\\()",
681 next: "function_arguments"
682 }, {
683 token: [
684 "text", "text", "storage.type", "text", "paren.lparen"
685 ],
686 regex: "(:)(\\s*)(function\\*?)(\\s*)(\\()",
687 next: "function_arguments"
688 }, {
689 token: "keyword",
690 regex: "from(?=\\s*('|\"))"
691 }, {
692 token: "keyword",
693 regex: "(?:" + kwBeforeRe + ")\\b",
694 next: "start"
695 }, {
696 token: "support.constant",
697 regex: /that\b/
698 }, {
699 token: ["storage.type", "punctuation.operator", "support.function.firebug"],
700 regex: /(console)(\.)(warn|info|log|error|debug|time|trace|timeEnd|assert)\b/
701 }, {
702 token: keywordMapper,
703 regex: identifierRe
704 }, {
705 token: "punctuation.operator",
706 regex: /[.](?![.])/,
707 next: "property"
708 }, {
709 token: "storage.type",
710 regex: /=>/,
711 next: "start"
712 }, {
713 token: "keyword.operator",
714 regex: /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
715 next: "start"
716 }, {
717 token: "punctuation.operator",
718 regex: /[?:,;.]/,
719 next: "start"
720 }, {
721 token: "paren.lparen",
722 regex: /[\[({]/,
723 next: "start"
724 }, {
725 token: "paren.rparen",
726 regex: /[\])}]/
727 }, {
728 token: "comment",
729 regex: /^#!.*$/
730 }
731 ],
732 property: [{
733 token: "text",
734 regex: "\\s+"
735 }, {
736 token: [
737 "storage.type", "punctuation.operator", "entity.name.function", "text",
738 "keyword.operator", "text",
739 "storage.type", "text", "entity.name.function", "text", "paren.lparen"
740 ],
741 regex: "(" + identifierRe + ")(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)(function\\*?)(?:(\\s+)(\\w+))?(\\s*)(\\()",
742 next: "function_arguments"
743 }, {
744 token: "punctuation.operator",
745 regex: /[.](?![.])/
746 }, {
747 token: "support.function",
748 regex: /(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|lter|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward|rEach)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
749 }, {
750 token: "support.function.dom",
751 regex: /(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
752 }, {
753 token: "support.constant",
754 regex: /(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
755 }, {
756 token: "identifier",
757 regex: identifierRe
758 }, {
759 regex: "",
760 token: "empty",
761 next: "no_regex"
762 }
763 ],
764 "start": [
765 DocCommentHighlightRules.getStartRule("doc-start"),
766 comments("start"),
767 {
768 token: "string.regexp",
769 regex: "\\/",
770 next: "regex"
771 }, {
772 token: "text",
773 regex: "\\s+|^$",
774 next: "start"
775 }, {
776 token: "empty",
777 regex: "",
778 next: "no_regex"
779 }
780 ],
781 "regex": [
782 {
783 token: "regexp.keyword.operator",
784 regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
785 }, {
786 token: "string.regexp",
787 regex: "/[sxngimy]*",
788 next: "no_regex"
789 }, {
790 token: "invalid",
791 regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
792 }, {
793 token: "constant.language.escape",
794 regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
795 }, {
796 token: "constant.language.delimiter",
797 regex: /\|/
798 }, {
799 token: "constant.language.escape",
800 regex: /\[\^?/,
801 next: "regex_character_class"
802 }, {
803 token: "empty",
804 regex: "$",
805 next: "no_regex"
806 }, {
807 defaultToken: "string.regexp"
808 }
809 ],
810 "regex_character_class": [
811 {
812 token: "regexp.charclass.keyword.operator",
813 regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
814 }, {
815 token: "constant.language.escape",
816 regex: "]",
817 next: "regex"
818 }, {
819 token: "constant.language.escape",
820 regex: "-"
821 }, {
822 token: "empty",
823 regex: "$",
824 next: "no_regex"
825 }, {
826 defaultToken: "string.regexp.charachterclass"
827 }
828 ],
829 "default_parameter": [
830 {
831 token: "string",
832 regex: "'(?=.)",
833 push: [
834 {
835 token: "string",
836 regex: "'|$",
837 next: "pop"
838 }, {
839 include: "qstring"
840 }
841 ]
842 }, {
843 token: "string",
844 regex: '"(?=.)',
845 push: [
846 {
847 token: "string",
848 regex: '"|$',
849 next: "pop"
850 }, {
851 include: "qqstring"
852 }
853 ]
854 }, {
855 token: "constant.language",
856 regex: "null|Infinity|NaN|undefined"
857 }, {
858 token: "constant.numeric", // hexadecimal, octal and binary
859 regex: /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
860 }, {
861 token: "constant.numeric", // decimal integers and floats
862 regex: /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
863 }, {
864 token: "punctuation.operator",
865 regex: ",",
866 next: "function_arguments"
867 }, {
868 token: "text",
869 regex: "\\s+"
870 }, {
871 token: "punctuation.operator",
872 regex: "$"
873 }, {
874 token: "empty",
875 regex: "",
876 next: "no_regex"
877 }
878 ],
879 "function_arguments": [
880 comments("function_arguments"),
881 {
882 token: "variable.parameter",
883 regex: identifierRe
884 }, {
885 token: "punctuation.operator",
886 regex: ","
887 }, {
888 token: "text",
889 regex: "\\s+"
890 }, {
891 token: "punctuation.operator",
892 regex: "$"
893 }, {
894 token: "empty",
895 regex: "",
896 next: "no_regex"
897 }
898 ],
899 "qqstring": [
900 {
901 token: "constant.language.escape",
902 regex: escapedRe
903 }, {
904 token: "string",
905 regex: "\\\\$",
906 consumeLineEnd: true
907 }, {
908 token: "string",
909 regex: '"|$',
910 next: "no_regex"
911 }, {
912 defaultToken: "string"
913 }
914 ],
915 "qstring": [
916 {
917 token: "constant.language.escape",
918 regex: escapedRe
919 }, {
920 token: "string",
921 regex: "\\\\$",
922 consumeLineEnd: true
923 }, {
924 token: "string",
925 regex: "'|$",
926 next: "no_regex"
927 }, {
928 defaultToken: "string"
929 }
930 ]
931 };
932 if (!options || !options.noES6) {
933 this.$rules.no_regex.unshift({
934 regex: "[{}]", onMatch: function (val, state, stack) {
935 this.next = val == "{" ? this.nextState : "";
936 if (val == "{" && stack.length) {
937 stack.unshift("start", state);
938 }
939 else if (val == "}" && stack.length) {
940 stack.shift();
941 this.next = stack.shift();
942 if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
943 return "paren.quasi.end";
944 }
945 return val == "{" ? "paren.lparen" : "paren.rparen";
946 },
947 nextState: "start"
948 }, {
949 token: "string.quasi.start",
950 regex: /`/,
951 push: [{
952 token: "constant.language.escape",
953 regex: escapedRe
954 }, {
955 token: "paren.quasi.start",
956 regex: /\${/,
957 push: "start"
958 }, {
959 token: "string.quasi.end",
960 regex: /`/,
961 next: "pop"
962 }, {
963 defaultToken: "string.quasi"
964 }]
965 }, {
966 token: ["variable.parameter", "text"],
967 regex: "(" + identifierRe + ")(\\s*)(?=\\=>)"
968 }, {
969 token: "paren.lparen",
970 regex: "(\\()(?=.+\\s*=>)",
971 next: "function_arguments"
972 }, {
973 token: "variable.language",
974 regex: "(?:(?:(?:Weak)?(?:Set|Map))|Promise)\\b"
975 });
976 this.$rules["function_arguments"].unshift({
977 token: "keyword.operator",
978 regex: "=",
979 next: "default_parameter"
980 }, {
981 token: "keyword.operator",
982 regex: "\\.{3}"
983 });
984 this.$rules["property"].unshift({
985 token: "support.function",
986 regex: "(findIndex|repeat|startsWith|endsWith|includes|isSafeInteger|trunc|cbrt|log2|log10|sign|then|catch|"
987 + "finally|resolve|reject|race|any|all|allSettled|keys|entries|isInteger)\\b(?=\\()"
988 }, {
989 token: "constant.language",
990 regex: "(?:MAX_SAFE_INTEGER|MIN_SAFE_INTEGER|EPSILON)\\b"
991 });
992 if (!options || options.jsx != false)
993 JSX.call(this);
994 }
995 this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("no_regex")]);
996 this.normalizeRules();
997 };
998 oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
999 function JSX() {
1000 var tagRegex = identifierRe.replace("\\d", "\\d\\-");
1001 var jsxTag = {
1002 onMatch: function (val, state, stack) {
1003 var offset = val.charAt(1) == "/" ? 2 : 1;
1004 if (offset == 1) {
1005 if (state != this.nextState)
1006 stack.unshift(this.next, this.nextState, 0);
1007 else
1008 stack.unshift(this.next);
1009 stack[2]++;
1010 }
1011 else if (offset == 2) {
1012 if (state == this.nextState) {
1013 stack[1]--;
1014 if (!stack[1] || stack[1] < 0) {
1015 stack.shift();
1016 stack.shift();
1017 }
1018 }
1019 }
1020 return [{
1021 type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
1022 value: val.slice(0, offset)
1023 }, {
1024 type: "meta.tag.tag-name.xml",
1025 value: val.substr(offset)
1026 }];
1027 },
1028 regex: "</?" + tagRegex + "",
1029 next: "jsxAttributes",
1030 nextState: "jsx"
1031 };
1032 this.$rules.start.unshift(jsxTag);
1033 var jsxJsRule = {
1034 regex: "{",
1035 token: "paren.quasi.start",
1036 push: "start"
1037 };
1038 this.$rules.jsx = [
1039 jsxJsRule,
1040 jsxTag,
1041 { include: "reference" },
1042 { defaultToken: "string" }
1043 ];
1044 this.$rules.jsxAttributes = [{
1045 token: "meta.tag.punctuation.tag-close.xml",
1046 regex: "/?>",
1047 onMatch: function (value, currentState, stack) {
1048 if (currentState == stack[0])
1049 stack.shift();
1050 if (value.length == 2) {
1051 if (stack[0] == this.nextState)
1052 stack[1]--;
1053 if (!stack[1] || stack[1] < 0) {
1054 stack.splice(0, 2);
1055 }
1056 }
1057 this.next = stack[0] || "start";
1058 return [{ type: this.token, value: value }];
1059 },
1060 nextState: "jsx"
1061 },
1062 jsxJsRule,
1063 comments("jsxAttributes"),
1064 {
1065 token: "entity.other.attribute-name.xml",
1066 regex: tagRegex
1067 }, {
1068 token: "keyword.operator.attribute-equals.xml",
1069 regex: "="
1070 }, {
1071 token: "text.tag-whitespace.xml",
1072 regex: "\\s+"
1073 }, {
1074 token: "string.attribute-value.xml",
1075 regex: "'",
1076 stateName: "jsx_attr_q",
1077 push: [
1078 { token: "string.attribute-value.xml", regex: "'", next: "pop" },
1079 { include: "reference" },
1080 { defaultToken: "string.attribute-value.xml" }
1081 ]
1082 }, {
1083 token: "string.attribute-value.xml",
1084 regex: '"',
1085 stateName: "jsx_attr_qq",
1086 push: [
1087 { token: "string.attribute-value.xml", regex: '"', next: "pop" },
1088 { include: "reference" },
1089 { defaultToken: "string.attribute-value.xml" }
1090 ]
1091 },
1092 jsxTag
1093 ];
1094 this.$rules.reference = [{
1095 token: "constant.language.escape.reference.xml",
1096 regex: "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1097 }];
1098 }
1099 function comments(next) {
1100 return [
1101 {
1102 token: "comment", // multi line comment
1103 regex: /\/\*/,
1104 next: [
1105 DocCommentHighlightRules.getTagRule(),
1106 { token: "comment", regex: "\\*\\/", next: next || "pop" },
1107 { defaultToken: "comment", caseInsensitive: true }
1108 ]
1109 }, {
1110 token: "comment",
1111 regex: "\\/\\/",
1112 next: [
1113 DocCommentHighlightRules.getTagRule(),
1114 { token: "comment", regex: "$|^", next: next || "pop" },
1115 { defaultToken: "comment", caseInsensitive: true }
1116 ]
1117 }
1118 ];
1119 }
1120 exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
1121
1122 });
1123
1124 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
1125 var Range = require("../range").Range;
1126 var MatchingBraceOutdent = function () { };
1127 (function () {
1128 this.checkOutdent = function (line, input) {
1129 if (!/^\s+$/.test(line))
1130 return false;
1131 return /^\s*\}/.test(input);
1132 };
1133 this.autoOutdent = function (doc, row) {
1134 var line = doc.getLine(row);
1135 var match = line.match(/^(\s*\})/);
1136 if (!match)
1137 return 0;
1138 var column = match[1].length;
1139 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
1140 if (!openBracePos || openBracePos.row == row)
1141 return 0;
1142 var indent = this.$getIndent(doc.getLine(openBracePos.row));
1143 doc.replace(new Range(row, 0, row, column - 1), indent);
1144 };
1145 this.$getIndent = function (line) {
1146 return line.match(/^\s*/)[0];
1147 };
1148 }).call(MatchingBraceOutdent.prototype);
1149 exports.MatchingBraceOutdent = MatchingBraceOutdent;
1150
1151 });
1152
1153 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";
1154 var oop = require("../../lib/oop");
1155 var Range = require("../../range").Range;
1156 var BaseFoldMode = require("./fold_mode").FoldMode;
1157 var FoldMode = exports.FoldMode = function (commentRegex) {
1158 if (commentRegex) {
1159 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
1160 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
1161 }
1162 };
1163 oop.inherits(FoldMode, BaseFoldMode);
1164 (function () {
1165 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
1166 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
1167 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
1168 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
1169 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
1170 this._getFoldWidgetBase = this.getFoldWidget;
1171 this.getFoldWidget = function (session, foldStyle, row) {
1172 var line = session.getLine(row);
1173 if (this.singleLineBlockCommentRe.test(line)) {
1174 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
1175 return "";
1176 }
1177 var fw = this._getFoldWidgetBase(session, foldStyle, row);
1178 if (!fw && this.startRegionRe.test(line))
1179 return "start"; // lineCommentRegionStart
1180 return fw;
1181 };
1182 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
1183 var line = session.getLine(row);
1184 if (this.startRegionRe.test(line))
1185 return this.getCommentRegionBlock(session, line, row);
1186 var match = line.match(this.foldingStartMarker);
1187 if (match) {
1188 var i = match.index;
1189 if (match[1])
1190 return this.openingBracketBlock(session, match[1], row, i);
1191 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
1192 if (range && !range.isMultiLine()) {
1193 if (forceMultiline) {
1194 range = this.getSectionRange(session, row);
1195 }
1196 else if (foldStyle != "all")
1197 range = null;
1198 }
1199 return range;
1200 }
1201 if (foldStyle === "markbegin")
1202 return;
1203 var match = line.match(this.foldingStopMarker);
1204 if (match) {
1205 var i = match.index + match[0].length;
1206 if (match[1])
1207 return this.closingBracketBlock(session, match[1], row, i);
1208 return session.getCommentFoldRange(row, i, -1);
1209 }
1210 };
1211 this.getSectionRange = function (session, row) {
1212 var line = session.getLine(row);
1213 var startIndent = line.search(/\S/);
1214 var startRow = row;
1215 var startColumn = line.length;
1216 row = row + 1;
1217 var endRow = row;
1218 var maxRow = session.getLength();
1219 while (++row < maxRow) {
1220 line = session.getLine(row);
1221 var indent = line.search(/\S/);
1222 if (indent === -1)
1223 continue;
1224 if (startIndent > indent)
1225 break;
1226 var subRange = this.getFoldWidgetRange(session, "all", row);
1227 if (subRange) {
1228 if (subRange.start.row <= startRow) {
1229 break;
1230 }
1231 else if (subRange.isMultiLine()) {
1232 row = subRange.end.row;
1233 }
1234 else if (startIndent == indent) {
1235 break;
1236 }
1237 }
1238 endRow = row;
1239 }
1240 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
1241 };
1242 this.getCommentRegionBlock = function (session, line, row) {
1243 var startColumn = line.search(/\s*$/);
1244 var maxRow = session.getLength();
1245 var startRow = row;
1246 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
1247 var depth = 1;
1248 while (++row < maxRow) {
1249 line = session.getLine(row);
1250 var m = re.exec(line);
1251 if (!m)
1252 continue;
1253 if (m[1])
1254 depth--;
1255 else
1256 depth++;
1257 if (!depth)
1258 break;
1259 }
1260 var endRow = row;
1261 if (endRow > startRow) {
1262 return new Range(startRow, startColumn, endRow, line.length);
1263 }
1264 };
1265 }).call(FoldMode.prototype);
1266
1267 });
1268
1269 ace.define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
1270 var oop = require("../lib/oop");
1271 var TextMode = require("./text").Mode;
1272 var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1273 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
1274 var WorkerClient = require("../worker/worker_client").WorkerClient;
1275 var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
1276 var CStyleFoldMode = require("./folding/cstyle").FoldMode;
1277 var Mode = function () {
1278 this.HighlightRules = JavaScriptHighlightRules;
1279 this.$outdent = new MatchingBraceOutdent();
1280 this.$behaviour = new CstyleBehaviour();
1281 this.foldingRules = new CStyleFoldMode();
1282 };
1283 oop.inherits(Mode, TextMode);
1284 (function () {
1285 this.lineCommentStart = "//";
1286 this.blockComment = { start: "/*", end: "*/" };
1287 this.$quotes = { '"': '"', "'": "'", "`": "`" };
1288 this.$pairQuotesAfter = {
1289 "`": /\w/
1290 };
1291 this.getNextLineIndent = function (state, line, tab) {
1292 var indent = this.$getIndent(line);
1293 var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
1294 var tokens = tokenizedLine.tokens;
1295 var endState = tokenizedLine.state;
1296 if (tokens.length && tokens[tokens.length - 1].type == "comment") {
1297 return indent;
1298 }
1299 if (state == "start" || state == "no_regex") {
1300 var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
1301 if (match) {
1302 indent += tab;
1303 }
1304 }
1305 else if (state == "doc-start") {
1306 if (endState == "start" || endState == "no_regex") {
1307 return "";
1308 }
1309 var match = line.match(/^\s*(\/?)\*/);
1310 if (match) {
1311 if (match[1]) {
1312 indent += " ";
1313 }
1314 indent += "* ";
1315 }
1316 }
1317 return indent;
1318 };
1319 this.checkOutdent = function (state, line, input) {
1320 return this.$outdent.checkOutdent(line, input);
1321 };
1322 this.autoOutdent = function (state, doc, row) {
1323 this.$outdent.autoOutdent(doc, row);
1324 };
1325 this.createWorker = function (session) {
1326 var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
1327 worker.attachToDocument(session.getDocument());
1328 worker.on("annotate", function (results) {
1329 session.setAnnotations(results.data);
1330 });
1331 worker.on("terminate", function () {
1332 session.clearAnnotations();
1333 });
1334 return worker;
1335 };
1336 this.$id = "ace/mode/javascript";
1337 this.snippetFileId = "ace/snippets/javascript";
1338 }).call(Mode.prototype);
1339 exports.Mode = Mode;
1340
1341 });
1342
1343 ace.define("ace/mode/svg_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/javascript_highlight_rules","ace/mode/xml_highlight_rules"], function(require, exports, module){"use strict";
1344 var oop = require("../lib/oop");
1345 var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1346 var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
1347 var SvgHighlightRules = function () {
1348 XmlHighlightRules.call(this);
1349 this.embedTagRules(JavaScriptHighlightRules, "js-", "script");
1350 this.normalizeRules();
1351 };
1352 oop.inherits(SvgHighlightRules, XmlHighlightRules);
1353 exports.SvgHighlightRules = SvgHighlightRules;
1354
1355 });
1356
1357 ace.define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
1358 var oop = require("../../lib/oop");
1359 var BaseFoldMode = require("./fold_mode").FoldMode;
1360 var FoldMode = exports.FoldMode = function (defaultMode, subModes) {
1361 this.defaultMode = defaultMode;
1362 this.subModes = subModes;
1363 };
1364 oop.inherits(FoldMode, BaseFoldMode);
1365 (function () {
1366 this.$getMode = function (state) {
1367 if (typeof state != "string")
1368 state = state[0];
1369 for (var key in this.subModes) {
1370 if (state.indexOf(key) === 0)
1371 return this.subModes[key];
1372 }
1373 return null;
1374 };
1375 this.$tryMode = function (state, session, foldStyle, row) {
1376 var mode = this.$getMode(state);
1377 return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
1378 };
1379 this.getFoldWidget = function (session, foldStyle, row) {
1380 return (this.$tryMode(session.getState(row - 1), session, foldStyle, row) ||
1381 this.$tryMode(session.getState(row), session, foldStyle, row) ||
1382 this.defaultMode.getFoldWidget(session, foldStyle, row));
1383 };
1384 this.getFoldWidgetRange = function (session, foldStyle, row) {
1385 var mode = this.$getMode(session.getState(row - 1));
1386 if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1387 mode = this.$getMode(session.getState(row));
1388 if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1389 mode = this.defaultMode;
1390 return mode.getFoldWidgetRange(session, foldStyle, row);
1391 };
1392 }).call(FoldMode.prototype);
1393
1394 });
1395
1396 ace.define("ace/mode/svg",["require","exports","module","ace/lib/oop","ace/mode/xml","ace/mode/javascript","ace/mode/svg_highlight_rules","ace/mode/folding/mixed","ace/mode/folding/xml","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
1397 var oop = require("../lib/oop");
1398 var XmlMode = require("./xml").Mode;
1399 var JavaScriptMode = require("./javascript").Mode;
1400 var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules;
1401 var MixedFoldMode = require("./folding/mixed").FoldMode;
1402 var XmlFoldMode = require("./folding/xml").FoldMode;
1403 var CStyleFoldMode = require("./folding/cstyle").FoldMode;
1404 var Mode = function () {
1405 XmlMode.call(this);
1406 this.HighlightRules = SvgHighlightRules;
1407 this.createModeDelegates({
1408 "js-": JavaScriptMode
1409 });
1410 this.foldingRules = new MixedFoldMode(new XmlFoldMode(), {
1411 "js-": new CStyleFoldMode()
1412 });
1413 };
1414 oop.inherits(Mode, XmlMode);
1415 (function () {
1416 this.getNextLineIndent = function (state, line, tab) {
1417 return this.$getIndent(line);
1418 };
1419 this.$id = "ace/mode/svg";
1420 }).call(Mode.prototype);
1421 exports.Mode = Mode;
1422
1423 }); (function() {
1424 ace.require(["ace/mode/svg"], function(m) {
1425 if (typeof module == "object" && typeof exports == "object" && module) {
1426 module.exports = m;
1427 }
1428 });
1429 })();
1430