569c6845776ba1e46e8eb4b2ebe1b5e7.js 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191
  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.body",
  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. 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";
  123. var oop = require("../lib/oop");
  124. var DocCommentHighlightRules = require("./jsdoc_comment_highlight_rules").JsDocCommentHighlightRules;
  125. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  126. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
  127. var JavaScriptHighlightRules = function (options) {
  128. var keywords = {
  129. "variable.language": "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|Symbol|" + // Constructors
  130. "Namespace|QName|XML|XMLList|" + // E4X
  131. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  132. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  133. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
  134. "SyntaxError|TypeError|URIError|" +
  135. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
  136. "isNaN|parseFloat|parseInt|" +
  137. "JSON|Math|" + // Other
  138. "this|arguments|prototype|window|document", // Pseudo
  139. "keyword": "const|yield|import|get|set|async|await|" +
  140. "break|case|catch|continue|default|delete|do|else|finally|for|" +
  141. "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
  142. "__parent__|__count__|escape|unescape|with|__proto__|" +
  143. "class|enum|extends|super|export|implements|private|public|interface|package|protected|static|constructor",
  144. "storage.type": "const|let|var|function",
  145. "constant.language": "null|Infinity|NaN|undefined",
  146. "support.function": "alert",
  147. "constant.language.boolean": "true|false"
  148. };
  149. var keywordMapper = this.createKeywordMapper(keywords, "identifier");
  150. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
  151. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  152. "u[0-9a-fA-F]{4}|" + // unicode
  153. "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
  154. "[0-2][0-7]{0,2}|" + // oct
  155. "3[0-7][0-7]?|" + // oct
  156. "[4-7][0-7]?|" + //oct
  157. ".)";
  158. var anonymousFunctionRe = "(function)(\\s*)(\\*?)";
  159. var functionCallStartRule = {
  160. token: ["identifier", "text", "paren.lparen"],
  161. regex: "(\\b(?!" + Object.values(keywords).join("|") + "\\b)" + identifierRe + ")(\\s*)(\\()"
  162. };
  163. this.$rules = {
  164. "no_regex": [
  165. DocCommentHighlightRules.getStartRule("doc-start"),
  166. comments("no_regex"),
  167. functionCallStartRule,
  168. {
  169. token: "string",
  170. regex: "'(?=.)",
  171. next: "qstring"
  172. }, {
  173. token: "string",
  174. regex: '"(?=.)',
  175. next: "qqstring"
  176. }, {
  177. token: "constant.numeric", // hexadecimal, octal and binary
  178. regex: /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
  179. }, {
  180. token: "constant.numeric", // decimal integers and floats
  181. regex: /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
  182. }, {
  183. token: [
  184. "entity.name.function", "text", "keyword.operator", "text", "storage.type",
  185. "text", "storage.type", "text", "paren.lparen"
  186. ],
  187. regex: "(" + identifierRe + ")(\\s*)(=)(\\s*)" + anonymousFunctionRe + "(\\s*)(\\()",
  188. next: "function_arguments"
  189. }, {
  190. token: [
  191. "storage.type", "text", "storage.type", "text", "text", "entity.name.function", "text", "paren.lparen"
  192. ],
  193. regex: "(function)(?:(?:(\\s*)(\\*)(\\s*))|(\\s+))(" + identifierRe + ")(\\s*)(\\()",
  194. next: "function_arguments"
  195. }, {
  196. token: [
  197. "entity.name.function", "text", "punctuation.operator",
  198. "text", "storage.type", "text", "storage.type", "text", "paren.lparen"
  199. ],
  200. regex: "(" + identifierRe + ")(\\s*)(:)(\\s*)" + anonymousFunctionRe + "(\\s*)(\\()",
  201. next: "function_arguments"
  202. }, {
  203. token: [
  204. "text", "text", "storage.type", "text", "storage.type", "text", "paren.lparen"
  205. ],
  206. regex: "(:)(\\s*)" + anonymousFunctionRe + "(\\s*)(\\()",
  207. next: "function_arguments"
  208. }, {
  209. token: "keyword",
  210. regex: "from(?=\\s*('|\"))"
  211. }, {
  212. token: "keyword",
  213. regex: "(?:" + kwBeforeRe + ")\\b",
  214. next: "start"
  215. }, {
  216. token: "support.constant",
  217. regex: /that\b/
  218. }, {
  219. token: ["storage.type", "punctuation.operator", "support.function.firebug"],
  220. regex: /(console)(\.)(warn|info|log|error|debug|time|trace|timeEnd|assert)\b/
  221. }, {
  222. token: keywordMapper,
  223. regex: identifierRe
  224. }, {
  225. token: "punctuation.operator",
  226. regex: /[.](?![.])/,
  227. next: "property"
  228. }, {
  229. token: "storage.type",
  230. regex: /=>/,
  231. next: "start"
  232. }, {
  233. token: "keyword.operator",
  234. regex: /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
  235. next: "start"
  236. }, {
  237. token: "punctuation.operator",
  238. regex: /[?:,;.]/,
  239. next: "start"
  240. }, {
  241. token: "paren.lparen",
  242. regex: /[\[({]/,
  243. next: "start"
  244. }, {
  245. token: "paren.rparen",
  246. regex: /[\])}]/
  247. }, {
  248. token: "comment",
  249. regex: /^#!.*$/
  250. }
  251. ],
  252. property: [{
  253. token: "text",
  254. regex: "\\s+"
  255. }, {
  256. token: "keyword.operator",
  257. regex: /=/
  258. }, {
  259. token: [
  260. "storage.type", "text", "storage.type", "text", "paren.lparen"
  261. ],
  262. regex: anonymousFunctionRe + "(\\s*)(\\()",
  263. next: "function_arguments"
  264. }, {
  265. token: [
  266. "storage.type", "text", "storage.type", "text", "text", "entity.name.function", "text", "paren.lparen"
  267. ],
  268. regex: "(function)(?:(?:(\\s*)(\\*)(\\s*))|(\\s+))(\\w+)(\\s*)(\\()",
  269. next: "function_arguments"
  270. }, {
  271. token: "punctuation.operator",
  272. regex: /[.](?![.])/
  273. }, {
  274. token: "support.function",
  275. regex: "prototype"
  276. }, {
  277. token: "support.function",
  278. 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(?=\()/
  279. }, {
  280. token: "support.function.dom",
  281. 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(?=\()/
  282. }, {
  283. token: "support.constant",
  284. 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/
  285. }, {
  286. token: "identifier",
  287. regex: identifierRe
  288. }, {
  289. regex: "",
  290. token: "empty",
  291. next: "no_regex"
  292. }
  293. ],
  294. "start": [
  295. DocCommentHighlightRules.getStartRule("doc-start"),
  296. comments("start"),
  297. {
  298. token: "string.regexp",
  299. regex: "\\/",
  300. next: "regex"
  301. }, {
  302. token: "text",
  303. regex: "\\s+|^$",
  304. next: "start"
  305. }, {
  306. token: "empty",
  307. regex: "",
  308. next: "no_regex"
  309. }
  310. ],
  311. "regex": [
  312. {
  313. token: "regexp.keyword.operator",
  314. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  315. }, {
  316. token: "string.regexp",
  317. regex: "/[sxngimy]*",
  318. next: "no_regex"
  319. }, {
  320. token: "invalid",
  321. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  322. }, {
  323. token: "constant.language.escape",
  324. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  325. }, {
  326. token: "constant.language.delimiter",
  327. regex: /\|/
  328. }, {
  329. token: "constant.language.escape",
  330. regex: /\[\^?/,
  331. next: "regex_character_class"
  332. }, {
  333. token: "empty",
  334. regex: "$",
  335. next: "no_regex"
  336. }, {
  337. defaultToken: "string.regexp"
  338. }
  339. ],
  340. "regex_character_class": [
  341. {
  342. token: "regexp.charclass.keyword.operator",
  343. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  344. }, {
  345. token: "constant.language.escape",
  346. regex: "]",
  347. next: "regex"
  348. }, {
  349. token: "constant.language.escape",
  350. regex: "-"
  351. }, {
  352. token: "empty",
  353. regex: "$",
  354. next: "no_regex"
  355. }, {
  356. defaultToken: "string.regexp.charachterclass"
  357. }
  358. ],
  359. "default_parameter": [
  360. {
  361. token: "string",
  362. regex: "'(?=.)",
  363. push: [
  364. {
  365. token: "string",
  366. regex: "'|$",
  367. next: "pop"
  368. }, {
  369. include: "qstring"
  370. }
  371. ]
  372. }, {
  373. token: "string",
  374. regex: '"(?=.)',
  375. push: [
  376. {
  377. token: "string",
  378. regex: '"|$',
  379. next: "pop"
  380. }, {
  381. include: "qqstring"
  382. }
  383. ]
  384. }, {
  385. token: "constant.language",
  386. regex: "null|Infinity|NaN|undefined"
  387. }, {
  388. token: "constant.numeric", // hexadecimal, octal and binary
  389. regex: /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
  390. }, {
  391. token: "constant.numeric", // decimal integers and floats
  392. regex: /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
  393. }, {
  394. token: "punctuation.operator",
  395. regex: ",",
  396. next: "function_arguments"
  397. }, {
  398. token: "text",
  399. regex: "\\s+"
  400. }, {
  401. token: "punctuation.operator",
  402. regex: "$"
  403. }, {
  404. token: "empty",
  405. regex: "",
  406. next: "no_regex"
  407. }
  408. ],
  409. "function_arguments": [
  410. comments("function_arguments"),
  411. {
  412. token: "variable.parameter",
  413. regex: identifierRe
  414. }, {
  415. token: "punctuation.operator",
  416. regex: ","
  417. }, {
  418. token: "text",
  419. regex: "\\s+"
  420. }, {
  421. token: "punctuation.operator",
  422. regex: "$"
  423. }, {
  424. token: "empty",
  425. regex: "",
  426. next: "no_regex"
  427. }
  428. ],
  429. "qqstring": [
  430. {
  431. token: "constant.language.escape",
  432. regex: escapedRe
  433. }, {
  434. token: "string",
  435. regex: "\\\\$",
  436. consumeLineEnd: true
  437. }, {
  438. token: "string",
  439. regex: '"|$',
  440. next: "no_regex"
  441. }, {
  442. defaultToken: "string"
  443. }
  444. ],
  445. "qstring": [
  446. {
  447. token: "constant.language.escape",
  448. regex: escapedRe
  449. }, {
  450. token: "string",
  451. regex: "\\\\$",
  452. consumeLineEnd: true
  453. }, {
  454. token: "string",
  455. regex: "'|$",
  456. next: "no_regex"
  457. }, {
  458. defaultToken: "string"
  459. }
  460. ]
  461. };
  462. if (!options || !options.noES6) {
  463. this.$rules.no_regex.unshift({
  464. regex: "[{}]", onMatch: function (val, state, stack) {
  465. this.next = val == "{" ? this.nextState : "";
  466. if (val == "{" && stack.length) {
  467. stack.unshift("start", state);
  468. }
  469. else if (val == "}" && stack.length) {
  470. stack.shift();
  471. this.next = stack.shift();
  472. if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
  473. return "paren.quasi.end";
  474. }
  475. return val == "{" ? "paren.lparen" : "paren.rparen";
  476. },
  477. nextState: "start"
  478. }, {
  479. token: "string.quasi.start",
  480. regex: /`/,
  481. push: [{
  482. token: "constant.language.escape",
  483. regex: escapedRe
  484. }, {
  485. token: "paren.quasi.start",
  486. regex: /\${/,
  487. push: "start"
  488. }, {
  489. token: "string.quasi.end",
  490. regex: /`/,
  491. next: "pop"
  492. }, {
  493. defaultToken: "string.quasi"
  494. }]
  495. }, {
  496. token: ["variable.parameter", "text"],
  497. regex: "(" + identifierRe + ")(\\s*)(?=\\=>)"
  498. }, {
  499. token: "paren.lparen",
  500. regex: "(\\()(?=[^\\(]+\\s*=>)",
  501. next: "function_arguments"
  502. }, {
  503. token: "variable.language",
  504. regex: "(?:(?:(?:Weak)?(?:Set|Map))|Promise)\\b"
  505. });
  506. this.$rules["function_arguments"].unshift({
  507. token: "keyword.operator",
  508. regex: "=",
  509. next: "default_parameter"
  510. }, {
  511. token: "keyword.operator",
  512. regex: "\\.{3}"
  513. });
  514. this.$rules["property"].unshift({
  515. token: "support.function",
  516. regex: "(findIndex|repeat|startsWith|endsWith|includes|isSafeInteger|trunc|cbrt|log2|log10|sign|then|catch|"
  517. + "finally|resolve|reject|race|any|all|allSettled|keys|entries|isInteger)\\b(?=\\()"
  518. }, {
  519. token: "constant.language",
  520. regex: "(?:MAX_SAFE_INTEGER|MIN_SAFE_INTEGER|EPSILON)\\b"
  521. });
  522. if (!options || options.jsx != false)
  523. JSX.call(this);
  524. }
  525. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("no_regex")]);
  526. this.normalizeRules();
  527. };
  528. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  529. function JSX() {
  530. var tagRegex = identifierRe.replace("\\d", "\\d\\-");
  531. var jsxTag = {
  532. onMatch: function (val, state, stack) {
  533. var offset = val.charAt(1) == "/" ? 2 : 1;
  534. if (offset == 1) {
  535. if (state != this.nextState)
  536. stack.unshift(this.next, this.nextState, 0);
  537. else
  538. stack.unshift(this.next);
  539. stack[2]++;
  540. }
  541. else if (offset == 2) {
  542. if (state == this.nextState) {
  543. stack[1]--;
  544. if (!stack[1] || stack[1] < 0) {
  545. stack.shift();
  546. stack.shift();
  547. }
  548. }
  549. }
  550. return [{
  551. type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
  552. value: val.slice(0, offset)
  553. }, {
  554. type: "meta.tag.tag-name.xml",
  555. value: val.substr(offset)
  556. }];
  557. },
  558. regex: "</?(?:" + tagRegex + "|(?=>))",
  559. next: "jsxAttributes",
  560. nextState: "jsx"
  561. };
  562. this.$rules.start.unshift(jsxTag);
  563. var jsxJsRule = {
  564. regex: "{",
  565. token: "paren.quasi.start",
  566. push: "start"
  567. };
  568. this.$rules.jsx = [
  569. jsxJsRule,
  570. jsxTag,
  571. { include: "reference" }, { defaultToken: "string.xml" }
  572. ];
  573. this.$rules.jsxAttributes = [{
  574. token: "meta.tag.punctuation.tag-close.xml",
  575. regex: "/?>",
  576. onMatch: function (value, currentState, stack) {
  577. if (currentState == stack[0])
  578. stack.shift();
  579. if (value.length == 2) {
  580. if (stack[0] == this.nextState)
  581. stack[1]--;
  582. if (!stack[1] || stack[1] < 0) {
  583. stack.splice(0, 2);
  584. }
  585. }
  586. this.next = stack[0] || "start";
  587. return [{ type: this.token, value: value }];
  588. },
  589. nextState: "jsx"
  590. },
  591. jsxJsRule,
  592. comments("jsxAttributes"),
  593. {
  594. token: "entity.other.attribute-name.xml",
  595. regex: tagRegex
  596. }, {
  597. token: "keyword.operator.attribute-equals.xml",
  598. regex: "="
  599. }, {
  600. token: "text.tag-whitespace.xml",
  601. regex: "\\s+"
  602. }, {
  603. token: "string.attribute-value.xml",
  604. regex: "'",
  605. stateName: "jsx_attr_q",
  606. push: [
  607. { token: "string.attribute-value.xml", regex: "'", next: "pop" },
  608. { include: "reference" },
  609. { defaultToken: "string.attribute-value.xml" }
  610. ]
  611. }, {
  612. token: "string.attribute-value.xml",
  613. regex: '"',
  614. stateName: "jsx_attr_qq",
  615. push: [
  616. { token: "string.attribute-value.xml", regex: '"', next: "pop" },
  617. { include: "reference" },
  618. { defaultToken: "string.attribute-value.xml" }
  619. ]
  620. },
  621. jsxTag
  622. ];
  623. this.$rules.reference = [{
  624. token: "constant.language.escape.reference.xml",
  625. regex: "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  626. }];
  627. }
  628. function comments(next) {
  629. return [
  630. {
  631. token: "comment", // multi line comment
  632. regex: /\/\*/,
  633. next: [
  634. DocCommentHighlightRules.getTagRule(),
  635. { token: "comment", regex: "\\*\\/", next: next || "pop" },
  636. { defaultToken: "comment", caseInsensitive: true }
  637. ]
  638. }, {
  639. token: "comment",
  640. regex: "\\/\\/",
  641. next: [
  642. DocCommentHighlightRules.getTagRule(),
  643. { token: "comment", regex: "$|^", next: next || "pop" },
  644. { defaultToken: "comment", caseInsensitive: true }
  645. ]
  646. }
  647. ];
  648. }
  649. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  650. });
  651. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  652. var Range = require("../range").Range;
  653. var MatchingBraceOutdent = function () { };
  654. (function () {
  655. this.checkOutdent = function (line, input) {
  656. if (!/^\s+$/.test(line))
  657. return false;
  658. return /^\s*\}/.test(input);
  659. };
  660. this.autoOutdent = function (doc, row) {
  661. var line = doc.getLine(row);
  662. var match = line.match(/^(\s*\})/);
  663. if (!match)
  664. return 0;
  665. var column = match[1].length;
  666. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  667. if (!openBracePos || openBracePos.row == row)
  668. return 0;
  669. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  670. doc.replace(new Range(row, 0, row, column - 1), indent);
  671. };
  672. this.$getIndent = function (line) {
  673. return line.match(/^\s*/)[0];
  674. };
  675. }).call(MatchingBraceOutdent.prototype);
  676. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  677. });
  678. ace.define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator"], function(require, exports, module){"use strict";
  679. var oop = require("../../lib/oop");
  680. var Behaviour = require("../behaviour").Behaviour;
  681. var TokenIterator = require("../../token_iterator").TokenIterator;
  682. function is(token, type) {
  683. return token && token.type.lastIndexOf(type + ".xml") > -1;
  684. }
  685. var XmlBehaviour = function () {
  686. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  687. if (text == '"' || text == "'") {
  688. var quote = text;
  689. var selected = session.doc.getTextRange(editor.getSelectionRange());
  690. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  691. return {
  692. text: quote + selected + quote,
  693. selection: false
  694. };
  695. }
  696. var cursor = editor.getCursorPosition();
  697. var line = session.doc.getLine(cursor.row);
  698. var rightChar = line.substring(cursor.column, cursor.column + 1);
  699. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  700. var token = iterator.getCurrentToken();
  701. if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
  702. return {
  703. text: "",
  704. selection: [1, 1]
  705. };
  706. }
  707. if (!token)
  708. token = iterator.stepBackward();
  709. if (!token)
  710. return;
  711. while (is(token, "tag-whitespace") || is(token, "whitespace")) {
  712. token = iterator.stepBackward();
  713. }
  714. var rightSpace = !rightChar || rightChar.match(/\s/);
  715. if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
  716. return {
  717. text: quote + quote,
  718. selection: [1, 1]
  719. };
  720. }
  721. }
  722. });
  723. this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
  724. var selected = session.doc.getTextRange(range);
  725. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  726. var line = session.doc.getLine(range.start.row);
  727. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  728. if (rightChar == selected) {
  729. range.end.column++;
  730. return range;
  731. }
  732. }
  733. });
  734. this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
  735. if (text == '>') {
  736. var position = editor.getSelectionRange().start;
  737. var iterator = new TokenIterator(session, position.row, position.column);
  738. var token = iterator.getCurrentToken() || iterator.stepBackward();
  739. if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
  740. return;
  741. if (is(token, "reference.attribute-value"))
  742. return;
  743. if (is(token, "attribute-value")) {
  744. var tokenEndColumn = iterator.getCurrentTokenColumn() + token.value.length;
  745. if (position.column < tokenEndColumn)
  746. return;
  747. if (position.column == tokenEndColumn) {
  748. var nextToken = iterator.stepForward();
  749. if (nextToken && is(nextToken, "attribute-value"))
  750. return;
  751. iterator.stepBackward();
  752. }
  753. }
  754. if (/^\s*>/.test(session.getLine(position.row).slice(position.column)))
  755. return;
  756. while (!is(token, "tag-name")) {
  757. token = iterator.stepBackward();
  758. if (token.value == "<") {
  759. token = iterator.stepForward();
  760. break;
  761. }
  762. }
  763. var tokenRow = iterator.getCurrentTokenRow();
  764. var tokenColumn = iterator.getCurrentTokenColumn();
  765. if (is(iterator.stepBackward(), "end-tag-open"))
  766. return;
  767. var element = token.value;
  768. if (tokenRow == position.row)
  769. element = element.substring(0, position.column - tokenColumn);
  770. if (this.voidElements && this.voidElements.hasOwnProperty(element.toLowerCase()))
  771. return;
  772. return {
  773. text: ">" + "</" + element + ">",
  774. selection: [1, 1]
  775. };
  776. }
  777. });
  778. this.add("autoindent", "insertion", function (state, action, editor, session, text) {
  779. if (text == "\n") {
  780. var cursor = editor.getCursorPosition();
  781. var line = session.getLine(cursor.row);
  782. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  783. var token = iterator.getCurrentToken();
  784. if (is(token, "") && token.type.indexOf("tag-close") !== -1) {
  785. if (token.value == "/>")
  786. return;
  787. while (token && token.type.indexOf("tag-name") === -1) {
  788. token = iterator.stepBackward();
  789. }
  790. if (!token) {
  791. return;
  792. }
  793. var tag = token.value;
  794. var row = iterator.getCurrentTokenRow();
  795. token = iterator.stepBackward();
  796. if (!token || token.type.indexOf("end-tag") !== -1) {
  797. return;
  798. }
  799. if (this.voidElements && !this.voidElements[tag] || !this.voidElements) {
  800. var nextToken = session.getTokenAt(cursor.row, cursor.column + 1);
  801. var line = session.getLine(row);
  802. var nextIndent = this.$getIndent(line);
  803. var indent = nextIndent + session.getTabString();
  804. if (nextToken && nextToken.value === "</") {
  805. return {
  806. text: "\n" + indent + "\n" + nextIndent,
  807. selection: [1, indent.length, 1, indent.length]
  808. };
  809. }
  810. else {
  811. return {
  812. text: "\n" + indent
  813. };
  814. }
  815. }
  816. }
  817. }
  818. });
  819. };
  820. oop.inherits(XmlBehaviour, Behaviour);
  821. exports.XmlBehaviour = XmlBehaviour;
  822. });
  823. ace.define("ace/mode/behaviour/javascript",["require","exports","module","ace/lib/oop","ace/token_iterator","ace/mode/behaviour/cstyle","ace/mode/behaviour/xml"], function(require, exports, module){"use strict";
  824. var oop = require("../../lib/oop");
  825. var TokenIterator = require("../../token_iterator").TokenIterator;
  826. var CstyleBehaviour = require("../behaviour/cstyle").CstyleBehaviour;
  827. var XmlBehaviour = require("../behaviour/xml").XmlBehaviour;
  828. var JavaScriptBehaviour = function () {
  829. var xmlBehaviours = new XmlBehaviour({ closeCurlyBraces: true }).getBehaviours();
  830. this.addBehaviours(xmlBehaviours);
  831. this.inherit(CstyleBehaviour);
  832. this.add("autoclosing-fragment", "insertion", function (state, action, editor, session, text) {
  833. if (text == '>') {
  834. var position = editor.getSelectionRange().start;
  835. var iterator = new TokenIterator(session, position.row, position.column);
  836. var token = iterator.getCurrentToken() || iterator.stepBackward();
  837. if (!token)
  838. return;
  839. if (token.value == '<') {
  840. return {
  841. text: "></>",
  842. selection: [1, 1]
  843. };
  844. }
  845. }
  846. });
  847. };
  848. oop.inherits(JavaScriptBehaviour, CstyleBehaviour);
  849. exports.JavaScriptBehaviour = JavaScriptBehaviour;
  850. });
  851. ace.define("ace/mode/folding/xml",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
  852. var oop = require("../../lib/oop");
  853. var Range = require("../../range").Range;
  854. var BaseFoldMode = require("./fold_mode").FoldMode;
  855. var FoldMode = exports.FoldMode = function (voidElements, optionalEndTags) {
  856. BaseFoldMode.call(this);
  857. this.voidElements = voidElements || {};
  858. this.optionalEndTags = oop.mixin({}, this.voidElements);
  859. if (optionalEndTags)
  860. oop.mixin(this.optionalEndTags, optionalEndTags);
  861. };
  862. oop.inherits(FoldMode, BaseFoldMode);
  863. var Tag = function () {
  864. this.tagName = "";
  865. this.closing = false;
  866. this.selfClosing = false;
  867. this.start = { row: 0, column: 0 };
  868. this.end = { row: 0, column: 0 };
  869. };
  870. function is(token, type) {
  871. return token && token.type && token.type.lastIndexOf(type + ".xml") > -1;
  872. }
  873. (function () {
  874. this.getFoldWidget = function (session, foldStyle, row) {
  875. var tag = this._getFirstTagInLine(session, row);
  876. if (!tag)
  877. return this.getCommentFoldWidget(session, row);
  878. if (tag.closing || (!tag.tagName && tag.selfClosing))
  879. return foldStyle === "markbeginend" ? "end" : "";
  880. if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
  881. return "";
  882. if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
  883. return "";
  884. return "start";
  885. };
  886. this.getCommentFoldWidget = function (session, row) {
  887. if (/comment/.test(session.getState(row)) && /<!-/.test(session.getLine(row)))
  888. return "start";
  889. return "";
  890. };
  891. this._getFirstTagInLine = function (session, row) {
  892. var tokens = session.getTokens(row);
  893. var tag = new Tag();
  894. for (var i = 0; i < tokens.length; i++) {
  895. var token = tokens[i];
  896. if (is(token, "tag-open")) {
  897. tag.end.column = tag.start.column + token.value.length;
  898. tag.closing = is(token, "end-tag-open");
  899. token = tokens[++i];
  900. if (!token)
  901. return null;
  902. tag.tagName = token.value;
  903. if (token.value === "") { //skip empty tag name token for fragment
  904. token = tokens[++i];
  905. if (!token)
  906. return null;
  907. tag.tagName = token.value;
  908. }
  909. tag.end.column += token.value.length;
  910. for (i++; i < tokens.length; i++) {
  911. token = tokens[i];
  912. tag.end.column += token.value.length;
  913. if (is(token, "tag-close")) {
  914. tag.selfClosing = token.value == '/>';
  915. break;
  916. }
  917. }
  918. return tag;
  919. }
  920. else if (is(token, "tag-close")) {
  921. tag.selfClosing = token.value == '/>';
  922. return tag;
  923. }
  924. tag.start.column += token.value.length;
  925. }
  926. return null;
  927. };
  928. this._findEndTagInLine = function (session, row, tagName, startColumn) {
  929. var tokens = session.getTokens(row);
  930. var column = 0;
  931. for (var i = 0; i < tokens.length; i++) {
  932. var token = tokens[i];
  933. column += token.value.length;
  934. if (column < startColumn - 1)
  935. continue;
  936. if (is(token, "end-tag-open")) {
  937. token = tokens[i + 1];
  938. if (is(token, "tag-name") && token.value === "") {
  939. token = tokens[i + 2];
  940. }
  941. if (token && token.value == tagName)
  942. return true;
  943. }
  944. }
  945. return false;
  946. };
  947. this.getFoldWidgetRange = function (session, foldStyle, row) {
  948. var firstTag = this._getFirstTagInLine(session, row);
  949. if (!firstTag) {
  950. return this.getCommentFoldWidget(session, row) && session.getCommentFoldRange(row, session.getLine(row).length);
  951. }
  952. var tags = session.getMatchingTags({ row: row, column: 0 });
  953. if (tags) {
  954. return new Range(tags.openTag.end.row, tags.openTag.end.column, tags.closeTag.start.row, tags.closeTag.start.column);
  955. }
  956. };
  957. }).call(FoldMode.prototype);
  958. });
  959. 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";
  960. var oop = require("../../lib/oop");
  961. var Range = require("../../range").Range;
  962. var BaseFoldMode = require("./fold_mode").FoldMode;
  963. var FoldMode = exports.FoldMode = function (commentRegex) {
  964. if (commentRegex) {
  965. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  966. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  967. }
  968. };
  969. oop.inherits(FoldMode, BaseFoldMode);
  970. (function () {
  971. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  972. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  973. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  974. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  975. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  976. this._getFoldWidgetBase = this.getFoldWidget;
  977. this.getFoldWidget = function (session, foldStyle, row) {
  978. var line = session.getLine(row);
  979. if (this.singleLineBlockCommentRe.test(line)) {
  980. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  981. return "";
  982. }
  983. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  984. if (!fw && this.startRegionRe.test(line))
  985. return "start"; // lineCommentRegionStart
  986. return fw;
  987. };
  988. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  989. var line = session.getLine(row);
  990. if (this.startRegionRe.test(line))
  991. return this.getCommentRegionBlock(session, line, row);
  992. var match = line.match(this.foldingStartMarker);
  993. if (match) {
  994. var i = match.index;
  995. if (match[1])
  996. return this.openingBracketBlock(session, match[1], row, i);
  997. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  998. if (range && !range.isMultiLine()) {
  999. if (forceMultiline) {
  1000. range = this.getSectionRange(session, row);
  1001. }
  1002. else if (foldStyle != "all")
  1003. range = null;
  1004. }
  1005. return range;
  1006. }
  1007. if (foldStyle === "markbegin")
  1008. return;
  1009. var match = line.match(this.foldingStopMarker);
  1010. if (match) {
  1011. var i = match.index + match[0].length;
  1012. if (match[1])
  1013. return this.closingBracketBlock(session, match[1], row, i);
  1014. return session.getCommentFoldRange(row, i, -1);
  1015. }
  1016. };
  1017. this.getSectionRange = function (session, row) {
  1018. var line = session.getLine(row);
  1019. var startIndent = line.search(/\S/);
  1020. var startRow = row;
  1021. var startColumn = line.length;
  1022. row = row + 1;
  1023. var endRow = row;
  1024. var maxRow = session.getLength();
  1025. while (++row < maxRow) {
  1026. line = session.getLine(row);
  1027. var indent = line.search(/\S/);
  1028. if (indent === -1)
  1029. continue;
  1030. if (startIndent > indent)
  1031. break;
  1032. var subRange = this.getFoldWidgetRange(session, "all", row);
  1033. if (subRange) {
  1034. if (subRange.start.row <= startRow) {
  1035. break;
  1036. }
  1037. else if (subRange.isMultiLine()) {
  1038. row = subRange.end.row;
  1039. }
  1040. else if (startIndent == indent) {
  1041. break;
  1042. }
  1043. }
  1044. endRow = row;
  1045. }
  1046. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  1047. };
  1048. this.getCommentRegionBlock = function (session, line, row) {
  1049. var startColumn = line.search(/\s*$/);
  1050. var maxRow = session.getLength();
  1051. var startRow = row;
  1052. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  1053. var depth = 1;
  1054. while (++row < maxRow) {
  1055. line = session.getLine(row);
  1056. var m = re.exec(line);
  1057. if (!m)
  1058. continue;
  1059. if (m[1])
  1060. depth--;
  1061. else
  1062. depth++;
  1063. if (!depth)
  1064. break;
  1065. }
  1066. var endRow = row;
  1067. if (endRow > startRow) {
  1068. return new Range(startRow, startColumn, endRow, line.length);
  1069. }
  1070. };
  1071. }).call(FoldMode.prototype);
  1072. });
  1073. ace.define("ace/mode/folding/javascript",["require","exports","module","ace/lib/oop","ace/mode/folding/xml","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  1074. var oop = require("../../lib/oop");
  1075. var XmlFoldMode = require("./xml").FoldMode;
  1076. var CFoldMode = require("./cstyle").FoldMode;
  1077. var FoldMode = exports.FoldMode = function (commentRegex) {
  1078. if (commentRegex) {
  1079. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  1080. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  1081. }
  1082. this.xmlFoldMode = new XmlFoldMode();
  1083. };
  1084. oop.inherits(FoldMode, CFoldMode);
  1085. (function () {
  1086. this.getFoldWidgetRangeBase = this.getFoldWidgetRange;
  1087. this.getFoldWidgetBase = this.getFoldWidget;
  1088. this.getFoldWidget = function (session, foldStyle, row) {
  1089. var fw = this.getFoldWidgetBase(session, foldStyle, row);
  1090. if (!fw) {
  1091. return this.xmlFoldMode.getFoldWidget(session, foldStyle, row);
  1092. }
  1093. return fw;
  1094. };
  1095. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  1096. var range = this.getFoldWidgetRangeBase(session, foldStyle, row, forceMultiline);
  1097. if (range)
  1098. return range;
  1099. return this.xmlFoldMode.getFoldWidgetRange(session, foldStyle, row);
  1100. };
  1101. }).call(FoldMode.prototype);
  1102. });
  1103. 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/javascript","ace/mode/folding/javascript"], function(require, exports, module){"use strict";
  1104. var oop = require("../lib/oop");
  1105. var TextMode = require("./text").Mode;
  1106. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1107. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1108. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1109. var JavaScriptBehaviour = require("./behaviour/javascript").JavaScriptBehaviour;
  1110. var JavaScriptFoldMode = require("./folding/javascript").FoldMode;
  1111. var Mode = function () {
  1112. this.HighlightRules = JavaScriptHighlightRules;
  1113. this.$outdent = new MatchingBraceOutdent();
  1114. this.$behaviour = new JavaScriptBehaviour();
  1115. this.foldingRules = new JavaScriptFoldMode();
  1116. };
  1117. oop.inherits(Mode, TextMode);
  1118. (function () {
  1119. this.lineCommentStart = "//";
  1120. this.blockComment = { start: "/*", end: "*/" };
  1121. this.$quotes = { '"': '"', "'": "'", "`": "`" };
  1122. this.$pairQuotesAfter = {
  1123. "`": /\w/
  1124. };
  1125. this.getNextLineIndent = function (state, line, tab) {
  1126. var indent = this.$getIndent(line);
  1127. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  1128. var tokens = tokenizedLine.tokens;
  1129. var endState = tokenizedLine.state;
  1130. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  1131. return indent;
  1132. }
  1133. if (state == "start" || state == "no_regex") {
  1134. var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
  1135. if (match) {
  1136. indent += tab;
  1137. }
  1138. }
  1139. else if (state == "doc-start") {
  1140. if (endState == "start" || endState == "no_regex") {
  1141. return "";
  1142. }
  1143. }
  1144. return indent;
  1145. };
  1146. this.checkOutdent = function (state, line, input) {
  1147. return this.$outdent.checkOutdent(line, input);
  1148. };
  1149. this.autoOutdent = function (state, doc, row) {
  1150. this.$outdent.autoOutdent(doc, row);
  1151. };
  1152. this.createWorker = function (session) {
  1153. var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
  1154. worker.attachToDocument(session.getDocument());
  1155. worker.on("annotate", function (results) {
  1156. session.setAnnotations(results.data);
  1157. });
  1158. worker.on("terminate", function () {
  1159. session.clearAnnotations();
  1160. });
  1161. return worker;
  1162. };
  1163. this.$id = "ace/mode/javascript";
  1164. this.snippetFileId = "ace/snippets/javascript";
  1165. }).call(Mode.prototype);
  1166. exports.Mode = Mode;
  1167. }); (function() {
  1168. ace.require(["ace/mode/javascript"], function(m) {
  1169. if (typeof module == "object" && typeof exports == "object" && module) {
  1170. module.exports = m;
  1171. }
  1172. });
  1173. })();