mode-svg.js 58 KB

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