Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-jsx.js

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