mode-svg.js 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801
  1. 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. 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.getCursorPosition();
  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. }
  267. var tokenRow = iterator.getCurrentTokenRow();
  268. var tokenColumn = iterator.getCurrentTokenColumn();
  269. if (is(iterator.stepBackward(), "end-tag-open"))
  270. return;
  271. var element = token.value;
  272. if (tokenRow == position.row)
  273. element = element.substring(0, position.column - tokenColumn);
  274. if (this.voidElements.hasOwnProperty(element.toLowerCase()))
  275. return;
  276. return {
  277. text: ">" + "</" + element + ">",
  278. selection: [1, 1]
  279. };
  280. }
  281. });
  282. this.add("autoindent", "insertion", function (state, action, editor, session, text) {
  283. if (text == "\n") {
  284. var cursor = editor.getCursorPosition();
  285. var line = session.getLine(cursor.row);
  286. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  287. var token = iterator.getCurrentToken();
  288. if (token && token.type.indexOf("tag-close") !== -1) {
  289. if (token.value == "/>")
  290. return;
  291. while (token && token.type.indexOf("tag-name") === -1) {
  292. token = iterator.stepBackward();
  293. }
  294. if (!token) {
  295. return;
  296. }
  297. var tag = token.value;
  298. var row = iterator.getCurrentTokenRow();
  299. token = iterator.stepBackward();
  300. if (!token || token.type.indexOf("end-tag") !== -1) {
  301. return;
  302. }
  303. if (this.voidElements && !this.voidElements[tag]) {
  304. var nextToken = session.getTokenAt(cursor.row, cursor.column+1);
  305. var line = session.getLine(row);
  306. var nextIndent = this.$getIndent(line);
  307. var indent = nextIndent + session.getTabString();
  308. if (nextToken && nextToken.value === "</") {
  309. return {
  310. text: "\n" + indent + "\n" + nextIndent,
  311. selection: [1, indent.length, 1, indent.length]
  312. };
  313. } else {
  314. return {
  315. text: "\n" + indent
  316. };
  317. }
  318. }
  319. }
  320. }
  321. });
  322. };
  323. oop.inherits(XmlBehaviour, Behaviour);
  324. exports.XmlBehaviour = XmlBehaviour;
  325. });
  326. define("ace/mode/folding/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/range","ace/mode/folding/fold_mode","ace/token_iterator"], 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 "";
  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._getFirstTagInLine = function(session, row) {
  365. var tokens = session.getTokens(row);
  366. var tag = new Tag();
  367. for (var i = 0; i < tokens.length; i++) {
  368. var token = tokens[i];
  369. if (is(token, "tag-open")) {
  370. tag.end.column = tag.start.column + token.value.length;
  371. tag.closing = is(token, "end-tag-open");
  372. token = tokens[++i];
  373. if (!token)
  374. return null;
  375. tag.tagName = token.value;
  376. tag.end.column += token.value.length;
  377. for (i++; i < tokens.length; i++) {
  378. token = tokens[i];
  379. tag.end.column += token.value.length;
  380. if (is(token, "tag-close")) {
  381. tag.selfClosing = token.value == '/>';
  382. break;
  383. }
  384. }
  385. return tag;
  386. } else if (is(token, "tag-close")) {
  387. tag.selfClosing = token.value == '/>';
  388. return tag;
  389. }
  390. tag.start.column += token.value.length;
  391. }
  392. return null;
  393. };
  394. this._findEndTagInLine = function(session, row, tagName, startColumn) {
  395. var tokens = session.getTokens(row);
  396. var column = 0;
  397. for (var i = 0; i < tokens.length; i++) {
  398. var token = tokens[i];
  399. column += token.value.length;
  400. if (column < startColumn)
  401. continue;
  402. if (is(token, "end-tag-open")) {
  403. token = tokens[i + 1];
  404. if (token && token.value == tagName)
  405. return true;
  406. }
  407. }
  408. return false;
  409. };
  410. this._readTagForward = function(iterator) {
  411. var token = iterator.getCurrentToken();
  412. if (!token)
  413. return null;
  414. var tag = new Tag();
  415. do {
  416. if (is(token, "tag-open")) {
  417. tag.closing = is(token, "end-tag-open");
  418. tag.start.row = iterator.getCurrentTokenRow();
  419. tag.start.column = iterator.getCurrentTokenColumn();
  420. } else if (is(token, "tag-name")) {
  421. tag.tagName = token.value;
  422. } else if (is(token, "tag-close")) {
  423. tag.selfClosing = token.value == "/>";
  424. tag.end.row = iterator.getCurrentTokenRow();
  425. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  426. iterator.stepForward();
  427. return tag;
  428. }
  429. } while(token = iterator.stepForward());
  430. return null;
  431. };
  432. this._readTagBackward = function(iterator) {
  433. var token = iterator.getCurrentToken();
  434. if (!token)
  435. return null;
  436. var tag = new Tag();
  437. do {
  438. if (is(token, "tag-open")) {
  439. tag.closing = is(token, "end-tag-open");
  440. tag.start.row = iterator.getCurrentTokenRow();
  441. tag.start.column = iterator.getCurrentTokenColumn();
  442. iterator.stepBackward();
  443. return tag;
  444. } else if (is(token, "tag-name")) {
  445. tag.tagName = token.value;
  446. } else if (is(token, "tag-close")) {
  447. tag.selfClosing = token.value == "/>";
  448. tag.end.row = iterator.getCurrentTokenRow();
  449. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  450. }
  451. } while(token = iterator.stepBackward());
  452. return null;
  453. };
  454. this._pop = function(stack, tag) {
  455. while (stack.length) {
  456. var top = stack[stack.length-1];
  457. if (!tag || top.tagName == tag.tagName) {
  458. return stack.pop();
  459. }
  460. else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
  461. stack.pop();
  462. continue;
  463. } else {
  464. return null;
  465. }
  466. }
  467. };
  468. this.getFoldWidgetRange = function(session, foldStyle, row) {
  469. var firstTag = this._getFirstTagInLine(session, row);
  470. if (!firstTag)
  471. return null;
  472. var isBackward = firstTag.closing || firstTag.selfClosing;
  473. var stack = [];
  474. var tag;
  475. if (!isBackward) {
  476. var iterator = new TokenIterator(session, row, firstTag.start.column);
  477. var start = {
  478. row: row,
  479. column: firstTag.start.column + firstTag.tagName.length + 2
  480. };
  481. if (firstTag.start.row == firstTag.end.row)
  482. start.column = firstTag.end.column;
  483. while (tag = this._readTagForward(iterator)) {
  484. if (tag.selfClosing) {
  485. if (!stack.length) {
  486. tag.start.column += tag.tagName.length + 2;
  487. tag.end.column -= 2;
  488. return Range.fromPoints(tag.start, tag.end);
  489. } else
  490. continue;
  491. }
  492. if (tag.closing) {
  493. this._pop(stack, tag);
  494. if (stack.length == 0)
  495. return Range.fromPoints(start, tag.start);
  496. }
  497. else {
  498. stack.push(tag);
  499. }
  500. }
  501. }
  502. else {
  503. var iterator = new TokenIterator(session, row, firstTag.end.column);
  504. var end = {
  505. row: row,
  506. column: firstTag.start.column
  507. };
  508. while (tag = this._readTagBackward(iterator)) {
  509. if (tag.selfClosing) {
  510. if (!stack.length) {
  511. tag.start.column += tag.tagName.length + 2;
  512. tag.end.column -= 2;
  513. return Range.fromPoints(tag.start, tag.end);
  514. } else
  515. continue;
  516. }
  517. if (!tag.closing) {
  518. this._pop(stack, tag);
  519. if (stack.length == 0) {
  520. tag.start.column += tag.tagName.length + 2;
  521. if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
  522. tag.start.column = tag.end.column;
  523. return Range.fromPoints(tag.start, end);
  524. }
  525. }
  526. else {
  527. stack.push(tag);
  528. }
  529. }
  530. }
  531. };
  532. }).call(FoldMode.prototype);
  533. });
  534. 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) {
  535. "use strict";
  536. var oop = require("../lib/oop");
  537. var lang = require("../lib/lang");
  538. var TextMode = require("./text").Mode;
  539. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  540. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  541. var XmlFoldMode = require("./folding/xml").FoldMode;
  542. var WorkerClient = require("../worker/worker_client").WorkerClient;
  543. var Mode = function() {
  544. this.HighlightRules = XmlHighlightRules;
  545. this.$behaviour = new XmlBehaviour();
  546. this.foldingRules = new XmlFoldMode();
  547. };
  548. oop.inherits(Mode, TextMode);
  549. (function() {
  550. this.voidElements = lang.arrayToMap([]);
  551. this.blockComment = {start: "<!--", end: "-->"};
  552. this.createWorker = function(session) {
  553. var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
  554. worker.attachToDocument(session.getDocument());
  555. worker.on("error", function(e) {
  556. session.setAnnotations(e.data);
  557. });
  558. worker.on("terminate", function() {
  559. session.clearAnnotations();
  560. });
  561. return worker;
  562. };
  563. this.$id = "ace/mode/xml";
  564. }).call(Mode.prototype);
  565. exports.Mode = Mode;
  566. });
  567. define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  568. "use strict";
  569. var oop = require("../lib/oop");
  570. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  571. var DocCommentHighlightRules = function() {
  572. this.$rules = {
  573. "start" : [ {
  574. token : "comment.doc.tag",
  575. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  576. },
  577. DocCommentHighlightRules.getTagRule(),
  578. {
  579. defaultToken : "comment.doc",
  580. caseInsensitive: true
  581. }]
  582. };
  583. };
  584. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  585. DocCommentHighlightRules.getTagRule = function(start) {
  586. return {
  587. token : "comment.doc.tag.storage.type",
  588. regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  589. };
  590. }
  591. DocCommentHighlightRules.getStartRule = function(start) {
  592. return {
  593. token : "comment.doc", // doc comment
  594. regex : "\\/\\*(?=\\*)",
  595. next : start
  596. };
  597. };
  598. DocCommentHighlightRules.getEndRule = function (start) {
  599. return {
  600. token : "comment.doc", // closing comment
  601. regex : "\\*\\/",
  602. next : start
  603. };
  604. };
  605. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  606. });
  607. 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) {
  608. "use strict";
  609. var oop = require("../lib/oop");
  610. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  611. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  612. var JavaScriptHighlightRules = function(options) {
  613. var keywordMapper = this.createKeywordMapper({
  614. "variable.language":
  615. "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
  616. "Namespace|QName|XML|XMLList|" + // E4X
  617. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  618. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  619. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
  620. "SyntaxError|TypeError|URIError|" +
  621. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
  622. "isNaN|parseFloat|parseInt|" +
  623. "JSON|Math|" + // Other
  624. "this|arguments|prototype|window|document" , // Pseudo
  625. "keyword":
  626. "const|yield|import|get|set|" +
  627. "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
  628. "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
  629. "__parent__|__count__|escape|unescape|with|__proto__|" +
  630. "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
  631. "storage.type":
  632. "const|let|var|function",
  633. "constant.language":
  634. "null|Infinity|NaN|undefined",
  635. "support.function":
  636. "alert",
  637. "constant.language.boolean": "true|false"
  638. }, "identifier");
  639. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
  640. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
  641. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  642. "u[0-9a-fA-F]{4}|" + // unicode
  643. "[0-2][0-7]{0,2}|" + // oct
  644. "3[0-6][0-7]?|" + // oct
  645. "37[0-7]?|" + // oct
  646. "[4-7][0-7]?|" + //oct
  647. ".)";
  648. this.$rules = {
  649. "no_regex" : [
  650. {
  651. token : "comment",
  652. regex : "\\/\\/",
  653. next : "line_comment"
  654. },
  655. DocCommentHighlightRules.getStartRule("doc-start"),
  656. {
  657. token : "comment", // multi line comment
  658. regex : /\/\*/,
  659. next : "comment"
  660. }, {
  661. token : "string",
  662. regex : "'(?=.)",
  663. next : "qstring"
  664. }, {
  665. token : "string",
  666. regex : '"(?=.)',
  667. next : "qqstring"
  668. }, {
  669. token : "constant.numeric", // hex
  670. regex : /0[xX][0-9a-fA-F]+\b/
  671. }, {
  672. token : "constant.numeric", // float
  673. regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
  674. }, {
  675. token : [
  676. "storage.type", "punctuation.operator", "support.function",
  677. "punctuation.operator", "entity.name.function", "text","keyword.operator"
  678. ],
  679. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
  680. next: "function_arguments"
  681. }, {
  682. token : [
  683. "storage.type", "punctuation.operator", "entity.name.function", "text",
  684. "keyword.operator", "text", "storage.type", "text", "paren.lparen"
  685. ],
  686. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  687. next: "function_arguments"
  688. }, {
  689. token : [
  690. "entity.name.function", "text", "keyword.operator", "text", "storage.type",
  691. "text", "paren.lparen"
  692. ],
  693. regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  694. next: "function_arguments"
  695. }, {
  696. token : [
  697. "storage.type", "punctuation.operator", "entity.name.function", "text",
  698. "keyword.operator", "text",
  699. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  700. ],
  701. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
  702. next: "function_arguments"
  703. }, {
  704. token : [
  705. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  706. ],
  707. regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
  708. next: "function_arguments"
  709. }, {
  710. token : [
  711. "entity.name.function", "text", "punctuation.operator",
  712. "text", "storage.type", "text", "paren.lparen"
  713. ],
  714. regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
  715. next: "function_arguments"
  716. }, {
  717. token : [
  718. "text", "text", "storage.type", "text", "paren.lparen"
  719. ],
  720. regex : "(:)(\\s*)(function)(\\s*)(\\()",
  721. next: "function_arguments"
  722. }, {
  723. token : "keyword",
  724. regex : "(?:" + kwBeforeRe + ")\\b",
  725. next : "start"
  726. }, {
  727. token : ["punctuation.operator", "support.function"],
  728. 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(?=\()/
  729. }, {
  730. token : ["punctuation.operator", "support.function.dom"],
  731. 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(?=\()/
  732. }, {
  733. token : ["punctuation.operator", "support.constant"],
  734. 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/
  735. }, {
  736. token : ["support.constant"],
  737. regex : /that\b/
  738. }, {
  739. token : ["storage.type", "punctuation.operator", "support.function.firebug"],
  740. regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
  741. }, {
  742. token : keywordMapper,
  743. regex : identifierRe
  744. }, {
  745. token : "keyword.operator",
  746. regex : /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
  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. "start": [
  765. DocCommentHighlightRules.getStartRule("doc-start"),
  766. {
  767. token : "comment", // multi line comment
  768. regex : "\\/\\*",
  769. next : "comment_regex_allowed"
  770. }, {
  771. token : "comment",
  772. regex : "\\/\\/",
  773. next : "line_comment_regex_allowed"
  774. }, {
  775. token: "string.regexp",
  776. regex: "\\/",
  777. next: "regex"
  778. }, {
  779. token : "text",
  780. regex : "\\s+|^$",
  781. next : "start"
  782. }, {
  783. token: "empty",
  784. regex: "",
  785. next: "no_regex"
  786. }
  787. ],
  788. "regex": [
  789. {
  790. token: "regexp.keyword.operator",
  791. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  792. }, {
  793. token: "string.regexp",
  794. regex: "/[sxngimy]*",
  795. next: "no_regex"
  796. }, {
  797. token : "invalid",
  798. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  799. }, {
  800. token : "constant.language.escape",
  801. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  802. }, {
  803. token : "constant.language.delimiter",
  804. regex: /\|/
  805. }, {
  806. token: "constant.language.escape",
  807. regex: /\[\^?/,
  808. next: "regex_character_class"
  809. }, {
  810. token: "empty",
  811. regex: "$",
  812. next: "no_regex"
  813. }, {
  814. defaultToken: "string.regexp"
  815. }
  816. ],
  817. "regex_character_class": [
  818. {
  819. token: "regexp.charclass.keyword.operator",
  820. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  821. }, {
  822. token: "constant.language.escape",
  823. regex: "]",
  824. next: "regex"
  825. }, {
  826. token: "constant.language.escape",
  827. regex: "-"
  828. }, {
  829. token: "empty",
  830. regex: "$",
  831. next: "no_regex"
  832. }, {
  833. defaultToken: "string.regexp.charachterclass"
  834. }
  835. ],
  836. "function_arguments": [
  837. {
  838. token: "variable.parameter",
  839. regex: identifierRe
  840. }, {
  841. token: "punctuation.operator",
  842. regex: "[, ]+"
  843. }, {
  844. token: "punctuation.operator",
  845. regex: "$"
  846. }, {
  847. token: "empty",
  848. regex: "",
  849. next: "no_regex"
  850. }
  851. ],
  852. "comment_regex_allowed" : [
  853. DocCommentHighlightRules.getTagRule(),
  854. {token : "comment", regex : "\\*\\/", next : "start"},
  855. {defaultToken : "comment", caseInsensitive: true}
  856. ],
  857. "comment" : [
  858. DocCommentHighlightRules.getTagRule(),
  859. {token : "comment", regex : "\\*\\/", next : "no_regex"},
  860. {defaultToken : "comment", caseInsensitive: true}
  861. ],
  862. "line_comment_regex_allowed" : [
  863. DocCommentHighlightRules.getTagRule(),
  864. {token : "comment", regex : "$|^", next : "start"},
  865. {defaultToken : "comment", caseInsensitive: true}
  866. ],
  867. "line_comment" : [
  868. DocCommentHighlightRules.getTagRule(),
  869. {token : "comment", regex : "$|^", next : "no_regex"},
  870. {defaultToken : "comment", caseInsensitive: true}
  871. ],
  872. "qqstring" : [
  873. {
  874. token : "constant.language.escape",
  875. regex : escapedRe
  876. }, {
  877. token : "string",
  878. regex : "\\\\$",
  879. next : "qqstring"
  880. }, {
  881. token : "string",
  882. regex : '"|$',
  883. next : "no_regex"
  884. }, {
  885. defaultToken: "string"
  886. }
  887. ],
  888. "qstring" : [
  889. {
  890. token : "constant.language.escape",
  891. regex : escapedRe
  892. }, {
  893. token : "string",
  894. regex : "\\\\$",
  895. next : "qstring"
  896. }, {
  897. token : "string",
  898. regex : "'|$",
  899. next : "no_regex"
  900. }, {
  901. defaultToken: "string"
  902. }
  903. ]
  904. };
  905. if (!options || !options.noES6) {
  906. this.$rules.no_regex.unshift({
  907. regex: "[{}]", onMatch: function(val, state, stack) {
  908. this.next = val == "{" ? this.nextState : "";
  909. if (val == "{" && stack.length) {
  910. stack.unshift("start", state);
  911. return "paren";
  912. }
  913. if (val == "}" && stack.length) {
  914. stack.shift();
  915. this.next = stack.shift();
  916. if (this.next.indexOf("string") != -1)
  917. return "paren.quasi.end";
  918. }
  919. return val == "{" ? "paren.lparen" : "paren.rparen";
  920. },
  921. nextState: "start"
  922. }, {
  923. token : "string.quasi.start",
  924. regex : /`/,
  925. push : [{
  926. token : "constant.language.escape",
  927. regex : escapedRe
  928. }, {
  929. token : "paren.quasi.start",
  930. regex : /\${/,
  931. push : "start"
  932. }, {
  933. token : "string.quasi.end",
  934. regex : /`/,
  935. next : "pop"
  936. }, {
  937. defaultToken: "string.quasi"
  938. }]
  939. });
  940. }
  941. this.embedRules(DocCommentHighlightRules, "doc-",
  942. [ DocCommentHighlightRules.getEndRule("no_regex") ]);
  943. this.normalizeRules();
  944. };
  945. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  946. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  947. });
  948. define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
  949. "use strict";
  950. var Range = require("../range").Range;
  951. var MatchingBraceOutdent = function() {};
  952. (function() {
  953. this.checkOutdent = function(line, input) {
  954. if (! /^\s+$/.test(line))
  955. return false;
  956. return /^\s*\}/.test(input);
  957. };
  958. this.autoOutdent = function(doc, row) {
  959. var line = doc.getLine(row);
  960. var match = line.match(/^(\s*\})/);
  961. if (!match) return 0;
  962. var column = match[1].length;
  963. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  964. if (!openBracePos || openBracePos.row == row) return 0;
  965. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  966. doc.replace(new Range(row, 0, row, column-1), indent);
  967. };
  968. this.$getIndent = function(line) {
  969. return line.match(/^\s*/)[0];
  970. };
  971. }).call(MatchingBraceOutdent.prototype);
  972. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  973. });
  974. define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
  975. "use strict";
  976. var oop = require("../../lib/oop");
  977. var Behaviour = require("../behaviour").Behaviour;
  978. var TokenIterator = require("../../token_iterator").TokenIterator;
  979. var lang = require("../../lib/lang");
  980. var SAFE_INSERT_IN_TOKENS =
  981. ["text", "paren.rparen", "punctuation.operator"];
  982. var SAFE_INSERT_BEFORE_TOKENS =
  983. ["text", "paren.rparen", "punctuation.operator", "comment"];
  984. var context;
  985. var contextCache = {};
  986. var initContext = function(editor) {
  987. var id = -1;
  988. if (editor.multiSelect) {
  989. id = editor.selection.index;
  990. if (contextCache.rangeCount != editor.multiSelect.rangeCount)
  991. contextCache = {rangeCount: editor.multiSelect.rangeCount};
  992. }
  993. if (contextCache[id])
  994. return context = contextCache[id];
  995. context = contextCache[id] = {
  996. autoInsertedBrackets: 0,
  997. autoInsertedRow: -1,
  998. autoInsertedLineEnd: "",
  999. maybeInsertedBrackets: 0,
  1000. maybeInsertedRow: -1,
  1001. maybeInsertedLineStart: "",
  1002. maybeInsertedLineEnd: ""
  1003. };
  1004. };
  1005. var getWrapped = function(selection, selected, opening, closing) {
  1006. var rowDiff = selection.end.row - selection.start.row;
  1007. return {
  1008. text: opening + selected + closing,
  1009. selection: [
  1010. 0,
  1011. selection.start.column + 1,
  1012. rowDiff,
  1013. selection.end.column + (rowDiff ? 0 : 1)
  1014. ]
  1015. };
  1016. };
  1017. var CstyleBehaviour = function() {
  1018. this.add("braces", "insertion", function(state, action, editor, session, text) {
  1019. var cursor = editor.getCursorPosition();
  1020. var line = session.doc.getLine(cursor.row);
  1021. if (text == '{') {
  1022. initContext(editor);
  1023. var selection = editor.getSelectionRange();
  1024. var selected = session.doc.getTextRange(selection);
  1025. if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
  1026. return getWrapped(selection, selected, '{', '}');
  1027. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  1028. if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
  1029. CstyleBehaviour.recordAutoInsert(editor, session, "}");
  1030. return {
  1031. text: '{}',
  1032. selection: [1, 1]
  1033. };
  1034. } else {
  1035. CstyleBehaviour.recordMaybeInsert(editor, session, "{");
  1036. return {
  1037. text: '{',
  1038. selection: [1, 1]
  1039. };
  1040. }
  1041. }
  1042. } else if (text == '}') {
  1043. initContext(editor);
  1044. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1045. if (rightChar == '}') {
  1046. var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
  1047. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  1048. CstyleBehaviour.popAutoInsertedClosing();
  1049. return {
  1050. text: '',
  1051. selection: [1, 1]
  1052. };
  1053. }
  1054. }
  1055. } else if (text == "\n" || text == "\r\n") {
  1056. initContext(editor);
  1057. var closing = "";
  1058. if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
  1059. closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
  1060. CstyleBehaviour.clearMaybeInsertedClosing();
  1061. }
  1062. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1063. if (rightChar === '}') {
  1064. var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
  1065. if (!openBracePos)
  1066. return null;
  1067. var next_indent = this.$getIndent(session.getLine(openBracePos.row));
  1068. } else if (closing) {
  1069. var next_indent = this.$getIndent(line);
  1070. } else {
  1071. CstyleBehaviour.clearMaybeInsertedClosing();
  1072. return;
  1073. }
  1074. var indent = next_indent + session.getTabString();
  1075. return {
  1076. text: '\n' + indent + '\n' + next_indent + closing,
  1077. selection: [1, indent.length, 1, indent.length]
  1078. };
  1079. } else {
  1080. CstyleBehaviour.clearMaybeInsertedClosing();
  1081. }
  1082. });
  1083. this.add("braces", "deletion", function(state, action, editor, session, range) {
  1084. var selected = session.doc.getTextRange(range);
  1085. if (!range.isMultiLine() && selected == '{') {
  1086. initContext(editor);
  1087. var line = session.doc.getLine(range.start.row);
  1088. var rightChar = line.substring(range.end.column, range.end.column + 1);
  1089. if (rightChar == '}') {
  1090. range.end.column++;
  1091. return range;
  1092. } else {
  1093. context.maybeInsertedBrackets--;
  1094. }
  1095. }
  1096. });
  1097. this.add("parens", "insertion", function(state, action, editor, session, text) {
  1098. if (text == '(') {
  1099. initContext(editor);
  1100. var selection = editor.getSelectionRange();
  1101. var selected = session.doc.getTextRange(selection);
  1102. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  1103. return getWrapped(selection, selected, '(', ')');
  1104. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  1105. CstyleBehaviour.recordAutoInsert(editor, session, ")");
  1106. return {
  1107. text: '()',
  1108. selection: [1, 1]
  1109. };
  1110. }
  1111. } else if (text == ')') {
  1112. initContext(editor);
  1113. var cursor = editor.getCursorPosition();
  1114. var line = session.doc.getLine(cursor.row);
  1115. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1116. if (rightChar == ')') {
  1117. var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
  1118. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  1119. CstyleBehaviour.popAutoInsertedClosing();
  1120. return {
  1121. text: '',
  1122. selection: [1, 1]
  1123. };
  1124. }
  1125. }
  1126. }
  1127. });
  1128. this.add("parens", "deletion", function(state, action, editor, session, range) {
  1129. var selected = session.doc.getTextRange(range);
  1130. if (!range.isMultiLine() && selected == '(') {
  1131. initContext(editor);
  1132. var line = session.doc.getLine(range.start.row);
  1133. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  1134. if (rightChar == ')') {
  1135. range.end.column++;
  1136. return range;
  1137. }
  1138. }
  1139. });
  1140. this.add("brackets", "insertion", function(state, action, editor, session, text) {
  1141. if (text == '[') {
  1142. initContext(editor);
  1143. var selection = editor.getSelectionRange();
  1144. var selected = session.doc.getTextRange(selection);
  1145. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  1146. return getWrapped(selection, selected, '[', ']');
  1147. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  1148. CstyleBehaviour.recordAutoInsert(editor, session, "]");
  1149. return {
  1150. text: '[]',
  1151. selection: [1, 1]
  1152. };
  1153. }
  1154. } else if (text == ']') {
  1155. initContext(editor);
  1156. var cursor = editor.getCursorPosition();
  1157. var line = session.doc.getLine(cursor.row);
  1158. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1159. if (rightChar == ']') {
  1160. var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
  1161. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  1162. CstyleBehaviour.popAutoInsertedClosing();
  1163. return {
  1164. text: '',
  1165. selection: [1, 1]
  1166. };
  1167. }
  1168. }
  1169. }
  1170. });
  1171. this.add("brackets", "deletion", function(state, action, editor, session, range) {
  1172. var selected = session.doc.getTextRange(range);
  1173. if (!range.isMultiLine() && selected == '[') {
  1174. initContext(editor);
  1175. var line = session.doc.getLine(range.start.row);
  1176. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  1177. if (rightChar == ']') {
  1178. range.end.column++;
  1179. return range;
  1180. }
  1181. }
  1182. });
  1183. this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
  1184. if (text == '"' || text == "'") {
  1185. initContext(editor);
  1186. var quote = text;
  1187. var selection = editor.getSelectionRange();
  1188. var selected = session.doc.getTextRange(selection);
  1189. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  1190. return getWrapped(selection, selected, quote, quote);
  1191. } else if (!selected) {
  1192. var cursor = editor.getCursorPosition();
  1193. var line = session.doc.getLine(cursor.row);
  1194. var leftChar = line.substring(cursor.column-1, cursor.column);
  1195. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1196. var token = session.getTokenAt(cursor.row, cursor.column);
  1197. var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
  1198. if (leftChar == "\\" && token && /escape/.test(token.type))
  1199. return null;
  1200. var stringBefore = token && /string|escape/.test(token.type);
  1201. var stringAfter = !rightToken || /string|escape/.test(rightToken.type);
  1202. var pair;
  1203. if (rightChar == quote) {
  1204. pair = stringBefore !== stringAfter;
  1205. } else {
  1206. if (stringBefore && !stringAfter)
  1207. return null; // wrap string with different quote
  1208. if (stringBefore && stringAfter)
  1209. return null; // do not pair quotes inside strings
  1210. var wordRe = session.$mode.tokenRe;
  1211. wordRe.lastIndex = 0;
  1212. var isWordBefore = wordRe.test(leftChar);
  1213. wordRe.lastIndex = 0;
  1214. var isWordAfter = wordRe.test(leftChar);
  1215. if (isWordBefore || isWordAfter)
  1216. return null; // before or after alphanumeric
  1217. if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
  1218. return null; // there is rightChar and it isn't closing
  1219. pair = true;
  1220. }
  1221. return {
  1222. text: pair ? quote + quote : "",
  1223. selection: [1,1]
  1224. };
  1225. }
  1226. }
  1227. });
  1228. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  1229. var selected = session.doc.getTextRange(range);
  1230. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  1231. initContext(editor);
  1232. var line = session.doc.getLine(range.start.row);
  1233. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  1234. if (rightChar == selected) {
  1235. range.end.column++;
  1236. return range;
  1237. }
  1238. }
  1239. });
  1240. };
  1241. CstyleBehaviour.isSaneInsertion = function(editor, session) {
  1242. var cursor = editor.getCursorPosition();
  1243. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1244. if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
  1245. var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
  1246. if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
  1247. return false;
  1248. }
  1249. iterator.stepForward();
  1250. return iterator.getCurrentTokenRow() !== cursor.row ||
  1251. this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
  1252. };
  1253. CstyleBehaviour.$matchTokenType = function(token, types) {
  1254. return types.indexOf(token.type || token) > -1;
  1255. };
  1256. CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
  1257. var cursor = editor.getCursorPosition();
  1258. var line = session.doc.getLine(cursor.row);
  1259. if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
  1260. context.autoInsertedBrackets = 0;
  1261. context.autoInsertedRow = cursor.row;
  1262. context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
  1263. context.autoInsertedBrackets++;
  1264. };
  1265. CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
  1266. var cursor = editor.getCursorPosition();
  1267. var line = session.doc.getLine(cursor.row);
  1268. if (!this.isMaybeInsertedClosing(cursor, line))
  1269. context.maybeInsertedBrackets = 0;
  1270. context.maybeInsertedRow = cursor.row;
  1271. context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
  1272. context.maybeInsertedLineEnd = line.substr(cursor.column);
  1273. context.maybeInsertedBrackets++;
  1274. };
  1275. CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
  1276. return context.autoInsertedBrackets > 0 &&
  1277. cursor.row === context.autoInsertedRow &&
  1278. bracket === context.autoInsertedLineEnd[0] &&
  1279. line.substr(cursor.column) === context.autoInsertedLineEnd;
  1280. };
  1281. CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
  1282. return context.maybeInsertedBrackets > 0 &&
  1283. cursor.row === context.maybeInsertedRow &&
  1284. line.substr(cursor.column) === context.maybeInsertedLineEnd &&
  1285. line.substr(0, cursor.column) == context.maybeInsertedLineStart;
  1286. };
  1287. CstyleBehaviour.popAutoInsertedClosing = function() {
  1288. context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
  1289. context.autoInsertedBrackets--;
  1290. };
  1291. CstyleBehaviour.clearMaybeInsertedClosing = function() {
  1292. if (context) {
  1293. context.maybeInsertedBrackets = 0;
  1294. context.maybeInsertedRow = -1;
  1295. }
  1296. };
  1297. oop.inherits(CstyleBehaviour, Behaviour);
  1298. exports.CstyleBehaviour = CstyleBehaviour;
  1299. });
  1300. define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  1301. "use strict";
  1302. var oop = require("../../lib/oop");
  1303. var Range = require("../../range").Range;
  1304. var BaseFoldMode = require("./fold_mode").FoldMode;
  1305. var FoldMode = exports.FoldMode = function(commentRegex) {
  1306. if (commentRegex) {
  1307. this.foldingStartMarker = new RegExp(
  1308. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  1309. );
  1310. this.foldingStopMarker = new RegExp(
  1311. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  1312. );
  1313. }
  1314. };
  1315. oop.inherits(FoldMode, BaseFoldMode);
  1316. (function() {
  1317. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  1318. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  1319. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  1320. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  1321. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  1322. this._getFoldWidgetBase = this.getFoldWidget;
  1323. this.getFoldWidget = function(session, foldStyle, row) {
  1324. var line = session.getLine(row);
  1325. if (this.singleLineBlockCommentRe.test(line)) {
  1326. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  1327. return "";
  1328. }
  1329. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  1330. if (!fw && this.startRegionRe.test(line))
  1331. return "start"; // lineCommentRegionStart
  1332. return fw;
  1333. };
  1334. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  1335. var line = session.getLine(row);
  1336. if (this.startRegionRe.test(line))
  1337. return this.getCommentRegionBlock(session, line, row);
  1338. var match = line.match(this.foldingStartMarker);
  1339. if (match) {
  1340. var i = match.index;
  1341. if (match[1])
  1342. return this.openingBracketBlock(session, match[1], row, i);
  1343. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  1344. if (range && !range.isMultiLine()) {
  1345. if (forceMultiline) {
  1346. range = this.getSectionRange(session, row);
  1347. } else if (foldStyle != "all")
  1348. range = null;
  1349. }
  1350. return range;
  1351. }
  1352. if (foldStyle === "markbegin")
  1353. return;
  1354. var match = line.match(this.foldingStopMarker);
  1355. if (match) {
  1356. var i = match.index + match[0].length;
  1357. if (match[1])
  1358. return this.closingBracketBlock(session, match[1], row, i);
  1359. return session.getCommentFoldRange(row, i, -1);
  1360. }
  1361. };
  1362. this.getSectionRange = function(session, row) {
  1363. var line = session.getLine(row);
  1364. var startIndent = line.search(/\S/);
  1365. var startRow = row;
  1366. var startColumn = line.length;
  1367. row = row + 1;
  1368. var endRow = row;
  1369. var maxRow = session.getLength();
  1370. while (++row < maxRow) {
  1371. line = session.getLine(row);
  1372. var indent = line.search(/\S/);
  1373. if (indent === -1)
  1374. continue;
  1375. if (startIndent > indent)
  1376. break;
  1377. var subRange = this.getFoldWidgetRange(session, "all", row);
  1378. if (subRange) {
  1379. if (subRange.start.row <= startRow) {
  1380. break;
  1381. } else if (subRange.isMultiLine()) {
  1382. row = subRange.end.row;
  1383. } else if (startIndent == indent) {
  1384. break;
  1385. }
  1386. }
  1387. endRow = row;
  1388. }
  1389. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  1390. };
  1391. this.getCommentRegionBlock = function(session, line, row) {
  1392. var startColumn = line.search(/\s*$/);
  1393. var maxRow = session.getLength();
  1394. var startRow = row;
  1395. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  1396. var depth = 1;
  1397. while (++row < maxRow) {
  1398. line = session.getLine(row);
  1399. var m = re.exec(line);
  1400. if (!m) continue;
  1401. if (m[1]) depth--;
  1402. else depth++;
  1403. if (!depth) break;
  1404. }
  1405. var endRow = row;
  1406. if (endRow > startRow) {
  1407. return new Range(startRow, startColumn, endRow, line.length);
  1408. }
  1409. };
  1410. }).call(FoldMode.prototype);
  1411. });
  1412. define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
  1413. "use strict";
  1414. var oop = require("../lib/oop");
  1415. var TextMode = require("./text").Mode;
  1416. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1417. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1418. var Range = require("../range").Range;
  1419. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1420. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  1421. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1422. var Mode = function() {
  1423. this.HighlightRules = JavaScriptHighlightRules;
  1424. this.$outdent = new MatchingBraceOutdent();
  1425. this.$behaviour = new CstyleBehaviour();
  1426. this.foldingRules = new CStyleFoldMode();
  1427. };
  1428. oop.inherits(Mode, TextMode);
  1429. (function() {
  1430. this.lineCommentStart = "//";
  1431. this.blockComment = {start: "/*", end: "*/"};
  1432. this.getNextLineIndent = function(state, line, tab) {
  1433. var indent = this.$getIndent(line);
  1434. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  1435. var tokens = tokenizedLine.tokens;
  1436. var endState = tokenizedLine.state;
  1437. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  1438. return indent;
  1439. }
  1440. if (state == "start" || state == "no_regex") {
  1441. var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
  1442. if (match) {
  1443. indent += tab;
  1444. }
  1445. } else if (state == "doc-start") {
  1446. if (endState == "start" || endState == "no_regex") {
  1447. return "";
  1448. }
  1449. var match = line.match(/^\s*(\/?)\*/);
  1450. if (match) {
  1451. if (match[1]) {
  1452. indent += " ";
  1453. }
  1454. indent += "* ";
  1455. }
  1456. }
  1457. return indent;
  1458. };
  1459. this.checkOutdent = function(state, line, input) {
  1460. return this.$outdent.checkOutdent(line, input);
  1461. };
  1462. this.autoOutdent = function(state, doc, row) {
  1463. this.$outdent.autoOutdent(doc, row);
  1464. };
  1465. this.createWorker = function(session) {
  1466. var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
  1467. worker.attachToDocument(session.getDocument());
  1468. worker.on("annotate", function(results) {
  1469. session.setAnnotations(results.data);
  1470. });
  1471. worker.on("terminate", function() {
  1472. session.clearAnnotations();
  1473. });
  1474. return worker;
  1475. };
  1476. this.$id = "ace/mode/javascript";
  1477. }).call(Mode.prototype);
  1478. exports.Mode = Mode;
  1479. });
  1480. 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) {
  1481. "use strict";
  1482. var oop = require("../lib/oop");
  1483. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1484. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1485. var SvgHighlightRules = function() {
  1486. XmlHighlightRules.call(this);
  1487. this.embedTagRules(JavaScriptHighlightRules, "js-", "script");
  1488. this.normalizeRules();
  1489. };
  1490. oop.inherits(SvgHighlightRules, XmlHighlightRules);
  1491. exports.SvgHighlightRules = SvgHighlightRules;
  1492. });
  1493. define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module) {
  1494. "use strict";
  1495. var oop = require("../../lib/oop");
  1496. var BaseFoldMode = require("./fold_mode").FoldMode;
  1497. var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
  1498. this.defaultMode = defaultMode;
  1499. this.subModes = subModes;
  1500. };
  1501. oop.inherits(FoldMode, BaseFoldMode);
  1502. (function() {
  1503. this.$getMode = function(state) {
  1504. if (typeof state != "string")
  1505. state = state[0];
  1506. for (var key in this.subModes) {
  1507. if (state.indexOf(key) === 0)
  1508. return this.subModes[key];
  1509. }
  1510. return null;
  1511. };
  1512. this.$tryMode = function(state, session, foldStyle, row) {
  1513. var mode = this.$getMode(state);
  1514. return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
  1515. };
  1516. this.getFoldWidget = function(session, foldStyle, row) {
  1517. return (
  1518. this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
  1519. this.$tryMode(session.getState(row), session, foldStyle, row) ||
  1520. this.defaultMode.getFoldWidget(session, foldStyle, row)
  1521. );
  1522. };
  1523. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1524. var mode = this.$getMode(session.getState(row-1));
  1525. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1526. mode = this.$getMode(session.getState(row));
  1527. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1528. mode = this.defaultMode;
  1529. return mode.getFoldWidgetRange(session, foldStyle, row);
  1530. };
  1531. }).call(FoldMode.prototype);
  1532. });
  1533. 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) {
  1534. "use strict";
  1535. var oop = require("../lib/oop");
  1536. var XmlMode = require("./xml").Mode;
  1537. var JavaScriptMode = require("./javascript").Mode;
  1538. var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules;
  1539. var MixedFoldMode = require("./folding/mixed").FoldMode;
  1540. var XmlFoldMode = require("./folding/xml").FoldMode;
  1541. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1542. var Mode = function() {
  1543. XmlMode.call(this);
  1544. this.HighlightRules = SvgHighlightRules;
  1545. this.createModeDelegates({
  1546. "js-": JavaScriptMode
  1547. });
  1548. this.foldingRules = new MixedFoldMode(new XmlFoldMode(), {
  1549. "js-": new CStyleFoldMode()
  1550. });
  1551. };
  1552. oop.inherits(Mode, XmlMode);
  1553. (function() {
  1554. this.getNextLineIndent = function(state, line, tab) {
  1555. return this.$getIndent(line);
  1556. };
  1557. this.$id = "ace/mode/svg";
  1558. }).call(Mode.prototype);
  1559. exports.Mode = Mode;
  1560. });