/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
15.1.1 by galaxyAbstractor
Started implementation of a new codeviewer using Ace
1
define('ace/mode/scala', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/javascript', 'ace/tokenizer', 'ace/mode/scala_highlight_rules'], function(require, exports, module) {
2
3
4
var oop = require("../lib/oop");
5
var JavaScriptMode = require("./javascript").Mode;
6
var Tokenizer = require("../tokenizer").Tokenizer;
7
var ScalaHighlightRules = require("./scala_highlight_rules").ScalaHighlightRules;
8
9
var Mode = function() {
10
    JavaScriptMode.call(this);
11
    
12
    this.$tokenizer = new Tokenizer(new ScalaHighlightRules().getRules());
13
};
14
oop.inherits(Mode, JavaScriptMode);
15
16
(function() {
17
18
    this.createWorker = function(session) {
19
        return null;
20
    };
21
22
}).call(Mode.prototype);
23
24
exports.Mode = Mode;
25
});
26
27
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) {
28
29
30
var oop = require("../lib/oop");
31
var TextMode = require("./text").Mode;
32
var Tokenizer = require("../tokenizer").Tokenizer;
33
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
34
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
35
var Range = require("../range").Range;
36
var WorkerClient = require("../worker/worker_client").WorkerClient;
37
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
38
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
39
40
var Mode = function() {
41
    this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
42
    this.$outdent = new MatchingBraceOutdent();
43
    this.$behaviour = new CstyleBehaviour();
44
    this.foldingRules = new CStyleFoldMode();
45
};
46
oop.inherits(Mode, TextMode);
47
48
(function() {
49
50
    this.lineCommentStart = "//";
51
    this.blockComment = {start: "/*", end: "*/"};
52
53
    this.getNextLineIndent = function(state, line, tab) {
54
        var indent = this.$getIndent(line);
55
56
        var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
57
        var tokens = tokenizedLine.tokens;
58
        var endState = tokenizedLine.state;
59
60
        if (tokens.length && tokens[tokens.length-1].type == "comment") {
61
            return indent;
62
        }
63
64
        if (state == "start" || state == "no_regex") {
65
            var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
66
            if (match) {
67
                indent += tab;
68
            }
69
        } else if (state == "doc-start") {
70
            if (endState == "start" || endState == "no_regex") {
71
                return "";
72
            }
73
            var match = line.match(/^\s*(\/?)\*/);
74
            if (match) {
75
                if (match[1]) {
76
                    indent += " ";
77
                }
78
                indent += "* ";
79
            }
80
        }
81
82
        return indent;
83
    };
84
85
    this.checkOutdent = function(state, line, input) {
86
        return this.$outdent.checkOutdent(line, input);
87
    };
88
89
    this.autoOutdent = function(state, doc, row) {
90
        this.$outdent.autoOutdent(doc, row);
91
    };
92
93
    this.createWorker = function(session) {
94
        var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
95
        worker.attachToDocument(session.getDocument());
96
97
        worker.on("jslint", function(results) {
98
            session.setAnnotations(results.data);
99
        });
100
101
        worker.on("terminate", function() {
102
            session.clearAnnotations();
103
        });
104
105
        return worker;
106
    };
107
108
}).call(Mode.prototype);
109
110
exports.Mode = Mode;
111
});
112
113
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) {
114
115
116
var oop = require("../lib/oop");
117
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
118
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
119
120
var JavaScriptHighlightRules = function() {
121
    var keywordMapper = this.createKeywordMapper({
122
        "variable.language":
123
            "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|"  + // Constructors
124
            "Namespace|QName|XML|XMLList|"                                             + // E4X
125
            "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|"   +
126
            "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|"                    +
127
            "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|"   + // Errors
128
            "SyntaxError|TypeError|URIError|"                                          +
129
            "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
130
            "isNaN|parseFloat|parseInt|"                                               +
131
            "JSON|Math|"                                                               + // Other
132
            "this|arguments|prototype|window|document"                                 , // Pseudo
133
        "keyword":
134
            "const|yield|import|get|set|" +
135
            "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
136
            "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
137
            "__parent__|__count__|escape|unescape|with|__proto__|" +
138
            "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
139
        "storage.type":
140
            "const|let|var|function",
141
        "constant.language":
142
            "null|Infinity|NaN|undefined",
143
        "support.function":
144
            "alert",
145
        "constant.language.boolean": "true|false"
146
    }, "identifier");
147
    var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
148
    var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
149
150
    var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
151
        "u[0-9a-fA-F]{4}|" + // unicode
152
        "[0-2][0-7]{0,2}|" + // oct
153
        "3[0-6][0-7]?|" + // oct
154
        "37[0-7]?|" + // oct
155
        "[4-7][0-7]?|" + //oct
156
        ".)";
157
158
    this.$rules = {
159
        "no_regex" : [
160
            {
161
                token : "comment",
162
                regex : /\/\/.*$/
163
            },
164
            DocCommentHighlightRules.getStartRule("doc-start"),
165
            {
166
                token : "comment", // multi line comment
167
                regex : /\/\*/,
168
                next : "comment"
169
            }, {
170
                token : "string",
171
                regex : "'(?=.)",
172
                next  : "qstring"
173
            }, {
174
                token : "string",
175
                regex : '"(?=.)',
176
                next  : "qqstring"
177
            }, {
178
                token : "constant.numeric", // hex
179
                regex : /0[xX][0-9a-fA-F]+\b/
180
            }, {
181
                token : "constant.numeric", // float
182
                regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
183
            }, {
184
                token : [
185
                    "storage.type", "punctuation.operator", "support.function",
186
                    "punctuation.operator", "entity.name.function", "text","keyword.operator"
187
                ],
188
                regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
189
                next: "function_arguments"
190
            }, {
191
                token : [
192
                    "storage.type", "punctuation.operator", "entity.name.function", "text",
193
                    "keyword.operator", "text", "storage.type", "text", "paren.lparen"
194
                ],
195
                regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
196
                next: "function_arguments"
197
            }, {
198
                token : [
199
                    "entity.name.function", "text", "keyword.operator", "text", "storage.type",
200
                    "text", "paren.lparen"
201
                ],
202
                regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
203
                next: "function_arguments"
204
            }, {
205
                token : [
206
                    "storage.type", "punctuation.operator", "entity.name.function", "text",
207
                    "keyword.operator", "text",
208
                    "storage.type", "text", "entity.name.function", "text", "paren.lparen"
209
                ],
210
                regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
211
                next: "function_arguments"
212
            }, {
213
                token : [
214
                    "storage.type", "text", "entity.name.function", "text", "paren.lparen"
215
                ],
216
                regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
217
                next: "function_arguments"
218
            }, {
219
                token : [
220
                    "entity.name.function", "text", "punctuation.operator",
221
                    "text", "storage.type", "text", "paren.lparen"
222
                ],
223
                regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
224
                next: "function_arguments"
225
            }, {
226
                token : [
227
                    "text", "text", "storage.type", "text", "paren.lparen"
228
                ],
229
                regex : "(:)(\\s*)(function)(\\s*)(\\()",
230
                next: "function_arguments"
231
            }, {
232
                token : "keyword",
233
                regex : "(?:" + kwBeforeRe + ")\\b",
234
                next : "start"
235
            }, {
236
                token : ["punctuation.operator", "support.function"],
237
                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(?=\()/
238
            }, {
239
                token : ["punctuation.operator", "support.function.dom"],
240
                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(?=\()/
241
            }, {
242
                token : ["punctuation.operator", "support.constant"],
243
                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/
244
            }, {
245
                token : ["storage.type", "punctuation.operator", "support.function.firebug"],
246
                regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
247
            }, {
248
                token : keywordMapper,
249
                regex : identifierRe
250
            }, {
251
                token : "keyword.operator",
252
                regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
253
                next  : "start"
254
            }, {
255
                token : "punctuation.operator",
256
                regex : /\?|\:|\,|\;|\./,
257
                next  : "start"
258
            }, {
259
                token : "paren.lparen",
260
                regex : /[\[({]/,
261
                next  : "start"
262
            }, {
263
                token : "paren.rparen",
264
                regex : /[\])}]/
265
            }, {
266
                token : "keyword.operator",
267
                regex : /\/=?/,
268
                next  : "start"
269
            }, {
270
                token: "comment",
271
                regex: /^#!.*$/
272
            }
273
        ],
274
        "start": [
275
            DocCommentHighlightRules.getStartRule("doc-start"),
276
            {
277
                token : "comment", // multi line comment
278
                regex : "\\/\\*",
279
                next : "comment_regex_allowed"
280
            }, {
281
                token : "comment",
282
                regex : "\\/\\/.*$",
283
                next : "start"
284
            }, {
285
                token: "string.regexp",
286
                regex: "\\/",
287
                next: "regex",
288
            }, {
289
                token : "text",
290
                regex : "\\s+|^$",
291
                next : "start"
292
            }, {
293
                token: "empty",
294
                regex: "",
295
                next: "no_regex"
296
            }
297
        ],
298
        "regex": [
299
            {
300
                token: "regexp.keyword.operator",
301
                regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
302
            }, {
303
                token: "string.regexp",
304
                regex: "/\\w*",
305
                next: "no_regex",
306
            }, {
307
                token : "invalid",
308
                regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
309
            }, {
310
                token : "constant.language.escape",
311
                regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?]/
312
            }, {
313
                token : "constant.language.delimiter",
314
                regex: /\|/
315
            }, {
316
                token: "constant.language.escape",
317
                regex: /\[\^?/,
318
                next: "regex_character_class",
319
            }, {
320
                token: "empty",
321
                regex: "$",
322
                next: "no_regex"
323
            }, {
324
                defaultToken: "string.regexp"
325
            }
326
        ],
327
        "regex_character_class": [
328
            {
329
                token: "regexp.keyword.operator",
330
                regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
331
            }, {
332
                token: "constant.language.escape",
333
                regex: "]",
334
                next: "regex",
335
            }, {
336
                token: "constant.language.escape",
337
                regex: "-"
338
            }, {
339
                token: "empty",
340
                regex: "$",
341
                next: "no_regex"
342
            }, {
343
                defaultToken: "string.regexp.charachterclass"
344
            }
345
        ],
346
        "function_arguments": [
347
            {
348
                token: "variable.parameter",
349
                regex: identifierRe
350
            }, {
351
                token: "punctuation.operator",
352
                regex: "[, ]+",
353
            }, {
354
                token: "punctuation.operator",
355
                regex: "$",
356
            }, {
357
                token: "empty",
358
                regex: "",
359
                next: "no_regex"
360
            }
361
        ],
362
        "comment_regex_allowed" : [
363
            {token : "comment", regex : "\\*\\/", next : "start"},
364
            {defaultToken : "comment"}
365
        ],
366
        "comment" : [
367
            {token : "comment", regex : "\\*\\/", next : "no_regex"},
368
            {defaultToken : "comment"}
369
        ],
370
        "qqstring" : [
371
            {
372
                token : "constant.language.escape",
373
                regex : escapedRe
374
            }, {
375
                token : "string",
376
                regex : "\\\\$",
377
                next  : "qqstring",
378
            }, {
379
                token : "string",
380
                regex : '"|$',
381
                next  : "no_regex",
382
            }, {
383
                defaultToken: "string"
384
            }
385
        ],
386
        "qstring" : [
387
            {
388
                token : "constant.language.escape",
389
                regex : escapedRe
390
            }, {
391
                token : "string",
392
                regex : "\\\\$",
393
                next  : "qstring",
394
            }, {
395
                token : "string",
396
                regex : "'|$",
397
                next  : "no_regex",
398
            }, {
399
                defaultToken: "string"
400
            }
401
        ]
402
    };
403
404
    this.embedRules(DocCommentHighlightRules, "doc-",
405
        [ DocCommentHighlightRules.getEndRule("no_regex") ]);
406
};
407
408
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
409
410
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
411
});
412
413
define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
414
415
416
var oop = require("../lib/oop");
417
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
418
419
var DocCommentHighlightRules = function() {
420
421
    this.$rules = {
422
        "start" : [ {
423
            token : "comment.doc.tag",
424
            regex : "@[\\w\\d_]+" // TODO: fix email addresses
425
        }, {
426
            token : "comment.doc.tag",
427
            regex : "\\bTODO\\b"
428
        }, {
429
            defaultToken : "comment.doc"
430
        }]
431
    };
432
};
433
434
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
435
436
DocCommentHighlightRules.getStartRule = function(start) {
437
    return {
438
        token : "comment.doc", // doc comment
439
        regex : "\\/\\*(?=\\*)",
440
        next  : start
441
    };
442
};
443
444
DocCommentHighlightRules.getEndRule = function (start) {
445
    return {
446
        token : "comment.doc", // closing comment
447
        regex : "\\*\\/",
448
        next  : start
449
    };
450
};
451
452
453
exports.DocCommentHighlightRules = DocCommentHighlightRules;
454
455
});
456
457
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
458
459
460
var Range = require("../range").Range;
461
462
var MatchingBraceOutdent = function() {};
463
464
(function() {
465
466
    this.checkOutdent = function(line, input) {
467
        if (! /^\s+$/.test(line))
468
            return false;
469
470
        return /^\s*\}/.test(input);
471
    };
472
473
    this.autoOutdent = function(doc, row) {
474
        var line = doc.getLine(row);
475
        var match = line.match(/^(\s*\})/);
476
477
        if (!match) return 0;
478
479
        var column = match[1].length;
480
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
481
482
        if (!openBracePos || openBracePos.row == row) return 0;
483
484
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
485
        doc.replace(new Range(row, 0, row, column-1), indent);
486
    };
487
488
    this.$getIndent = function(line) {
489
        return line.match(/^\s*/)[0];
490
    };
491
492
}).call(MatchingBraceOutdent.prototype);
493
494
exports.MatchingBraceOutdent = MatchingBraceOutdent;
495
});
496
497
define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
498
499
500
var oop = require("../../lib/oop");
501
var Behaviour = require("../behaviour").Behaviour;
502
var TokenIterator = require("../../token_iterator").TokenIterator;
503
var lang = require("../../lib/lang");
504
505
var SAFE_INSERT_IN_TOKENS =
506
    ["text", "paren.rparen", "punctuation.operator"];
507
var SAFE_INSERT_BEFORE_TOKENS =
508
    ["text", "paren.rparen", "punctuation.operator", "comment"];
509
510
511
var autoInsertedBrackets = 0;
512
var autoInsertedRow = -1;
513
var autoInsertedLineEnd = "";
514
var maybeInsertedBrackets = 0;
515
var maybeInsertedRow = -1;
516
var maybeInsertedLineStart = "";
517
var maybeInsertedLineEnd = "";
518
519
var CstyleBehaviour = function () {
520
    
521
    CstyleBehaviour.isSaneInsertion = function(editor, session) {
522
        var cursor = editor.getCursorPosition();
523
        var iterator = new TokenIterator(session, cursor.row, cursor.column);
524
        if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
525
            var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
526
            if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
527
                return false;
528
        }
529
        iterator.stepForward();
530
        return iterator.getCurrentTokenRow() !== cursor.row ||
531
            this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
532
    };
533
    
534
    CstyleBehaviour.$matchTokenType = function(token, types) {
535
        return types.indexOf(token.type || token) > -1;
536
    };
537
    
538
    CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
539
        var cursor = editor.getCursorPosition();
540
        var line = session.doc.getLine(cursor.row);
541
        if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
542
            autoInsertedBrackets = 0;
543
        autoInsertedRow = cursor.row;
544
        autoInsertedLineEnd = bracket + line.substr(cursor.column);
545
        autoInsertedBrackets++;
546
    };
547
    
548
    CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
549
        var cursor = editor.getCursorPosition();
550
        var line = session.doc.getLine(cursor.row);
551
        if (!this.isMaybeInsertedClosing(cursor, line))
552
            maybeInsertedBrackets = 0;
553
        maybeInsertedRow = cursor.row;
554
        maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
555
        maybeInsertedLineEnd = line.substr(cursor.column);
556
        maybeInsertedBrackets++;
557
    };
558
    
559
    CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
560
        return autoInsertedBrackets > 0 &&
561
            cursor.row === autoInsertedRow &&
562
            bracket === autoInsertedLineEnd[0] &&
563
            line.substr(cursor.column) === autoInsertedLineEnd;
564
    };
565
    
566
    CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
567
        return maybeInsertedBrackets > 0 &&
568
            cursor.row === maybeInsertedRow &&
569
            line.substr(cursor.column) === maybeInsertedLineEnd &&
570
            line.substr(0, cursor.column) == maybeInsertedLineStart;
571
    };
572
    
573
    CstyleBehaviour.popAutoInsertedClosing = function() {
574
        autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
575
        autoInsertedBrackets--;
576
    };
577
    
578
    CstyleBehaviour.clearMaybeInsertedClosing = function() {
579
        maybeInsertedBrackets = 0;
580
        maybeInsertedRow = -1;
581
    };
582
583
    this.add("braces", "insertion", function (state, action, editor, session, text) {
584
        var cursor = editor.getCursorPosition();
585
        var line = session.doc.getLine(cursor.row);
586
        if (text == '{') {
587
            var selection = editor.getSelectionRange();
588
            var selected = session.doc.getTextRange(selection);
589
            if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
590
                return {
591
                    text: '{' + selected + '}',
592
                    selection: false
593
                };
594
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
595
                if (/[\]\}\)]/.test(line[cursor.column])) {
596
                    CstyleBehaviour.recordAutoInsert(editor, session, "}");
597
                    return {
598
                        text: '{}',
599
                        selection: [1, 1]
600
                    };
601
                } else {
602
                    CstyleBehaviour.recordMaybeInsert(editor, session, "{");
603
                    return {
604
                        text: '{',
605
                        selection: [1, 1]
606
                    };
607
                }
608
            }
609
        } else if (text == '}') {
610
            var rightChar = line.substring(cursor.column, cursor.column + 1);
611
            if (rightChar == '}') {
612
                var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
613
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
614
                    CstyleBehaviour.popAutoInsertedClosing();
615
                    return {
616
                        text: '',
617
                        selection: [1, 1]
618
                    };
619
                }
620
            }
621
        } else if (text == "\n" || text == "\r\n") {
622
            var closing = "";
623
            if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
624
                closing = lang.stringRepeat("}", maybeInsertedBrackets);
625
                CstyleBehaviour.clearMaybeInsertedClosing();
626
            }
627
            var rightChar = line.substring(cursor.column, cursor.column + 1);
628
            if (rightChar == '}' || closing !== "") {
629
                var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
630
                if (!openBracePos)
631
                     return null;
632
633
                var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
634
                var next_indent = this.$getIndent(line);
635
636
                return {
637
                    text: '\n' + indent + '\n' + next_indent + closing,
638
                    selection: [1, indent.length, 1, indent.length]
639
                };
640
            }
641
        }
642
    });
643
644
    this.add("braces", "deletion", function (state, action, editor, session, range) {
645
        var selected = session.doc.getTextRange(range);
646
        if (!range.isMultiLine() && selected == '{') {
647
            var line = session.doc.getLine(range.start.row);
648
            var rightChar = line.substring(range.end.column, range.end.column + 1);
649
            if (rightChar == '}') {
650
                range.end.column++;
651
                return range;
652
            } else {
653
                maybeInsertedBrackets--;
654
            }
655
        }
656
    });
657
658
    this.add("parens", "insertion", function (state, action, editor, session, text) {
659
        if (text == '(') {
660
            var selection = editor.getSelectionRange();
661
            var selected = session.doc.getTextRange(selection);
662
            if (selected !== "" && editor.getWrapBehavioursEnabled()) {
663
                return {
664
                    text: '(' + selected + ')',
665
                    selection: false
666
                };
667
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
668
                CstyleBehaviour.recordAutoInsert(editor, session, ")");
669
                return {
670
                    text: '()',
671
                    selection: [1, 1]
672
                };
673
            }
674
        } else if (text == ')') {
675
            var cursor = editor.getCursorPosition();
676
            var line = session.doc.getLine(cursor.row);
677
            var rightChar = line.substring(cursor.column, cursor.column + 1);
678
            if (rightChar == ')') {
679
                var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
680
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
681
                    CstyleBehaviour.popAutoInsertedClosing();
682
                    return {
683
                        text: '',
684
                        selection: [1, 1]
685
                    };
686
                }
687
            }
688
        }
689
    });
690
691
    this.add("parens", "deletion", function (state, action, editor, session, range) {
692
        var selected = session.doc.getTextRange(range);
693
        if (!range.isMultiLine() && selected == '(') {
694
            var line = session.doc.getLine(range.start.row);
695
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
696
            if (rightChar == ')') {
697
                range.end.column++;
698
                return range;
699
            }
700
        }
701
    });
702
703
    this.add("brackets", "insertion", function (state, action, editor, session, text) {
704
        if (text == '[') {
705
            var selection = editor.getSelectionRange();
706
            var selected = session.doc.getTextRange(selection);
707
            if (selected !== "" && editor.getWrapBehavioursEnabled()) {
708
                return {
709
                    text: '[' + selected + ']',
710
                    selection: false
711
                };
712
            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
713
                CstyleBehaviour.recordAutoInsert(editor, session, "]");
714
                return {
715
                    text: '[]',
716
                    selection: [1, 1]
717
                };
718
            }
719
        } else if (text == ']') {
720
            var cursor = editor.getCursorPosition();
721
            var line = session.doc.getLine(cursor.row);
722
            var rightChar = line.substring(cursor.column, cursor.column + 1);
723
            if (rightChar == ']') {
724
                var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
725
                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
726
                    CstyleBehaviour.popAutoInsertedClosing();
727
                    return {
728
                        text: '',
729
                        selection: [1, 1]
730
                    };
731
                }
732
            }
733
        }
734
    });
735
736
    this.add("brackets", "deletion", function (state, action, editor, session, range) {
737
        var selected = session.doc.getTextRange(range);
738
        if (!range.isMultiLine() && selected == '[') {
739
            var line = session.doc.getLine(range.start.row);
740
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
741
            if (rightChar == ']') {
742
                range.end.column++;
743
                return range;
744
            }
745
        }
746
    });
747
748
    this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
749
        if (text == '"' || text == "'") {
750
            var quote = text;
751
            var selection = editor.getSelectionRange();
752
            var selected = session.doc.getTextRange(selection);
753
            if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
754
                return {
755
                    text: quote + selected + quote,
756
                    selection: false
757
                };
758
            } else {
759
                var cursor = editor.getCursorPosition();
760
                var line = session.doc.getLine(cursor.row);
761
                var leftChar = line.substring(cursor.column-1, cursor.column);
762
                if (leftChar == '\\') {
763
                    return null;
764
                }
765
                var tokens = session.getTokens(selection.start.row);
766
                var col = 0, token;
767
                var quotepos = -1; // Track whether we're inside an open quote.
768
769
                for (var x = 0; x < tokens.length; x++) {
770
                    token = tokens[x];
771
                    if (token.type == "string") {
772
                      quotepos = -1;
773
                    } else if (quotepos < 0) {
774
                      quotepos = token.value.indexOf(quote);
775
                    }
776
                    if ((token.value.length + col) > selection.start.column) {
777
                        break;
778
                    }
779
                    col += tokens[x].value.length;
780
                }
781
                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)))) {
782
                    if (!CstyleBehaviour.isSaneInsertion(editor, session))
783
                        return;
784
                    return {
785
                        text: quote + quote,
786
                        selection: [1,1]
787
                    };
788
                } else if (token && token.type === "string") {
789
                    var rightChar = line.substring(cursor.column, cursor.column + 1);
790
                    if (rightChar == quote) {
791
                        return {
792
                            text: '',
793
                            selection: [1, 1]
794
                        };
795
                    }
796
                }
797
            }
798
        }
799
    });
800
801
    this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
802
        var selected = session.doc.getTextRange(range);
803
        if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
804
            var line = session.doc.getLine(range.start.row);
805
            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
806
            if (rightChar == selected) {
807
                range.end.column++;
808
                return range;
809
            }
810
        }
811
    });
812
813
};
814
815
oop.inherits(CstyleBehaviour, Behaviour);
816
817
exports.CstyleBehaviour = CstyleBehaviour;
818
});
819
820
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
821
822
823
var oop = require("../../lib/oop");
824
var Range = require("../../range").Range;
825
var BaseFoldMode = require("./fold_mode").FoldMode;
826
827
var FoldMode = exports.FoldMode = function(commentRegex) {
828
    if (commentRegex) {
829
        this.foldingStartMarker = new RegExp(
830
            this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
831
        );
832
        this.foldingStopMarker = new RegExp(
833
            this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
834
        );
835
    }
836
};
837
oop.inherits(FoldMode, BaseFoldMode);
838
839
(function() {
840
841
    this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
842
    this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
843
844
    this.getFoldWidgetRange = function(session, foldStyle, row) {
845
        var line = session.getLine(row);
846
        var match = line.match(this.foldingStartMarker);
847
        if (match) {
848
            var i = match.index;
849
850
            if (match[1])
851
                return this.openingBracketBlock(session, match[1], row, i);
852
853
            return session.getCommentFoldRange(row, i + match[0].length, 1);
854
        }
855
856
        if (foldStyle !== "markbeginend")
857
            return;
858
859
        var match = line.match(this.foldingStopMarker);
860
        if (match) {
861
            var i = match.index + match[0].length;
862
863
            if (match[1])
864
                return this.closingBracketBlock(session, match[1], row, i);
865
866
            return session.getCommentFoldRange(row, i, -1);
867
        }
868
    };
869
870
}).call(FoldMode.prototype);
871
872
});
873
define('ace/mode/scala_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
874
875
876
var oop = require("../lib/oop");
877
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
878
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
879
880
var ScalaHighlightRules = function() {
881
    var keywords = (
882
            "case|default|do|else|for|if|match|while|throw|return|try|catch|finally|yield|" +
883
            "abstract|class|def|extends|final|forSome|implicit|implicits|import|lazy|new|object|" +
884
            "override|package|private|protected|sealed|super|this|trait|type|val|var|with"
885
    );
886
887
    var buildinConstants = ("true|false");
888
889
    var langClasses = (
890
        "AbstractMethodError|AssertionError|ClassCircularityError|"+
891
        "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+
892
        "ExceptionInInitializerError|IllegalAccessError|"+
893
        "IllegalThreadStateException|InstantiationError|InternalError|"+
894
895
        "NegativeArraySizeException|NoSuchFieldError|Override|Process|"+
896
        "ProcessBuilder|SecurityManager|StringIndexOutOfBoundsException|"+
897
        "SuppressWarnings|TypeNotPresentException|UnknownError|"+
898
        "UnsatisfiedLinkError|UnsupportedClassVersionError|VerifyError|"+
899
        "InstantiationException|IndexOutOfBoundsException|"+
900
        "ArrayIndexOutOfBoundsException|CloneNotSupportedException|"+
901
        "NoSuchFieldException|IllegalArgumentException|NumberFormatException|"+
902
        "SecurityException|Void|InheritableThreadLocal|IllegalStateException|"+
903
        "InterruptedException|NoSuchMethodException|IllegalAccessException|"+
904
        "UnsupportedOperationException|Enum|StrictMath|Package|Compiler|"+
905
        "Readable|Runtime|StringBuilder|Math|IncompatibleClassChangeError|"+
906
        "NoSuchMethodError|ThreadLocal|RuntimePermission|ArithmeticException|"+
907
        "NullPointerException|Long|Integer|Short|Byte|Double|Number|Float|"+
908
        "Character|Boolean|StackTraceElement|Appendable|StringBuffer|"+
909
        "Iterable|ThreadGroup|Runnable|Thread|IllegalMonitorStateException|"+
910
        "StackOverflowError|OutOfMemoryError|VirtualMachineError|"+
911
        "ArrayStoreException|ClassCastException|LinkageError|"+
912
        "NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+
913
        "Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+
914
        "Cloneable|Class|CharSequence|Comparable|String|Object|" +
915
        "Unit|Any|AnyVal|AnyRef|Null|ScalaObject|Singleton|Seq|Iterable|List|" +
916
        "Option|Array|Char|Byte|Short|Int|Long|Nothing"
917
918
919
    );
920
921
    var keywordMapper = this.createKeywordMapper({
922
        "variable.language": "this",
923
        "keyword": keywords,
924
        "support.function": langClasses,
925
        "constant.language": buildinConstants
926
    }, "identifier");
927
928
    this.$rules = {
929
        "start" : [
930
            {
931
                token : "comment",
932
                regex : "\\/\\/.*$"
933
            },
934
            DocCommentHighlightRules.getStartRule("doc-start"),
935
            {
936
                token : "comment", // multi line comment
937
                regex : "\\/\\*",
938
                next : "comment"
939
            }, {
940
                token : "string.regexp",
941
                regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
942
            }, {
943
                token : "string",
944
                regex : '"""',
945
                next : "tstring"
946
            }, {
947
                token : "string",
948
                regex : '"(?=.)', // " strings can't span multiple lines
949
                next : "string"
950
            }, {
951
                token : "symbol.constant", // single line
952
                regex : "'[\\w\\d_]+"
953
            }, {
954
                token : "constant.numeric", // hex
955
                regex : "0[xX][0-9a-fA-F]+\\b"
956
            }, {
957
                token : "constant.numeric", // float
958
                regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
959
            }, {
960
                token : "constant.language.boolean",
961
                regex : "(?:true|false)\\b"
962
            }, {
963
                token : keywordMapper,
964
                regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
965
            }, {
966
                token : "keyword.operator",
967
                regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
968
            }, {
969
                token : "paren.lparen",
970
                regex : "[[({]"
971
            }, {
972
                token : "paren.rparen",
973
                regex : "[\\])}]"
974
            }, {
975
                token : "text",
976
                regex : "\\s+"
977
            }
978
        ],
979
        "comment" : [
980
            {
981
                token : "comment", // closing comment
982
                regex : ".*?\\*\\/",
983
                next : "start"
984
            }, {
985
                token : "comment", // comment spanning whole line
986
                regex : ".+"
987
            }
988
        ],
989
        "string" : [
990
            {
991
                token : "escape",
992
                regex : '\\\\"'
993
            }, {
994
                token : "string",
995
                regex : '"',
996
                next : "start"
997
            }, {
998
                token : "string.invalid",
999
                regex : '[^"\\\\]*$',
1000
                next : "start"
1001
            }, {
1002
                token : "string",
1003
                regex : '[^"\\\\]+'
1004
            }
1005
        ],
1006
        "tstring" : [
1007
            {
1008
                token : "string", // closing comment
1009
                regex : '"{3,5}',
1010
                next : "start"
1011
            }, {
1012
                token : "string", // comment spanning whole line
1013
                regex : ".+?"
1014
            }
1015
        ]
1016
    };
1017
1018
    this.embedRules(DocCommentHighlightRules, "doc-",
1019
        [ DocCommentHighlightRules.getEndRule("start") ]);
1020
};
1021
1022
oop.inherits(ScalaHighlightRules, TextHighlightRules);
1023
1024
exports.ScalaHighlightRules = ScalaHighlightRules;
1025
});