d0f2beb089c9c264e95d83022ad2024d.js 54 KB

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