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/javascript_highlight_rules",["require","exports","module","ace/lib/oop","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 DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
56
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
57
|
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
|
58
|
|
59
|
var JavaScriptHighlightRules = function(options) {
|
60
|
var keywordMapper = this.createKeywordMapper({
|
61
|
"variable.language":
|
62
|
"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
|
63
|
"Namespace|QName|XML|XMLList|" + // E4X
|
64
|
"ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
|
65
|
"Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
|
66
|
"Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
|
67
|
"SyntaxError|TypeError|URIError|" +
|
68
|
"decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
|
69
|
"isNaN|parseFloat|parseInt|" +
|
70
|
"JSON|Math|" + // Other
|
71
|
"this|arguments|prototype|window|document" , // Pseudo
|
72
|
"keyword":
|
73
|
"const|yield|import|get|set|async|await|" +
|
74
|
"break|case|catch|continue|default|delete|do|else|finally|for|function|" +
|
75
|
"if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
|
76
|
"__parent__|__count__|escape|unescape|with|__proto__|" +
|
77
|
"class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
|
78
|
"storage.type":
|
79
|
"const|let|var|function",
|
80
|
"constant.language":
|
81
|
"null|Infinity|NaN|undefined",
|
82
|
"support.function":
|
83
|
"alert",
|
84
|
"constant.language.boolean": "true|false"
|
85
|
}, "identifier");
|
86
|
var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
|
87
|
|
88
|
var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
|
89
|
"u[0-9a-fA-F]{4}|" + // unicode
|
90
|
"u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
|
91
|
"[0-2][0-7]{0,2}|" + // oct
|
92
|
"3[0-7][0-7]?|" + // oct
|
93
|
"[4-7][0-7]?|" + //oct
|
94
|
".)";
|
95
|
|
96
|
this.$rules = {
|
97
|
"no_regex" : [
|
98
|
DocCommentHighlightRules.getStartRule("doc-start"),
|
99
|
comments("no_regex"),
|
100
|
{
|
101
|
token : "string",
|
102
|
regex : "'(?=.)",
|
103
|
next : "qstring"
|
104
|
}, {
|
105
|
token : "string",
|
106
|
regex : '"(?=.)',
|
107
|
next : "qqstring"
|
108
|
}, {
|
109
|
token : "constant.numeric", // hexadecimal, octal and binary
|
110
|
regex : /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
|
111
|
}, {
|
112
|
token : "constant.numeric", // decimal integers and floats
|
113
|
regex : /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
|
114
|
}, {
|
115
|
token : [
|
116
|
"storage.type", "punctuation.operator", "support.function",
|
117
|
"punctuation.operator", "entity.name.function", "text","keyword.operator"
|
118
|
],
|
119
|
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
|
120
|
next: "function_arguments"
|
121
|
}, {
|
122
|
token : [
|
123
|
"storage.type", "punctuation.operator", "entity.name.function", "text",
|
124
|
"keyword.operator", "text", "storage.type", "text", "paren.lparen"
|
125
|
],
|
126
|
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
|
127
|
next: "function_arguments"
|
128
|
}, {
|
129
|
token : [
|
130
|
"entity.name.function", "text", "keyword.operator", "text", "storage.type",
|
131
|
"text", "paren.lparen"
|
132
|
],
|
133
|
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
|
134
|
next: "function_arguments"
|
135
|
}, {
|
136
|
token : [
|
137
|
"storage.type", "punctuation.operator", "entity.name.function", "text",
|
138
|
"keyword.operator", "text",
|
139
|
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
|
140
|
],
|
141
|
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
|
142
|
next: "function_arguments"
|
143
|
}, {
|
144
|
token : [
|
145
|
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
|
146
|
],
|
147
|
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
|
148
|
next: "function_arguments"
|
149
|
}, {
|
150
|
token : [
|
151
|
"entity.name.function", "text", "punctuation.operator",
|
152
|
"text", "storage.type", "text", "paren.lparen"
|
153
|
],
|
154
|
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
|
155
|
next: "function_arguments"
|
156
|
}, {
|
157
|
token : [
|
158
|
"text", "text", "storage.type", "text", "paren.lparen"
|
159
|
],
|
160
|
regex : "(:)(\\s*)(function)(\\s*)(\\()",
|
161
|
next: "function_arguments"
|
162
|
}, {
|
163
|
token : "keyword",
|
164
|
regex : "from(?=\\s*('|\"))"
|
165
|
}, {
|
166
|
token : "keyword",
|
167
|
regex : "(?:" + kwBeforeRe + ")\\b",
|
168
|
next : "start"
|
169
|
}, {
|
170
|
token : ["support.constant"],
|
171
|
regex : /that\b/
|
172
|
}, {
|
173
|
token : ["storage.type", "punctuation.operator", "support.function.firebug"],
|
174
|
regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
|
175
|
}, {
|
176
|
token : keywordMapper,
|
177
|
regex : identifierRe
|
178
|
}, {
|
179
|
token : "punctuation.operator",
|
180
|
regex : /[.](?![.])/,
|
181
|
next : "property"
|
182
|
}, {
|
183
|
token : "storage.type",
|
184
|
regex : /=>/,
|
185
|
next : "start"
|
186
|
}, {
|
187
|
token : "keyword.operator",
|
188
|
regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
|
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
|
token: "comment",
|
203
|
regex: /^#!.*$/
|
204
|
}
|
205
|
],
|
206
|
property: [{
|
207
|
token : "text",
|
208
|
regex : "\\s+"
|
209
|
}, {
|
210
|
token : [
|
211
|
"storage.type", "punctuation.operator", "entity.name.function", "text",
|
212
|
"keyword.operator", "text",
|
213
|
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
|
214
|
],
|
215
|
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",
|
216
|
next: "function_arguments"
|
217
|
}, {
|
218
|
token : "punctuation.operator",
|
219
|
regex : /[.](?![.])/
|
220
|
}, {
|
221
|
token : "support.function",
|
222
|
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(?=\()/
|
223
|
}, {
|
224
|
token : "support.function.dom",
|
225
|
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(?=\()/
|
226
|
}, {
|
227
|
token : "support.constant",
|
228
|
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/
|
229
|
}, {
|
230
|
token : "identifier",
|
231
|
regex : identifierRe
|
232
|
}, {
|
233
|
regex: "",
|
234
|
token: "empty",
|
235
|
next: "no_regex"
|
236
|
}
|
237
|
],
|
238
|
"start": [
|
239
|
DocCommentHighlightRules.getStartRule("doc-start"),
|
240
|
comments("start"),
|
241
|
{
|
242
|
token: "string.regexp",
|
243
|
regex: "\\/",
|
244
|
next: "regex"
|
245
|
}, {
|
246
|
token : "text",
|
247
|
regex : "\\s+|^$",
|
248
|
next : "start"
|
249
|
}, {
|
250
|
token: "empty",
|
251
|
regex: "",
|
252
|
next: "no_regex"
|
253
|
}
|
254
|
],
|
255
|
"regex": [
|
256
|
{
|
257
|
token: "regexp.keyword.operator",
|
258
|
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
|
259
|
}, {
|
260
|
token: "string.regexp",
|
261
|
regex: "/[sxngimy]*",
|
262
|
next: "no_regex"
|
263
|
}, {
|
264
|
token : "invalid",
|
265
|
regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
|
266
|
}, {
|
267
|
token : "constant.language.escape",
|
268
|
regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
|
269
|
}, {
|
270
|
token : "constant.language.delimiter",
|
271
|
regex: /\|/
|
272
|
}, {
|
273
|
token: "constant.language.escape",
|
274
|
regex: /\[\^?/,
|
275
|
next: "regex_character_class"
|
276
|
}, {
|
277
|
token: "empty",
|
278
|
regex: "$",
|
279
|
next: "no_regex"
|
280
|
}, {
|
281
|
defaultToken: "string.regexp"
|
282
|
}
|
283
|
],
|
284
|
"regex_character_class": [
|
285
|
{
|
286
|
token: "regexp.charclass.keyword.operator",
|
287
|
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
|
288
|
}, {
|
289
|
token: "constant.language.escape",
|
290
|
regex: "]",
|
291
|
next: "regex"
|
292
|
}, {
|
293
|
token: "constant.language.escape",
|
294
|
regex: "-"
|
295
|
}, {
|
296
|
token: "empty",
|
297
|
regex: "$",
|
298
|
next: "no_regex"
|
299
|
}, {
|
300
|
defaultToken: "string.regexp.charachterclass"
|
301
|
}
|
302
|
],
|
303
|
"function_arguments": [
|
304
|
{
|
305
|
token: "variable.parameter",
|
306
|
regex: identifierRe
|
307
|
}, {
|
308
|
token: "punctuation.operator",
|
309
|
regex: "[, ]+"
|
310
|
}, {
|
311
|
token: "punctuation.operator",
|
312
|
regex: "$"
|
313
|
}, {
|
314
|
token: "empty",
|
315
|
regex: "",
|
316
|
next: "no_regex"
|
317
|
}
|
318
|
],
|
319
|
"qqstring" : [
|
320
|
{
|
321
|
token : "constant.language.escape",
|
322
|
regex : escapedRe
|
323
|
}, {
|
324
|
token : "string",
|
325
|
regex : "\\\\$",
|
326
|
consumeLineEnd : true
|
327
|
}, {
|
328
|
token : "string",
|
329
|
regex : '"|$',
|
330
|
next : "no_regex"
|
331
|
}, {
|
332
|
defaultToken: "string"
|
333
|
}
|
334
|
],
|
335
|
"qstring" : [
|
336
|
{
|
337
|
token : "constant.language.escape",
|
338
|
regex : escapedRe
|
339
|
}, {
|
340
|
token : "string",
|
341
|
regex : "\\\\$",
|
342
|
consumeLineEnd : true
|
343
|
}, {
|
344
|
token : "string",
|
345
|
regex : "'|$",
|
346
|
next : "no_regex"
|
347
|
}, {
|
348
|
defaultToken: "string"
|
349
|
}
|
350
|
]
|
351
|
};
|
352
|
|
353
|
|
354
|
if (!options || !options.noES6) {
|
355
|
this.$rules.no_regex.unshift({
|
356
|
regex: "[{}]", onMatch: function(val, state, stack) {
|
357
|
this.next = val == "{" ? this.nextState : "";
|
358
|
if (val == "{" && stack.length) {
|
359
|
stack.unshift("start", state);
|
360
|
}
|
361
|
else if (val == "}" && stack.length) {
|
362
|
stack.shift();
|
363
|
this.next = stack.shift();
|
364
|
if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
|
365
|
return "paren.quasi.end";
|
366
|
}
|
367
|
return val == "{" ? "paren.lparen" : "paren.rparen";
|
368
|
},
|
369
|
nextState: "start"
|
370
|
}, {
|
371
|
token : "string.quasi.start",
|
372
|
regex : /`/,
|
373
|
push : [{
|
374
|
token : "constant.language.escape",
|
375
|
regex : escapedRe
|
376
|
}, {
|
377
|
token : "paren.quasi.start",
|
378
|
regex : /\${/,
|
379
|
push : "start"
|
380
|
}, {
|
381
|
token : "string.quasi.end",
|
382
|
regex : /`/,
|
383
|
next : "pop"
|
384
|
}, {
|
385
|
defaultToken: "string.quasi"
|
386
|
}]
|
387
|
});
|
388
|
|
389
|
if (!options || options.jsx != false)
|
390
|
JSX.call(this);
|
391
|
}
|
392
|
|
393
|
this.embedRules(DocCommentHighlightRules, "doc-",
|
394
|
[ DocCommentHighlightRules.getEndRule("no_regex") ]);
|
395
|
|
396
|
this.normalizeRules();
|
397
|
};
|
398
|
|
399
|
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
|
400
|
|
401
|
function JSX() {
|
402
|
var tagRegex = identifierRe.replace("\\d", "\\d\\-");
|
403
|
var jsxTag = {
|
404
|
onMatch : function(val, state, stack) {
|
405
|
var offset = val.charAt(1) == "/" ? 2 : 1;
|
406
|
if (offset == 1) {
|
407
|
if (state != this.nextState)
|
408
|
stack.unshift(this.next, this.nextState, 0);
|
409
|
else
|
410
|
stack.unshift(this.next);
|
411
|
stack[2]++;
|
412
|
} else if (offset == 2) {
|
413
|
if (state == this.nextState) {
|
414
|
stack[1]--;
|
415
|
if (!stack[1] || stack[1] < 0) {
|
416
|
stack.shift();
|
417
|
stack.shift();
|
418
|
}
|
419
|
}
|
420
|
}
|
421
|
return [{
|
422
|
type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
|
423
|
value: val.slice(0, offset)
|
424
|
}, {
|
425
|
type: "meta.tag.tag-name.xml",
|
426
|
value: val.substr(offset)
|
427
|
}];
|
428
|
},
|
429
|
regex : "</?" + tagRegex + "",
|
430
|
next: "jsxAttributes",
|
431
|
nextState: "jsx"
|
432
|
};
|
433
|
this.$rules.start.unshift(jsxTag);
|
434
|
var jsxJsRule = {
|
435
|
regex: "{",
|
436
|
token: "paren.quasi.start",
|
437
|
push: "start"
|
438
|
};
|
439
|
this.$rules.jsx = [
|
440
|
jsxJsRule,
|
441
|
jsxTag,
|
442
|
{include : "reference"},
|
443
|
{defaultToken: "string"}
|
444
|
];
|
445
|
this.$rules.jsxAttributes = [{
|
446
|
token : "meta.tag.punctuation.tag-close.xml",
|
447
|
regex : "/?>",
|
448
|
onMatch : function(value, currentState, stack) {
|
449
|
if (currentState == stack[0])
|
450
|
stack.shift();
|
451
|
if (value.length == 2) {
|
452
|
if (stack[0] == this.nextState)
|
453
|
stack[1]--;
|
454
|
if (!stack[1] || stack[1] < 0) {
|
455
|
stack.splice(0, 2);
|
456
|
}
|
457
|
}
|
458
|
this.next = stack[0] || "start";
|
459
|
return [{type: this.token, value: value}];
|
460
|
},
|
461
|
nextState: "jsx"
|
462
|
},
|
463
|
jsxJsRule,
|
464
|
comments("jsxAttributes"),
|
465
|
{
|
466
|
token : "entity.other.attribute-name.xml",
|
467
|
regex : tagRegex
|
468
|
}, {
|
469
|
token : "keyword.operator.attribute-equals.xml",
|
470
|
regex : "="
|
471
|
}, {
|
472
|
token : "text.tag-whitespace.xml",
|
473
|
regex : "\\s+"
|
474
|
}, {
|
475
|
token : "string.attribute-value.xml",
|
476
|
regex : "'",
|
477
|
stateName : "jsx_attr_q",
|
478
|
push : [
|
479
|
{token : "string.attribute-value.xml", regex: "'", next: "pop"},
|
480
|
{include : "reference"},
|
481
|
{defaultToken : "string.attribute-value.xml"}
|
482
|
]
|
483
|
}, {
|
484
|
token : "string.attribute-value.xml",
|
485
|
regex : '"',
|
486
|
stateName : "jsx_attr_qq",
|
487
|
push : [
|
488
|
{token : "string.attribute-value.xml", regex: '"', next: "pop"},
|
489
|
{include : "reference"},
|
490
|
{defaultToken : "string.attribute-value.xml"}
|
491
|
]
|
492
|
},
|
493
|
jsxTag
|
494
|
];
|
495
|
this.$rules.reference = [{
|
496
|
token : "constant.language.escape.reference.xml",
|
497
|
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
|
498
|
}];
|
499
|
}
|
500
|
|
501
|
function comments(next) {
|
502
|
return [
|
503
|
{
|
504
|
token : "comment", // multi line comment
|
505
|
regex : /\/\*/,
|
506
|
next: [
|
507
|
DocCommentHighlightRules.getTagRule(),
|
508
|
{token : "comment", regex : "\\*\\/", next : next || "pop"},
|
509
|
{defaultToken : "comment", caseInsensitive: true}
|
510
|
]
|
511
|
}, {
|
512
|
token : "comment",
|
513
|
regex : "\\/\\/",
|
514
|
next: [
|
515
|
DocCommentHighlightRules.getTagRule(),
|
516
|
{token : "comment", regex : "$|^", next : next || "pop"},
|
517
|
{defaultToken : "comment", caseInsensitive: true}
|
518
|
]
|
519
|
}
|
520
|
];
|
521
|
}
|
522
|
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
|
523
|
});
|
524
|
|
525
|
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
526
|
"use strict";
|
527
|
|
528
|
var Range = require("../range").Range;
|
529
|
|
530
|
var MatchingBraceOutdent = function() {};
|
531
|
|
532
|
(function() {
|
533
|
|
534
|
this.checkOutdent = function(line, input) {
|
535
|
if (! /^\s+$/.test(line))
|
536
|
return false;
|
537
|
|
538
|
return /^\s*\}/.test(input);
|
539
|
};
|
540
|
|
541
|
this.autoOutdent = function(doc, row) {
|
542
|
var line = doc.getLine(row);
|
543
|
var match = line.match(/^(\s*\})/);
|
544
|
|
545
|
if (!match) return 0;
|
546
|
|
547
|
var column = match[1].length;
|
548
|
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
549
|
|
550
|
if (!openBracePos || openBracePos.row == row) return 0;
|
551
|
|
552
|
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
553
|
doc.replace(new Range(row, 0, row, column-1), indent);
|
554
|
};
|
555
|
|
556
|
this.$getIndent = function(line) {
|
557
|
return line.match(/^\s*/)[0];
|
558
|
};
|
559
|
|
560
|
}).call(MatchingBraceOutdent.prototype);
|
561
|
|
562
|
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
563
|
});
|
564
|
|
565
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
566
|
"use strict";
|
567
|
|
568
|
var oop = require("../../lib/oop");
|
569
|
var Range = require("../../range").Range;
|
570
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
571
|
|
572
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
573
|
if (commentRegex) {
|
574
|
this.foldingStartMarker = new RegExp(
|
575
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
576
|
);
|
577
|
this.foldingStopMarker = new RegExp(
|
578
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
579
|
);
|
580
|
}
|
581
|
};
|
582
|
oop.inherits(FoldMode, BaseFoldMode);
|
583
|
|
584
|
(function() {
|
585
|
|
586
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
587
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
588
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
589
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
590
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
591
|
this._getFoldWidgetBase = this.getFoldWidget;
|
592
|
this.getFoldWidget = function(session, foldStyle, row) {
|
593
|
var line = session.getLine(row);
|
594
|
|
595
|
if (this.singleLineBlockCommentRe.test(line)) {
|
596
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
597
|
return "";
|
598
|
}
|
599
|
|
600
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
601
|
|
602
|
if (!fw && this.startRegionRe.test(line))
|
603
|
return "start"; // lineCommentRegionStart
|
604
|
|
605
|
return fw;
|
606
|
};
|
607
|
|
608
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
609
|
var line = session.getLine(row);
|
610
|
|
611
|
if (this.startRegionRe.test(line))
|
612
|
return this.getCommentRegionBlock(session, line, row);
|
613
|
|
614
|
var match = line.match(this.foldingStartMarker);
|
615
|
if (match) {
|
616
|
var i = match.index;
|
617
|
|
618
|
if (match[1])
|
619
|
return this.openingBracketBlock(session, match[1], row, i);
|
620
|
|
621
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
622
|
|
623
|
if (range && !range.isMultiLine()) {
|
624
|
if (forceMultiline) {
|
625
|
range = this.getSectionRange(session, row);
|
626
|
} else if (foldStyle != "all")
|
627
|
range = null;
|
628
|
}
|
629
|
|
630
|
return range;
|
631
|
}
|
632
|
|
633
|
if (foldStyle === "markbegin")
|
634
|
return;
|
635
|
|
636
|
var match = line.match(this.foldingStopMarker);
|
637
|
if (match) {
|
638
|
var i = match.index + match[0].length;
|
639
|
|
640
|
if (match[1])
|
641
|
return this.closingBracketBlock(session, match[1], row, i);
|
642
|
|
643
|
return session.getCommentFoldRange(row, i, -1);
|
644
|
}
|
645
|
};
|
646
|
|
647
|
this.getSectionRange = function(session, row) {
|
648
|
var line = session.getLine(row);
|
649
|
var startIndent = line.search(/\S/);
|
650
|
var startRow = row;
|
651
|
var startColumn = line.length;
|
652
|
row = row + 1;
|
653
|
var endRow = row;
|
654
|
var maxRow = session.getLength();
|
655
|
while (++row < maxRow) {
|
656
|
line = session.getLine(row);
|
657
|
var indent = line.search(/\S/);
|
658
|
if (indent === -1)
|
659
|
continue;
|
660
|
if (startIndent > indent)
|
661
|
break;
|
662
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
663
|
|
664
|
if (subRange) {
|
665
|
if (subRange.start.row <= startRow) {
|
666
|
break;
|
667
|
} else if (subRange.isMultiLine()) {
|
668
|
row = subRange.end.row;
|
669
|
} else if (startIndent == indent) {
|
670
|
break;
|
671
|
}
|
672
|
}
|
673
|
endRow = row;
|
674
|
}
|
675
|
|
676
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
677
|
};
|
678
|
this.getCommentRegionBlock = function(session, line, row) {
|
679
|
var startColumn = line.search(/\s*$/);
|
680
|
var maxRow = session.getLength();
|
681
|
var startRow = row;
|
682
|
|
683
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
684
|
var depth = 1;
|
685
|
while (++row < maxRow) {
|
686
|
line = session.getLine(row);
|
687
|
var m = re.exec(line);
|
688
|
if (!m) continue;
|
689
|
if (m[1]) depth--;
|
690
|
else depth++;
|
691
|
|
692
|
if (!depth) break;
|
693
|
}
|
694
|
|
695
|
var endRow = row;
|
696
|
if (endRow > startRow) {
|
697
|
return new Range(startRow, startColumn, endRow, line.length);
|
698
|
}
|
699
|
};
|
700
|
|
701
|
}).call(FoldMode.prototype);
|
702
|
|
703
|
});
|
704
|
|
705
|
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) {
|
706
|
"use strict";
|
707
|
|
708
|
var oop = require("../lib/oop");
|
709
|
var TextMode = require("./text").Mode;
|
710
|
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
711
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
712
|
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
713
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
714
|
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
715
|
|
716
|
var Mode = function() {
|
717
|
this.HighlightRules = JavaScriptHighlightRules;
|
718
|
|
719
|
this.$outdent = new MatchingBraceOutdent();
|
720
|
this.$behaviour = new CstyleBehaviour();
|
721
|
this.foldingRules = new CStyleFoldMode();
|
722
|
};
|
723
|
oop.inherits(Mode, TextMode);
|
724
|
|
725
|
(function() {
|
726
|
|
727
|
this.lineCommentStart = "//";
|
728
|
this.blockComment = {start: "/*", end: "*/"};
|
729
|
this.$quotes = {'"': '"', "'": "'", "`": "`"};
|
730
|
|
731
|
this.getNextLineIndent = function(state, line, tab) {
|
732
|
var indent = this.$getIndent(line);
|
733
|
|
734
|
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
735
|
var tokens = tokenizedLine.tokens;
|
736
|
var endState = tokenizedLine.state;
|
737
|
|
738
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
739
|
return indent;
|
740
|
}
|
741
|
|
742
|
if (state == "start" || state == "no_regex") {
|
743
|
var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
|
744
|
if (match) {
|
745
|
indent += tab;
|
746
|
}
|
747
|
} else if (state == "doc-start") {
|
748
|
if (endState == "start" || endState == "no_regex") {
|
749
|
return "";
|
750
|
}
|
751
|
var match = line.match(/^\s*(\/?)\*/);
|
752
|
if (match) {
|
753
|
if (match[1]) {
|
754
|
indent += " ";
|
755
|
}
|
756
|
indent += "* ";
|
757
|
}
|
758
|
}
|
759
|
|
760
|
return indent;
|
761
|
};
|
762
|
|
763
|
this.checkOutdent = function(state, line, input) {
|
764
|
return this.$outdent.checkOutdent(line, input);
|
765
|
};
|
766
|
|
767
|
this.autoOutdent = function(state, doc, row) {
|
768
|
this.$outdent.autoOutdent(doc, row);
|
769
|
};
|
770
|
|
771
|
this.createWorker = function(session) {
|
772
|
var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
|
773
|
worker.attachToDocument(session.getDocument());
|
774
|
|
775
|
worker.on("annotate", function(results) {
|
776
|
session.setAnnotations(results.data);
|
777
|
});
|
778
|
|
779
|
worker.on("terminate", function() {
|
780
|
session.clearAnnotations();
|
781
|
});
|
782
|
|
783
|
return worker;
|
784
|
};
|
785
|
|
786
|
this.$id = "ace/mode/javascript";
|
787
|
this.snippetFileId = "ace/snippets/javascript";
|
788
|
}).call(Mode.prototype);
|
789
|
|
790
|
exports.Mode = Mode;
|
791
|
});
|
792
|
|
793
|
ace.define("ace/mode/wollok_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
794
|
"use strict";
|
795
|
|
796
|
var oop = require("../lib/oop");
|
797
|
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
798
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
799
|
|
800
|
var WollokHighlightRules = function() {
|
801
|
var keywords = (
|
802
|
"test|describe|package|inherits|false|import|else|or|class|and|not|native|override|program|self|try|const|var|catch|object|super|throw|if|null|return|true|new|constructor|method|mixin"
|
803
|
);
|
804
|
|
805
|
var buildinConstants = ("null|assert|console");
|
806
|
|
807
|
var langClasses = (
|
808
|
"Object|Pair|String|Boolean|Number|Integer|Double|Collection|Set|List|Exception|Range" +
|
809
|
"|StackTraceElement"
|
810
|
);
|
811
|
|
812
|
var keywordMapper = this.createKeywordMapper({
|
813
|
"variable.language": "self",
|
814
|
"keyword": keywords,
|
815
|
"constant.language": buildinConstants,
|
816
|
"support.function": langClasses
|
817
|
}, "identifier");
|
818
|
|
819
|
this.$rules = {
|
820
|
"start" : [
|
821
|
{
|
822
|
token : "comment",
|
823
|
regex : "\\/\\/.*$"
|
824
|
},
|
825
|
DocCommentHighlightRules.getStartRule("doc-start"),
|
826
|
{
|
827
|
token : "comment", // multi line comment
|
828
|
regex : "\\/\\*",
|
829
|
next : "comment"
|
830
|
}, {
|
831
|
token : "string", // single line
|
832
|
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
833
|
}, {
|
834
|
token : "string", // single line
|
835
|
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
836
|
}, {
|
837
|
token : "constant.numeric", // hex
|
838
|
regex : /0(?:[xX][0-9a-fA-F][0-9a-fA-F_]*|[bB][01][01_]*)[LlSsDdFfYy]?\b/
|
839
|
}, {
|
840
|
token : "constant.numeric", // float
|
841
|
regex : /[+-]?\d[\d_]*(?:(?:\.[\d_]*)?(?:[eE][+-]?[\d_]+)?)?[LlSsDdFfYy]?\b/
|
842
|
}, {
|
843
|
token : "constant.language.boolean",
|
844
|
regex : "(?:true|false)\\b"
|
845
|
}, {
|
846
|
token : keywordMapper,
|
847
|
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
848
|
}, {
|
849
|
token : "keyword.operator",
|
850
|
regex : "===|&&|\\*=|\\.\\.|\\*\\*|#|!|%|\\*|\\?:|\\+|\\/|,|\\+=|\\-|\\.\\.<|!==|:|\\/=|\\?\\.|\\+\\+|>|=|<|>=|=>|==|\\]|\\[|\\-=|\\->|\\||\\-\\-|<>|!=|%=|\\|"
|
851
|
}, {
|
852
|
token : "lparen",
|
853
|
regex : "[[({]"
|
854
|
}, {
|
855
|
token : "rparen",
|
856
|
regex : "[\\])}]"
|
857
|
}, {
|
858
|
token : "text",
|
859
|
regex : "\\s+"
|
860
|
}
|
861
|
],
|
862
|
"comment" : [
|
863
|
{
|
864
|
token : "comment", // closing comment
|
865
|
regex : ".*?\\*\\/",
|
866
|
next : "start"
|
867
|
}, {
|
868
|
token : "comment", // comment spanning whole line
|
869
|
regex : ".+"
|
870
|
}
|
871
|
]
|
872
|
};
|
873
|
|
874
|
this.embedRules(DocCommentHighlightRules, "doc-",
|
875
|
[ DocCommentHighlightRules.getEndRule("start") ]);
|
876
|
};
|
877
|
|
878
|
oop.inherits(WollokHighlightRules, TextHighlightRules);
|
879
|
|
880
|
exports.WollokHighlightRules = WollokHighlightRules;
|
881
|
});
|
882
|
|
883
|
ace.define("ace/mode/wollok",["require","exports","module","ace/lib/oop","ace/mode/javascript","ace/mode/wollok_highlight_rules"], function(require, exports, module) {
|
884
|
"use strict";
|
885
|
|
886
|
var oop = require("../lib/oop");
|
887
|
var JavaScriptMode = require("./javascript").Mode;
|
888
|
var WollokHighlightRules = require("./wollok_highlight_rules").WollokHighlightRules;
|
889
|
|
890
|
var Mode = function() {
|
891
|
JavaScriptMode.call(this);
|
892
|
this.HighlightRules = WollokHighlightRules;
|
893
|
};
|
894
|
oop.inherits(Mode, JavaScriptMode);
|
895
|
|
896
|
(function() {
|
897
|
|
898
|
this.createWorker = function(session) {
|
899
|
return null;
|
900
|
};
|
901
|
|
902
|
this.$id = "ace/mode/wollok";
|
903
|
this.snippetFileId = "ace/snippets/wollok";
|
904
|
}).call(Mode.prototype);
|
905
|
|
906
|
exports.Mode = Mode;
|
907
|
}); (function() {
|
908
|
ace.require(["ace/mode/wollok"], function(m) {
|
909
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
910
|
module.exports = m;
|
911
|
}
|
912
|
});
|
913
|
})();
|
914
|
|