d2f6fc7dd9a5141c7899aaf36606ebfc.js 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388
  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","ace/lib/lang"], 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. var lang = require("../../lib/lang");
  184. function is(token, type) {
  185. return token && token.type.lastIndexOf(type + ".xml") > -1;
  186. }
  187. var XmlBehaviour = function () {
  188. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  189. if (text == '"' || text == "'") {
  190. var quote = text;
  191. var selected = session.doc.getTextRange(editor.getSelectionRange());
  192. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  193. return {
  194. text: quote + selected + quote,
  195. selection: false
  196. };
  197. }
  198. var cursor = editor.getCursorPosition();
  199. var line = session.doc.getLine(cursor.row);
  200. var rightChar = line.substring(cursor.column, cursor.column + 1);
  201. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  202. var token = iterator.getCurrentToken();
  203. if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
  204. return {
  205. text: "",
  206. selection: [1, 1]
  207. };
  208. }
  209. if (!token)
  210. token = iterator.stepBackward();
  211. if (!token)
  212. return;
  213. while (is(token, "tag-whitespace") || is(token, "whitespace")) {
  214. token = iterator.stepBackward();
  215. }
  216. var rightSpace = !rightChar || rightChar.match(/\s/);
  217. if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
  218. return {
  219. text: quote + quote,
  220. selection: [1, 1]
  221. };
  222. }
  223. }
  224. });
  225. this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
  226. var selected = session.doc.getTextRange(range);
  227. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  228. var line = session.doc.getLine(range.start.row);
  229. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  230. if (rightChar == selected) {
  231. range.end.column++;
  232. return range;
  233. }
  234. }
  235. });
  236. this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
  237. if (text == '>') {
  238. var position = editor.getSelectionRange().start;
  239. var iterator = new TokenIterator(session, position.row, position.column);
  240. var token = iterator.getCurrentToken() || iterator.stepBackward();
  241. if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
  242. return;
  243. if (is(token, "reference.attribute-value"))
  244. return;
  245. if (is(token, "attribute-value")) {
  246. var tokenEndColumn = iterator.getCurrentTokenColumn() + token.value.length;
  247. if (position.column < tokenEndColumn)
  248. return;
  249. if (position.column == tokenEndColumn) {
  250. var nextToken = iterator.stepForward();
  251. if (nextToken && is(nextToken, "attribute-value"))
  252. return;
  253. iterator.stepBackward();
  254. }
  255. }
  256. if (/^\s*>/.test(session.getLine(position.row).slice(position.column)))
  257. return;
  258. while (!is(token, "tag-name")) {
  259. token = iterator.stepBackward();
  260. if (token.value == "<") {
  261. token = iterator.stepForward();
  262. break;
  263. }
  264. }
  265. var tokenRow = iterator.getCurrentTokenRow();
  266. var tokenColumn = iterator.getCurrentTokenColumn();
  267. if (is(iterator.stepBackward(), "end-tag-open"))
  268. return;
  269. var element = token.value;
  270. if (tokenRow == position.row)
  271. element = element.substring(0, position.column - tokenColumn);
  272. if (this.voidElements.hasOwnProperty(element.toLowerCase()))
  273. return;
  274. return {
  275. text: ">" + "</" + element + ">",
  276. selection: [1, 1]
  277. };
  278. }
  279. });
  280. this.add("autoindent", "insertion", function (state, action, editor, session, text) {
  281. if (text == "\n") {
  282. var cursor = editor.getCursorPosition();
  283. var line = session.getLine(cursor.row);
  284. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  285. var token = iterator.getCurrentToken();
  286. if (token && token.type.indexOf("tag-close") !== -1) {
  287. if (token.value == "/>")
  288. return;
  289. while (token && token.type.indexOf("tag-name") === -1) {
  290. token = iterator.stepBackward();
  291. }
  292. if (!token) {
  293. return;
  294. }
  295. var tag = token.value;
  296. var row = iterator.getCurrentTokenRow();
  297. token = iterator.stepBackward();
  298. if (!token || token.type.indexOf("end-tag") !== -1) {
  299. return;
  300. }
  301. if (this.voidElements && !this.voidElements[tag]) {
  302. var nextToken = session.getTokenAt(cursor.row, cursor.column + 1);
  303. var line = session.getLine(row);
  304. var nextIndent = this.$getIndent(line);
  305. var indent = nextIndent + session.getTabString();
  306. if (nextToken && nextToken.value === "</") {
  307. return {
  308. text: "\n" + indent + "\n" + nextIndent,
  309. selection: [1, indent.length, 1, indent.length]
  310. };
  311. }
  312. else {
  313. return {
  314. text: "\n" + indent
  315. };
  316. }
  317. }
  318. }
  319. }
  320. });
  321. };
  322. oop.inherits(XmlBehaviour, Behaviour);
  323. exports.XmlBehaviour = XmlBehaviour;
  324. });
  325. ace.define("ace/mode/folding/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/range","ace/mode/folding/fold_mode","ace/token_iterator"], function(require, exports, module){"use strict";
  326. var oop = require("../../lib/oop");
  327. var lang = require("../../lib/lang");
  328. var Range = require("../../range").Range;
  329. var BaseFoldMode = require("./fold_mode").FoldMode;
  330. var TokenIterator = require("../../token_iterator").TokenIterator;
  331. var FoldMode = exports.FoldMode = function (voidElements, optionalEndTags) {
  332. BaseFoldMode.call(this);
  333. this.voidElements = voidElements || {};
  334. this.optionalEndTags = oop.mixin({}, this.voidElements);
  335. if (optionalEndTags)
  336. oop.mixin(this.optionalEndTags, optionalEndTags);
  337. };
  338. oop.inherits(FoldMode, BaseFoldMode);
  339. var Tag = function () {
  340. this.tagName = "";
  341. this.closing = false;
  342. this.selfClosing = false;
  343. this.start = { row: 0, column: 0 };
  344. this.end = { row: 0, column: 0 };
  345. };
  346. function is(token, type) {
  347. return token.type.lastIndexOf(type + ".xml") > -1;
  348. }
  349. (function () {
  350. this.getFoldWidget = function (session, foldStyle, row) {
  351. var tag = this._getFirstTagInLine(session, row);
  352. if (!tag)
  353. return this.getCommentFoldWidget(session, row);
  354. if (tag.closing || (!tag.tagName && tag.selfClosing))
  355. return foldStyle == "markbeginend" ? "end" : "";
  356. if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
  357. return "";
  358. if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
  359. return "";
  360. return "start";
  361. };
  362. this.getCommentFoldWidget = function (session, row) {
  363. if (/comment/.test(session.getState(row)) && /<!-/.test(session.getLine(row)))
  364. return "start";
  365. return "";
  366. };
  367. this._getFirstTagInLine = function (session, row) {
  368. var tokens = session.getTokens(row);
  369. var tag = new Tag();
  370. for (var i = 0; i < tokens.length; i++) {
  371. var token = tokens[i];
  372. if (is(token, "tag-open")) {
  373. tag.end.column = tag.start.column + token.value.length;
  374. tag.closing = is(token, "end-tag-open");
  375. token = tokens[++i];
  376. if (!token)
  377. return null;
  378. tag.tagName = token.value;
  379. tag.end.column += token.value.length;
  380. for (i++; i < tokens.length; i++) {
  381. token = tokens[i];
  382. tag.end.column += token.value.length;
  383. if (is(token, "tag-close")) {
  384. tag.selfClosing = token.value == '/>';
  385. break;
  386. }
  387. }
  388. return tag;
  389. }
  390. else if (is(token, "tag-close")) {
  391. tag.selfClosing = token.value == '/>';
  392. return tag;
  393. }
  394. tag.start.column += token.value.length;
  395. }
  396. return null;
  397. };
  398. this._findEndTagInLine = function (session, row, tagName, startColumn) {
  399. var tokens = session.getTokens(row);
  400. var column = 0;
  401. for (var i = 0; i < tokens.length; i++) {
  402. var token = tokens[i];
  403. column += token.value.length;
  404. if (column < startColumn)
  405. continue;
  406. if (is(token, "end-tag-open")) {
  407. token = tokens[i + 1];
  408. if (token && token.value == tagName)
  409. return true;
  410. }
  411. }
  412. return false;
  413. };
  414. this._readTagForward = function (iterator) {
  415. var token = iterator.getCurrentToken();
  416. if (!token)
  417. return null;
  418. var tag = new Tag();
  419. do {
  420. if (is(token, "tag-open")) {
  421. tag.closing = is(token, "end-tag-open");
  422. tag.start.row = iterator.getCurrentTokenRow();
  423. tag.start.column = iterator.getCurrentTokenColumn();
  424. }
  425. else if (is(token, "tag-name")) {
  426. tag.tagName = token.value;
  427. }
  428. else if (is(token, "tag-close")) {
  429. tag.selfClosing = token.value == "/>";
  430. tag.end.row = iterator.getCurrentTokenRow();
  431. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  432. iterator.stepForward();
  433. return tag;
  434. }
  435. } while (token = iterator.stepForward());
  436. return null;
  437. };
  438. this._readTagBackward = function (iterator) {
  439. var token = iterator.getCurrentToken();
  440. if (!token)
  441. return null;
  442. var tag = new Tag();
  443. do {
  444. if (is(token, "tag-open")) {
  445. tag.closing = is(token, "end-tag-open");
  446. tag.start.row = iterator.getCurrentTokenRow();
  447. tag.start.column = iterator.getCurrentTokenColumn();
  448. iterator.stepBackward();
  449. return tag;
  450. }
  451. else if (is(token, "tag-name")) {
  452. tag.tagName = token.value;
  453. }
  454. else if (is(token, "tag-close")) {
  455. tag.selfClosing = token.value == "/>";
  456. tag.end.row = iterator.getCurrentTokenRow();
  457. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  458. }
  459. } while (token = iterator.stepBackward());
  460. return null;
  461. };
  462. this._pop = function (stack, tag) {
  463. while (stack.length) {
  464. var top = stack[stack.length - 1];
  465. if (!tag || top.tagName == tag.tagName) {
  466. return stack.pop();
  467. }
  468. else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
  469. stack.pop();
  470. continue;
  471. }
  472. else {
  473. return null;
  474. }
  475. }
  476. };
  477. this.getFoldWidgetRange = function (session, foldStyle, row) {
  478. var firstTag = this._getFirstTagInLine(session, row);
  479. if (!firstTag) {
  480. return this.getCommentFoldWidget(session, row)
  481. && session.getCommentFoldRange(row, session.getLine(row).length);
  482. }
  483. var isBackward = firstTag.closing || firstTag.selfClosing;
  484. var stack = [];
  485. var tag;
  486. if (!isBackward) {
  487. var iterator = new TokenIterator(session, row, firstTag.start.column);
  488. var start = {
  489. row: row,
  490. column: firstTag.start.column + firstTag.tagName.length + 2
  491. };
  492. if (firstTag.start.row == firstTag.end.row)
  493. start.column = firstTag.end.column;
  494. while (tag = this._readTagForward(iterator)) {
  495. if (tag.selfClosing) {
  496. if (!stack.length) {
  497. tag.start.column += tag.tagName.length + 2;
  498. tag.end.column -= 2;
  499. return Range.fromPoints(tag.start, tag.end);
  500. }
  501. else
  502. continue;
  503. }
  504. if (tag.closing) {
  505. this._pop(stack, tag);
  506. if (stack.length == 0)
  507. return Range.fromPoints(start, tag.start);
  508. }
  509. else {
  510. stack.push(tag);
  511. }
  512. }
  513. }
  514. else {
  515. var iterator = new TokenIterator(session, row, firstTag.end.column);
  516. var end = {
  517. row: row,
  518. column: firstTag.start.column
  519. };
  520. while (tag = this._readTagBackward(iterator)) {
  521. if (tag.selfClosing) {
  522. if (!stack.length) {
  523. tag.start.column += tag.tagName.length + 2;
  524. tag.end.column -= 2;
  525. return Range.fromPoints(tag.start, tag.end);
  526. }
  527. else
  528. continue;
  529. }
  530. if (!tag.closing) {
  531. this._pop(stack, tag);
  532. if (stack.length == 0) {
  533. tag.start.column += tag.tagName.length + 2;
  534. if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
  535. tag.start.column = tag.end.column;
  536. return Range.fromPoints(tag.start, end);
  537. }
  538. }
  539. else {
  540. stack.push(tag);
  541. }
  542. }
  543. }
  544. };
  545. }).call(FoldMode.prototype);
  546. });
  547. 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";
  548. var oop = require("../lib/oop");
  549. var lang = require("../lib/lang");
  550. var TextMode = require("./text").Mode;
  551. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  552. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  553. var XmlFoldMode = require("./folding/xml").FoldMode;
  554. var WorkerClient = require("../worker/worker_client").WorkerClient;
  555. var Mode = function () {
  556. this.HighlightRules = XmlHighlightRules;
  557. this.$behaviour = new XmlBehaviour();
  558. this.foldingRules = new XmlFoldMode();
  559. };
  560. oop.inherits(Mode, TextMode);
  561. (function () {
  562. this.voidElements = lang.arrayToMap([]);
  563. this.blockComment = { start: "<!--", end: "-->" };
  564. this.createWorker = function (session) {
  565. var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
  566. worker.attachToDocument(session.getDocument());
  567. worker.on("error", function (e) {
  568. session.setAnnotations(e.data);
  569. });
  570. worker.on("terminate", function () {
  571. session.clearAnnotations();
  572. });
  573. return worker;
  574. };
  575. this.$id = "ace/mode/xml";
  576. }).call(Mode.prototype);
  577. exports.Mode = Mode;
  578. });
  579. ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  580. var oop = require("../lib/oop");
  581. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  582. var DocCommentHighlightRules = function () {
  583. this.$rules = {
  584. "start": [{
  585. token: "comment.doc.tag",
  586. regex: "@[\\w\\d_]+" // TODO: fix email addresses
  587. },
  588. DocCommentHighlightRules.getTagRule(),
  589. {
  590. defaultToken: "comment.doc",
  591. caseInsensitive: true
  592. }]
  593. };
  594. };
  595. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  596. DocCommentHighlightRules.getTagRule = function (start) {
  597. return {
  598. token: "comment.doc.tag.storage.type",
  599. regex: "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  600. };
  601. };
  602. DocCommentHighlightRules.getStartRule = function (start) {
  603. return {
  604. token: "comment.doc",
  605. regex: "\\/\\*(?=\\*)",
  606. next: start
  607. };
  608. };
  609. DocCommentHighlightRules.getEndRule = function (start) {
  610. return {
  611. token: "comment.doc",
  612. regex: "\\*\\/",
  613. next: start
  614. };
  615. };
  616. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  617. });
  618. ace.define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  619. var oop = require("../lib/oop");
  620. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  621. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  622. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
  623. var JavaScriptHighlightRules = function (options) {
  624. var keywordMapper = this.createKeywordMapper({
  625. "variable.language": "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
  626. "Namespace|QName|XML|XMLList|" + // E4X
  627. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  628. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  629. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
  630. "SyntaxError|TypeError|URIError|" +
  631. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
  632. "isNaN|parseFloat|parseInt|" +
  633. "JSON|Math|" + // Other
  634. "this|arguments|prototype|window|document",
  635. "keyword": "const|yield|import|get|set|async|await|" +
  636. "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
  637. "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
  638. "__parent__|__count__|escape|unescape|with|__proto__|" +
  639. "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
  640. "storage.type": "const|let|var|function",
  641. "constant.language": "null|Infinity|NaN|undefined",
  642. "support.function": "alert",
  643. "constant.language.boolean": "true|false"
  644. }, "identifier");
  645. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
  646. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  647. "u[0-9a-fA-F]{4}|" + // unicode
  648. "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
  649. "[0-2][0-7]{0,2}|" + // oct
  650. "3[0-7][0-7]?|" + // oct
  651. "[4-7][0-7]?|" + //oct
  652. ".)";
  653. this.$rules = {
  654. "no_regex": [
  655. DocCommentHighlightRules.getStartRule("doc-start"),
  656. comments("no_regex"),
  657. {
  658. token: "string",
  659. regex: "'(?=.)",
  660. next: "qstring"
  661. }, {
  662. token: "string",
  663. regex: '"(?=.)',
  664. next: "qqstring"
  665. }, {
  666. token: "constant.numeric",
  667. regex: /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
  668. }, {
  669. token: "constant.numeric",
  670. regex: /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
  671. }, {
  672. token: [
  673. "storage.type", "punctuation.operator", "support.function",
  674. "punctuation.operator", "entity.name.function", "text", "keyword.operator"
  675. ],
  676. regex: "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe + ")(\\s*)(=)",
  677. next: "function_arguments"
  678. }, {
  679. token: [
  680. "storage.type", "punctuation.operator", "entity.name.function", "text",
  681. "keyword.operator", "text", "storage.type", "text", "paren.lparen"
  682. ],
  683. regex: "(" + identifierRe + ")(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  684. next: "function_arguments"
  685. }, {
  686. token: [
  687. "entity.name.function", "text", "keyword.operator", "text", "storage.type",
  688. "text", "paren.lparen"
  689. ],
  690. regex: "(" + identifierRe + ")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  691. next: "function_arguments"
  692. }, {
  693. token: [
  694. "storage.type", "punctuation.operator", "entity.name.function", "text",
  695. "keyword.operator", "text",
  696. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  697. ],
  698. regex: "(" + identifierRe + ")(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
  699. next: "function_arguments"
  700. }, {
  701. token: [
  702. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  703. ],
  704. regex: "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
  705. next: "function_arguments"
  706. }, {
  707. token: [
  708. "entity.name.function", "text", "punctuation.operator",
  709. "text", "storage.type", "text", "paren.lparen"
  710. ],
  711. regex: "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
  712. next: "function_arguments"
  713. }, {
  714. token: [
  715. "text", "text", "storage.type", "text", "paren.lparen"
  716. ],
  717. regex: "(:)(\\s*)(function)(\\s*)(\\()",
  718. next: "function_arguments"
  719. }, {
  720. token: "keyword",
  721. regex: "from(?=\\s*('|\"))"
  722. }, {
  723. token: "keyword",
  724. regex: "(?:" + kwBeforeRe + ")\\b",
  725. next: "start"
  726. }, {
  727. token: ["support.constant"],
  728. regex: /that\b/
  729. }, {
  730. token: ["storage.type", "punctuation.operator", "support.function.firebug"],
  731. regex: /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
  732. }, {
  733. token: keywordMapper,
  734. regex: identifierRe
  735. }, {
  736. token: "punctuation.operator",
  737. regex: /[.](?![.])/,
  738. next: "property"
  739. }, {
  740. token: "storage.type",
  741. regex: /=>/,
  742. next: "start"
  743. }, {
  744. token: "keyword.operator",
  745. regex: /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
  746. next: "start"
  747. }, {
  748. token: "punctuation.operator",
  749. regex: /[?:,;.]/,
  750. next: "start"
  751. }, {
  752. token: "paren.lparen",
  753. regex: /[\[({]/,
  754. next: "start"
  755. }, {
  756. token: "paren.rparen",
  757. regex: /[\])}]/
  758. }, {
  759. token: "comment",
  760. regex: /^#!.*$/
  761. }
  762. ],
  763. property: [{
  764. token: "text",
  765. regex: "\\s+"
  766. }, {
  767. token: [
  768. "storage.type", "punctuation.operator", "entity.name.function", "text",
  769. "keyword.operator", "text",
  770. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  771. ],
  772. regex: "(" + identifierRe + ")(\\.)(" + identifierRe + ")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",
  773. next: "function_arguments"
  774. }, {
  775. token: "punctuation.operator",
  776. regex: /[.](?![.])/
  777. }, {
  778. token: "support.function",
  779. regex: /(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
  780. }, {
  781. token: "support.function.dom",
  782. 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(?=\()/
  783. }, {
  784. token: "support.constant",
  785. 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/
  786. }, {
  787. token: "identifier",
  788. regex: identifierRe
  789. }, {
  790. regex: "",
  791. token: "empty",
  792. next: "no_regex"
  793. }
  794. ],
  795. "start": [
  796. DocCommentHighlightRules.getStartRule("doc-start"),
  797. comments("start"),
  798. {
  799. token: "string.regexp",
  800. regex: "\\/",
  801. next: "regex"
  802. }, {
  803. token: "text",
  804. regex: "\\s+|^$",
  805. next: "start"
  806. }, {
  807. token: "empty",
  808. regex: "",
  809. next: "no_regex"
  810. }
  811. ],
  812. "regex": [
  813. {
  814. token: "regexp.keyword.operator",
  815. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  816. }, {
  817. token: "string.regexp",
  818. regex: "/[sxngimy]*",
  819. next: "no_regex"
  820. }, {
  821. token: "invalid",
  822. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  823. }, {
  824. token: "constant.language.escape",
  825. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  826. }, {
  827. token: "constant.language.delimiter",
  828. regex: /\|/
  829. }, {
  830. token: "constant.language.escape",
  831. regex: /\[\^?/,
  832. next: "regex_character_class"
  833. }, {
  834. token: "empty",
  835. regex: "$",
  836. next: "no_regex"
  837. }, {
  838. defaultToken: "string.regexp"
  839. }
  840. ],
  841. "regex_character_class": [
  842. {
  843. token: "regexp.charclass.keyword.operator",
  844. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  845. }, {
  846. token: "constant.language.escape",
  847. regex: "]",
  848. next: "regex"
  849. }, {
  850. token: "constant.language.escape",
  851. regex: "-"
  852. }, {
  853. token: "empty",
  854. regex: "$",
  855. next: "no_regex"
  856. }, {
  857. defaultToken: "string.regexp.charachterclass"
  858. }
  859. ],
  860. "function_arguments": [
  861. {
  862. token: "variable.parameter",
  863. regex: identifierRe
  864. }, {
  865. token: "punctuation.operator",
  866. regex: "[, ]+"
  867. }, {
  868. token: "punctuation.operator",
  869. regex: "$"
  870. }, {
  871. token: "empty",
  872. regex: "",
  873. next: "no_regex"
  874. }
  875. ],
  876. "qqstring": [
  877. {
  878. token: "constant.language.escape",
  879. regex: escapedRe
  880. }, {
  881. token: "string",
  882. regex: "\\\\$",
  883. consumeLineEnd: true
  884. }, {
  885. token: "string",
  886. regex: '"|$',
  887. next: "no_regex"
  888. }, {
  889. defaultToken: "string"
  890. }
  891. ],
  892. "qstring": [
  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. };
  909. if (!options || !options.noES6) {
  910. this.$rules.no_regex.unshift({
  911. regex: "[{}]", onMatch: function (val, state, stack) {
  912. this.next = val == "{" ? this.nextState : "";
  913. if (val == "{" && stack.length) {
  914. stack.unshift("start", state);
  915. }
  916. else if (val == "}" && stack.length) {
  917. stack.shift();
  918. this.next = stack.shift();
  919. if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
  920. return "paren.quasi.end";
  921. }
  922. return val == "{" ? "paren.lparen" : "paren.rparen";
  923. },
  924. nextState: "start"
  925. }, {
  926. token: "string.quasi.start",
  927. regex: /`/,
  928. push: [{
  929. token: "constant.language.escape",
  930. regex: escapedRe
  931. }, {
  932. token: "paren.quasi.start",
  933. regex: /\${/,
  934. push: "start"
  935. }, {
  936. token: "string.quasi.end",
  937. regex: /`/,
  938. next: "pop"
  939. }, {
  940. defaultToken: "string.quasi"
  941. }]
  942. });
  943. if (!options || options.jsx != false)
  944. JSX.call(this);
  945. }
  946. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("no_regex")]);
  947. this.normalizeRules();
  948. };
  949. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  950. function JSX() {
  951. var tagRegex = identifierRe.replace("\\d", "\\d\\-");
  952. var jsxTag = {
  953. onMatch: function (val, state, stack) {
  954. var offset = val.charAt(1) == "/" ? 2 : 1;
  955. if (offset == 1) {
  956. if (state != this.nextState)
  957. stack.unshift(this.next, this.nextState, 0);
  958. else
  959. stack.unshift(this.next);
  960. stack[2]++;
  961. }
  962. else if (offset == 2) {
  963. if (state == this.nextState) {
  964. stack[1]--;
  965. if (!stack[1] || stack[1] < 0) {
  966. stack.shift();
  967. stack.shift();
  968. }
  969. }
  970. }
  971. return [{
  972. type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
  973. value: val.slice(0, offset)
  974. }, {
  975. type: "meta.tag.tag-name.xml",
  976. value: val.substr(offset)
  977. }];
  978. },
  979. regex: "</?" + tagRegex + "",
  980. next: "jsxAttributes",
  981. nextState: "jsx"
  982. };
  983. this.$rules.start.unshift(jsxTag);
  984. var jsxJsRule = {
  985. regex: "{",
  986. token: "paren.quasi.start",
  987. push: "start"
  988. };
  989. this.$rules.jsx = [
  990. jsxJsRule,
  991. jsxTag,
  992. { include: "reference" },
  993. { defaultToken: "string" }
  994. ];
  995. this.$rules.jsxAttributes = [{
  996. token: "meta.tag.punctuation.tag-close.xml",
  997. regex: "/?>",
  998. onMatch: function (value, currentState, stack) {
  999. if (currentState == stack[0])
  1000. stack.shift();
  1001. if (value.length == 2) {
  1002. if (stack[0] == this.nextState)
  1003. stack[1]--;
  1004. if (!stack[1] || stack[1] < 0) {
  1005. stack.splice(0, 2);
  1006. }
  1007. }
  1008. this.next = stack[0] || "start";
  1009. return [{ type: this.token, value: value }];
  1010. },
  1011. nextState: "jsx"
  1012. },
  1013. jsxJsRule,
  1014. comments("jsxAttributes"),
  1015. {
  1016. token: "entity.other.attribute-name.xml",
  1017. regex: tagRegex
  1018. }, {
  1019. token: "keyword.operator.attribute-equals.xml",
  1020. regex: "="
  1021. }, {
  1022. token: "text.tag-whitespace.xml",
  1023. regex: "\\s+"
  1024. }, {
  1025. token: "string.attribute-value.xml",
  1026. regex: "'",
  1027. stateName: "jsx_attr_q",
  1028. push: [
  1029. { token: "string.attribute-value.xml", regex: "'", next: "pop" },
  1030. { include: "reference" },
  1031. { defaultToken: "string.attribute-value.xml" }
  1032. ]
  1033. }, {
  1034. token: "string.attribute-value.xml",
  1035. regex: '"',
  1036. stateName: "jsx_attr_qq",
  1037. push: [
  1038. { token: "string.attribute-value.xml", regex: '"', next: "pop" },
  1039. { include: "reference" },
  1040. { defaultToken: "string.attribute-value.xml" }
  1041. ]
  1042. },
  1043. jsxTag
  1044. ];
  1045. this.$rules.reference = [{
  1046. token: "constant.language.escape.reference.xml",
  1047. regex: "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  1048. }];
  1049. }
  1050. function comments(next) {
  1051. return [
  1052. {
  1053. token: "comment",
  1054. regex: /\/\*/,
  1055. next: [
  1056. DocCommentHighlightRules.getTagRule(),
  1057. { token: "comment", regex: "\\*\\/", next: next || "pop" },
  1058. { defaultToken: "comment", caseInsensitive: true }
  1059. ]
  1060. }, {
  1061. token: "comment",
  1062. regex: "\\/\\/",
  1063. next: [
  1064. DocCommentHighlightRules.getTagRule(),
  1065. { token: "comment", regex: "$|^", next: next || "pop" },
  1066. { defaultToken: "comment", caseInsensitive: true }
  1067. ]
  1068. }
  1069. ];
  1070. }
  1071. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  1072. });
  1073. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  1074. var Range = require("../range").Range;
  1075. var MatchingBraceOutdent = function () { };
  1076. (function () {
  1077. this.checkOutdent = function (line, input) {
  1078. if (!/^\s+$/.test(line))
  1079. return false;
  1080. return /^\s*\}/.test(input);
  1081. };
  1082. this.autoOutdent = function (doc, row) {
  1083. var line = doc.getLine(row);
  1084. var match = line.match(/^(\s*\})/);
  1085. if (!match)
  1086. return 0;
  1087. var column = match[1].length;
  1088. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  1089. if (!openBracePos || openBracePos.row == row)
  1090. return 0;
  1091. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  1092. doc.replace(new Range(row, 0, row, column - 1), indent);
  1093. };
  1094. this.$getIndent = function (line) {
  1095. return line.match(/^\s*/)[0];
  1096. };
  1097. }).call(MatchingBraceOutdent.prototype);
  1098. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  1099. });
  1100. 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";
  1101. var oop = require("../../lib/oop");
  1102. var Range = require("../../range").Range;
  1103. var BaseFoldMode = require("./fold_mode").FoldMode;
  1104. var FoldMode = exports.FoldMode = function (commentRegex) {
  1105. if (commentRegex) {
  1106. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  1107. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  1108. }
  1109. };
  1110. oop.inherits(FoldMode, BaseFoldMode);
  1111. (function () {
  1112. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  1113. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  1114. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  1115. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  1116. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  1117. this._getFoldWidgetBase = this.getFoldWidget;
  1118. this.getFoldWidget = function (session, foldStyle, row) {
  1119. var line = session.getLine(row);
  1120. if (this.singleLineBlockCommentRe.test(line)) {
  1121. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  1122. return "";
  1123. }
  1124. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  1125. if (!fw && this.startRegionRe.test(line))
  1126. return "start"; // lineCommentRegionStart
  1127. return fw;
  1128. };
  1129. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  1130. var line = session.getLine(row);
  1131. if (this.startRegionRe.test(line))
  1132. return this.getCommentRegionBlock(session, line, row);
  1133. var match = line.match(this.foldingStartMarker);
  1134. if (match) {
  1135. var i = match.index;
  1136. if (match[1])
  1137. return this.openingBracketBlock(session, match[1], row, i);
  1138. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  1139. if (range && !range.isMultiLine()) {
  1140. if (forceMultiline) {
  1141. range = this.getSectionRange(session, row);
  1142. }
  1143. else if (foldStyle != "all")
  1144. range = null;
  1145. }
  1146. return range;
  1147. }
  1148. if (foldStyle === "markbegin")
  1149. return;
  1150. var match = line.match(this.foldingStopMarker);
  1151. if (match) {
  1152. var i = match.index + match[0].length;
  1153. if (match[1])
  1154. return this.closingBracketBlock(session, match[1], row, i);
  1155. return session.getCommentFoldRange(row, i, -1);
  1156. }
  1157. };
  1158. this.getSectionRange = function (session, row) {
  1159. var line = session.getLine(row);
  1160. var startIndent = line.search(/\S/);
  1161. var startRow = row;
  1162. var startColumn = line.length;
  1163. row = row + 1;
  1164. var endRow = row;
  1165. var maxRow = session.getLength();
  1166. while (++row < maxRow) {
  1167. line = session.getLine(row);
  1168. var indent = line.search(/\S/);
  1169. if (indent === -1)
  1170. continue;
  1171. if (startIndent > indent)
  1172. break;
  1173. var subRange = this.getFoldWidgetRange(session, "all", row);
  1174. if (subRange) {
  1175. if (subRange.start.row <= startRow) {
  1176. break;
  1177. }
  1178. else if (subRange.isMultiLine()) {
  1179. row = subRange.end.row;
  1180. }
  1181. else if (startIndent == indent) {
  1182. break;
  1183. }
  1184. }
  1185. endRow = row;
  1186. }
  1187. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  1188. };
  1189. this.getCommentRegionBlock = function (session, line, row) {
  1190. var startColumn = line.search(/\s*$/);
  1191. var maxRow = session.getLength();
  1192. var startRow = row;
  1193. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  1194. var depth = 1;
  1195. while (++row < maxRow) {
  1196. line = session.getLine(row);
  1197. var m = re.exec(line);
  1198. if (!m)
  1199. continue;
  1200. if (m[1])
  1201. depth--;
  1202. else
  1203. depth++;
  1204. if (!depth)
  1205. break;
  1206. }
  1207. var endRow = row;
  1208. if (endRow > startRow) {
  1209. return new Range(startRow, startColumn, endRow, line.length);
  1210. }
  1211. };
  1212. }).call(FoldMode.prototype);
  1213. });
  1214. ace.define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  1215. var oop = require("../lib/oop");
  1216. var TextMode = require("./text").Mode;
  1217. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1218. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1219. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1220. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  1221. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1222. var Mode = function () {
  1223. this.HighlightRules = JavaScriptHighlightRules;
  1224. this.$outdent = new MatchingBraceOutdent();
  1225. this.$behaviour = new CstyleBehaviour();
  1226. this.foldingRules = new CStyleFoldMode();
  1227. };
  1228. oop.inherits(Mode, TextMode);
  1229. (function () {
  1230. this.lineCommentStart = "//";
  1231. this.blockComment = { start: "/*", end: "*/" };
  1232. this.$quotes = { '"': '"', "'": "'", "`": "`" };
  1233. this.getNextLineIndent = function (state, line, tab) {
  1234. var indent = this.$getIndent(line);
  1235. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  1236. var tokens = tokenizedLine.tokens;
  1237. var endState = tokenizedLine.state;
  1238. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  1239. return indent;
  1240. }
  1241. if (state == "start" || state == "no_regex") {
  1242. var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
  1243. if (match) {
  1244. indent += tab;
  1245. }
  1246. }
  1247. else if (state == "doc-start") {
  1248. if (endState == "start" || endState == "no_regex") {
  1249. return "";
  1250. }
  1251. var match = line.match(/^\s*(\/?)\*/);
  1252. if (match) {
  1253. if (match[1]) {
  1254. indent += " ";
  1255. }
  1256. indent += "* ";
  1257. }
  1258. }
  1259. return indent;
  1260. };
  1261. this.checkOutdent = function (state, line, input) {
  1262. return this.$outdent.checkOutdent(line, input);
  1263. };
  1264. this.autoOutdent = function (state, doc, row) {
  1265. this.$outdent.autoOutdent(doc, row);
  1266. };
  1267. this.createWorker = function (session) {
  1268. var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
  1269. worker.attachToDocument(session.getDocument());
  1270. worker.on("annotate", function (results) {
  1271. session.setAnnotations(results.data);
  1272. });
  1273. worker.on("terminate", function () {
  1274. session.clearAnnotations();
  1275. });
  1276. return worker;
  1277. };
  1278. this.$id = "ace/mode/javascript";
  1279. this.snippetFileId = "ace/snippets/javascript";
  1280. }).call(Mode.prototype);
  1281. exports.Mode = Mode;
  1282. });
  1283. 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";
  1284. var oop = require("../lib/oop");
  1285. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1286. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1287. var SvgHighlightRules = function () {
  1288. XmlHighlightRules.call(this);
  1289. this.embedTagRules(JavaScriptHighlightRules, "js-", "script");
  1290. this.normalizeRules();
  1291. };
  1292. oop.inherits(SvgHighlightRules, XmlHighlightRules);
  1293. exports.SvgHighlightRules = SvgHighlightRules;
  1294. });
  1295. ace.define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
  1296. var oop = require("../../lib/oop");
  1297. var BaseFoldMode = require("./fold_mode").FoldMode;
  1298. var FoldMode = exports.FoldMode = function (defaultMode, subModes) {
  1299. this.defaultMode = defaultMode;
  1300. this.subModes = subModes;
  1301. };
  1302. oop.inherits(FoldMode, BaseFoldMode);
  1303. (function () {
  1304. this.$getMode = function (state) {
  1305. if (typeof state != "string")
  1306. state = state[0];
  1307. for (var key in this.subModes) {
  1308. if (state.indexOf(key) === 0)
  1309. return this.subModes[key];
  1310. }
  1311. return null;
  1312. };
  1313. this.$tryMode = function (state, session, foldStyle, row) {
  1314. var mode = this.$getMode(state);
  1315. return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
  1316. };
  1317. this.getFoldWidget = function (session, foldStyle, row) {
  1318. return (this.$tryMode(session.getState(row - 1), session, foldStyle, row) ||
  1319. this.$tryMode(session.getState(row), session, foldStyle, row) ||
  1320. this.defaultMode.getFoldWidget(session, foldStyle, row));
  1321. };
  1322. this.getFoldWidgetRange = function (session, foldStyle, row) {
  1323. var mode = this.$getMode(session.getState(row - 1));
  1324. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1325. mode = this.$getMode(session.getState(row));
  1326. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1327. mode = this.defaultMode;
  1328. return mode.getFoldWidgetRange(session, foldStyle, row);
  1329. };
  1330. }).call(FoldMode.prototype);
  1331. });
  1332. 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";
  1333. var oop = require("../lib/oop");
  1334. var XmlMode = require("./xml").Mode;
  1335. var JavaScriptMode = require("./javascript").Mode;
  1336. var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules;
  1337. var MixedFoldMode = require("./folding/mixed").FoldMode;
  1338. var XmlFoldMode = require("./folding/xml").FoldMode;
  1339. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1340. var Mode = function () {
  1341. XmlMode.call(this);
  1342. this.HighlightRules = SvgHighlightRules;
  1343. this.createModeDelegates({
  1344. "js-": JavaScriptMode
  1345. });
  1346. this.foldingRules = new MixedFoldMode(new XmlFoldMode(), {
  1347. "js-": new CStyleFoldMode()
  1348. });
  1349. };
  1350. oop.inherits(Mode, XmlMode);
  1351. (function () {
  1352. this.getNextLineIndent = function (state, line, tab) {
  1353. return this.$getIndent(line);
  1354. };
  1355. this.$id = "ace/mode/svg";
  1356. }).call(Mode.prototype);
  1357. exports.Mode = Mode;
  1358. }); (function() {
  1359. ace.require(["ace/mode/svg"], function(m) {
  1360. if (typeof module == "object" && typeof exports == "object" && module) {
  1361. module.exports = m;
  1362. }
  1363. });
  1364. })();