mode-scala.js 37 KB

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