ddaa1c38ff4f124bff0ab66b50e32665.js 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487
  1. ace.define("ace/mode/xml_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 XmlHighlightRules = function (normalize) {
  5. var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*";
  6. this.$rules = {
  7. start: [
  8. { token: "string.cdata.xml", regex: "<\\!\\[CDATA\\[", next: "cdata" },
  9. {
  10. token: ["punctuation.instruction.xml", "keyword.instruction.xml"],
  11. regex: "(<\\?)(" + tagRegex + ")", next: "processing_instruction"
  12. },
  13. { token: "comment.start.xml", regex: "<\\!--", next: "comment" },
  14. {
  15. token: ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
  16. regex: "(<\\!)(DOCTYPE)(?=[\\s])", next: "doctype", caseInsensitive: true
  17. },
  18. { include: "tag" },
  19. { token: "text.end-tag-open.xml", regex: "</" },
  20. { token: "text.tag-open.xml", regex: "<" },
  21. { include: "reference" },
  22. { defaultToken: "text.xml" }
  23. ],
  24. processing_instruction: [{
  25. token: "entity.other.attribute-name.decl-attribute-name.xml",
  26. regex: tagRegex
  27. }, {
  28. token: "keyword.operator.decl-attribute-equals.xml",
  29. regex: "="
  30. }, {
  31. include: "whitespace"
  32. }, {
  33. include: "string"
  34. }, {
  35. token: "punctuation.xml-decl.xml",
  36. regex: "\\?>",
  37. next: "start"
  38. }],
  39. doctype: [
  40. { include: "whitespace" },
  41. { include: "string" },
  42. { token: "xml-pe.doctype.xml", regex: ">", next: "start" },
  43. { token: "xml-pe.xml", regex: "[-_a-zA-Z0-9:]+" },
  44. { token: "punctuation.int-subset", regex: "\\[", push: "int_subset" }
  45. ],
  46. int_subset: [{
  47. token: "text.xml",
  48. regex: "\\s+"
  49. }, {
  50. token: "punctuation.int-subset.xml",
  51. regex: "]",
  52. next: "pop"
  53. }, {
  54. token: ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
  55. regex: "(<\\!)(" + tagRegex + ")",
  56. push: [{
  57. token: "text",
  58. regex: "\\s+"
  59. },
  60. {
  61. token: "punctuation.markup-decl.xml",
  62. regex: ">",
  63. next: "pop"
  64. },
  65. { include: "string" }]
  66. }],
  67. cdata: [
  68. { token: "string.cdata.xml", regex: "\\]\\]>", next: "start" },
  69. { token: "text.xml", regex: "\\s+" },
  70. { token: "text.xml", regex: "(?:[^\\]]|\\](?!\\]>))+" }
  71. ],
  72. comment: [
  73. { token: "comment.end.xml", regex: "-->", next: "start" },
  74. { defaultToken: "comment.xml" }
  75. ],
  76. reference: [{
  77. token: "constant.language.escape.reference.xml",
  78. regex: "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  79. }],
  80. attr_reference: [{
  81. token: "constant.language.escape.reference.attribute-value.xml",
  82. regex: "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  83. }],
  84. tag: [{
  85. token: ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
  86. regex: "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
  87. next: [
  88. { include: "attributes" },
  89. { token: "meta.tag.punctuation.tag-close.xml", regex: "/?>", next: "start" }
  90. ]
  91. }],
  92. tag_whitespace: [
  93. { token: "text.tag-whitespace.xml", regex: "\\s+" }
  94. ],
  95. whitespace: [
  96. { token: "text.whitespace.xml", regex: "\\s+" }
  97. ],
  98. string: [{
  99. token: "string.xml",
  100. regex: "'",
  101. push: [
  102. { token: "string.xml", regex: "'", next: "pop" },
  103. { defaultToken: "string.xml" }
  104. ]
  105. }, {
  106. token: "string.xml",
  107. regex: '"',
  108. push: [
  109. { token: "string.xml", regex: '"', next: "pop" },
  110. { defaultToken: "string.xml" }
  111. ]
  112. }],
  113. attributes: [{
  114. token: "entity.other.attribute-name.xml",
  115. regex: tagRegex
  116. }, {
  117. token: "keyword.operator.attribute-equals.xml",
  118. regex: "="
  119. }, {
  120. include: "tag_whitespace"
  121. }, {
  122. include: "attribute_value"
  123. }],
  124. attribute_value: [{
  125. token: "string.attribute-value.xml",
  126. regex: "'",
  127. push: [
  128. { token: "string.attribute-value.xml", regex: "'", next: "pop" },
  129. { include: "attr_reference" },
  130. { defaultToken: "string.attribute-value.xml" }
  131. ]
  132. }, {
  133. token: "string.attribute-value.xml",
  134. regex: '"',
  135. push: [
  136. { token: "string.attribute-value.xml", regex: '"', next: "pop" },
  137. { include: "attr_reference" },
  138. { defaultToken: "string.attribute-value.xml" }
  139. ]
  140. }]
  141. };
  142. if (this.constructor === XmlHighlightRules)
  143. this.normalizeRules();
  144. };
  145. (function () {
  146. this.embedTagRules = function (HighlightRules, prefix, tag) {
  147. this.$rules.tag.unshift({
  148. token: ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  149. regex: "(<)(" + tag + "(?=\\s|>|$))",
  150. next: [
  151. { include: "attributes" },
  152. { token: "meta.tag.punctuation.tag-close.xml", regex: "/?>", next: prefix + "start" }
  153. ]
  154. });
  155. this.$rules[tag + "-end"] = [
  156. { include: "attributes" },
  157. { token: "meta.tag.punctuation.tag-close.xml", regex: "/?>", next: "start",
  158. onMatch: function (value, currentState, stack) {
  159. stack.splice(0);
  160. return this.token;
  161. } }
  162. ];
  163. this.embedRules(HighlightRules, prefix, [{
  164. token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  165. regex: "(</)(" + tag + "(?=\\s|>|$))",
  166. next: tag + "-end"
  167. }, {
  168. token: "string.cdata.xml",
  169. regex: "<\\!\\[CDATA\\["
  170. }, {
  171. token: "string.cdata.xml",
  172. regex: "\\]\\]>"
  173. }]);
  174. };
  175. }).call(TextHighlightRules.prototype);
  176. oop.inherits(XmlHighlightRules, TextHighlightRules);
  177. exports.XmlHighlightRules = XmlHighlightRules;
  178. });
  179. ace.define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator"], function(require, exports, module){"use strict";
  180. var oop = require("../../lib/oop");
  181. var Behaviour = require("../behaviour").Behaviour;
  182. var TokenIterator = require("../../token_iterator").TokenIterator;
  183. function is(token, type) {
  184. return token && token.type.lastIndexOf(type + ".xml") > -1;
  185. }
  186. var XmlBehaviour = function () {
  187. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  188. if (text == '"' || text == "'") {
  189. var quote = text;
  190. var selected = session.doc.getTextRange(editor.getSelectionRange());
  191. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  192. return {
  193. text: quote + selected + quote,
  194. selection: false
  195. };
  196. }
  197. var cursor = editor.getCursorPosition();
  198. var line = session.doc.getLine(cursor.row);
  199. var rightChar = line.substring(cursor.column, cursor.column + 1);
  200. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  201. var token = iterator.getCurrentToken();
  202. if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
  203. return {
  204. text: "",
  205. selection: [1, 1]
  206. };
  207. }
  208. if (!token)
  209. token = iterator.stepBackward();
  210. if (!token)
  211. return;
  212. while (is(token, "tag-whitespace") || is(token, "whitespace")) {
  213. token = iterator.stepBackward();
  214. }
  215. var rightSpace = !rightChar || rightChar.match(/\s/);
  216. if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
  217. return {
  218. text: quote + quote,
  219. selection: [1, 1]
  220. };
  221. }
  222. }
  223. });
  224. this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
  225. var selected = session.doc.getTextRange(range);
  226. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  227. var line = session.doc.getLine(range.start.row);
  228. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  229. if (rightChar == selected) {
  230. range.end.column++;
  231. return range;
  232. }
  233. }
  234. });
  235. this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
  236. if (text == '>') {
  237. var position = editor.getSelectionRange().start;
  238. var iterator = new TokenIterator(session, position.row, position.column);
  239. var token = iterator.getCurrentToken() || iterator.stepBackward();
  240. if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
  241. return;
  242. if (is(token, "reference.attribute-value"))
  243. return;
  244. if (is(token, "attribute-value")) {
  245. var tokenEndColumn = iterator.getCurrentTokenColumn() + token.value.length;
  246. if (position.column < tokenEndColumn)
  247. return;
  248. if (position.column == tokenEndColumn) {
  249. var nextToken = iterator.stepForward();
  250. if (nextToken && is(nextToken, "attribute-value"))
  251. return;
  252. iterator.stepBackward();
  253. }
  254. }
  255. if (/^\s*>/.test(session.getLine(position.row).slice(position.column)))
  256. return;
  257. while (!is(token, "tag-name")) {
  258. token = iterator.stepBackward();
  259. if (token.value == "<") {
  260. token = iterator.stepForward();
  261. break;
  262. }
  263. }
  264. var tokenRow = iterator.getCurrentTokenRow();
  265. var tokenColumn = iterator.getCurrentTokenColumn();
  266. if (is(iterator.stepBackward(), "end-tag-open"))
  267. return;
  268. var element = token.value;
  269. if (tokenRow == position.row)
  270. element = element.substring(0, position.column - tokenColumn);
  271. if (this.voidElements && this.voidElements.hasOwnProperty(element.toLowerCase()))
  272. return;
  273. return {
  274. text: ">" + "</" + element + ">",
  275. selection: [1, 1]
  276. };
  277. }
  278. });
  279. this.add("autoindent", "insertion", function (state, action, editor, session, text) {
  280. if (text == "\n") {
  281. var cursor = editor.getCursorPosition();
  282. var line = session.getLine(cursor.row);
  283. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  284. var token = iterator.getCurrentToken();
  285. if (is(token, "") && token.type.indexOf("tag-close") !== -1) {
  286. if (token.value == "/>")
  287. return;
  288. while (token && token.type.indexOf("tag-name") === -1) {
  289. token = iterator.stepBackward();
  290. }
  291. if (!token) {
  292. return;
  293. }
  294. var tag = token.value;
  295. var row = iterator.getCurrentTokenRow();
  296. token = iterator.stepBackward();
  297. if (!token || token.type.indexOf("end-tag") !== -1) {
  298. return;
  299. }
  300. if (this.voidElements && !this.voidElements[tag] || !this.voidElements) {
  301. var nextToken = session.getTokenAt(cursor.row, cursor.column + 1);
  302. var line = session.getLine(row);
  303. var nextIndent = this.$getIndent(line);
  304. var indent = nextIndent + session.getTabString();
  305. if (nextToken && nextToken.value === "</") {
  306. return {
  307. text: "\n" + indent + "\n" + nextIndent,
  308. selection: [1, indent.length, 1, indent.length]
  309. };
  310. }
  311. else {
  312. return {
  313. text: "\n" + indent
  314. };
  315. }
  316. }
  317. }
  318. }
  319. });
  320. };
  321. oop.inherits(XmlBehaviour, Behaviour);
  322. exports.XmlBehaviour = XmlBehaviour;
  323. });
  324. 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";
  325. var oop = require("../../lib/oop");
  326. var Range = require("../../range").Range;
  327. var BaseFoldMode = require("./fold_mode").FoldMode;
  328. var FoldMode = exports.FoldMode = function (voidElements, optionalEndTags) {
  329. BaseFoldMode.call(this);
  330. this.voidElements = voidElements || {};
  331. this.optionalEndTags = oop.mixin({}, this.voidElements);
  332. if (optionalEndTags)
  333. oop.mixin(this.optionalEndTags, optionalEndTags);
  334. };
  335. oop.inherits(FoldMode, BaseFoldMode);
  336. var Tag = function () {
  337. this.tagName = "";
  338. this.closing = false;
  339. this.selfClosing = false;
  340. this.start = { row: 0, column: 0 };
  341. this.end = { row: 0, column: 0 };
  342. };
  343. function is(token, type) {
  344. return token && token.type && token.type.lastIndexOf(type + ".xml") > -1;
  345. }
  346. (function () {
  347. this.getFoldWidget = function (session, foldStyle, row) {
  348. var tag = this._getFirstTagInLine(session, row);
  349. if (!tag)
  350. return this.getCommentFoldWidget(session, row);
  351. if (tag.closing || (!tag.tagName && tag.selfClosing))
  352. return foldStyle === "markbeginend" ? "end" : "";
  353. if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
  354. return "";
  355. if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
  356. return "";
  357. return "start";
  358. };
  359. this.getCommentFoldWidget = function (session, row) {
  360. if (/comment/.test(session.getState(row)) && /<!-/.test(session.getLine(row)))
  361. return "start";
  362. return "";
  363. };
  364. this._getFirstTagInLine = function (session, row) {
  365. var tokens = session.getTokens(row);
  366. var tag = new Tag();
  367. for (var i = 0; i < tokens.length; i++) {
  368. var token = tokens[i];
  369. if (is(token, "tag-open")) {
  370. tag.end.column = tag.start.column + token.value.length;
  371. tag.closing = is(token, "end-tag-open");
  372. token = tokens[++i];
  373. if (!token)
  374. return null;
  375. tag.tagName = token.value;
  376. if (token.value === "") { //skip empty tag name token for fragment
  377. token = tokens[++i];
  378. if (!token)
  379. return null;
  380. tag.tagName = token.value;
  381. }
  382. tag.end.column += token.value.length;
  383. for (i++; i < tokens.length; i++) {
  384. token = tokens[i];
  385. tag.end.column += token.value.length;
  386. if (is(token, "tag-close")) {
  387. tag.selfClosing = token.value == '/>';
  388. break;
  389. }
  390. }
  391. return tag;
  392. }
  393. else if (is(token, "tag-close")) {
  394. tag.selfClosing = token.value == '/>';
  395. return tag;
  396. }
  397. tag.start.column += token.value.length;
  398. }
  399. return null;
  400. };
  401. this._findEndTagInLine = function (session, row, tagName, startColumn) {
  402. var tokens = session.getTokens(row);
  403. var column = 0;
  404. for (var i = 0; i < tokens.length; i++) {
  405. var token = tokens[i];
  406. column += token.value.length;
  407. if (column < startColumn - 1)
  408. continue;
  409. if (is(token, "end-tag-open")) {
  410. token = tokens[i + 1];
  411. if (is(token, "tag-name") && token.value === "") {
  412. token = tokens[i + 2];
  413. }
  414. if (token && token.value == tagName)
  415. return true;
  416. }
  417. }
  418. return false;
  419. };
  420. this.getFoldWidgetRange = function (session, foldStyle, row) {
  421. var firstTag = this._getFirstTagInLine(session, row);
  422. if (!firstTag) {
  423. return this.getCommentFoldWidget(session, row) && session.getCommentFoldRange(row, session.getLine(row).length);
  424. }
  425. var tags = session.getMatchingTags({ row: row, column: 0 });
  426. if (tags) {
  427. return new Range(tags.openTag.end.row, tags.openTag.end.column, tags.closeTag.start.row, tags.closeTag.start.column);
  428. }
  429. };
  430. }).call(FoldMode.prototype);
  431. });
  432. ace.define("ace/mode/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/xml_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/xml","ace/worker/worker_client"], function(require, exports, module){"use strict";
  433. var oop = require("../lib/oop");
  434. var lang = require("../lib/lang");
  435. var TextMode = require("./text").Mode;
  436. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  437. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  438. var XmlFoldMode = require("./folding/xml").FoldMode;
  439. var WorkerClient = require("../worker/worker_client").WorkerClient;
  440. var Mode = function () {
  441. this.HighlightRules = XmlHighlightRules;
  442. this.$behaviour = new XmlBehaviour();
  443. this.foldingRules = new XmlFoldMode();
  444. };
  445. oop.inherits(Mode, TextMode);
  446. (function () {
  447. this.voidElements = lang.arrayToMap([]);
  448. this.blockComment = { start: "<!--", end: "-->" };
  449. this.createWorker = function (session) {
  450. var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
  451. worker.attachToDocument(session.getDocument());
  452. worker.on("error", function (e) {
  453. session.setAnnotations(e.data);
  454. });
  455. worker.on("terminate", function () {
  456. session.clearAnnotations();
  457. });
  458. return worker;
  459. };
  460. this.$id = "ace/mode/xml";
  461. }).call(Mode.prototype);
  462. exports.Mode = Mode;
  463. });
  464. 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";
  465. var oop = require("../lib/oop");
  466. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  467. var JsDocCommentHighlightRules = function () {
  468. this.$rules = {
  469. "start": [
  470. {
  471. token: ["comment.doc.tag", "comment.doc.text", "lparen.doc"],
  472. regex: "(@(?:param|member|typedef|property|namespace|var|const|callback))(\\s*)({)",
  473. push: [
  474. {
  475. token: "lparen.doc",
  476. regex: "{",
  477. push: [
  478. {
  479. include: "doc-syntax"
  480. }, {
  481. token: "rparen.doc",
  482. regex: "}|(?=$)",
  483. next: "pop"
  484. }
  485. ]
  486. }, {
  487. token: ["rparen.doc", "text.doc", "variable.parameter.doc", "lparen.doc", "variable.parameter.doc", "rparen.doc"],
  488. regex: /(})(\s*)(?:([\w=:\/\.]+)|(?:(\[)([\w=:\/\.\-\'\" ]+)(\])))/,
  489. next: "pop"
  490. }, {
  491. token: "rparen.doc",
  492. regex: "}|(?=$)",
  493. next: "pop"
  494. }, {
  495. include: "doc-syntax"
  496. }, {
  497. defaultToken: "text.doc"
  498. }
  499. ]
  500. }, {
  501. token: ["comment.doc.tag", "text.doc", "lparen.doc"],
  502. regex: "(@(?:returns?|yields|type|this|suppress|public|protected|private|package|modifies|"
  503. + "implements|external|exception|throws|enum|define|extends))(\\s*)({)",
  504. push: [
  505. {
  506. token: "lparen.doc",
  507. regex: "{",
  508. push: [
  509. {
  510. include: "doc-syntax"
  511. }, {
  512. token: "rparen.doc",
  513. regex: "}|(?=$)",
  514. next: "pop"
  515. }
  516. ]
  517. }, {
  518. token: "rparen.doc",
  519. regex: "}|(?=$)",
  520. next: "pop"
  521. }, {
  522. include: "doc-syntax"
  523. }, {
  524. defaultToken: "text.doc"
  525. }
  526. ]
  527. }, {
  528. token: ["comment.doc.tag", "text.doc", "variable.parameter.doc"],
  529. regex: "(@(?:alias|memberof|instance|module|name|lends|namespace|external|this|template|"
  530. + "requires|param|implements|function|extends|typedef|mixes|constructor|var|"
  531. + "memberof\\!|event|listens|exports|class|constructs|interface|emits|fires|"
  532. + "throws|const|callback|borrows|augments))(\\s+)(\\w[\\w#\.:\/~\"\\-]*)?"
  533. }, {
  534. token: ["comment.doc.tag", "text.doc", "variable.parameter.doc"],
  535. regex: "(@method)(\\s+)(\\w[\\w\.\\(\\)]*)"
  536. }, {
  537. token: "comment.doc.tag",
  538. regex: "@access\\s+(?:private|public|protected)"
  539. }, {
  540. token: "comment.doc.tag",
  541. regex: "@kind\\s+(?:class|constant|event|external|file|function|member|mixin|module|namespace|typedef)"
  542. }, {
  543. token: "comment.doc.tag",
  544. regex: "@\\w+(?=\\s|$)"
  545. },
  546. JsDocCommentHighlightRules.getTagRule(),
  547. {
  548. defaultToken: "comment.doc.body",
  549. caseInsensitive: true
  550. }
  551. ],
  552. "doc-syntax": [{
  553. token: "operator.doc",
  554. regex: /[|:]/
  555. }, {
  556. token: "paren.doc",
  557. regex: /[\[\]]/
  558. }]
  559. };
  560. this.normalizeRules();
  561. };
  562. oop.inherits(JsDocCommentHighlightRules, TextHighlightRules);
  563. JsDocCommentHighlightRules.getTagRule = function (start) {
  564. return {
  565. token: "comment.doc.tag.storage.type",
  566. regex: "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  567. };
  568. };
  569. JsDocCommentHighlightRules.getStartRule = function (start) {
  570. return {
  571. token: "comment.doc", // doc comment
  572. regex: /\/\*\*(?!\/)/,
  573. next: start
  574. };
  575. };
  576. JsDocCommentHighlightRules.getEndRule = function (start) {
  577. return {
  578. token: "comment.doc", // closing comment
  579. regex: "\\*\\/",
  580. next: start
  581. };
  582. };
  583. exports.JsDocCommentHighlightRules = JsDocCommentHighlightRules;
  584. });
  585. 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";
  586. var oop = require("../lib/oop");
  587. var DocCommentHighlightRules = require("./jsdoc_comment_highlight_rules").JsDocCommentHighlightRules;
  588. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  589. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
  590. var JavaScriptHighlightRules = function (options) {
  591. var keywords = {
  592. "variable.language": "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|Symbol|" + // Constructors
  593. "Namespace|QName|XML|XMLList|" + // E4X
  594. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  595. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  596. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
  597. "SyntaxError|TypeError|URIError|" +
  598. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
  599. "isNaN|parseFloat|parseInt|" +
  600. "JSON|Math|" + // Other
  601. "this|arguments|prototype|window|document", // Pseudo
  602. "keyword": "const|yield|import|get|set|async|await|" +
  603. "break|case|catch|continue|default|delete|do|else|finally|for|" +
  604. "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
  605. "__parent__|__count__|escape|unescape|with|__proto__|" +
  606. "class|enum|extends|super|export|implements|private|public|interface|package|protected|static|constructor",
  607. "storage.type": "const|let|var|function",
  608. "constant.language": "null|Infinity|NaN|undefined",
  609. "support.function": "alert",
  610. "constant.language.boolean": "true|false"
  611. };
  612. var keywordMapper = this.createKeywordMapper(keywords, "identifier");
  613. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
  614. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  615. "u[0-9a-fA-F]{4}|" + // unicode
  616. "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
  617. "[0-2][0-7]{0,2}|" + // oct
  618. "3[0-7][0-7]?|" + // oct
  619. "[4-7][0-7]?|" + //oct
  620. ".)";
  621. var anonymousFunctionRe = "(function)(\\s*)(\\*?)";
  622. var functionCallStartRule = {
  623. token: ["identifier", "text", "paren.lparen"],
  624. regex: "(\\b(?!" + Object.values(keywords).join("|") + "\\b)" + identifierRe + ")(\\s*)(\\()"
  625. };
  626. this.$rules = {
  627. "no_regex": [
  628. DocCommentHighlightRules.getStartRule("doc-start"),
  629. comments("no_regex"),
  630. functionCallStartRule,
  631. {
  632. token: "string",
  633. regex: "'(?=.)",
  634. next: "qstring"
  635. }, {
  636. token: "string",
  637. regex: '"(?=.)',
  638. next: "qqstring"
  639. }, {
  640. token: "constant.numeric", // hexadecimal, octal and binary
  641. regex: /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
  642. }, {
  643. token: "constant.numeric", // decimal integers and floats
  644. regex: /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
  645. }, {
  646. token: [
  647. "entity.name.function", "text", "keyword.operator", "text", "storage.type",
  648. "text", "storage.type", "text", "paren.lparen"
  649. ],
  650. regex: "(" + identifierRe + ")(\\s*)(=)(\\s*)" + anonymousFunctionRe + "(\\s*)(\\()",
  651. next: "function_arguments"
  652. }, {
  653. token: [
  654. "storage.type", "text", "storage.type", "text", "text", "entity.name.function", "text", "paren.lparen"
  655. ],
  656. regex: "(function)(?:(?:(\\s*)(\\*)(\\s*))|(\\s+))(" + identifierRe + ")(\\s*)(\\()",
  657. next: "function_arguments"
  658. }, {
  659. token: [
  660. "entity.name.function", "text", "punctuation.operator",
  661. "text", "storage.type", "text", "storage.type", "text", "paren.lparen"
  662. ],
  663. regex: "(" + identifierRe + ")(\\s*)(:)(\\s*)" + anonymousFunctionRe + "(\\s*)(\\()",
  664. next: "function_arguments"
  665. }, {
  666. token: [
  667. "text", "text", "storage.type", "text", "storage.type", "text", "paren.lparen"
  668. ],
  669. regex: "(:)(\\s*)" + anonymousFunctionRe + "(\\s*)(\\()",
  670. next: "function_arguments"
  671. }, {
  672. token: "keyword",
  673. regex: "from(?=\\s*('|\"))"
  674. }, {
  675. token: "keyword",
  676. regex: "(?:" + kwBeforeRe + ")\\b",
  677. next: "start"
  678. }, {
  679. token: "support.constant",
  680. regex: /that\b/
  681. }, {
  682. token: ["storage.type", "punctuation.operator", "support.function.firebug"],
  683. regex: /(console)(\.)(warn|info|log|error|debug|time|trace|timeEnd|assert)\b/
  684. }, {
  685. token: keywordMapper,
  686. regex: identifierRe
  687. }, {
  688. token: "punctuation.operator",
  689. regex: /[.](?![.])/,
  690. next: "property"
  691. }, {
  692. token: "storage.type",
  693. regex: /=>/,
  694. next: "start"
  695. }, {
  696. token: "keyword.operator",
  697. regex: /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
  698. next: "start"
  699. }, {
  700. token: "punctuation.operator",
  701. regex: /[?:,;.]/,
  702. next: "start"
  703. }, {
  704. token: "paren.lparen",
  705. regex: /[\[({]/,
  706. next: "start"
  707. }, {
  708. token: "paren.rparen",
  709. regex: /[\])}]/
  710. }, {
  711. token: "comment",
  712. regex: /^#!.*$/
  713. }
  714. ],
  715. property: [{
  716. token: "text",
  717. regex: "\\s+"
  718. }, {
  719. token: "keyword.operator",
  720. regex: /=/
  721. }, {
  722. token: [
  723. "storage.type", "text", "storage.type", "text", "paren.lparen"
  724. ],
  725. regex: anonymousFunctionRe + "(\\s*)(\\()",
  726. next: "function_arguments"
  727. }, {
  728. token: [
  729. "storage.type", "text", "storage.type", "text", "text", "entity.name.function", "text", "paren.lparen"
  730. ],
  731. regex: "(function)(?:(?:(\\s*)(\\*)(\\s*))|(\\s+))(\\w+)(\\s*)(\\()",
  732. next: "function_arguments"
  733. }, {
  734. token: "punctuation.operator",
  735. regex: /[.](?![.])/
  736. }, {
  737. token: "support.function",
  738. regex: "prototype"
  739. }, {
  740. token: "support.function",
  741. 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(?=\()/
  742. }, {
  743. token: "support.function.dom",
  744. 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(?=\()/
  745. }, {
  746. token: "support.constant",
  747. 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/
  748. }, {
  749. token: "identifier",
  750. regex: identifierRe
  751. }, {
  752. regex: "",
  753. token: "empty",
  754. next: "no_regex"
  755. }
  756. ],
  757. "start": [
  758. DocCommentHighlightRules.getStartRule("doc-start"),
  759. comments("start"),
  760. {
  761. token: "string.regexp",
  762. regex: "\\/",
  763. next: "regex"
  764. }, {
  765. token: "text",
  766. regex: "\\s+|^$",
  767. next: "start"
  768. }, {
  769. token: "empty",
  770. regex: "",
  771. next: "no_regex"
  772. }
  773. ],
  774. "regex": [
  775. {
  776. token: "regexp.keyword.operator",
  777. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  778. }, {
  779. token: "string.regexp",
  780. regex: "/[sxngimy]*",
  781. next: "no_regex"
  782. }, {
  783. token: "invalid",
  784. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  785. }, {
  786. token: "constant.language.escape",
  787. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  788. }, {
  789. token: "constant.language.delimiter",
  790. regex: /\|/
  791. }, {
  792. token: "constant.language.escape",
  793. regex: /\[\^?/,
  794. next: "regex_character_class"
  795. }, {
  796. token: "empty",
  797. regex: "$",
  798. next: "no_regex"
  799. }, {
  800. defaultToken: "string.regexp"
  801. }
  802. ],
  803. "regex_character_class": [
  804. {
  805. token: "regexp.charclass.keyword.operator",
  806. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  807. }, {
  808. token: "constant.language.escape",
  809. regex: "]",
  810. next: "regex"
  811. }, {
  812. token: "constant.language.escape",
  813. regex: "-"
  814. }, {
  815. token: "empty",
  816. regex: "$",
  817. next: "no_regex"
  818. }, {
  819. defaultToken: "string.regexp.charachterclass"
  820. }
  821. ],
  822. "default_parameter": [
  823. {
  824. token: "string",
  825. regex: "'(?=.)",
  826. push: [
  827. {
  828. token: "string",
  829. regex: "'|$",
  830. next: "pop"
  831. }, {
  832. include: "qstring"
  833. }
  834. ]
  835. }, {
  836. token: "string",
  837. regex: '"(?=.)',
  838. push: [
  839. {
  840. token: "string",
  841. regex: '"|$',
  842. next: "pop"
  843. }, {
  844. include: "qqstring"
  845. }
  846. ]
  847. }, {
  848. token: "constant.language",
  849. regex: "null|Infinity|NaN|undefined"
  850. }, {
  851. token: "constant.numeric", // hexadecimal, octal and binary
  852. regex: /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
  853. }, {
  854. token: "constant.numeric", // decimal integers and floats
  855. regex: /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
  856. }, {
  857. token: "punctuation.operator",
  858. regex: ",",
  859. next: "function_arguments"
  860. }, {
  861. token: "text",
  862. regex: "\\s+"
  863. }, {
  864. token: "punctuation.operator",
  865. regex: "$"
  866. }, {
  867. token: "empty",
  868. regex: "",
  869. next: "no_regex"
  870. }
  871. ],
  872. "function_arguments": [
  873. comments("function_arguments"),
  874. {
  875. token: "variable.parameter",
  876. regex: identifierRe
  877. }, {
  878. token: "punctuation.operator",
  879. regex: ","
  880. }, {
  881. token: "text",
  882. regex: "\\s+"
  883. }, {
  884. token: "punctuation.operator",
  885. regex: "$"
  886. }, {
  887. token: "empty",
  888. regex: "",
  889. next: "no_regex"
  890. }
  891. ],
  892. "qqstring": [
  893. {
  894. token: "constant.language.escape",
  895. regex: escapedRe
  896. }, {
  897. token: "string",
  898. regex: "\\\\$",
  899. consumeLineEnd: true
  900. }, {
  901. token: "string",
  902. regex: '"|$',
  903. next: "no_regex"
  904. }, {
  905. defaultToken: "string"
  906. }
  907. ],
  908. "qstring": [
  909. {
  910. token: "constant.language.escape",
  911. regex: escapedRe
  912. }, {
  913. token: "string",
  914. regex: "\\\\$",
  915. consumeLineEnd: true
  916. }, {
  917. token: "string",
  918. regex: "'|$",
  919. next: "no_regex"
  920. }, {
  921. defaultToken: "string"
  922. }
  923. ]
  924. };
  925. if (!options || !options.noES6) {
  926. this.$rules.no_regex.unshift({
  927. regex: "[{}]", onMatch: function (val, state, stack) {
  928. this.next = val == "{" ? this.nextState : "";
  929. if (val == "{" && stack.length) {
  930. stack.unshift("start", state);
  931. }
  932. else if (val == "}" && stack.length) {
  933. stack.shift();
  934. this.next = stack.shift();
  935. if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
  936. return "paren.quasi.end";
  937. }
  938. return val == "{" ? "paren.lparen" : "paren.rparen";
  939. },
  940. nextState: "start"
  941. }, {
  942. token: "string.quasi.start",
  943. regex: /`/,
  944. push: [{
  945. token: "constant.language.escape",
  946. regex: escapedRe
  947. }, {
  948. token: "paren.quasi.start",
  949. regex: /\${/,
  950. push: "start"
  951. }, {
  952. token: "string.quasi.end",
  953. regex: /`/,
  954. next: "pop"
  955. }, {
  956. defaultToken: "string.quasi"
  957. }]
  958. }, {
  959. token: ["variable.parameter", "text"],
  960. regex: "(" + identifierRe + ")(\\s*)(?=\\=>)"
  961. }, {
  962. token: "paren.lparen",
  963. regex: "(\\()(?=[^\\(]+\\s*=>)",
  964. next: "function_arguments"
  965. }, {
  966. token: "variable.language",
  967. regex: "(?:(?:(?:Weak)?(?:Set|Map))|Promise)\\b"
  968. });
  969. this.$rules["function_arguments"].unshift({
  970. token: "keyword.operator",
  971. regex: "=",
  972. next: "default_parameter"
  973. }, {
  974. token: "keyword.operator",
  975. regex: "\\.{3}"
  976. });
  977. this.$rules["property"].unshift({
  978. token: "support.function",
  979. regex: "(findIndex|repeat|startsWith|endsWith|includes|isSafeInteger|trunc|cbrt|log2|log10|sign|then|catch|"
  980. + "finally|resolve|reject|race|any|all|allSettled|keys|entries|isInteger)\\b(?=\\()"
  981. }, {
  982. token: "constant.language",
  983. regex: "(?:MAX_SAFE_INTEGER|MIN_SAFE_INTEGER|EPSILON)\\b"
  984. });
  985. if (!options || options.jsx != false)
  986. JSX.call(this);
  987. }
  988. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("no_regex")]);
  989. this.normalizeRules();
  990. };
  991. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  992. function JSX() {
  993. var tagRegex = identifierRe.replace("\\d", "\\d\\-");
  994. var jsxTag = {
  995. onMatch: function (val, state, stack) {
  996. var offset = val.charAt(1) == "/" ? 2 : 1;
  997. if (offset == 1) {
  998. if (state != this.nextState)
  999. stack.unshift(this.next, this.nextState, 0);
  1000. else
  1001. stack.unshift(this.next);
  1002. stack[2]++;
  1003. }
  1004. else if (offset == 2) {
  1005. if (state == this.nextState) {
  1006. stack[1]--;
  1007. if (!stack[1] || stack[1] < 0) {
  1008. stack.shift();
  1009. stack.shift();
  1010. }
  1011. }
  1012. }
  1013. return [{
  1014. type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
  1015. value: val.slice(0, offset)
  1016. }, {
  1017. type: "meta.tag.tag-name.xml",
  1018. value: val.substr(offset)
  1019. }];
  1020. },
  1021. regex: "</?(?:" + tagRegex + "|(?=>))",
  1022. next: "jsxAttributes",
  1023. nextState: "jsx"
  1024. };
  1025. this.$rules.start.unshift(jsxTag);
  1026. var jsxJsRule = {
  1027. regex: "{",
  1028. token: "paren.quasi.start",
  1029. push: "start"
  1030. };
  1031. this.$rules.jsx = [
  1032. jsxJsRule,
  1033. jsxTag,
  1034. { include: "reference" }, { defaultToken: "string.xml" }
  1035. ];
  1036. this.$rules.jsxAttributes = [{
  1037. token: "meta.tag.punctuation.tag-close.xml",
  1038. regex: "/?>",
  1039. onMatch: function (value, currentState, stack) {
  1040. if (currentState == stack[0])
  1041. stack.shift();
  1042. if (value.length == 2) {
  1043. if (stack[0] == this.nextState)
  1044. stack[1]--;
  1045. if (!stack[1] || stack[1] < 0) {
  1046. stack.splice(0, 2);
  1047. }
  1048. }
  1049. this.next = stack[0] || "start";
  1050. return [{ type: this.token, value: value }];
  1051. },
  1052. nextState: "jsx"
  1053. },
  1054. jsxJsRule,
  1055. comments("jsxAttributes"),
  1056. {
  1057. token: "entity.other.attribute-name.xml",
  1058. regex: tagRegex
  1059. }, {
  1060. token: "keyword.operator.attribute-equals.xml",
  1061. regex: "="
  1062. }, {
  1063. token: "text.tag-whitespace.xml",
  1064. regex: "\\s+"
  1065. }, {
  1066. token: "string.attribute-value.xml",
  1067. regex: "'",
  1068. stateName: "jsx_attr_q",
  1069. push: [
  1070. { token: "string.attribute-value.xml", regex: "'", next: "pop" },
  1071. { include: "reference" },
  1072. { defaultToken: "string.attribute-value.xml" }
  1073. ]
  1074. }, {
  1075. token: "string.attribute-value.xml",
  1076. regex: '"',
  1077. stateName: "jsx_attr_qq",
  1078. push: [
  1079. { token: "string.attribute-value.xml", regex: '"', next: "pop" },
  1080. { include: "reference" },
  1081. { defaultToken: "string.attribute-value.xml" }
  1082. ]
  1083. },
  1084. jsxTag
  1085. ];
  1086. this.$rules.reference = [{
  1087. token: "constant.language.escape.reference.xml",
  1088. regex: "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  1089. }];
  1090. }
  1091. function comments(next) {
  1092. return [
  1093. {
  1094. token: "comment", // multi line comment
  1095. regex: /\/\*/,
  1096. next: [
  1097. DocCommentHighlightRules.getTagRule(),
  1098. { token: "comment", regex: "\\*\\/", next: next || "pop" },
  1099. { defaultToken: "comment", caseInsensitive: true }
  1100. ]
  1101. }, {
  1102. token: "comment",
  1103. regex: "\\/\\/",
  1104. next: [
  1105. DocCommentHighlightRules.getTagRule(),
  1106. { token: "comment", regex: "$|^", next: next || "pop" },
  1107. { defaultToken: "comment", caseInsensitive: true }
  1108. ]
  1109. }
  1110. ];
  1111. }
  1112. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  1113. });
  1114. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  1115. var Range = require("../range").Range;
  1116. var MatchingBraceOutdent = function () { };
  1117. (function () {
  1118. this.checkOutdent = function (line, input) {
  1119. if (!/^\s+$/.test(line))
  1120. return false;
  1121. return /^\s*\}/.test(input);
  1122. };
  1123. this.autoOutdent = function (doc, row) {
  1124. var line = doc.getLine(row);
  1125. var match = line.match(/^(\s*\})/);
  1126. if (!match)
  1127. return 0;
  1128. var column = match[1].length;
  1129. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  1130. if (!openBracePos || openBracePos.row == row)
  1131. return 0;
  1132. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  1133. doc.replace(new Range(row, 0, row, column - 1), indent);
  1134. };
  1135. this.$getIndent = function (line) {
  1136. return line.match(/^\s*/)[0];
  1137. };
  1138. }).call(MatchingBraceOutdent.prototype);
  1139. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  1140. });
  1141. 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";
  1142. var oop = require("../../lib/oop");
  1143. var TokenIterator = require("../../token_iterator").TokenIterator;
  1144. var CstyleBehaviour = require("../behaviour/cstyle").CstyleBehaviour;
  1145. var XmlBehaviour = require("../behaviour/xml").XmlBehaviour;
  1146. var JavaScriptBehaviour = function () {
  1147. var xmlBehaviours = new XmlBehaviour({ closeCurlyBraces: true }).getBehaviours();
  1148. this.addBehaviours(xmlBehaviours);
  1149. this.inherit(CstyleBehaviour);
  1150. this.add("autoclosing-fragment", "insertion", function (state, action, editor, session, text) {
  1151. if (text == '>') {
  1152. var position = editor.getSelectionRange().start;
  1153. var iterator = new TokenIterator(session, position.row, position.column);
  1154. var token = iterator.getCurrentToken() || iterator.stepBackward();
  1155. if (!token)
  1156. return;
  1157. if (token.value == '<') {
  1158. return {
  1159. text: "></>",
  1160. selection: [1, 1]
  1161. };
  1162. }
  1163. }
  1164. });
  1165. };
  1166. oop.inherits(JavaScriptBehaviour, CstyleBehaviour);
  1167. exports.JavaScriptBehaviour = JavaScriptBehaviour;
  1168. });
  1169. 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";
  1170. var oop = require("../../lib/oop");
  1171. var Range = require("../../range").Range;
  1172. var BaseFoldMode = require("./fold_mode").FoldMode;
  1173. var FoldMode = exports.FoldMode = function (commentRegex) {
  1174. if (commentRegex) {
  1175. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  1176. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  1177. }
  1178. };
  1179. oop.inherits(FoldMode, BaseFoldMode);
  1180. (function () {
  1181. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  1182. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  1183. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  1184. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  1185. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  1186. this._getFoldWidgetBase = this.getFoldWidget;
  1187. this.getFoldWidget = function (session, foldStyle, row) {
  1188. var line = session.getLine(row);
  1189. if (this.singleLineBlockCommentRe.test(line)) {
  1190. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  1191. return "";
  1192. }
  1193. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  1194. if (!fw && this.startRegionRe.test(line))
  1195. return "start"; // lineCommentRegionStart
  1196. return fw;
  1197. };
  1198. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  1199. var line = session.getLine(row);
  1200. if (this.startRegionRe.test(line))
  1201. return this.getCommentRegionBlock(session, line, row);
  1202. var match = line.match(this.foldingStartMarker);
  1203. if (match) {
  1204. var i = match.index;
  1205. if (match[1])
  1206. return this.openingBracketBlock(session, match[1], row, i);
  1207. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  1208. if (range && !range.isMultiLine()) {
  1209. if (forceMultiline) {
  1210. range = this.getSectionRange(session, row);
  1211. }
  1212. else if (foldStyle != "all")
  1213. range = null;
  1214. }
  1215. return range;
  1216. }
  1217. if (foldStyle === "markbegin")
  1218. return;
  1219. var match = line.match(this.foldingStopMarker);
  1220. if (match) {
  1221. var i = match.index + match[0].length;
  1222. if (match[1])
  1223. return this.closingBracketBlock(session, match[1], row, i);
  1224. return session.getCommentFoldRange(row, i, -1);
  1225. }
  1226. };
  1227. this.getSectionRange = function (session, row) {
  1228. var line = session.getLine(row);
  1229. var startIndent = line.search(/\S/);
  1230. var startRow = row;
  1231. var startColumn = line.length;
  1232. row = row + 1;
  1233. var endRow = row;
  1234. var maxRow = session.getLength();
  1235. while (++row < maxRow) {
  1236. line = session.getLine(row);
  1237. var indent = line.search(/\S/);
  1238. if (indent === -1)
  1239. continue;
  1240. if (startIndent > indent)
  1241. break;
  1242. var subRange = this.getFoldWidgetRange(session, "all", row);
  1243. if (subRange) {
  1244. if (subRange.start.row <= startRow) {
  1245. break;
  1246. }
  1247. else if (subRange.isMultiLine()) {
  1248. row = subRange.end.row;
  1249. }
  1250. else if (startIndent == indent) {
  1251. break;
  1252. }
  1253. }
  1254. endRow = row;
  1255. }
  1256. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  1257. };
  1258. this.getCommentRegionBlock = function (session, line, row) {
  1259. var startColumn = line.search(/\s*$/);
  1260. var maxRow = session.getLength();
  1261. var startRow = row;
  1262. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  1263. var depth = 1;
  1264. while (++row < maxRow) {
  1265. line = session.getLine(row);
  1266. var m = re.exec(line);
  1267. if (!m)
  1268. continue;
  1269. if (m[1])
  1270. depth--;
  1271. else
  1272. depth++;
  1273. if (!depth)
  1274. break;
  1275. }
  1276. var endRow = row;
  1277. if (endRow > startRow) {
  1278. return new Range(startRow, startColumn, endRow, line.length);
  1279. }
  1280. };
  1281. }).call(FoldMode.prototype);
  1282. });
  1283. 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";
  1284. var oop = require("../../lib/oop");
  1285. var XmlFoldMode = require("./xml").FoldMode;
  1286. var CFoldMode = require("./cstyle").FoldMode;
  1287. var FoldMode = exports.FoldMode = function (commentRegex) {
  1288. if (commentRegex) {
  1289. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  1290. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  1291. }
  1292. this.xmlFoldMode = new XmlFoldMode();
  1293. };
  1294. oop.inherits(FoldMode, CFoldMode);
  1295. (function () {
  1296. this.getFoldWidgetRangeBase = this.getFoldWidgetRange;
  1297. this.getFoldWidgetBase = this.getFoldWidget;
  1298. this.getFoldWidget = function (session, foldStyle, row) {
  1299. var fw = this.getFoldWidgetBase(session, foldStyle, row);
  1300. if (!fw) {
  1301. return this.xmlFoldMode.getFoldWidget(session, foldStyle, row);
  1302. }
  1303. return fw;
  1304. };
  1305. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  1306. var range = this.getFoldWidgetRangeBase(session, foldStyle, row, forceMultiline);
  1307. if (range)
  1308. return range;
  1309. return this.xmlFoldMode.getFoldWidgetRange(session, foldStyle, row);
  1310. };
  1311. }).call(FoldMode.prototype);
  1312. });
  1313. 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";
  1314. var oop = require("../lib/oop");
  1315. var TextMode = require("./text").Mode;
  1316. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1317. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1318. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1319. var JavaScriptBehaviour = require("./behaviour/javascript").JavaScriptBehaviour;
  1320. var JavaScriptFoldMode = require("./folding/javascript").FoldMode;
  1321. var Mode = function () {
  1322. this.HighlightRules = JavaScriptHighlightRules;
  1323. this.$outdent = new MatchingBraceOutdent();
  1324. this.$behaviour = new JavaScriptBehaviour();
  1325. this.foldingRules = new JavaScriptFoldMode();
  1326. };
  1327. oop.inherits(Mode, TextMode);
  1328. (function () {
  1329. this.lineCommentStart = "//";
  1330. this.blockComment = { start: "/*", end: "*/" };
  1331. this.$quotes = { '"': '"', "'": "'", "`": "`" };
  1332. this.$pairQuotesAfter = {
  1333. "`": /\w/
  1334. };
  1335. this.getNextLineIndent = function (state, line, tab) {
  1336. var indent = this.$getIndent(line);
  1337. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  1338. var tokens = tokenizedLine.tokens;
  1339. var endState = tokenizedLine.state;
  1340. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  1341. return indent;
  1342. }
  1343. if (state == "start" || state == "no_regex") {
  1344. var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
  1345. if (match) {
  1346. indent += tab;
  1347. }
  1348. }
  1349. else if (state == "doc-start") {
  1350. if (endState == "start" || endState == "no_regex") {
  1351. return "";
  1352. }
  1353. }
  1354. return indent;
  1355. };
  1356. this.checkOutdent = function (state, line, input) {
  1357. return this.$outdent.checkOutdent(line, input);
  1358. };
  1359. this.autoOutdent = function (state, doc, row) {
  1360. this.$outdent.autoOutdent(doc, row);
  1361. };
  1362. this.createWorker = function (session) {
  1363. var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
  1364. worker.attachToDocument(session.getDocument());
  1365. worker.on("annotate", function (results) {
  1366. session.setAnnotations(results.data);
  1367. });
  1368. worker.on("terminate", function () {
  1369. session.clearAnnotations();
  1370. });
  1371. return worker;
  1372. };
  1373. this.$id = "ace/mode/javascript";
  1374. this.snippetFileId = "ace/snippets/javascript";
  1375. }).call(Mode.prototype);
  1376. exports.Mode = Mode;
  1377. });
  1378. ace.define("ace/mode/svg_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/javascript_highlight_rules","ace/mode/xml_highlight_rules"], function(require, exports, module){"use strict";
  1379. var oop = require("../lib/oop");
  1380. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1381. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1382. var SvgHighlightRules = function () {
  1383. XmlHighlightRules.call(this);
  1384. this.embedTagRules(JavaScriptHighlightRules, "js-", "script");
  1385. this.normalizeRules();
  1386. };
  1387. oop.inherits(SvgHighlightRules, XmlHighlightRules);
  1388. exports.SvgHighlightRules = SvgHighlightRules;
  1389. });
  1390. ace.define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
  1391. var oop = require("../../lib/oop");
  1392. var BaseFoldMode = require("./fold_mode").FoldMode;
  1393. var FoldMode = exports.FoldMode = function (defaultMode, subModes) {
  1394. this.defaultMode = defaultMode;
  1395. this.subModes = subModes;
  1396. };
  1397. oop.inherits(FoldMode, BaseFoldMode);
  1398. (function () {
  1399. this.$getMode = function (state) {
  1400. if (typeof state != "string")
  1401. state = state[0];
  1402. for (var key in this.subModes) {
  1403. if (state.indexOf(key) === 0)
  1404. return this.subModes[key];
  1405. }
  1406. return null;
  1407. };
  1408. this.$tryMode = function (state, session, foldStyle, row) {
  1409. var mode = this.$getMode(state);
  1410. return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
  1411. };
  1412. this.getFoldWidget = function (session, foldStyle, row) {
  1413. return (this.$tryMode(session.getState(row - 1), session, foldStyle, row) ||
  1414. this.$tryMode(session.getState(row), session, foldStyle, row) ||
  1415. this.defaultMode.getFoldWidget(session, foldStyle, row));
  1416. };
  1417. this.getFoldWidgetRange = function (session, foldStyle, row) {
  1418. var mode = this.$getMode(session.getState(row - 1));
  1419. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1420. mode = this.$getMode(session.getState(row));
  1421. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1422. mode = this.defaultMode;
  1423. return mode.getFoldWidgetRange(session, foldStyle, row);
  1424. };
  1425. }).call(FoldMode.prototype);
  1426. });
  1427. ace.define("ace/mode/svg",["require","exports","module","ace/lib/oop","ace/mode/xml","ace/mode/javascript","ace/mode/svg_highlight_rules","ace/mode/folding/mixed","ace/mode/folding/xml","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  1428. var oop = require("../lib/oop");
  1429. var XmlMode = require("./xml").Mode;
  1430. var JavaScriptMode = require("./javascript").Mode;
  1431. var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules;
  1432. var MixedFoldMode = require("./folding/mixed").FoldMode;
  1433. var XmlFoldMode = require("./folding/xml").FoldMode;
  1434. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1435. var Mode = function () {
  1436. XmlMode.call(this);
  1437. this.HighlightRules = SvgHighlightRules;
  1438. this.createModeDelegates({
  1439. "js-": JavaScriptMode
  1440. });
  1441. this.foldingRules = new MixedFoldMode(new XmlFoldMode(), {
  1442. "js-": new CStyleFoldMode()
  1443. });
  1444. };
  1445. oop.inherits(Mode, XmlMode);
  1446. (function () {
  1447. this.getNextLineIndent = function (state, line, tab) {
  1448. return this.$getIndent(line);
  1449. };
  1450. this.$id = "ace/mode/svg";
  1451. }).call(Mode.prototype);
  1452. exports.Mode = Mode;
  1453. }); (function() {
  1454. ace.require(["ace/mode/svg"], function(m) {
  1455. if (typeof module == "object" && typeof exports == "object" && module) {
  1456. module.exports = m;
  1457. }
  1458. });
  1459. })();