1
|
ace.define("ace/mode/doc_comment_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 DocCommentHighlightRules = function() {
|
8
|
this.$rules = {
|
9
|
"start" : [ {
|
10
|
token : "comment.doc.tag",
|
11
|
regex : "@[\\w\\d_]+" // TODO: fix email addresses
|
12
|
},
|
13
|
DocCommentHighlightRules.getTagRule(),
|
14
|
{
|
15
|
defaultToken : "comment.doc",
|
16
|
caseInsensitive: true
|
17
|
}]
|
18
|
};
|
19
|
};
|
20
|
|
21
|
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
|
22
|
|
23
|
DocCommentHighlightRules.getTagRule = function(start) {
|
24
|
return {
|
25
|
token : "comment.doc.tag.storage.type",
|
26
|
regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
|
27
|
};
|
28
|
};
|
29
|
|
30
|
DocCommentHighlightRules.getStartRule = function(start) {
|
31
|
return {
|
32
|
token : "comment.doc", // doc comment
|
33
|
regex : "\\/\\*(?=\\*)",
|
34
|
next : start
|
35
|
};
|
36
|
};
|
37
|
|
38
|
DocCommentHighlightRules.getEndRule = function (start) {
|
39
|
return {
|
40
|
token : "comment.doc", // closing comment
|
41
|
regex : "\\*\\/",
|
42
|
next : start
|
43
|
};
|
44
|
};
|
45
|
|
46
|
|
47
|
exports.DocCommentHighlightRules = DocCommentHighlightRules;
|
48
|
|
49
|
});
|
50
|
|
51
|
ace.define("ace/mode/swift_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
52
|
"use strict";
|
53
|
|
54
|
var oop = require("../lib/oop");
|
55
|
var lang = require("../lib/lang");
|
56
|
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
57
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
58
|
|
59
|
var SwiftHighlightRules = function() {
|
60
|
var keywordMapper = this.createKeywordMapper({
|
61
|
"variable.language": "",
|
62
|
"keyword": "__COLUMN__|__FILE__|__FUNCTION__|__LINE__"
|
63
|
+ "|as|associativity|break|case|class|continue|default|deinit|didSet"
|
64
|
+ "|do|dynamicType|else|enum|extension|fallthrough|for|func|get|if|import"
|
65
|
+ "|in|infix|init|inout|is|left|let|let|mutating|new|none|nonmutating"
|
66
|
+ "|operator|override|postfix|precedence|prefix|protocol|return|right"
|
67
|
+ "|safe|Self|self|set|struct|subscript|switch|Type|typealias"
|
68
|
+ "|unowned|unsafe|var|weak|where|while|willSet"
|
69
|
+ "|convenience|dynamic|final|infix|lazy|mutating|nonmutating|optional|override|postfix"
|
70
|
+ "|prefix|required|static|guard|defer",
|
71
|
"storage.type": "bool|double|Double"
|
72
|
+ "|extension|float|Float|int|Int|open|internal|fileprivate|private|public|string|String",
|
73
|
"constant.language":
|
74
|
"false|Infinity|NaN|nil|no|null|null|off|on|super|this|true|undefined|yes",
|
75
|
"support.function":
|
76
|
""
|
77
|
}, "identifier");
|
78
|
|
79
|
function string(start, options) {
|
80
|
var nestable = options.nestable || options.interpolation;
|
81
|
var interpStart = options.interpolation && options.interpolation.nextState || "start";
|
82
|
var mainRule = {
|
83
|
regex: start + (options.multiline ? "" : "(?=.)"),
|
84
|
token: "string.start"
|
85
|
};
|
86
|
var nextState = [
|
87
|
options.escape && {
|
88
|
regex: options.escape,
|
89
|
token: "character.escape"
|
90
|
},
|
91
|
options.interpolation && {
|
92
|
token : "paren.quasi.start",
|
93
|
regex : lang.escapeRegExp(options.interpolation.lead + options.interpolation.open),
|
94
|
push : interpStart
|
95
|
},
|
96
|
options.error && {
|
97
|
regex: options.error,
|
98
|
token: "error.invalid"
|
99
|
},
|
100
|
{
|
101
|
regex: start + (options.multiline ? "" : "|$"),
|
102
|
token: "string.end",
|
103
|
next: nestable ? "pop" : "start"
|
104
|
}, {
|
105
|
defaultToken: "string"
|
106
|
}
|
107
|
].filter(Boolean);
|
108
|
|
109
|
if (nestable)
|
110
|
mainRule.push = nextState;
|
111
|
else
|
112
|
mainRule.next = nextState;
|
113
|
|
114
|
if (!options.interpolation)
|
115
|
return mainRule;
|
116
|
|
117
|
var open = options.interpolation.open;
|
118
|
var close = options.interpolation.close;
|
119
|
var counter = {
|
120
|
regex: "[" + lang.escapeRegExp(open + close) + "]",
|
121
|
onMatch: function(val, state, stack) {
|
122
|
this.next = val == open ? this.nextState : "";
|
123
|
if (val == open && stack.length) {
|
124
|
stack.unshift("start", state);
|
125
|
return "paren";
|
126
|
}
|
127
|
if (val == close && stack.length) {
|
128
|
stack.shift();
|
129
|
this.next = stack.shift();
|
130
|
if (this.next.indexOf("string") != -1)
|
131
|
return "paren.quasi.end";
|
132
|
}
|
133
|
return val == open ? "paren.lparen" : "paren.rparen";
|
134
|
},
|
135
|
nextState: interpStart
|
136
|
};
|
137
|
return [counter, mainRule];
|
138
|
}
|
139
|
|
140
|
function comments() {
|
141
|
return [{
|
142
|
token : "comment",
|
143
|
regex : "\\/\\/(?=.)",
|
144
|
next : [
|
145
|
DocCommentHighlightRules.getTagRule(),
|
146
|
{token : "comment", regex : "$|^", next: "start"},
|
147
|
{defaultToken : "comment", caseInsensitive: true}
|
148
|
]
|
149
|
},
|
150
|
DocCommentHighlightRules.getStartRule("doc-start"),
|
151
|
{
|
152
|
token : "comment.start",
|
153
|
regex : /\/\*/,
|
154
|
stateName: "nested_comment",
|
155
|
push : [
|
156
|
DocCommentHighlightRules.getTagRule(),
|
157
|
{token : "comment.start", regex : /\/\*/, push: "nested_comment"},
|
158
|
{token : "comment.end", regex : "\\*\\/", next : "pop"},
|
159
|
{defaultToken : "comment", caseInsensitive: true}
|
160
|
]
|
161
|
}
|
162
|
];
|
163
|
}
|
164
|
|
165
|
|
166
|
this.$rules = {
|
167
|
start: [
|
168
|
string('"', {
|
169
|
escape: /\\(?:[0\\tnr"']|u{[a-fA-F1-9]{0,8}})/,
|
170
|
interpolation: {lead: "\\", open: "(", close: ")"},
|
171
|
error: /\\./,
|
172
|
multiline: false
|
173
|
}),
|
174
|
comments(),
|
175
|
{
|
176
|
regex: /@[a-zA-Z_$][a-zA-Z_$\d\u0080-\ufffe]*/,
|
177
|
token: "variable.parameter"
|
178
|
},
|
179
|
{
|
180
|
regex: /[a-zA-Z_$][a-zA-Z_$\d\u0080-\ufffe]*/,
|
181
|
token: keywordMapper
|
182
|
},
|
183
|
{
|
184
|
token : "constant.numeric",
|
185
|
regex : /[+-]?(?:0(?:b[01]+|o[0-7]+|x[\da-fA-F])|\d+(?:(?:\.\d*)?(?:[PpEe][+-]?\d+)?)\b)/
|
186
|
}, {
|
187
|
token : "keyword.operator",
|
188
|
regex : /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
|
189
|
next : "start"
|
190
|
}, {
|
191
|
token : "punctuation.operator",
|
192
|
regex : /[?:,;.]/,
|
193
|
next : "start"
|
194
|
}, {
|
195
|
token : "paren.lparen",
|
196
|
regex : /[\[({]/,
|
197
|
next : "start"
|
198
|
}, {
|
199
|
token : "paren.rparen",
|
200
|
regex : /[\])}]/
|
201
|
}
|
202
|
|
203
|
]
|
204
|
};
|
205
|
this.embedRules(DocCommentHighlightRules, "doc-",
|
206
|
[ DocCommentHighlightRules.getEndRule("start") ]);
|
207
|
|
208
|
this.normalizeRules();
|
209
|
};
|
210
|
|
211
|
|
212
|
oop.inherits(SwiftHighlightRules, TextHighlightRules);
|
213
|
|
214
|
exports.HighlightRules = SwiftHighlightRules;
|
215
|
});
|
216
|
|
217
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
218
|
"use strict";
|
219
|
|
220
|
var oop = require("../../lib/oop");
|
221
|
var Range = require("../../range").Range;
|
222
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
223
|
|
224
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
225
|
if (commentRegex) {
|
226
|
this.foldingStartMarker = new RegExp(
|
227
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
228
|
);
|
229
|
this.foldingStopMarker = new RegExp(
|
230
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
231
|
);
|
232
|
}
|
233
|
};
|
234
|
oop.inherits(FoldMode, BaseFoldMode);
|
235
|
|
236
|
(function() {
|
237
|
|
238
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
239
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
240
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
241
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
242
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
243
|
this._getFoldWidgetBase = this.getFoldWidget;
|
244
|
this.getFoldWidget = function(session, foldStyle, row) {
|
245
|
var line = session.getLine(row);
|
246
|
|
247
|
if (this.singleLineBlockCommentRe.test(line)) {
|
248
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
249
|
return "";
|
250
|
}
|
251
|
|
252
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
253
|
|
254
|
if (!fw && this.startRegionRe.test(line))
|
255
|
return "start"; // lineCommentRegionStart
|
256
|
|
257
|
return fw;
|
258
|
};
|
259
|
|
260
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
261
|
var line = session.getLine(row);
|
262
|
|
263
|
if (this.startRegionRe.test(line))
|
264
|
return this.getCommentRegionBlock(session, line, row);
|
265
|
|
266
|
var match = line.match(this.foldingStartMarker);
|
267
|
if (match) {
|
268
|
var i = match.index;
|
269
|
|
270
|
if (match[1])
|
271
|
return this.openingBracketBlock(session, match[1], row, i);
|
272
|
|
273
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
274
|
|
275
|
if (range && !range.isMultiLine()) {
|
276
|
if (forceMultiline) {
|
277
|
range = this.getSectionRange(session, row);
|
278
|
} else if (foldStyle != "all")
|
279
|
range = null;
|
280
|
}
|
281
|
|
282
|
return range;
|
283
|
}
|
284
|
|
285
|
if (foldStyle === "markbegin")
|
286
|
return;
|
287
|
|
288
|
var match = line.match(this.foldingStopMarker);
|
289
|
if (match) {
|
290
|
var i = match.index + match[0].length;
|
291
|
|
292
|
if (match[1])
|
293
|
return this.closingBracketBlock(session, match[1], row, i);
|
294
|
|
295
|
return session.getCommentFoldRange(row, i, -1);
|
296
|
}
|
297
|
};
|
298
|
|
299
|
this.getSectionRange = function(session, row) {
|
300
|
var line = session.getLine(row);
|
301
|
var startIndent = line.search(/\S/);
|
302
|
var startRow = row;
|
303
|
var startColumn = line.length;
|
304
|
row = row + 1;
|
305
|
var endRow = row;
|
306
|
var maxRow = session.getLength();
|
307
|
while (++row < maxRow) {
|
308
|
line = session.getLine(row);
|
309
|
var indent = line.search(/\S/);
|
310
|
if (indent === -1)
|
311
|
continue;
|
312
|
if (startIndent > indent)
|
313
|
break;
|
314
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
315
|
|
316
|
if (subRange) {
|
317
|
if (subRange.start.row <= startRow) {
|
318
|
break;
|
319
|
} else if (subRange.isMultiLine()) {
|
320
|
row = subRange.end.row;
|
321
|
} else if (startIndent == indent) {
|
322
|
break;
|
323
|
}
|
324
|
}
|
325
|
endRow = row;
|
326
|
}
|
327
|
|
328
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
329
|
};
|
330
|
this.getCommentRegionBlock = function(session, line, row) {
|
331
|
var startColumn = line.search(/\s*$/);
|
332
|
var maxRow = session.getLength();
|
333
|
var startRow = row;
|
334
|
|
335
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
336
|
var depth = 1;
|
337
|
while (++row < maxRow) {
|
338
|
line = session.getLine(row);
|
339
|
var m = re.exec(line);
|
340
|
if (!m) continue;
|
341
|
if (m[1]) depth--;
|
342
|
else depth++;
|
343
|
|
344
|
if (!depth) break;
|
345
|
}
|
346
|
|
347
|
var endRow = row;
|
348
|
if (endRow > startRow) {
|
349
|
return new Range(startRow, startColumn, endRow, line.length);
|
350
|
}
|
351
|
};
|
352
|
|
353
|
}).call(FoldMode.prototype);
|
354
|
|
355
|
});
|
356
|
|
357
|
ace.define("ace/mode/swift",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/swift_highlight_rules","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
|
358
|
"use strict";
|
359
|
|
360
|
var oop = require("../lib/oop");
|
361
|
var TextMode = require("./text").Mode;
|
362
|
var HighlightRules = require("./swift_highlight_rules").HighlightRules;
|
363
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
364
|
var FoldMode = require("./folding/cstyle").FoldMode;
|
365
|
|
366
|
var Mode = function() {
|
367
|
this.HighlightRules = HighlightRules;
|
368
|
this.foldingRules = new FoldMode();
|
369
|
this.$behaviour = new CstyleBehaviour();
|
370
|
this.$behaviour = this.$defaultBehaviour;
|
371
|
};
|
372
|
oop.inherits(Mode, TextMode);
|
373
|
|
374
|
(function() {
|
375
|
this.lineCommentStart = "//";
|
376
|
this.blockComment = {start: "/*", end: "*/", nestable: true};
|
377
|
|
378
|
this.$id = "ace/mode/swift";
|
379
|
}).call(Mode.prototype);
|
380
|
|
381
|
exports.Mode = Mode;
|
382
|
}); (function() {
|
383
|
ace.require(["ace/mode/swift"], function(m) {
|
384
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
385
|
module.exports = m;
|
386
|
}
|
387
|
});
|
388
|
})();
|
389
|
|