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) {
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;
9
var Mode = function() {
10
JavaScriptMode.call(this);
12
this.$tokenizer = new Tokenizer(new ScalaHighlightRules().getRules());
14
oop.inherits(Mode, JavaScriptMode);
18
this.createWorker = function(session) {
22
}).call(Mode.prototype);
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) {
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;
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();
46
oop.inherits(Mode, TextMode);
50
this.lineCommentStart = "//";
51
this.blockComment = {start: "/*", end: "*/"};
53
this.getNextLineIndent = function(state, line, tab) {
54
var indent = this.$getIndent(line);
56
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
57
var tokens = tokenizedLine.tokens;
58
var endState = tokenizedLine.state;
60
if (tokens.length && tokens[tokens.length-1].type == "comment") {
64
if (state == "start" || state == "no_regex") {
65
var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
69
} else if (state == "doc-start") {
70
if (endState == "start" || endState == "no_regex") {
73
var match = line.match(/^\s*(\/?)\*/);
85
this.checkOutdent = function(state, line, input) {
86
return this.$outdent.checkOutdent(line, input);
89
this.autoOutdent = function(state, doc, row) {
90
this.$outdent.autoOutdent(doc, row);
93
this.createWorker = function(session) {
94
var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
95
worker.attachToDocument(session.getDocument());
97
worker.on("jslint", function(results) {
98
session.setAnnotations(results.data);
101
worker.on("terminate", function() {
102
session.clearAnnotations();
108
}).call(Mode.prototype);
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) {
116
var oop = require("../lib/oop");
117
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
118
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
120
var JavaScriptHighlightRules = function() {
121
var keywordMapper = this.createKeywordMapper({
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
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",
140
"const|let|var|function",
142
"null|Infinity|NaN|undefined",
145
"constant.language.boolean": "true|false"
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";
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
155
"[4-7][0-7]?|" + //oct
164
DocCommentHighlightRules.getStartRule("doc-start"),
166
token : "comment", // multi line comment
178
token : "constant.numeric", // hex
179
regex : /0[xX][0-9a-fA-F]+\b/
181
token : "constant.numeric", // float
182
regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
185
"storage.type", "punctuation.operator", "support.function",
186
"punctuation.operator", "entity.name.function", "text","keyword.operator"
188
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
189
next: "function_arguments"
192
"storage.type", "punctuation.operator", "entity.name.function", "text",
193
"keyword.operator", "text", "storage.type", "text", "paren.lparen"
195
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
196
next: "function_arguments"
199
"entity.name.function", "text", "keyword.operator", "text", "storage.type",
200
"text", "paren.lparen"
202
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
203
next: "function_arguments"
206
"storage.type", "punctuation.operator", "entity.name.function", "text",
207
"keyword.operator", "text",
208
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
210
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
211
next: "function_arguments"
214
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
216
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
217
next: "function_arguments"
220
"entity.name.function", "text", "punctuation.operator",
221
"text", "storage.type", "text", "paren.lparen"
223
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
224
next: "function_arguments"
227
"text", "text", "storage.type", "text", "paren.lparen"
229
regex : "(:)(\\s*)(function)(\\s*)(\\()",
230
next: "function_arguments"
233
regex : "(?:" + kwBeforeRe + ")\\b",
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(?=\()/
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(?=\()/
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/
245
token : ["storage.type", "punctuation.operator", "support.function.firebug"],
246
regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
248
token : keywordMapper,
251
token : "keyword.operator",
252
regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
255
token : "punctuation.operator",
256
regex : /\?|\:|\,|\;|\./,
259
token : "paren.lparen",
263
token : "paren.rparen",
266
token : "keyword.operator",
275
DocCommentHighlightRules.getStartRule("doc-start"),
277
token : "comment", // multi line comment
279
next : "comment_regex_allowed"
285
token: "string.regexp",
300
token: "regexp.keyword.operator",
301
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
303
token: "string.regexp",
308
regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
310
token : "constant.language.escape",
311
regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?]/
313
token : "constant.language.delimiter",
316
token: "constant.language.escape",
318
next: "regex_character_class",
324
defaultToken: "string.regexp"
327
"regex_character_class": [
329
token: "regexp.keyword.operator",
330
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
332
token: "constant.language.escape",
336
token: "constant.language.escape",
343
defaultToken: "string.regexp.charachterclass"
346
"function_arguments": [
348
token: "variable.parameter",
351
token: "punctuation.operator",
354
token: "punctuation.operator",
362
"comment_regex_allowed" : [
363
{token : "comment", regex : "\\*\\/", next : "start"},
364
{defaultToken : "comment"}
367
{token : "comment", regex : "\\*\\/", next : "no_regex"},
368
{defaultToken : "comment"}
372
token : "constant.language.escape",
383
defaultToken: "string"
388
token : "constant.language.escape",
399
defaultToken: "string"
404
this.embedRules(DocCommentHighlightRules, "doc-",
405
[ DocCommentHighlightRules.getEndRule("no_regex") ]);
408
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
410
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
413
define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
416
var oop = require("../lib/oop");
417
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
419
var DocCommentHighlightRules = function() {
423
token : "comment.doc.tag",
424
regex : "@[\\w\\d_]+" // TODO: fix email addresses
426
token : "comment.doc.tag",
429
defaultToken : "comment.doc"
434
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
436
DocCommentHighlightRules.getStartRule = function(start) {
438
token : "comment.doc", // doc comment
439
regex : "\\/\\*(?=\\*)",
444
DocCommentHighlightRules.getEndRule = function (start) {
446
token : "comment.doc", // closing comment
453
exports.DocCommentHighlightRules = DocCommentHighlightRules;
457
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
460
var Range = require("../range").Range;
462
var MatchingBraceOutdent = function() {};
466
this.checkOutdent = function(line, input) {
467
if (! /^\s+$/.test(line))
470
return /^\s*\}/.test(input);
473
this.autoOutdent = function(doc, row) {
474
var line = doc.getLine(row);
475
var match = line.match(/^(\s*\})/);
477
if (!match) return 0;
479
var column = match[1].length;
480
var openBracePos = doc.findMatchingBracket({row: row, column: column});
482
if (!openBracePos || openBracePos.row == row) return 0;
484
var indent = this.$getIndent(doc.getLine(openBracePos.row));
485
doc.replace(new Range(row, 0, row, column-1), indent);
488
this.$getIndent = function(line) {
489
return line.match(/^\s*/)[0];
492
}).call(MatchingBraceOutdent.prototype);
494
exports.MatchingBraceOutdent = MatchingBraceOutdent;
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) {
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");
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"];
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 = "";
519
var CstyleBehaviour = function () {
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))
529
iterator.stepForward();
530
return iterator.getCurrentTokenRow() !== cursor.row ||
531
this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
534
CstyleBehaviour.$matchTokenType = function(token, types) {
535
return types.indexOf(token.type || token) > -1;
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++;
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++;
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;
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;
573
CstyleBehaviour.popAutoInsertedClosing = function() {
574
autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
575
autoInsertedBrackets--;
578
CstyleBehaviour.clearMaybeInsertedClosing = function() {
579
maybeInsertedBrackets = 0;
580
maybeInsertedRow = -1;
583
this.add("braces", "insertion", function (state, action, editor, session, text) {
584
var cursor = editor.getCursorPosition();
585
var line = session.doc.getLine(cursor.row);
587
var selection = editor.getSelectionRange();
588
var selected = session.doc.getTextRange(selection);
589
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
591
text: '{' + selected + '}',
594
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
595
if (/[\]\}\)]/.test(line[cursor.column])) {
596
CstyleBehaviour.recordAutoInsert(editor, session, "}");
602
CstyleBehaviour.recordMaybeInsert(editor, session, "{");
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();
621
} else if (text == "\n" || text == "\r\n") {
623
if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
624
closing = lang.stringRepeat("}", maybeInsertedBrackets);
625
CstyleBehaviour.clearMaybeInsertedClosing();
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}, '}');
633
var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
634
var next_indent = this.$getIndent(line);
637
text: '\n' + indent + '\n' + next_indent + closing,
638
selection: [1, indent.length, 1, indent.length]
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 == '}') {
653
maybeInsertedBrackets--;
658
this.add("parens", "insertion", function (state, action, editor, session, text) {
660
var selection = editor.getSelectionRange();
661
var selected = session.doc.getTextRange(selection);
662
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
664
text: '(' + selected + ')',
667
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
668
CstyleBehaviour.recordAutoInsert(editor, session, ")");
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();
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 == ')') {
703
this.add("brackets", "insertion", function (state, action, editor, session, text) {
705
var selection = editor.getSelectionRange();
706
var selected = session.doc.getTextRange(selection);
707
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
709
text: '[' + selected + ']',
712
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
713
CstyleBehaviour.recordAutoInsert(editor, session, "]");
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();
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 == ']') {
748
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
749
if (text == '"' || text == "'") {
751
var selection = editor.getSelectionRange();
752
var selected = session.doc.getTextRange(selection);
753
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
755
text: quote + selected + quote,
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 == '\\') {
765
var tokens = session.getTokens(selection.start.row);
767
var quotepos = -1; // Track whether we're inside an open quote.
769
for (var x = 0; x < tokens.length; x++) {
771
if (token.type == "string") {
773
} else if (quotepos < 0) {
774
quotepos = token.value.indexOf(quote);
776
if ((token.value.length + col) > selection.start.column) {
779
col += tokens[x].value.length;
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))
788
} else if (token && token.type === "string") {
789
var rightChar = line.substring(cursor.column, cursor.column + 1);
790
if (rightChar == quote) {
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) {
815
oop.inherits(CstyleBehaviour, Behaviour);
817
exports.CstyleBehaviour = CstyleBehaviour;
820
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
823
var oop = require("../../lib/oop");
824
var Range = require("../../range").Range;
825
var BaseFoldMode = require("./fold_mode").FoldMode;
827
var FoldMode = exports.FoldMode = function(commentRegex) {
829
this.foldingStartMarker = new RegExp(
830
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
832
this.foldingStopMarker = new RegExp(
833
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
837
oop.inherits(FoldMode, BaseFoldMode);
841
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
842
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
844
this.getFoldWidgetRange = function(session, foldStyle, row) {
845
var line = session.getLine(row);
846
var match = line.match(this.foldingStartMarker);
851
return this.openingBracketBlock(session, match[1], row, i);
853
return session.getCommentFoldRange(row, i + match[0].length, 1);
856
if (foldStyle !== "markbeginend")
859
var match = line.match(this.foldingStopMarker);
861
var i = match.index + match[0].length;
864
return this.closingBracketBlock(session, match[1], row, i);
866
return session.getCommentFoldRange(row, i, -1);
870
}).call(FoldMode.prototype);
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) {
876
var oop = require("../lib/oop");
877
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
878
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
880
var ScalaHighlightRules = function() {
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"
887
var buildinConstants = ("true|false");
890
"AbstractMethodError|AssertionError|ClassCircularityError|"+
891
"ClassFormatError|Deprecated|EnumConstantNotPresentException|"+
892
"ExceptionInInitializerError|IllegalAccessError|"+
893
"IllegalThreadStateException|InstantiationError|InternalError|"+
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"
921
var keywordMapper = this.createKeywordMapper({
922
"variable.language": "this",
924
"support.function": langClasses,
925
"constant.language": buildinConstants
934
DocCommentHighlightRules.getStartRule("doc-start"),
936
token : "comment", // multi line comment
940
token : "string.regexp",
941
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
948
regex : '"(?=.)', // " strings can't span multiple lines
951
token : "symbol.constant", // single line
952
regex : "'[\\w\\d_]+"
954
token : "constant.numeric", // hex
955
regex : "0[xX][0-9a-fA-F]+\\b"
957
token : "constant.numeric", // float
958
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
960
token : "constant.language.boolean",
961
regex : "(?:true|false)\\b"
963
token : keywordMapper,
964
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
966
token : "keyword.operator",
967
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
969
token : "paren.lparen",
972
token : "paren.rparen",
981
token : "comment", // closing comment
985
token : "comment", // comment spanning whole line
998
token : "string.invalid",
999
regex : '[^"\\\\]*$',
1008
token : "string", // closing comment
1012
token : "string", // comment spanning whole line
1018
this.embedRules(DocCommentHighlightRules, "doc-",
1019
[ DocCommentHighlightRules.getEndRule("start") ]);
1022
oop.inherits(ScalaHighlightRules, TextHighlightRules);
1024
exports.ScalaHighlightRules = ScalaHighlightRules;