You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1568 lines
57 KiB

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