mode-svg.js 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580
  1. ace.define("ace/mode/xml_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.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. ace.define("ace/mode/behaviour/xml",[], function(require, exports, module) {
  181. "use strict";
  182. var oop = require("../../lib/oop");
  183. var Behaviour = require("../behaviour").Behaviour;
  184. var TokenIterator = require("../../token_iterator").TokenIterator;
  185. var lang = 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. ace.define("ace/mode/folding/xml",[], function(require, exports, module) {
  327. "use strict";
  328. var oop = require("../../lib/oop");
  329. var lang = require("../../lib/lang");
  330. var Range = require("../../range").Range;
  331. var BaseFoldMode = require("./fold_mode").FoldMode;
  332. var TokenIterator = 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. ace.define("ace/mode/xml",[], function(require, exports, module) {
  542. "use strict";
  543. var oop = require("../lib/oop");
  544. var lang = require("../lib/lang");
  545. var TextMode = require("./text").Mode;
  546. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  547. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  548. var XmlFoldMode = require("./folding/xml").FoldMode;
  549. var WorkerClient = 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. ace.define("ace/mode/doc_comment_highlight_rules",[], function(require, exports, module) {
  575. "use strict";
  576. var oop = require("../lib/oop");
  577. var TextHighlightRules = 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. ace.define("ace/mode/javascript_highlight_rules",[], function(require, exports, module) {
  615. "use strict";
  616. var oop = require("../lib/oop");
  617. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  618. var TextHighlightRules = 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. }, {
  745. token : "keyword.operator",
  746. regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
  747. next : "start"
  748. }, {
  749. token : "punctuation.operator",
  750. regex : /[?:,;.]/,
  751. next : "start"
  752. }, {
  753. token : "paren.lparen",
  754. regex : /[\[({]/,
  755. next : "start"
  756. }, {
  757. token : "paren.rparen",
  758. regex : /[\])}]/
  759. }, {
  760. token: "comment",
  761. regex: /^#!.*$/
  762. }
  763. ],
  764. property: [{
  765. token : "text",
  766. regex : "\\s+"
  767. }, {
  768. token : [
  769. "storage.type", "punctuation.operator", "entity.name.function", "text",
  770. "keyword.operator", "text",
  771. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  772. ],
  773. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",
  774. next: "function_arguments"
  775. }, {
  776. token : "punctuation.operator",
  777. regex : /[.](?![.])/
  778. }, {
  779. token : "support.function",
  780. 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(?=\()/
  781. }, {
  782. token : "support.function.dom",
  783. 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(?=\()/
  784. }, {
  785. token : "support.constant",
  786. 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/
  787. }, {
  788. token : "identifier",
  789. regex : identifierRe
  790. }, {
  791. regex: "",
  792. token: "empty",
  793. next: "no_regex"
  794. }
  795. ],
  796. "start": [
  797. DocCommentHighlightRules.getStartRule("doc-start"),
  798. comments("start"),
  799. {
  800. token: "string.regexp",
  801. regex: "\\/",
  802. next: "regex"
  803. }, {
  804. token : "text",
  805. regex : "\\s+|^$",
  806. next : "start"
  807. }, {
  808. token: "empty",
  809. regex: "",
  810. next: "no_regex"
  811. }
  812. ],
  813. "regex": [
  814. {
  815. token: "regexp.keyword.operator",
  816. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  817. }, {
  818. token: "string.regexp",
  819. regex: "/[sxngimy]*",
  820. next: "no_regex"
  821. }, {
  822. token : "invalid",
  823. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  824. }, {
  825. token : "constant.language.escape",
  826. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  827. }, {
  828. token : "constant.language.delimiter",
  829. regex: /\|/
  830. }, {
  831. token: "constant.language.escape",
  832. regex: /\[\^?/,
  833. next: "regex_character_class"
  834. }, {
  835. token: "empty",
  836. regex: "$",
  837. next: "no_regex"
  838. }, {
  839. defaultToken: "string.regexp"
  840. }
  841. ],
  842. "regex_character_class": [
  843. {
  844. token: "regexp.charclass.keyword.operator",
  845. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  846. }, {
  847. token: "constant.language.escape",
  848. regex: "]",
  849. next: "regex"
  850. }, {
  851. token: "constant.language.escape",
  852. regex: "-"
  853. }, {
  854. token: "empty",
  855. regex: "$",
  856. next: "no_regex"
  857. }, {
  858. defaultToken: "string.regexp.charachterclass"
  859. }
  860. ],
  861. "function_arguments": [
  862. {
  863. token: "variable.parameter",
  864. regex: identifierRe
  865. }, {
  866. token: "punctuation.operator",
  867. regex: "[, ]+"
  868. }, {
  869. token: "punctuation.operator",
  870. regex: "$"
  871. }, {
  872. token: "empty",
  873. regex: "",
  874. next: "no_regex"
  875. }
  876. ],
  877. "qqstring" : [
  878. {
  879. token : "constant.language.escape",
  880. regex : escapedRe
  881. }, {
  882. token : "string",
  883. regex : "\\\\$",
  884. consumeLineEnd : true
  885. }, {
  886. token : "string",
  887. regex : '"|$',
  888. next : "no_regex"
  889. }, {
  890. defaultToken: "string"
  891. }
  892. ],
  893. "qstring" : [
  894. {
  895. token : "constant.language.escape",
  896. regex : escapedRe
  897. }, {
  898. token : "string",
  899. regex : "\\\\$",
  900. consumeLineEnd : true
  901. }, {
  902. token : "string",
  903. regex : "'|$",
  904. next : "no_regex"
  905. }, {
  906. defaultToken: "string"
  907. }
  908. ]
  909. };
  910. if (!options || !options.noES6) {
  911. this.$rules.no_regex.unshift({
  912. regex: "[{}]", onMatch: function(val, state, stack) {
  913. this.next = val == "{" ? this.nextState : "";
  914. if (val == "{" && stack.length) {
  915. stack.unshift("start", state);
  916. }
  917. else if (val == "}" && stack.length) {
  918. stack.shift();
  919. this.next = stack.shift();
  920. if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
  921. return "paren.quasi.end";
  922. }
  923. return val == "{" ? "paren.lparen" : "paren.rparen";
  924. },
  925. nextState: "start"
  926. }, {
  927. token : "string.quasi.start",
  928. regex : /`/,
  929. push : [{
  930. token : "constant.language.escape",
  931. regex : escapedRe
  932. }, {
  933. token : "paren.quasi.start",
  934. regex : /\${/,
  935. push : "start"
  936. }, {
  937. token : "string.quasi.end",
  938. regex : /`/,
  939. next : "pop"
  940. }, {
  941. defaultToken: "string.quasi"
  942. }]
  943. });
  944. if (!options || options.jsx != false)
  945. JSX.call(this);
  946. }
  947. this.embedRules(DocCommentHighlightRules, "doc-",
  948. [ DocCommentHighlightRules.getEndRule("no_regex") ]);
  949. this.normalizeRules();
  950. };
  951. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  952. function JSX() {
  953. var tagRegex = identifierRe.replace("\\d", "\\d\\-");
  954. var jsxTag = {
  955. onMatch : function(val, state, stack) {
  956. var offset = val.charAt(1) == "/" ? 2 : 1;
  957. if (offset == 1) {
  958. if (state != this.nextState)
  959. stack.unshift(this.next, this.nextState, 0);
  960. else
  961. stack.unshift(this.next);
  962. stack[2]++;
  963. } else if (offset == 2) {
  964. if (state == this.nextState) {
  965. stack[1]--;
  966. if (!stack[1] || stack[1] < 0) {
  967. stack.shift();
  968. stack.shift();
  969. }
  970. }
  971. }
  972. return [{
  973. type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
  974. value: val.slice(0, offset)
  975. }, {
  976. type: "meta.tag.tag-name.xml",
  977. value: val.substr(offset)
  978. }];
  979. },
  980. regex : "</?" + tagRegex + "",
  981. next: "jsxAttributes",
  982. nextState: "jsx"
  983. };
  984. this.$rules.start.unshift(jsxTag);
  985. var jsxJsRule = {
  986. regex: "{",
  987. token: "paren.quasi.start",
  988. push: "start"
  989. };
  990. this.$rules.jsx = [
  991. jsxJsRule,
  992. jsxTag,
  993. {include : "reference"},
  994. {defaultToken: "string"}
  995. ];
  996. this.$rules.jsxAttributes = [{
  997. token : "meta.tag.punctuation.tag-close.xml",
  998. regex : "/?>",
  999. onMatch : function(value, currentState, stack) {
  1000. if (currentState == stack[0])
  1001. stack.shift();
  1002. if (value.length == 2) {
  1003. if (stack[0] == this.nextState)
  1004. stack[1]--;
  1005. if (!stack[1] || stack[1] < 0) {
  1006. stack.splice(0, 2);
  1007. }
  1008. }
  1009. this.next = stack[0] || "start";
  1010. return [{type: this.token, value: value}];
  1011. },
  1012. nextState: "jsx"
  1013. },
  1014. jsxJsRule,
  1015. comments("jsxAttributes"),
  1016. {
  1017. token : "entity.other.attribute-name.xml",
  1018. regex : tagRegex
  1019. }, {
  1020. token : "keyword.operator.attribute-equals.xml",
  1021. regex : "="
  1022. }, {
  1023. token : "text.tag-whitespace.xml",
  1024. regex : "\\s+"
  1025. }, {
  1026. token : "string.attribute-value.xml",
  1027. regex : "'",
  1028. stateName : "jsx_attr_q",
  1029. push : [
  1030. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  1031. {include : "reference"},
  1032. {defaultToken : "string.attribute-value.xml"}
  1033. ]
  1034. }, {
  1035. token : "string.attribute-value.xml",
  1036. regex : '"',
  1037. stateName : "jsx_attr_qq",
  1038. push : [
  1039. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  1040. {include : "reference"},
  1041. {defaultToken : "string.attribute-value.xml"}
  1042. ]
  1043. },
  1044. jsxTag
  1045. ];
  1046. this.$rules.reference = [{
  1047. token : "constant.language.escape.reference.xml",
  1048. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  1049. }];
  1050. }
  1051. function comments(next) {
  1052. return [
  1053. {
  1054. token : "comment", // multi line comment
  1055. regex : /\/\*/,
  1056. next: [
  1057. DocCommentHighlightRules.getTagRule(),
  1058. {token : "comment", regex : "\\*\\/", next : next || "pop"},
  1059. {defaultToken : "comment", caseInsensitive: true}
  1060. ]
  1061. }, {
  1062. token : "comment",
  1063. regex : "\\/\\/",
  1064. next: [
  1065. DocCommentHighlightRules.getTagRule(),
  1066. {token : "comment", regex : "$|^", next : next || "pop"},
  1067. {defaultToken : "comment", caseInsensitive: true}
  1068. ]
  1069. }
  1070. ];
  1071. }
  1072. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  1073. });
  1074. ace.define("ace/mode/matching_brace_outdent",[], function(require, exports, module) {
  1075. "use strict";
  1076. var Range = require("../range").Range;
  1077. var MatchingBraceOutdent = function() {};
  1078. (function() {
  1079. this.checkOutdent = function(line, input) {
  1080. if (! /^\s+$/.test(line))
  1081. return false;
  1082. return /^\s*\}/.test(input);
  1083. };
  1084. this.autoOutdent = function(doc, row) {
  1085. var line = doc.getLine(row);
  1086. var match = line.match(/^(\s*\})/);
  1087. if (!match) return 0;
  1088. var column = match[1].length;
  1089. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  1090. if (!openBracePos || openBracePos.row == row) return 0;
  1091. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  1092. doc.replace(new Range(row, 0, row, column-1), indent);
  1093. };
  1094. this.$getIndent = function(line) {
  1095. return line.match(/^\s*/)[0];
  1096. };
  1097. }).call(MatchingBraceOutdent.prototype);
  1098. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  1099. });
  1100. ace.define("ace/mode/folding/cstyle",[], function(require, exports, module) {
  1101. "use strict";
  1102. var oop = require("../../lib/oop");
  1103. var Range = require("../../range").Range;
  1104. var BaseFoldMode = require("./fold_mode").FoldMode;
  1105. var FoldMode = exports.FoldMode = function(commentRegex) {
  1106. if (commentRegex) {
  1107. this.foldingStartMarker = new RegExp(
  1108. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  1109. );
  1110. this.foldingStopMarker = new RegExp(
  1111. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  1112. );
  1113. }
  1114. };
  1115. oop.inherits(FoldMode, BaseFoldMode);
  1116. (function() {
  1117. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  1118. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  1119. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  1120. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  1121. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  1122. this._getFoldWidgetBase = this.getFoldWidget;
  1123. this.getFoldWidget = function(session, foldStyle, row) {
  1124. var line = session.getLine(row);
  1125. if (this.singleLineBlockCommentRe.test(line)) {
  1126. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  1127. return "";
  1128. }
  1129. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  1130. if (!fw && this.startRegionRe.test(line))
  1131. return "start"; // lineCommentRegionStart
  1132. return fw;
  1133. };
  1134. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  1135. var line = session.getLine(row);
  1136. if (this.startRegionRe.test(line))
  1137. return this.getCommentRegionBlock(session, line, row);
  1138. var match = line.match(this.foldingStartMarker);
  1139. if (match) {
  1140. var i = match.index;
  1141. if (match[1])
  1142. return this.openingBracketBlock(session, match[1], row, i);
  1143. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  1144. if (range && !range.isMultiLine()) {
  1145. if (forceMultiline) {
  1146. range = this.getSectionRange(session, row);
  1147. } else if (foldStyle != "all")
  1148. range = null;
  1149. }
  1150. return range;
  1151. }
  1152. if (foldStyle === "markbegin")
  1153. return;
  1154. var match = line.match(this.foldingStopMarker);
  1155. if (match) {
  1156. var i = match.index + match[0].length;
  1157. if (match[1])
  1158. return this.closingBracketBlock(session, match[1], row, i);
  1159. return session.getCommentFoldRange(row, i, -1);
  1160. }
  1161. };
  1162. this.getSectionRange = function(session, row) {
  1163. var line = session.getLine(row);
  1164. var startIndent = line.search(/\S/);
  1165. var startRow = row;
  1166. var startColumn = line.length;
  1167. row = row + 1;
  1168. var endRow = row;
  1169. var maxRow = session.getLength();
  1170. while (++row < maxRow) {
  1171. line = session.getLine(row);
  1172. var indent = line.search(/\S/);
  1173. if (indent === -1)
  1174. continue;
  1175. if (startIndent > indent)
  1176. break;
  1177. var subRange = this.getFoldWidgetRange(session, "all", row);
  1178. if (subRange) {
  1179. if (subRange.start.row <= startRow) {
  1180. break;
  1181. } else if (subRange.isMultiLine()) {
  1182. row = subRange.end.row;
  1183. } else if (startIndent == indent) {
  1184. break;
  1185. }
  1186. }
  1187. endRow = row;
  1188. }
  1189. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  1190. };
  1191. this.getCommentRegionBlock = function(session, line, row) {
  1192. var startColumn = line.search(/\s*$/);
  1193. var maxRow = session.getLength();
  1194. var startRow = row;
  1195. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  1196. var depth = 1;
  1197. while (++row < maxRow) {
  1198. line = session.getLine(row);
  1199. var m = re.exec(line);
  1200. if (!m) continue;
  1201. if (m[1]) depth--;
  1202. else depth++;
  1203. if (!depth) break;
  1204. }
  1205. var endRow = row;
  1206. if (endRow > startRow) {
  1207. return new Range(startRow, startColumn, endRow, line.length);
  1208. }
  1209. };
  1210. }).call(FoldMode.prototype);
  1211. });
  1212. ace.define("ace/mode/javascript",[], function(require, exports, module) {
  1213. "use strict";
  1214. var oop = require("../lib/oop");
  1215. var TextMode = require("./text").Mode;
  1216. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1217. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1218. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1219. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  1220. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1221. var Mode = function() {
  1222. this.HighlightRules = JavaScriptHighlightRules;
  1223. this.$outdent = new MatchingBraceOutdent();
  1224. this.$behaviour = new CstyleBehaviour();
  1225. this.foldingRules = new CStyleFoldMode();
  1226. };
  1227. oop.inherits(Mode, TextMode);
  1228. (function() {
  1229. this.lineCommentStart = "//";
  1230. this.blockComment = {start: "/*", end: "*/"};
  1231. this.$quotes = {'"': '"', "'": "'", "`": "`"};
  1232. this.getNextLineIndent = function(state, line, tab) {
  1233. var indent = this.$getIndent(line);
  1234. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  1235. var tokens = tokenizedLine.tokens;
  1236. var endState = tokenizedLine.state;
  1237. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  1238. return indent;
  1239. }
  1240. if (state == "start" || state == "no_regex") {
  1241. var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
  1242. if (match) {
  1243. indent += tab;
  1244. }
  1245. } else if (state == "doc-start") {
  1246. if (endState == "start" || endState == "no_regex") {
  1247. return "";
  1248. }
  1249. var match = line.match(/^\s*(\/?)\*/);
  1250. if (match) {
  1251. if (match[1]) {
  1252. indent += " ";
  1253. }
  1254. indent += "* ";
  1255. }
  1256. }
  1257. return indent;
  1258. };
  1259. this.checkOutdent = function(state, line, input) {
  1260. return this.$outdent.checkOutdent(line, input);
  1261. };
  1262. this.autoOutdent = function(state, doc, row) {
  1263. this.$outdent.autoOutdent(doc, row);
  1264. };
  1265. this.createWorker = function(session) {
  1266. var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
  1267. worker.attachToDocument(session.getDocument());
  1268. worker.on("annotate", function(results) {
  1269. session.setAnnotations(results.data);
  1270. });
  1271. worker.on("terminate", function() {
  1272. session.clearAnnotations();
  1273. });
  1274. return worker;
  1275. };
  1276. this.$id = "ace/mode/javascript";
  1277. }).call(Mode.prototype);
  1278. exports.Mode = Mode;
  1279. });
  1280. ace.define("ace/mode/svg_highlight_rules",[], function(require, exports, module) {
  1281. "use strict";
  1282. var oop = require("../lib/oop");
  1283. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1284. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1285. var SvgHighlightRules = function() {
  1286. XmlHighlightRules.call(this);
  1287. this.embedTagRules(JavaScriptHighlightRules, "js-", "script");
  1288. this.normalizeRules();
  1289. };
  1290. oop.inherits(SvgHighlightRules, XmlHighlightRules);
  1291. exports.SvgHighlightRules = SvgHighlightRules;
  1292. });
  1293. ace.define("ace/mode/folding/mixed",[], function(require, exports, module) {
  1294. "use strict";
  1295. var oop = require("../../lib/oop");
  1296. var BaseFoldMode = require("./fold_mode").FoldMode;
  1297. var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
  1298. this.defaultMode = defaultMode;
  1299. this.subModes = subModes;
  1300. };
  1301. oop.inherits(FoldMode, BaseFoldMode);
  1302. (function() {
  1303. this.$getMode = function(state) {
  1304. if (typeof state != "string")
  1305. state = state[0];
  1306. for (var key in this.subModes) {
  1307. if (state.indexOf(key) === 0)
  1308. return this.subModes[key];
  1309. }
  1310. return null;
  1311. };
  1312. this.$tryMode = function(state, session, foldStyle, row) {
  1313. var mode = this.$getMode(state);
  1314. return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
  1315. };
  1316. this.getFoldWidget = function(session, foldStyle, row) {
  1317. return (
  1318. this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
  1319. this.$tryMode(session.getState(row), session, foldStyle, row) ||
  1320. this.defaultMode.getFoldWidget(session, foldStyle, row)
  1321. );
  1322. };
  1323. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1324. var mode = this.$getMode(session.getState(row-1));
  1325. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1326. mode = this.$getMode(session.getState(row));
  1327. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1328. mode = this.defaultMode;
  1329. return mode.getFoldWidgetRange(session, foldStyle, row);
  1330. };
  1331. }).call(FoldMode.prototype);
  1332. });
  1333. ace.define("ace/mode/svg",[], function(require, exports, module) {
  1334. "use strict";
  1335. var oop = require("../lib/oop");
  1336. var XmlMode = require("./xml").Mode;
  1337. var JavaScriptMode = require("./javascript").Mode;
  1338. var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules;
  1339. var MixedFoldMode = require("./folding/mixed").FoldMode;
  1340. var XmlFoldMode = require("./folding/xml").FoldMode;
  1341. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1342. var Mode = function() {
  1343. XmlMode.call(this);
  1344. this.HighlightRules = SvgHighlightRules;
  1345. this.createModeDelegates({
  1346. "js-": JavaScriptMode
  1347. });
  1348. this.foldingRules = new MixedFoldMode(new XmlFoldMode(), {
  1349. "js-": new CStyleFoldMode()
  1350. });
  1351. };
  1352. oop.inherits(Mode, XmlMode);
  1353. (function() {
  1354. this.getNextLineIndent = function(state, line, tab) {
  1355. return this.$getIndent(line);
  1356. };
  1357. this.$id = "ace/mode/svg";
  1358. }).call(Mode.prototype);
  1359. exports.Mode = Mode;
  1360. });
  1361. (function() {
  1362. ace.require(["ace/mode/svg"], function(m) {
  1363. if (typeof module == "object" && typeof exports == "object" && module) {
  1364. module.exports = m;
  1365. }
  1366. });
  1367. })();