Projekt

Obecné

Profil

Stáhnout (57.7 KB) Statistiky
| Větev: | Tag: | Revize:
1
ace.define("ace/mode/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
2
"use strict";
3

    
4
var oop = require("../lib/oop");
5
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
6

    
7
var XmlHighlightRules = function(normalize) {
8
    var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*";
9

    
10
    this.$rules = {
11
        start : [
12
            {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
13
            {
14
                token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
15
                regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction"
16
            },
17
            {token : "comment.start.xml", regex : "<\\!--", next : "comment"},
18
            {
19
                token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
20
                regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
21
            },
22
            {include : "tag"},
23
            {token : "text.end-tag-open.xml", regex: "</"},
24
            {token : "text.tag-open.xml", regex: "<"},
25
            {include : "reference"},
26
            {defaultToken : "text.xml"}
27
        ],
28

    
29
        processing_instruction : [{
30
            token : "entity.other.attribute-name.decl-attribute-name.xml",
31
            regex : tagRegex
32
        }, {
33
            token : "keyword.operator.decl-attribute-equals.xml",
34
            regex : "="
35
        }, {
36
            include: "whitespace"
37
        }, {
38
            include: "string"
39
        }, {
40
            token : "punctuation.xml-decl.xml",
41
            regex : "\\?>",
42
            next : "start"
43
        }],
44

    
45
        doctype : [
46
            {include : "whitespace"},
47
            {include : "string"},
48
            {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
49
            {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
50
            {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
51
        ],
52

    
53
        int_subset : [{
54
            token : "text.xml",
55
            regex : "\\s+"
56
        }, {
57
            token: "punctuation.int-subset.xml",
58
            regex: "]",
59
            next: "pop"
60
        }, {
61
            token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
62
            regex : "(<\\!)(" + tagRegex + ")",
63
            push : [{
64
                token : "text",
65
                regex : "\\s+"
66
            },
67
            {
68
                token : "punctuation.markup-decl.xml",
69
                regex : ">",
70
                next : "pop"
71
            },
72
            {include : "string"}]
73
        }],
74

    
75
        cdata : [
76
            {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
77
            {token : "text.xml", regex : "\\s+"},
78
            {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
79
        ],
80

    
81
        comment : [
82
            {token : "comment.end.xml", regex : "-->", next : "start"},
83
            {defaultToken : "comment.xml"}
84
        ],
85

    
86
        reference : [{
87
            token : "constant.language.escape.reference.xml",
88
            regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
89
        }],
90

    
91
        attr_reference : [{
92
            token : "constant.language.escape.reference.attribute-value.xml",
93
            regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
94
        }],
95

    
96
        tag : [{
97
            token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
98
            regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
99
            next: [
100
                {include : "attributes"},
101
                {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
102
            ]
103
        }],
104

    
105
        tag_whitespace : [
106
            {token : "text.tag-whitespace.xml", regex : "\\s+"}
107
        ],
108
        whitespace : [
109
            {token : "text.whitespace.xml", regex : "\\s+"}
110
        ],
111
        string: [{
112
            token : "string.xml",
113
            regex : "'",
114
            push : [
115
                {token : "string.xml", regex: "'", next: "pop"},
116
                {defaultToken : "string.xml"}
117
            ]
118
        }, {
119
            token : "string.xml",
120
            regex : '"',
121
            push : [
122
                {token : "string.xml", regex: '"', next: "pop"},
123
                {defaultToken : "string.xml"}
124
            ]
125
        }],
126

    
127
        attributes: [{
128
            token : "entity.other.attribute-name.xml",
129
            regex : tagRegex
130
        }, {
131
            token : "keyword.operator.attribute-equals.xml",
132
            regex : "="
133
        }, {
134
            include: "tag_whitespace"
135
        }, {
136
            include: "attribute_value"
137
        }],
138

    
139
        attribute_value: [{
140
            token : "string.attribute-value.xml",
141
            regex : "'",
142
            push : [
143
                {token : "string.attribute-value.xml", regex: "'", next: "pop"},
144
                {include : "attr_reference"},
145
                {defaultToken : "string.attribute-value.xml"}
146
            ]
147
        }, {
148
            token : "string.attribute-value.xml",
149
            regex : '"',
150
            push : [
151
                {token : "string.attribute-value.xml", regex: '"', next: "pop"},
152
                {include : "attr_reference"},
153
                {defaultToken : "string.attribute-value.xml"}
154
            ]
155
        }]
156
    };
157

    
158
    if (this.constructor === XmlHighlightRules)
159
        this.normalizeRules();
160
};
161

    
162

    
163
(function() {
164

    
165
    this.embedTagRules = function(HighlightRules, prefix, tag){
166
        this.$rules.tag.unshift({
167
            token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
168
            regex : "(<)(" + tag + "(?=\\s|>|$))",
169
            next: [
170
                {include : "attributes"},
171
                {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
172
            ]
173
        });
174

    
175
        this.$rules[tag + "-end"] = [
176
            {include : "attributes"},
177
            {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>",  next: "start",
178
                onMatch : function(value, currentState, stack) {
179
                    stack.splice(0);
180
                    return this.token;
181
            }}
182
        ];
183

    
184
        this.embedRules(HighlightRules, prefix, [{
185
            token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
186
            regex : "(</)(" + tag + "(?=\\s|>|$))",
187
            next: tag + "-end"
188
        }, {
189
            token: "string.cdata.xml",
190
            regex : "<\\!\\[CDATA\\["
191
        }, {
192
            token: "string.cdata.xml",
193
            regex : "\\]\\]>"
194
        }]);
195
    };
196

    
197
}).call(TextHighlightRules.prototype);
198

    
199
oop.inherits(XmlHighlightRules, TextHighlightRules);
200

    
201
exports.XmlHighlightRules = XmlHighlightRules;
202
});
203

    
204
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) {
205
"use strict";
206

    
207
var oop = require("../../lib/oop");
208
var Behaviour = require("../behaviour").Behaviour;
209
var TokenIterator = require("../../token_iterator").TokenIterator;
210
var lang = require("../../lib/lang");
211

    
212
function is(token, type) {
213
    return token && token.type.lastIndexOf(type + ".xml") > -1;
214
}
215

    
216
var XmlBehaviour = function () {
217

    
218
    this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
219
        if (text == '"' || text == "'") {
220
            var quote = text;
221
            var selected = session.doc.getTextRange(editor.getSelectionRange());
222
            if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
223
                return {
224
                    text: quote + selected + quote,
225
                    selection: false
226
                };
227
            }
228

    
229
            var cursor = editor.getCursorPosition();
230
            var line = session.doc.getLine(cursor.row);
231
            var rightChar = line.substring(cursor.column, cursor.column + 1);
232
            var iterator = new TokenIterator(session, cursor.row, cursor.column);
233
            var token = iterator.getCurrentToken();
234

    
235
            if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
236
                return {
237
                    text: "",
238
                    selection: [1, 1]
239
                };
240
            }
241

    
242
            if (!token)
243
                token = iterator.stepBackward();
244

    
245
            if (!token)
246
                return;
247

    
248
            while (is(token, "tag-whitespace") || is(token, "whitespace")) {
249
                token = iterator.stepBackward();
250
            }
251
            var rightSpace = !rightChar || rightChar.match(/\s/);
252
            if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
253
                return {
254
                    text: quote + quote,
255
                    selection: [1, 1]
256
                };
257
            }
258
        }
259
    });
260

    
261
    this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
262
        var selected = session.doc.getTextRange(range);
263
        if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
264
            var line = session.doc.getLine(range.start.row);
265
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
266
            if (rightChar == selected) {
267
                range.end.column++;
268
                return range;
269
            }
270
        }
271
    });
272

    
273
    this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
274
        if (text == '>') {
275
            var position = editor.getSelectionRange().start;
276
            var iterator = new TokenIterator(session, position.row, position.column);
277
            var token = iterator.getCurrentToken() || iterator.stepBackward();
278
            if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
279
                return;
280
            if (is(token, "reference.attribute-value"))
281
                return;
282
            if (is(token, "attribute-value")) {
283
                var tokenEndColumn = iterator.getCurrentTokenColumn() + token.value.length;
284
                if (position.column < tokenEndColumn)
285
                    return;
286
                if (position.column == tokenEndColumn) {
287
                    var nextToken = iterator.stepForward();
288
                    if (nextToken && is(nextToken, "attribute-value"))
289
                        return;
290
                    iterator.stepBackward();
291
                }
292
            }
293
            
294
            if (/^\s*>/.test(session.getLine(position.row).slice(position.column)))
295
                return;
296
            while (!is(token, "tag-name")) {
297
                token = iterator.stepBackward();
298
                if (token.value == "<") {
299
                    token = iterator.stepForward();
300
                    break;
301
                }
302
            }
303

    
304
            var tokenRow = iterator.getCurrentTokenRow();
305
            var tokenColumn = iterator.getCurrentTokenColumn();
306
            if (is(iterator.stepBackward(), "end-tag-open"))
307
                return;
308

    
309
            var element = token.value;
310
            if (tokenRow == position.row)
311
                element = element.substring(0, position.column - tokenColumn);
312

    
313
            if (this.voidElements.hasOwnProperty(element.toLowerCase()))
314
                 return;
315

    
316
            return {
317
               text: ">" + "</" + element + ">",
318
               selection: [1, 1]
319
            };
320
        }
321
    });
322

    
323
    this.add("autoindent", "insertion", function (state, action, editor, session, text) {
324
        if (text == "\n") {
325
            var cursor = editor.getCursorPosition();
326
            var line = session.getLine(cursor.row);
327
            var iterator = new TokenIterator(session, cursor.row, cursor.column);
328
            var token = iterator.getCurrentToken();
329

    
330
            if (token && token.type.indexOf("tag-close") !== -1) {
331
                if (token.value == "/>")
332
                    return;
333
                while (token && token.type.indexOf("tag-name") === -1) {
334
                    token = iterator.stepBackward();
335
                }
336

    
337
                if (!token) {
338
                    return;
339
                }
340

    
341
                var tag = token.value;
342
                var row = iterator.getCurrentTokenRow();
343
                token = iterator.stepBackward();
344
                if (!token || token.type.indexOf("end-tag") !== -1) {
345
                    return;
346
                }
347

    
348
                if (this.voidElements && !this.voidElements[tag]) {
349
                    var nextToken = session.getTokenAt(cursor.row, cursor.column+1);
350
                    var line = session.getLine(row);
351
                    var nextIndent = this.$getIndent(line);
352
                    var indent = nextIndent + session.getTabString();
353

    
354
                    if (nextToken && nextToken.value === "</") {
355
                        return {
356
                            text: "\n" + indent + "\n" + nextIndent,
357
                            selection: [1, indent.length, 1, indent.length]
358
                        };
359
                    } else {
360
                        return {
361
                            text: "\n" + indent
362
                        };
363
                    }
364
                }
365
            }
366
        }
367
    });
368

    
369
};
370

    
371
oop.inherits(XmlBehaviour, Behaviour);
372

    
373
exports.XmlBehaviour = XmlBehaviour;
374
});
375

    
376
ace.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) {
377
"use strict";
378

    
379
var oop = require("../../lib/oop");
380
var lang = require("../../lib/lang");
381
var Range = require("../../range").Range;
382
var BaseFoldMode = require("./fold_mode").FoldMode;
383
var TokenIterator = require("../../token_iterator").TokenIterator;
384

    
385
var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
386
    BaseFoldMode.call(this);
387
    this.voidElements = voidElements || {};
388
    this.optionalEndTags = oop.mixin({}, this.voidElements);
389
    if (optionalEndTags)
390
        oop.mixin(this.optionalEndTags, optionalEndTags);
391
    
392
};
393
oop.inherits(FoldMode, BaseFoldMode);
394

    
395
var Tag = function() {
396
    this.tagName = "";
397
    this.closing = false;
398
    this.selfClosing = false;
399
    this.start = {row: 0, column: 0};
400
    this.end = {row: 0, column: 0};
401
};
402

    
403
function is(token, type) {
404
    return token.type.lastIndexOf(type + ".xml") > -1;
405
}
406

    
407
(function() {
408

    
409
    this.getFoldWidget = function(session, foldStyle, row) {
410
        var tag = this._getFirstTagInLine(session, row);
411

    
412
        if (!tag)
413
            return this.getCommentFoldWidget(session, row);
414

    
415
        if (tag.closing || (!tag.tagName && tag.selfClosing))
416
            return foldStyle == "markbeginend" ? "end" : "";
417

    
418
        if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
419
            return "";
420

    
421
        if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
422
            return "";
423

    
424
        return "start";
425
    };
426
    
427
    this.getCommentFoldWidget = function(session, row) {
428
        if (/comment/.test(session.getState(row)) && /<!-/.test(session.getLine(row)))
429
            return "start";
430
        return "";
431
    };
432
    this._getFirstTagInLine = function(session, row) {
433
        var tokens = session.getTokens(row);
434
        var tag = new Tag();
435

    
436
        for (var i = 0; i < tokens.length; i++) {
437
            var token = tokens[i];
438
            if (is(token, "tag-open")) {
439
                tag.end.column = tag.start.column + token.value.length;
440
                tag.closing = is(token, "end-tag-open");
441
                token = tokens[++i];
442
                if (!token)
443
                    return null;
444
                tag.tagName = token.value;
445
                tag.end.column += token.value.length;
446
                for (i++; i < tokens.length; i++) {
447
                    token = tokens[i];
448
                    tag.end.column += token.value.length;
449
                    if (is(token, "tag-close")) {
450
                        tag.selfClosing = token.value == '/>';
451
                        break;
452
                    }
453
                }
454
                return tag;
455
            } else if (is(token, "tag-close")) {
456
                tag.selfClosing = token.value == '/>';
457
                return tag;
458
            }
459
            tag.start.column += token.value.length;
460
        }
461

    
462
        return null;
463
    };
464

    
465
    this._findEndTagInLine = function(session, row, tagName, startColumn) {
466
        var tokens = session.getTokens(row);
467
        var column = 0;
468
        for (var i = 0; i < tokens.length; i++) {
469
            var token = tokens[i];
470
            column += token.value.length;
471
            if (column < startColumn)
472
                continue;
473
            if (is(token, "end-tag-open")) {
474
                token = tokens[i + 1];
475
                if (token && token.value == tagName)
476
                    return true;
477
            }
478
        }
479
        return false;
480
    };
481
    this._readTagForward = function(iterator) {
482
        var token = iterator.getCurrentToken();
483
        if (!token)
484
            return null;
485

    
486
        var tag = new Tag();
487
        do {
488
            if (is(token, "tag-open")) {
489
                tag.closing = is(token, "end-tag-open");
490
                tag.start.row = iterator.getCurrentTokenRow();
491
                tag.start.column = iterator.getCurrentTokenColumn();
492
            } else if (is(token, "tag-name")) {
493
                tag.tagName = token.value;
494
            } else if (is(token, "tag-close")) {
495
                tag.selfClosing = token.value == "/>";
496
                tag.end.row = iterator.getCurrentTokenRow();
497
                tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
498
                iterator.stepForward();
499
                return tag;
500
            }
501
        } while(token = iterator.stepForward());
502

    
503
        return null;
504
    };
505
    
506
    this._readTagBackward = function(iterator) {
507
        var token = iterator.getCurrentToken();
508
        if (!token)
509
            return null;
510

    
511
        var tag = new Tag();
512
        do {
513
            if (is(token, "tag-open")) {
514
                tag.closing = is(token, "end-tag-open");
515
                tag.start.row = iterator.getCurrentTokenRow();
516
                tag.start.column = iterator.getCurrentTokenColumn();
517
                iterator.stepBackward();
518
                return tag;
519
            } else if (is(token, "tag-name")) {
520
                tag.tagName = token.value;
521
            } else if (is(token, "tag-close")) {
522
                tag.selfClosing = token.value == "/>";
523
                tag.end.row = iterator.getCurrentTokenRow();
524
                tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
525
            }
526
        } while(token = iterator.stepBackward());
527

    
528
        return null;
529
    };
530
    
531
    this._pop = function(stack, tag) {
532
        while (stack.length) {
533
            
534
            var top = stack[stack.length-1];
535
            if (!tag || top.tagName == tag.tagName) {
536
                return stack.pop();
537
            }
538
            else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
539
                stack.pop();
540
                continue;
541
            } else {
542
                return null;
543
            }
544
        }
545
    };
546
    
547
    this.getFoldWidgetRange = function(session, foldStyle, row) {
548
        var firstTag = this._getFirstTagInLine(session, row);
549
        
550
        if (!firstTag) {
551
            return this.getCommentFoldWidget(session, row)
552
                && session.getCommentFoldRange(row, session.getLine(row).length);
553
        }
554
        
555
        var isBackward = firstTag.closing || firstTag.selfClosing;
556
        var stack = [];
557
        var tag;
558
        
559
        if (!isBackward) {
560
            var iterator = new TokenIterator(session, row, firstTag.start.column);
561
            var start = {
562
                row: row,
563
                column: firstTag.start.column + firstTag.tagName.length + 2
564
            };
565
            if (firstTag.start.row == firstTag.end.row)
566
                start.column = firstTag.end.column;
567
            while (tag = this._readTagForward(iterator)) {
568
                if (tag.selfClosing) {
569
                    if (!stack.length) {
570
                        tag.start.column += tag.tagName.length + 2;
571
                        tag.end.column -= 2;
572
                        return Range.fromPoints(tag.start, tag.end);
573
                    } else
574
                        continue;
575
                }
576
                
577
                if (tag.closing) {
578
                    this._pop(stack, tag);
579
                    if (stack.length == 0)
580
                        return Range.fromPoints(start, tag.start);
581
                }
582
                else {
583
                    stack.push(tag);
584
                }
585
            }
586
        }
587
        else {
588
            var iterator = new TokenIterator(session, row, firstTag.end.column);
589
            var end = {
590
                row: row,
591
                column: firstTag.start.column
592
            };
593
            
594
            while (tag = this._readTagBackward(iterator)) {
595
                if (tag.selfClosing) {
596
                    if (!stack.length) {
597
                        tag.start.column += tag.tagName.length + 2;
598
                        tag.end.column -= 2;
599
                        return Range.fromPoints(tag.start, tag.end);
600
                    } else
601
                        continue;
602
                }
603
                
604
                if (!tag.closing) {
605
                    this._pop(stack, tag);
606
                    if (stack.length == 0) {
607
                        tag.start.column += tag.tagName.length + 2;
608
                        if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
609
                            tag.start.column = tag.end.column;
610
                        return Range.fromPoints(tag.start, end);
611
                    }
612
                }
613
                else {
614
                    stack.push(tag);
615
                }
616
            }
617
        }
618
        
619
    };
620

    
621
}).call(FoldMode.prototype);
622

    
623
});
624

    
625
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) {
626
"use strict";
627

    
628
var oop = require("../lib/oop");
629
var lang = require("../lib/lang");
630
var TextMode = require("./text").Mode;
631
var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
632
var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
633
var XmlFoldMode = require("./folding/xml").FoldMode;
634
var WorkerClient = require("../worker/worker_client").WorkerClient;
635

    
636
var Mode = function() {
637
   this.HighlightRules = XmlHighlightRules;
638
   this.$behaviour = new XmlBehaviour();
639
   this.foldingRules = new XmlFoldMode();
640
};
641

    
642
oop.inherits(Mode, TextMode);
643

    
644
(function() {
645

    
646
    this.voidElements = lang.arrayToMap([]);
647

    
648
    this.blockComment = {start: "<!--", end: "-->"};
649

    
650
    this.createWorker = function(session) {
651
        var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
652
        worker.attachToDocument(session.getDocument());
653

    
654
        worker.on("error", function(e) {
655
            session.setAnnotations(e.data);
656
        });
657

    
658
        worker.on("terminate", function() {
659
            session.clearAnnotations();
660
        });
661

    
662
        return worker;
663
    };
664
    
665
    this.$id = "ace/mode/xml";
666
}).call(Mode.prototype);
667

    
668
exports.Mode = Mode;
669
});
670

    
671
ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
672
"use strict";
673

    
674
var oop = require("../lib/oop");
675
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
676

    
677
var DocCommentHighlightRules = function() {
678
    this.$rules = {
679
        "start" : [ {
680
            token : "comment.doc.tag",
681
            regex : "@[\\w\\d_]+" // TODO: fix email addresses
682
        }, 
683
        DocCommentHighlightRules.getTagRule(),
684
        {
685
            defaultToken : "comment.doc",
686
            caseInsensitive: true
687
        }]
688
    };
689
};
690

    
691
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
692

    
693
DocCommentHighlightRules.getTagRule = function(start) {
694
    return {
695
        token : "comment.doc.tag.storage.type",
696
        regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
697
    };
698
};
699

    
700
DocCommentHighlightRules.getStartRule = function(start) {
701
    return {
702
        token : "comment.doc", // doc comment
703
        regex : "\\/\\*(?=\\*)",
704
        next  : start
705
    };
706
};
707

    
708
DocCommentHighlightRules.getEndRule = function (start) {
709
    return {
710
        token : "comment.doc", // closing comment
711
        regex : "\\*\\/",
712
        next  : start
713
    };
714
};
715

    
716

    
717
exports.DocCommentHighlightRules = DocCommentHighlightRules;
718

    
719
});
720

    
721
ace.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) {
722
"use strict";
723

    
724
var oop = require("../lib/oop");
725
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
726
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
727
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
728

    
729
var JavaScriptHighlightRules = function(options) {
730
    var keywordMapper = this.createKeywordMapper({
731
        "variable.language":
732
            "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|"  + // Constructors
733
            "Namespace|QName|XML|XMLList|"                                             + // E4X
734
            "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|"   +
735
            "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|"                    +
736
            "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|"   + // Errors
737
            "SyntaxError|TypeError|URIError|"                                          +
738
            "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
739
            "isNaN|parseFloat|parseInt|"                                               +
740
            "JSON|Math|"                                                               + // Other
741
            "this|arguments|prototype|window|document"                                 , // Pseudo
742
        "keyword":
743
            "const|yield|import|get|set|async|await|" +
744
            "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
745
            "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
746
            "__parent__|__count__|escape|unescape|with|__proto__|" +
747
            "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
748
        "storage.type":
749
            "const|let|var|function",
750
        "constant.language":
751
            "null|Infinity|NaN|undefined",
752
        "support.function":
753
            "alert",
754
        "constant.language.boolean": "true|false"
755
    }, "identifier");
756
    var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
757

    
758
    var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
759
        "u[0-9a-fA-F]{4}|" + // unicode
760
        "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
761
        "[0-2][0-7]{0,2}|" + // oct
762
        "3[0-7][0-7]?|" + // oct
763
        "[4-7][0-7]?|" + //oct
764
        ".)";
765

    
766
    this.$rules = {
767
        "no_regex" : [
768
            DocCommentHighlightRules.getStartRule("doc-start"),
769
            comments("no_regex"),
770
            {
771
                token : "string",
772
                regex : "'(?=.)",
773
                next  : "qstring"
774
            }, {
775
                token : "string",
776
                regex : '"(?=.)',
777
                next  : "qqstring"
778
            }, {
779
                token : "constant.numeric", // hexadecimal, octal and binary
780
                regex : /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
781
            }, {
782
                token : "constant.numeric", // decimal integers and floats
783
                regex : /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
784
            }, {
785
                token : [
786
                    "storage.type", "punctuation.operator", "support.function",
787
                    "punctuation.operator", "entity.name.function", "text","keyword.operator"
788
                ],
789
                regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
790
                next: "function_arguments"
791
            }, {
792
                token : [
793
                    "storage.type", "punctuation.operator", "entity.name.function", "text",
794
                    "keyword.operator", "text", "storage.type", "text", "paren.lparen"
795
                ],
796
                regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
797
                next: "function_arguments"
798
            }, {
799
                token : [
800
                    "entity.name.function", "text", "keyword.operator", "text", "storage.type",
801
                    "text", "paren.lparen"
802
                ],
803
                regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
804
                next: "function_arguments"
805
            }, {
806
                token : [
807
                    "storage.type", "punctuation.operator", "entity.name.function", "text",
808
                    "keyword.operator", "text",
809
                    "storage.type", "text", "entity.name.function", "text", "paren.lparen"
810
                ],
811
                regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
812
                next: "function_arguments"
813
            }, {
814
                token : [
815
                    "storage.type", "text", "entity.name.function", "text", "paren.lparen"
816
                ],
817
                regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
818
                next: "function_arguments"
819
            }, {
820
                token : [
821
                    "entity.name.function", "text", "punctuation.operator",
822
                    "text", "storage.type", "text", "paren.lparen"
823
                ],
824
                regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
825
                next: "function_arguments"
826
            }, {
827
                token : [
828
                    "text", "text", "storage.type", "text", "paren.lparen"
829
                ],
830
                regex : "(:)(\\s*)(function)(\\s*)(\\()",
831
                next: "function_arguments"
832
            }, {
833
                token : "keyword",
834
                regex : "from(?=\\s*('|\"))"
835
            }, {
836
                token : "keyword",
837
                regex : "(?:" + kwBeforeRe + ")\\b",
838
                next : "start"
839
            }, {
840
                token : ["support.constant"],
841
                regex : /that\b/
842
            }, {
843
                token : ["storage.type", "punctuation.operator", "support.function.firebug"],
844
                regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
845
            }, {
846
                token : keywordMapper,
847
                regex : identifierRe
848
            }, {
849
                token : "punctuation.operator",
850
                regex : /[.](?![.])/,
851
                next  : "property"
852
            }, {
853
                token : "storage.type",
854
                regex : /=>/,
855
                next  : "start"
856
            }, {
857
                token : "keyword.operator",
858
                regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
859
                next  : "start"
860
            }, {
861
                token : "punctuation.operator",
862
                regex : /[?:,;.]/,
863
                next  : "start"
864
            }, {
865
                token : "paren.lparen",
866
                regex : /[\[({]/,
867
                next  : "start"
868
            }, {
869
                token : "paren.rparen",
870
                regex : /[\])}]/
871
            }, {
872
                token: "comment",
873
                regex: /^#!.*$/
874
            }
875
        ],
876
        property: [{
877
                token : "text",
878
                regex : "\\s+"
879
            }, {
880
                token : [
881
                    "storage.type", "punctuation.operator", "entity.name.function", "text",
882
                    "keyword.operator", "text",
883
                    "storage.type", "text", "entity.name.function", "text", "paren.lparen"
884
                ],
885
                regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",
886
                next: "function_arguments"
887
            }, {
888
                token : "punctuation.operator",
889
                regex : /[.](?![.])/
890
            }, {
891
                token : "support.function",
892
                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|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(?=\()/
893
            }, {
894
                token : "support.function.dom",
895
                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(?=\()/
896
            }, {
897
                token :  "support.constant",
898
                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/
899
            }, {
900
                token : "identifier",
901
                regex : identifierRe
902
            }, {
903
                regex: "",
904
                token: "empty",
905
                next: "no_regex"
906
            }
907
        ],
908
        "start": [
909
            DocCommentHighlightRules.getStartRule("doc-start"),
910
            comments("start"),
911
            {
912
                token: "string.regexp",
913
                regex: "\\/",
914
                next: "regex"
915
            }, {
916
                token : "text",
917
                regex : "\\s+|^$",
918
                next : "start"
919
            }, {
920
                token: "empty",
921
                regex: "",
922
                next: "no_regex"
923
            }
924
        ],
925
        "regex": [
926
            {
927
                token: "regexp.keyword.operator",
928
                regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
929
            }, {
930
                token: "string.regexp",
931
                regex: "/[sxngimy]*",
932
                next: "no_regex"
933
            }, {
934
                token : "invalid",
935
                regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
936
            }, {
937
                token : "constant.language.escape",
938
                regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
939
            }, {
940
                token : "constant.language.delimiter",
941
                regex: /\|/
942
            }, {
943
                token: "constant.language.escape",
944
                regex: /\[\^?/,
945
                next: "regex_character_class"
946
            }, {
947
                token: "empty",
948
                regex: "$",
949
                next: "no_regex"
950
            }, {
951
                defaultToken: "string.regexp"
952
            }
953
        ],
954
        "regex_character_class": [
955
            {
956
                token: "regexp.charclass.keyword.operator",
957
                regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
958
            }, {
959
                token: "constant.language.escape",
960
                regex: "]",
961
                next: "regex"
962
            }, {
963
                token: "constant.language.escape",
964
                regex: "-"
965
            }, {
966
                token: "empty",
967
                regex: "$",
968
                next: "no_regex"
969
            }, {
970
                defaultToken: "string.regexp.charachterclass"
971
            }
972
        ],
973
        "function_arguments": [
974
            {
975
                token: "variable.parameter",
976
                regex: identifierRe
977
            }, {
978
                token: "punctuation.operator",
979
                regex: "[, ]+"
980
            }, {
981
                token: "punctuation.operator",
982
                regex: "$"
983
            }, {
984
                token: "empty",
985
                regex: "",
986
                next: "no_regex"
987
            }
988
        ],
989
        "qqstring" : [
990
            {
991
                token : "constant.language.escape",
992
                regex : escapedRe
993
            }, {
994
                token : "string",
995
                regex : "\\\\$",
996
                consumeLineEnd  : true
997
            }, {
998
                token : "string",
999
                regex : '"|$',
1000
                next  : "no_regex"
1001
            }, {
1002
                defaultToken: "string"
1003
            }
1004
        ],
1005
        "qstring" : [
1006
            {
1007
                token : "constant.language.escape",
1008
                regex : escapedRe
1009
            }, {
1010
                token : "string",
1011
                regex : "\\\\$",
1012
                consumeLineEnd  : true
1013
            }, {
1014
                token : "string",
1015
                regex : "'|$",
1016
                next  : "no_regex"
1017
            }, {
1018
                defaultToken: "string"
1019
            }
1020
        ]
1021
    };
1022

    
1023

    
1024
    if (!options || !options.noES6) {
1025
        this.$rules.no_regex.unshift({
1026
            regex: "[{}]", onMatch: function(val, state, stack) {
1027
                this.next = val == "{" ? this.nextState : "";
1028
                if (val == "{" && stack.length) {
1029
                    stack.unshift("start", state);
1030
                }
1031
                else if (val == "}" && stack.length) {
1032
                    stack.shift();
1033
                    this.next = stack.shift();
1034
                    if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
1035
                        return "paren.quasi.end";
1036
                }
1037
                return val == "{" ? "paren.lparen" : "paren.rparen";
1038
            },
1039
            nextState: "start"
1040
        }, {
1041
            token : "string.quasi.start",
1042
            regex : /`/,
1043
            push  : [{
1044
                token : "constant.language.escape",
1045
                regex : escapedRe
1046
            }, {
1047
                token : "paren.quasi.start",
1048
                regex : /\${/,
1049
                push  : "start"
1050
            }, {
1051
                token : "string.quasi.end",
1052
                regex : /`/,
1053
                next  : "pop"
1054
            }, {
1055
                defaultToken: "string.quasi"
1056
            }]
1057
        });
1058

    
1059
        if (!options || options.jsx != false)
1060
            JSX.call(this);
1061
    }
1062

    
1063
    this.embedRules(DocCommentHighlightRules, "doc-",
1064
        [ DocCommentHighlightRules.getEndRule("no_regex") ]);
1065

    
1066
    this.normalizeRules();
1067
};
1068

    
1069
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
1070

    
1071
function JSX() {
1072
    var tagRegex = identifierRe.replace("\\d", "\\d\\-");
1073
    var jsxTag = {
1074
        onMatch : function(val, state, stack) {
1075
            var offset = val.charAt(1) == "/" ? 2 : 1;
1076
            if (offset == 1) {
1077
                if (state != this.nextState)
1078
                    stack.unshift(this.next, this.nextState, 0);
1079
                else
1080
                    stack.unshift(this.next);
1081
                stack[2]++;
1082
            } else if (offset == 2) {
1083
                if (state == this.nextState) {
1084
                    stack[1]--;
1085
                    if (!stack[1] || stack[1] < 0) {
1086
                        stack.shift();
1087
                        stack.shift();
1088
                    }
1089
                }
1090
            }
1091
            return [{
1092
                type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
1093
                value: val.slice(0, offset)
1094
            }, {
1095
                type: "meta.tag.tag-name.xml",
1096
                value: val.substr(offset)
1097
            }];
1098
        },
1099
        regex : "</?" + tagRegex + "",
1100
        next: "jsxAttributes",
1101
        nextState: "jsx"
1102
    };
1103
    this.$rules.start.unshift(jsxTag);
1104
    var jsxJsRule = {
1105
        regex: "{",
1106
        token: "paren.quasi.start",
1107
        push: "start"
1108
    };
1109
    this.$rules.jsx = [
1110
        jsxJsRule,
1111
        jsxTag,
1112
        {include : "reference"},
1113
        {defaultToken: "string"}
1114
    ];
1115
    this.$rules.jsxAttributes = [{
1116
        token : "meta.tag.punctuation.tag-close.xml",
1117
        regex : "/?>",
1118
        onMatch : function(value, currentState, stack) {
1119
            if (currentState == stack[0])
1120
                stack.shift();
1121
            if (value.length == 2) {
1122
                if (stack[0] == this.nextState)
1123
                    stack[1]--;
1124
                if (!stack[1] || stack[1] < 0) {
1125
                    stack.splice(0, 2);
1126
                }
1127
            }
1128
            this.next = stack[0] || "start";
1129
            return [{type: this.token, value: value}];
1130
        },
1131
        nextState: "jsx"
1132
    },
1133
    jsxJsRule,
1134
    comments("jsxAttributes"),
1135
    {
1136
        token : "entity.other.attribute-name.xml",
1137
        regex : tagRegex
1138
    }, {
1139
        token : "keyword.operator.attribute-equals.xml",
1140
        regex : "="
1141
    }, {
1142
        token : "text.tag-whitespace.xml",
1143
        regex : "\\s+"
1144
    }, {
1145
        token : "string.attribute-value.xml",
1146
        regex : "'",
1147
        stateName : "jsx_attr_q",
1148
        push : [
1149
            {token : "string.attribute-value.xml", regex: "'", next: "pop"},
1150
            {include : "reference"},
1151
            {defaultToken : "string.attribute-value.xml"}
1152
        ]
1153
    }, {
1154
        token : "string.attribute-value.xml",
1155
        regex : '"',
1156
        stateName : "jsx_attr_qq",
1157
        push : [
1158
            {token : "string.attribute-value.xml", regex: '"', next: "pop"},
1159
            {include : "reference"},
1160
            {defaultToken : "string.attribute-value.xml"}
1161
        ]
1162
    },
1163
    jsxTag
1164
    ];
1165
    this.$rules.reference = [{
1166
        token : "constant.language.escape.reference.xml",
1167
        regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1168
    }];
1169
}
1170

    
1171
function comments(next) {
1172
    return [
1173
        {
1174
            token : "comment", // multi line comment
1175
            regex : /\/\*/,
1176
            next: [
1177
                DocCommentHighlightRules.getTagRule(),
1178
                {token : "comment", regex : "\\*\\/", next : next || "pop"},
1179
                {defaultToken : "comment", caseInsensitive: true}
1180
            ]
1181
        }, {
1182
            token : "comment",
1183
            regex : "\\/\\/",
1184
            next: [
1185
                DocCommentHighlightRules.getTagRule(),
1186
                {token : "comment", regex : "$|^", next : next || "pop"},
1187
                {defaultToken : "comment", caseInsensitive: true}
1188
            ]
1189
        }
1190
    ];
1191
}
1192
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
1193
});
1194

    
1195
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
1196
"use strict";
1197

    
1198
var Range = require("../range").Range;
1199

    
1200
var MatchingBraceOutdent = function() {};
1201

    
1202
(function() {
1203

    
1204
    this.checkOutdent = function(line, input) {
1205
        if (! /^\s+$/.test(line))
1206
            return false;
1207

    
1208
        return /^\s*\}/.test(input);
1209
    };
1210

    
1211
    this.autoOutdent = function(doc, row) {
1212
        var line = doc.getLine(row);
1213
        var match = line.match(/^(\s*\})/);
1214

    
1215
        if (!match) return 0;
1216

    
1217
        var column = match[1].length;
1218
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
1219

    
1220
        if (!openBracePos || openBracePos.row == row) return 0;
1221

    
1222
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
1223
        doc.replace(new Range(row, 0, row, column-1), indent);
1224
    };
1225

    
1226
    this.$getIndent = function(line) {
1227
        return line.match(/^\s*/)[0];
1228
    };
1229

    
1230
}).call(MatchingBraceOutdent.prototype);
1231

    
1232
exports.MatchingBraceOutdent = MatchingBraceOutdent;
1233
});
1234

    
1235
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
1236
"use strict";
1237

    
1238
var oop = require("../../lib/oop");
1239
var Range = require("../../range").Range;
1240
var BaseFoldMode = require("./fold_mode").FoldMode;
1241

    
1242
var FoldMode = exports.FoldMode = function(commentRegex) {
1243
    if (commentRegex) {
1244
        this.foldingStartMarker = new RegExp(
1245
            this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
1246
        );
1247
        this.foldingStopMarker = new RegExp(
1248
            this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
1249
        );
1250
    }
1251
};
1252
oop.inherits(FoldMode, BaseFoldMode);
1253

    
1254
(function() {
1255
    
1256
    this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
1257
    this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
1258
    this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
1259
    this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
1260
    this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
1261
    this._getFoldWidgetBase = this.getFoldWidget;
1262
    this.getFoldWidget = function(session, foldStyle, row) {
1263
        var line = session.getLine(row);
1264
    
1265
        if (this.singleLineBlockCommentRe.test(line)) {
1266
            if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
1267
                return "";
1268
        }
1269
    
1270
        var fw = this._getFoldWidgetBase(session, foldStyle, row);
1271
    
1272
        if (!fw && this.startRegionRe.test(line))
1273
            return "start"; // lineCommentRegionStart
1274
    
1275
        return fw;
1276
    };
1277

    
1278
    this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
1279
        var line = session.getLine(row);
1280
        
1281
        if (this.startRegionRe.test(line))
1282
            return this.getCommentRegionBlock(session, line, row);
1283
        
1284
        var match = line.match(this.foldingStartMarker);
1285
        if (match) {
1286
            var i = match.index;
1287

    
1288
            if (match[1])
1289
                return this.openingBracketBlock(session, match[1], row, i);
1290
                
1291
            var range = session.getCommentFoldRange(row, i + match[0].length, 1);
1292
            
1293
            if (range && !range.isMultiLine()) {
1294
                if (forceMultiline) {
1295
                    range = this.getSectionRange(session, row);
1296
                } else if (foldStyle != "all")
1297
                    range = null;
1298
            }
1299
            
1300
            return range;
1301
        }
1302

    
1303
        if (foldStyle === "markbegin")
1304
            return;
1305

    
1306
        var match = line.match(this.foldingStopMarker);
1307
        if (match) {
1308
            var i = match.index + match[0].length;
1309

    
1310
            if (match[1])
1311
                return this.closingBracketBlock(session, match[1], row, i);
1312

    
1313
            return session.getCommentFoldRange(row, i, -1);
1314
        }
1315
    };
1316
    
1317
    this.getSectionRange = function(session, row) {
1318
        var line = session.getLine(row);
1319
        var startIndent = line.search(/\S/);
1320
        var startRow = row;
1321
        var startColumn = line.length;
1322
        row = row + 1;
1323
        var endRow = row;
1324
        var maxRow = session.getLength();
1325
        while (++row < maxRow) {
1326
            line = session.getLine(row);
1327
            var indent = line.search(/\S/);
1328
            if (indent === -1)
1329
                continue;
1330
            if  (startIndent > indent)
1331
                break;
1332
            var subRange = this.getFoldWidgetRange(session, "all", row);
1333
            
1334
            if (subRange) {
1335
                if (subRange.start.row <= startRow) {
1336
                    break;
1337
                } else if (subRange.isMultiLine()) {
1338
                    row = subRange.end.row;
1339
                } else if (startIndent == indent) {
1340
                    break;
1341
                }
1342
            }
1343
            endRow = row;
1344
        }
1345
        
1346
        return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
1347
    };
1348
    this.getCommentRegionBlock = function(session, line, row) {
1349
        var startColumn = line.search(/\s*$/);
1350
        var maxRow = session.getLength();
1351
        var startRow = row;
1352
        
1353
        var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
1354
        var depth = 1;
1355
        while (++row < maxRow) {
1356
            line = session.getLine(row);
1357
            var m = re.exec(line);
1358
            if (!m) continue;
1359
            if (m[1]) depth--;
1360
            else depth++;
1361

    
1362
            if (!depth) break;
1363
        }
1364

    
1365
        var endRow = row;
1366
        if (endRow > startRow) {
1367
            return new Range(startRow, startColumn, endRow, line.length);
1368
        }
1369
    };
1370

    
1371
}).call(FoldMode.prototype);
1372

    
1373
});
1374

    
1375
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) {
1376
"use strict";
1377

    
1378
var oop = require("../lib/oop");
1379
var TextMode = require("./text").Mode;
1380
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1381
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
1382
var WorkerClient = require("../worker/worker_client").WorkerClient;
1383
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
1384
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
1385

    
1386
var Mode = function() {
1387
    this.HighlightRules = JavaScriptHighlightRules;
1388
    
1389
    this.$outdent = new MatchingBraceOutdent();
1390
    this.$behaviour = new CstyleBehaviour();
1391
    this.foldingRules = new CStyleFoldMode();
1392
};
1393
oop.inherits(Mode, TextMode);
1394

    
1395
(function() {
1396

    
1397
    this.lineCommentStart = "//";
1398
    this.blockComment = {start: "/*", end: "*/"};
1399
    this.$quotes = {'"': '"', "'": "'", "`": "`"};
1400

    
1401
    this.getNextLineIndent = function(state, line, tab) {
1402
        var indent = this.$getIndent(line);
1403

    
1404
        var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
1405
        var tokens = tokenizedLine.tokens;
1406
        var endState = tokenizedLine.state;
1407

    
1408
        if (tokens.length && tokens[tokens.length-1].type == "comment") {
1409
            return indent;
1410
        }
1411

    
1412
        if (state == "start" || state == "no_regex") {
1413
            var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
1414
            if (match) {
1415
                indent += tab;
1416
            }
1417
        } else if (state == "doc-start") {
1418
            if (endState == "start" || endState == "no_regex") {
1419
                return "";
1420
            }
1421
            var match = line.match(/^\s*(\/?)\*/);
1422
            if (match) {
1423
                if (match[1]) {
1424
                    indent += " ";
1425
                }
1426
                indent += "* ";
1427
            }
1428
        }
1429

    
1430
        return indent;
1431
    };
1432

    
1433
    this.checkOutdent = function(state, line, input) {
1434
        return this.$outdent.checkOutdent(line, input);
1435
    };
1436

    
1437
    this.autoOutdent = function(state, doc, row) {
1438
        this.$outdent.autoOutdent(doc, row);
1439
    };
1440

    
1441
    this.createWorker = function(session) {
1442
        var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
1443
        worker.attachToDocument(session.getDocument());
1444

    
1445
        worker.on("annotate", function(results) {
1446
            session.setAnnotations(results.data);
1447
        });
1448

    
1449
        worker.on("terminate", function() {
1450
            session.clearAnnotations();
1451
        });
1452

    
1453
        return worker;
1454
    };
1455

    
1456
    this.$id = "ace/mode/javascript";
1457
    this.snippetFileId = "ace/snippets/javascript";
1458
}).call(Mode.prototype);
1459

    
1460
exports.Mode = Mode;
1461
});
1462

    
1463
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) {
1464
"use strict";
1465

    
1466
var oop = require("../lib/oop");
1467
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1468
var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
1469

    
1470
var SvgHighlightRules = function() {
1471
    XmlHighlightRules.call(this);
1472

    
1473
    this.embedTagRules(JavaScriptHighlightRules, "js-", "script");
1474

    
1475
    this.normalizeRules();
1476
};
1477

    
1478
oop.inherits(SvgHighlightRules, XmlHighlightRules);
1479

    
1480
exports.SvgHighlightRules = SvgHighlightRules;
1481
});
1482

    
1483
ace.define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module) {
1484
"use strict";
1485

    
1486
var oop = require("../../lib/oop");
1487
var BaseFoldMode = require("./fold_mode").FoldMode;
1488

    
1489
var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
1490
    this.defaultMode = defaultMode;
1491
    this.subModes = subModes;
1492
};
1493
oop.inherits(FoldMode, BaseFoldMode);
1494

    
1495
(function() {
1496

    
1497

    
1498
    this.$getMode = function(state) {
1499
        if (typeof state != "string") 
1500
            state = state[0];
1501
        for (var key in this.subModes) {
1502
            if (state.indexOf(key) === 0)
1503
                return this.subModes[key];
1504
        }
1505
        return null;
1506
    };
1507
    
1508
    this.$tryMode = function(state, session, foldStyle, row) {
1509
        var mode = this.$getMode(state);
1510
        return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
1511
    };
1512

    
1513
    this.getFoldWidget = function(session, foldStyle, row) {
1514
        return (
1515
            this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
1516
            this.$tryMode(session.getState(row), session, foldStyle, row) ||
1517
            this.defaultMode.getFoldWidget(session, foldStyle, row)
1518
        );
1519
    };
1520

    
1521
    this.getFoldWidgetRange = function(session, foldStyle, row) {
1522
        var mode = this.$getMode(session.getState(row-1));
1523
        
1524
        if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1525
            mode = this.$getMode(session.getState(row));
1526
        
1527
        if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1528
            mode = this.defaultMode;
1529
        
1530
        return mode.getFoldWidgetRange(session, foldStyle, row);
1531
    };
1532

    
1533
}).call(FoldMode.prototype);
1534

    
1535
});
1536

    
1537
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) {
1538
"use strict";
1539

    
1540
var oop = require("../lib/oop");
1541
var XmlMode = require("./xml").Mode;
1542
var JavaScriptMode = require("./javascript").Mode;
1543
var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules;
1544
var MixedFoldMode = require("./folding/mixed").FoldMode;
1545
var XmlFoldMode = require("./folding/xml").FoldMode;
1546
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
1547

    
1548
var Mode = function() {
1549
    XmlMode.call(this);
1550
    
1551
    this.HighlightRules = SvgHighlightRules;
1552
    
1553
    this.createModeDelegates({
1554
        "js-": JavaScriptMode
1555
    });
1556
    
1557
    this.foldingRules = new MixedFoldMode(new XmlFoldMode(), {
1558
        "js-": new CStyleFoldMode()
1559
    });
1560
};
1561

    
1562
oop.inherits(Mode, XmlMode);
1563

    
1564
(function() {
1565

    
1566
    this.getNextLineIndent = function(state, line, tab) {
1567
        return this.$getIndent(line);
1568
    };
1569
    
1570

    
1571
    this.$id = "ace/mode/svg";
1572
}).call(Mode.prototype);
1573

    
1574
exports.Mode = Mode;
1575
});                (function() {
1576
                    ace.require(["ace/mode/svg"], function(m) {
1577
                        if (typeof module == "object" && typeof exports == "object" && module) {
1578
                            module.exports = m;
1579
                        }
1580
                    });
1581
                })();
1582
            
(175-175/244)