mode-svg.js 57 KB

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