1
/* ***** BEGIN LICENSE BLOCK *****
2
* Distributed under the BSD license:
4
* Copyright (c) 2010, Ajax.org B.V.
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* * Neither the name of Ajax.org B.V. nor the
15
* names of its contributors may be used to endorse or promote products
16
* derived from this software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
* ***** END LICENSE BLOCK ***** */
31
define('ace/mode/svg', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml', 'ace/mode/javascript', 'ace/tokenizer', 'ace/mode/svg_highlight_rules', 'ace/mode/folding/mixed', 'ace/mode/folding/xml', 'ace/mode/folding/cstyle'], function(require, exports, module) {
34
var oop = require("../lib/oop");
35
var XmlMode = require("./xml").Mode;
36
var JavaScriptMode = require("./javascript").Mode;
37
var Tokenizer = require("../tokenizer").Tokenizer;
38
var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules;
39
var MixedFoldMode = require("./folding/mixed").FoldMode;
40
var XmlFoldMode = require("./folding/xml").FoldMode;
41
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
43
var Mode = function() {
46
this.highlighter = new SvgHighlightRules();
47
this.$tokenizer = new Tokenizer(this.highlighter.getRules());
49
this.$embeds = this.highlighter.getEmbeds();
50
this.createModeDelegates({
54
this.foldingRules = new MixedFoldMode(new XmlFoldMode({}), {
55
"js-": new CStyleFoldMode()
59
oop.inherits(Mode, XmlMode);
63
this.getNextLineIndent = function(state, line, tab) {
64
return this.$getIndent(line);
68
}).call(Mode.prototype);
73
define('ace/mode/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xml_highlight_rules', 'ace/mode/behaviour/xml', 'ace/mode/folding/xml'], function(require, exports, module) {
76
var oop = require("../lib/oop");
77
var TextMode = require("./text").Mode;
78
var Tokenizer = require("../tokenizer").Tokenizer;
79
var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
80
var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
81
var XmlFoldMode = require("./folding/xml").FoldMode;
83
var Mode = function() {
84
this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules());
85
this.$behaviour = new XmlBehaviour();
86
this.foldingRules = new XmlFoldMode();
89
oop.inherits(Mode, TextMode);
93
this.blockComment = {start: "<!--", end: "-->"};
95
}).call(Mode.prototype);
100
define('ace/mode/xml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
103
var oop = require("../lib/oop");
104
var xmlUtil = require("./xml_util");
105
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
107
var XmlHighlightRules = function() {
110
{token : "text", regex : "<\\!\\[CDATA\\[", next : "cdata"},
111
{token : "xml-pe", regex : "<\\?.*?\\?>"},
112
{token : "comment", regex : "<\\!--", next : "comment"},
113
{token : "xml-pe", regex : "<\\!.*?>"},
114
{token : "meta.tag", regex : "<\\/?", next : "tag"},
115
{token : "text", regex : "\\s+"},
117
token : "constant.character.entity",
118
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
123
{token : "text", regex : "\\]\\]>", next : "start"},
124
{token : "text", regex : "\\s+"},
125
{token : "text", regex : "(?:[^\\]]|\\](?!\\]>))+"}
129
{token : "comment", regex : ".*?-->", next : "start"},
130
{token : "comment", regex : ".+"}
134
xmlUtil.tag(this.$rules, "tag", "start");
137
oop.inherits(XmlHighlightRules, TextHighlightRules);
139
exports.XmlHighlightRules = XmlHighlightRules;
142
define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) {
145
function string(state) {
149
next : state + "_qqstring"
153
next : state + "_qstring"
157
function multiLineString(quote, state) {
159
{token : "string", regex : quote, next : state},
161
token : "constant.language.escape",
162
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
164
{defaultToken : "string"}
168
exports.tag = function(states, name, nextState, tagMap) {
174
token : !tagMap ? "meta.tag.tag-name" : function(value) {
176
return "meta.tag.tag-name." + tagMap[value];
178
return "meta.tag.tag-name";
180
regex : "[-_a-zA-Z0-9:]+",
181
next : name + "_embed_attribute_list"
185
next : name + "_embed_attribute_list"
188
states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list");
189
states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list");
191
states[name + "_embed_attribute_list"] = [{
192
token : "meta.tag.r",
196
token : "keyword.operator",
199
token : "entity.other.attribute-name",
200
regex : "[-_a-zA-Z0-9:]+"
202
token : "constant.numeric", // float
203
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
207
}].concat(string(name));
212
define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) {
215
var oop = require("../../lib/oop");
216
var Behaviour = require("../behaviour").Behaviour;
217
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
218
var TokenIterator = require("../../token_iterator").TokenIterator;
220
function hasType(token, type) {
222
var typeList = token.type.split('.');
223
var needleList = type.split('.');
224
needleList.forEach(function(needle){
225
if (typeList.indexOf(needle) == -1) {
233
var XmlBehaviour = function () {
235
this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour
237
this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
239
var position = editor.getCursorPosition();
240
var iterator = new TokenIterator(session, position.row, position.column);
241
var token = iterator.getCurrentToken();
242
var atCursor = false;
243
if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
245
token = iterator.stepBackward();
246
} while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
250
if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
253
var tag = token.value;
255
var tag = tag.substring(0, position.column - token.start);
259
text: '>' + '</' + tag + '>',
265
this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
267
var cursor = editor.getCursorPosition();
268
var line = session.doc.getLine(cursor.row);
269
var rightChars = line.substring(cursor.column, cursor.column + 2);
270
if (rightChars == '</') {
271
var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
272
var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
275
text: '\n' + indent + '\n' + next_indent,
276
selection: [1, indent.length, 1, indent.length]
283
oop.inherits(XmlBehaviour, Behaviour);
285
exports.XmlBehaviour = XmlBehaviour;
288
define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
291
var oop = require("../../lib/oop");
292
var Behaviour = require("../behaviour").Behaviour;
293
var TokenIterator = require("../../token_iterator").TokenIterator;
294
var lang = require("../../lib/lang");
296
var SAFE_INSERT_IN_TOKENS =
297
["text", "paren.rparen", "punctuation.operator"];
298
var SAFE_INSERT_BEFORE_TOKENS =
299
["text", "paren.rparen", "punctuation.operator", "comment"];
302
var autoInsertedBrackets = 0;
303
var autoInsertedRow = -1;
304
var autoInsertedLineEnd = "";
305
var maybeInsertedBrackets = 0;
306
var maybeInsertedRow = -1;
307
var maybeInsertedLineStart = "";
308
var maybeInsertedLineEnd = "";
310
var CstyleBehaviour = function () {
312
CstyleBehaviour.isSaneInsertion = function(editor, session) {
313
var cursor = editor.getCursorPosition();
314
var iterator = new TokenIterator(session, cursor.row, cursor.column);
315
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
316
var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
317
if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
320
iterator.stepForward();
321
return iterator.getCurrentTokenRow() !== cursor.row ||
322
this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
325
CstyleBehaviour.$matchTokenType = function(token, types) {
326
return types.indexOf(token.type || token) > -1;
329
CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
330
var cursor = editor.getCursorPosition();
331
var line = session.doc.getLine(cursor.row);
332
if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
333
autoInsertedBrackets = 0;
334
autoInsertedRow = cursor.row;
335
autoInsertedLineEnd = bracket + line.substr(cursor.column);
336
autoInsertedBrackets++;
339
CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
340
var cursor = editor.getCursorPosition();
341
var line = session.doc.getLine(cursor.row);
342
if (!this.isMaybeInsertedClosing(cursor, line))
343
maybeInsertedBrackets = 0;
344
maybeInsertedRow = cursor.row;
345
maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
346
maybeInsertedLineEnd = line.substr(cursor.column);
347
maybeInsertedBrackets++;
350
CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
351
return autoInsertedBrackets > 0 &&
352
cursor.row === autoInsertedRow &&
353
bracket === autoInsertedLineEnd[0] &&
354
line.substr(cursor.column) === autoInsertedLineEnd;
357
CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
358
return maybeInsertedBrackets > 0 &&
359
cursor.row === maybeInsertedRow &&
360
line.substr(cursor.column) === maybeInsertedLineEnd &&
361
line.substr(0, cursor.column) == maybeInsertedLineStart;
364
CstyleBehaviour.popAutoInsertedClosing = function() {
365
autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
366
autoInsertedBrackets--;
369
CstyleBehaviour.clearMaybeInsertedClosing = function() {
370
maybeInsertedBrackets = 0;
371
maybeInsertedRow = -1;
374
this.add("braces", "insertion", function (state, action, editor, session, text) {
375
var cursor = editor.getCursorPosition();
376
var line = session.doc.getLine(cursor.row);
378
var selection = editor.getSelectionRange();
379
var selected = session.doc.getTextRange(selection);
380
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
382
text: '{' + selected + '}',
385
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
386
if (/[\]\}\)]/.test(line[cursor.column])) {
387
CstyleBehaviour.recordAutoInsert(editor, session, "}");
393
CstyleBehaviour.recordMaybeInsert(editor, session, "{");
400
} else if (text == '}') {
401
var rightChar = line.substring(cursor.column, cursor.column + 1);
402
if (rightChar == '}') {
403
var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
404
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
405
CstyleBehaviour.popAutoInsertedClosing();
412
} else if (text == "\n" || text == "\r\n") {
414
if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
415
closing = lang.stringRepeat("}", maybeInsertedBrackets);
416
CstyleBehaviour.clearMaybeInsertedClosing();
418
var rightChar = line.substring(cursor.column, cursor.column + 1);
419
if (rightChar == '}' || closing !== "") {
420
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
424
var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
425
var next_indent = this.$getIndent(line);
428
text: '\n' + indent + '\n' + next_indent + closing,
429
selection: [1, indent.length, 1, indent.length]
435
this.add("braces", "deletion", function (state, action, editor, session, range) {
436
var selected = session.doc.getTextRange(range);
437
if (!range.isMultiLine() && selected == '{') {
438
var line = session.doc.getLine(range.start.row);
439
var rightChar = line.substring(range.end.column, range.end.column + 1);
440
if (rightChar == '}') {
444
maybeInsertedBrackets--;
449
this.add("parens", "insertion", function (state, action, editor, session, text) {
451
var selection = editor.getSelectionRange();
452
var selected = session.doc.getTextRange(selection);
453
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
455
text: '(' + selected + ')',
458
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
459
CstyleBehaviour.recordAutoInsert(editor, session, ")");
465
} else if (text == ')') {
466
var cursor = editor.getCursorPosition();
467
var line = session.doc.getLine(cursor.row);
468
var rightChar = line.substring(cursor.column, cursor.column + 1);
469
if (rightChar == ')') {
470
var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
471
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
472
CstyleBehaviour.popAutoInsertedClosing();
482
this.add("parens", "deletion", function (state, action, editor, session, range) {
483
var selected = session.doc.getTextRange(range);
484
if (!range.isMultiLine() && selected == '(') {
485
var line = session.doc.getLine(range.start.row);
486
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
487
if (rightChar == ')') {
494
this.add("brackets", "insertion", function (state, action, editor, session, text) {
496
var selection = editor.getSelectionRange();
497
var selected = session.doc.getTextRange(selection);
498
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
500
text: '[' + selected + ']',
503
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
504
CstyleBehaviour.recordAutoInsert(editor, session, "]");
510
} else if (text == ']') {
511
var cursor = editor.getCursorPosition();
512
var line = session.doc.getLine(cursor.row);
513
var rightChar = line.substring(cursor.column, cursor.column + 1);
514
if (rightChar == ']') {
515
var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
516
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
517
CstyleBehaviour.popAutoInsertedClosing();
527
this.add("brackets", "deletion", function (state, action, editor, session, range) {
528
var selected = session.doc.getTextRange(range);
529
if (!range.isMultiLine() && selected == '[') {
530
var line = session.doc.getLine(range.start.row);
531
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
532
if (rightChar == ']') {
539
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
540
if (text == '"' || text == "'") {
542
var selection = editor.getSelectionRange();
543
var selected = session.doc.getTextRange(selection);
544
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
546
text: quote + selected + quote,
550
var cursor = editor.getCursorPosition();
551
var line = session.doc.getLine(cursor.row);
552
var leftChar = line.substring(cursor.column-1, cursor.column);
553
if (leftChar == '\\') {
556
var tokens = session.getTokens(selection.start.row);
558
var quotepos = -1; // Track whether we're inside an open quote.
560
for (var x = 0; x < tokens.length; x++) {
562
if (token.type == "string") {
564
} else if (quotepos < 0) {
565
quotepos = token.value.indexOf(quote);
567
if ((token.value.length + col) > selection.start.column) {
570
col += tokens[x].value.length;
572
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
573
if (!CstyleBehaviour.isSaneInsertion(editor, session))
579
} else if (token && token.type === "string") {
580
var rightChar = line.substring(cursor.column, cursor.column + 1);
581
if (rightChar == quote) {
592
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
593
var selected = session.doc.getTextRange(range);
594
if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
595
var line = session.doc.getLine(range.start.row);
596
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
597
if (rightChar == selected) {
606
oop.inherits(CstyleBehaviour, Behaviour);
608
exports.CstyleBehaviour = CstyleBehaviour;
611
define('ace/mode/folding/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/range', 'ace/mode/folding/fold_mode', 'ace/token_iterator'], function(require, exports, module) {
614
var oop = require("../../lib/oop");
615
var lang = require("../../lib/lang");
616
var Range = require("../../range").Range;
617
var BaseFoldMode = require("./fold_mode").FoldMode;
618
var TokenIterator = require("../../token_iterator").TokenIterator;
620
var FoldMode = exports.FoldMode = function(voidElements) {
621
BaseFoldMode.call(this);
622
this.voidElements = voidElements || {};
624
oop.inherits(FoldMode, BaseFoldMode);
628
this.getFoldWidget = function(session, foldStyle, row) {
629
var tag = this._getFirstTagInLine(session, row);
632
return foldStyle == "markbeginend" ? "end" : "";
634
if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()])
640
if (tag.value.indexOf("/" + tag.tagName) !== -1)
646
this._getFirstTagInLine = function(session, row) {
647
var tokens = session.getTokens(row);
649
for (var i = 0; i < tokens.length; i++) {
650
var token = tokens[i];
651
if (token.type.indexOf("meta.tag") === 0)
652
value += token.value;
654
value += lang.stringRepeat(" ", token.value.length);
657
return this._parseTag(value);
660
this.tagRe = /^(\s*)(<?(\/?)([-_a-zA-Z0-9:!]*)\s*(\/?)>?)/;
661
this._parseTag = function(tag) {
663
var match = this.tagRe.exec(tag);
664
var column = this.tagRe.lastIndex || 0;
665
this.tagRe.lastIndex = 0;
669
match: match ? match[2] : "",
670
closing: match ? !!match[3] : false,
671
selfClosing: match ? !!match[5] || match[2] == "/>" : false,
672
tagName: match ? match[4] : "",
673
column: match[1] ? column + match[1].length : column
676
this._readTagForward = function(iterator) {
677
var token = iterator.getCurrentToken();
685
if (token.type.indexOf("meta.tag") === 0) {
688
row: iterator.getCurrentTokenRow(),
689
column: iterator.getCurrentTokenColumn()
692
value += token.value;
693
if (value.indexOf(">") !== -1) {
694
var tag = this._parseTag(value);
697
row: iterator.getCurrentTokenRow(),
698
column: iterator.getCurrentTokenColumn() + token.value.length
700
iterator.stepForward();
704
} while(token = iterator.stepForward());
709
this._readTagBackward = function(iterator) {
710
var token = iterator.getCurrentToken();
718
if (token.type.indexOf("meta.tag") === 0) {
721
row: iterator.getCurrentTokenRow(),
722
column: iterator.getCurrentTokenColumn() + token.value.length
725
value = token.value + value;
726
if (value.indexOf("<") !== -1) {
727
var tag = this._parseTag(value);
730
row: iterator.getCurrentTokenRow(),
731
column: iterator.getCurrentTokenColumn()
733
iterator.stepBackward();
737
} while(token = iterator.stepBackward());
742
this._pop = function(stack, tag) {
743
while (stack.length) {
745
var top = stack[stack.length-1];
746
if (!tag || top.tagName == tag.tagName) {
749
else if (this.voidElements[tag.tagName]) {
752
else if (this.voidElements[top.tagName]) {
761
this.getFoldWidgetRange = function(session, foldStyle, row) {
762
var firstTag = this._getFirstTagInLine(session, row);
767
var isBackward = firstTag.closing || firstTag.selfClosing;
772
var iterator = new TokenIterator(session, row, firstTag.column);
775
column: firstTag.column + firstTag.tagName.length + 2
777
while (tag = this._readTagForward(iterator)) {
778
if (tag.selfClosing) {
780
tag.start.column += tag.tagName.length + 2;
782
return Range.fromPoints(tag.start, tag.end);
788
this._pop(stack, tag);
789
if (stack.length == 0)
790
return Range.fromPoints(start, tag.start);
798
var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length);
801
column: firstTag.column
804
while (tag = this._readTagBackward(iterator)) {
805
if (tag.selfClosing) {
807
tag.start.column += tag.tagName.length + 2;
809
return Range.fromPoints(tag.start, tag.end);
815
this._pop(stack, tag);
816
if (stack.length == 0) {
817
tag.start.column += tag.tagName.length + 2;
818
return Range.fromPoints(tag.start, end);
829
}).call(FoldMode.prototype);
833
define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
836
var oop = require("../lib/oop");
837
var TextMode = require("./text").Mode;
838
var Tokenizer = require("../tokenizer").Tokenizer;
839
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
840
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
841
var Range = require("../range").Range;
842
var WorkerClient = require("../worker/worker_client").WorkerClient;
843
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
844
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
846
var Mode = function() {
847
this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
848
this.$outdent = new MatchingBraceOutdent();
849
this.$behaviour = new CstyleBehaviour();
850
this.foldingRules = new CStyleFoldMode();
852
oop.inherits(Mode, TextMode);
856
this.lineCommentStart = "//";
857
this.blockComment = {start: "/*", end: "*/"};
859
this.getNextLineIndent = function(state, line, tab) {
860
var indent = this.$getIndent(line);
862
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
863
var tokens = tokenizedLine.tokens;
864
var endState = tokenizedLine.state;
866
if (tokens.length && tokens[tokens.length-1].type == "comment") {
870
if (state == "start" || state == "no_regex") {
871
var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
875
} else if (state == "doc-start") {
876
if (endState == "start" || endState == "no_regex") {
879
var match = line.match(/^\s*(\/?)\*/);
891
this.checkOutdent = function(state, line, input) {
892
return this.$outdent.checkOutdent(line, input);
895
this.autoOutdent = function(state, doc, row) {
896
this.$outdent.autoOutdent(doc, row);
899
this.createWorker = function(session) {
900
var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
901
worker.attachToDocument(session.getDocument());
903
worker.on("jslint", function(results) {
904
session.setAnnotations(results.data);
907
worker.on("terminate", function() {
908
session.clearAnnotations();
914
}).call(Mode.prototype);
919
define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
922
var oop = require("../lib/oop");
923
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
924
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
926
var JavaScriptHighlightRules = function() {
927
var keywordMapper = this.createKeywordMapper({
929
"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
930
"Namespace|QName|XML|XMLList|" + // E4X
931
"ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
932
"Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
933
"Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
934
"SyntaxError|TypeError|URIError|" +
935
"decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
936
"isNaN|parseFloat|parseInt|" +
937
"JSON|Math|" + // Other
938
"this|arguments|prototype|window|document" , // Pseudo
940
"const|yield|import|get|set|" +
941
"break|case|catch|continue|default|delete|do|else|finally|for|function|" +
942
"if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
943
"__parent__|__count__|escape|unescape|with|__proto__|" +
944
"class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
946
"const|let|var|function",
948
"null|Infinity|NaN|undefined",
951
"constant.language.boolean": "true|false"
953
var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
954
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
956
var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
957
"u[0-9a-fA-F]{4}|" + // unicode
958
"[0-2][0-7]{0,2}|" + // oct
959
"3[0-6][0-7]?|" + // oct
961
"[4-7][0-7]?|" + //oct
970
DocCommentHighlightRules.getStartRule("doc-start"),
972
token : "comment", // multi line comment
984
token : "constant.numeric", // hex
985
regex : /0[xX][0-9a-fA-F]+\b/
987
token : "constant.numeric", // float
988
regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
991
"storage.type", "punctuation.operator", "support.function",
992
"punctuation.operator", "entity.name.function", "text","keyword.operator"
994
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
995
next: "function_arguments"
998
"storage.type", "punctuation.operator", "entity.name.function", "text",
999
"keyword.operator", "text", "storage.type", "text", "paren.lparen"
1001
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
1002
next: "function_arguments"
1005
"entity.name.function", "text", "keyword.operator", "text", "storage.type",
1006
"text", "paren.lparen"
1008
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
1009
next: "function_arguments"
1012
"storage.type", "punctuation.operator", "entity.name.function", "text",
1013
"keyword.operator", "text",
1014
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
1016
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
1017
next: "function_arguments"
1020
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
1022
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
1023
next: "function_arguments"
1026
"entity.name.function", "text", "punctuation.operator",
1027
"text", "storage.type", "text", "paren.lparen"
1029
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
1030
next: "function_arguments"
1033
"text", "text", "storage.type", "text", "paren.lparen"
1035
regex : "(:)(\\s*)(function)(\\s*)(\\()",
1036
next: "function_arguments"
1039
regex : "(?:" + kwBeforeRe + ")\\b",
1042
token : ["punctuation.operator", "support.function"],
1043
regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|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|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|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(?=\()/
1045
token : ["punctuation.operator", "support.function.dom"],
1046
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)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
1048
token : ["punctuation.operator", "support.constant"],
1049
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/
1051
token : ["storage.type", "punctuation.operator", "support.function.firebug"],
1052
regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
1054
token : keywordMapper,
1055
regex : identifierRe
1057
token : "keyword.operator",
1058
regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
1061
token : "punctuation.operator",
1062
regex : /\?|\:|\,|\;|\./,
1065
token : "paren.lparen",
1069
token : "paren.rparen",
1072
token : "keyword.operator",
1081
DocCommentHighlightRules.getStartRule("doc-start"),
1083
token : "comment", // multi line comment
1085
next : "comment_regex_allowed"
1088
regex : "\\/\\/.*$",
1091
token: "string.regexp",
1106
token: "regexp.keyword.operator",
1107
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
1109
token: "string.regexp",
1114
regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
1116
token : "constant.language.escape",
1117
regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?]/
1119
token : "constant.language.delimiter",
1122
token: "constant.language.escape",
1124
next: "regex_character_class",
1130
defaultToken: "string.regexp"
1133
"regex_character_class": [
1135
token: "regexp.keyword.operator",
1136
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
1138
token: "constant.language.escape",
1142
token: "constant.language.escape",
1149
defaultToken: "string.regexp.charachterclass"
1152
"function_arguments": [
1154
token: "variable.parameter",
1157
token: "punctuation.operator",
1160
token: "punctuation.operator",
1168
"comment_regex_allowed" : [
1169
{token : "comment", regex : "\\*\\/", next : "start"},
1170
{defaultToken : "comment"}
1173
{token : "comment", regex : "\\*\\/", next : "no_regex"},
1174
{defaultToken : "comment"}
1178
token : "constant.language.escape",
1189
defaultToken: "string"
1194
token : "constant.language.escape",
1205
defaultToken: "string"
1210
this.embedRules(DocCommentHighlightRules, "doc-",
1211
[ DocCommentHighlightRules.getEndRule("no_regex") ]);
1214
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
1216
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
1219
define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
1222
var oop = require("../lib/oop");
1223
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1225
var DocCommentHighlightRules = function() {
1229
token : "comment.doc.tag",
1230
regex : "@[\\w\\d_]+" // TODO: fix email addresses
1232
token : "comment.doc.tag",
1233
regex : "\\bTODO\\b"
1235
defaultToken : "comment.doc"
1240
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
1242
DocCommentHighlightRules.getStartRule = function(start) {
1244
token : "comment.doc", // doc comment
1245
regex : "\\/\\*(?=\\*)",
1250
DocCommentHighlightRules.getEndRule = function (start) {
1252
token : "comment.doc", // closing comment
1259
exports.DocCommentHighlightRules = DocCommentHighlightRules;
1263
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
1266
var Range = require("../range").Range;
1268
var MatchingBraceOutdent = function() {};
1272
this.checkOutdent = function(line, input) {
1273
if (! /^\s+$/.test(line))
1276
return /^\s*\}/.test(input);
1279
this.autoOutdent = function(doc, row) {
1280
var line = doc.getLine(row);
1281
var match = line.match(/^(\s*\})/);
1283
if (!match) return 0;
1285
var column = match[1].length;
1286
var openBracePos = doc.findMatchingBracket({row: row, column: column});
1288
if (!openBracePos || openBracePos.row == row) return 0;
1290
var indent = this.$getIndent(doc.getLine(openBracePos.row));
1291
doc.replace(new Range(row, 0, row, column-1), indent);
1294
this.$getIndent = function(line) {
1295
return line.match(/^\s*/)[0];
1298
}).call(MatchingBraceOutdent.prototype);
1300
exports.MatchingBraceOutdent = MatchingBraceOutdent;
1303
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
1306
var oop = require("../../lib/oop");
1307
var Range = require("../../range").Range;
1308
var BaseFoldMode = require("./fold_mode").FoldMode;
1310
var FoldMode = exports.FoldMode = function(commentRegex) {
1312
this.foldingStartMarker = new RegExp(
1313
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
1315
this.foldingStopMarker = new RegExp(
1316
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
1320
oop.inherits(FoldMode, BaseFoldMode);
1324
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
1325
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
1327
this.getFoldWidgetRange = function(session, foldStyle, row) {
1328
var line = session.getLine(row);
1329
var match = line.match(this.foldingStartMarker);
1331
var i = match.index;
1334
return this.openingBracketBlock(session, match[1], row, i);
1336
return session.getCommentFoldRange(row, i + match[0].length, 1);
1339
if (foldStyle !== "markbeginend")
1342
var match = line.match(this.foldingStopMarker);
1344
var i = match.index + match[0].length;
1347
return this.closingBracketBlock(session, match[1], row, i);
1349
return session.getCommentFoldRange(row, i, -1);
1353
}).call(FoldMode.prototype);
1357
define('ace/mode/svg_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_highlight_rules', 'ace/mode/xml_util'], function(require, exports, module) {
1360
var oop = require("../lib/oop");
1361
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1362
var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
1363
var xmlUtil = require("./xml_util");
1365
var SvgHighlightRules = function() {
1366
XmlHighlightRules.call(this);
1368
this.$rules.start.splice(3, 0, {
1370
regex : "<(?=script)",
1374
xmlUtil.tag(this.$rules, "script", "js-start");
1376
this.embedRules(JavaScriptHighlightRules, "js-", [{
1378
regex: "\\/\\/.*(?=<\\/script>)",
1382
regex: "<\\/(?=script)",
1387
oop.inherits(SvgHighlightRules, XmlHighlightRules);
1389
exports.SvgHighlightRules = SvgHighlightRules;
1392
define('ace/mode/folding/mixed', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
1395
var oop = require("../../lib/oop");
1396
var BaseFoldMode = require("./fold_mode").FoldMode;
1398
var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
1399
this.defaultMode = defaultMode;
1400
this.subModes = subModes;
1402
oop.inherits(FoldMode, BaseFoldMode);
1407
this.$getMode = function(state) {
1408
for (var key in this.subModes) {
1409
if (state.indexOf(key) === 0)
1410
return this.subModes[key];
1415
this.$tryMode = function(state, session, foldStyle, row) {
1416
var mode = this.$getMode(state);
1417
return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
1420
this.getFoldWidget = function(session, foldStyle, row) {
1422
this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
1423
this.$tryMode(session.getState(row), session, foldStyle, row) ||
1424
this.defaultMode.getFoldWidget(session, foldStyle, row)
1428
this.getFoldWidgetRange = function(session, foldStyle, row) {
1429
var mode = this.$getMode(session.getState(row-1));
1431
if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1432
mode = this.$getMode(session.getState(row));
1434
if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1435
mode = this.defaultMode;
1437
return mode.getFoldWidgetRange(session, foldStyle, row);
1440
}).call(FoldMode.prototype);