5732fea8bd237446656490657f7b147d.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. ace.define("ace/mode/yaml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  2. var oop = require("../lib/oop");
  3. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4. var YamlHighlightRules = function () {
  5. this.$rules = {
  6. "start": [
  7. {
  8. token: "comment",
  9. regex: "#.*$"
  10. }, {
  11. token: "list.markup",
  12. regex: /^(?:-{3}|\.{3})\s*(?=#|$)/
  13. }, {
  14. token: "list.markup",
  15. regex: /^\s*[\-?](?:$|\s)/
  16. }, {
  17. token: "constant",
  18. regex: "!![\\w//]+"
  19. }, {
  20. token: "constant.language",
  21. regex: "[&\\*][a-zA-Z0-9-_]+"
  22. }, {
  23. token: ["meta.tag", "keyword"],
  24. regex: /^(\s*\w[^\s:]*?)(:(?=\s|$))/
  25. }, {
  26. token: ["meta.tag", "keyword"],
  27. regex: /(\w[^\s:]*?)(\s*:(?=\s|$))/
  28. }, {
  29. token: "keyword.operator",
  30. regex: "<<\\w*:\\w*"
  31. }, {
  32. token: "keyword.operator",
  33. regex: "-\\s*(?=[{])"
  34. }, {
  35. token: "string",
  36. regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  37. }, {
  38. token: "string",
  39. regex: /[|>][-+\d]*(?:$|\s+(?:$|#))/,
  40. onMatch: function (val, state, stack, line) {
  41. line = line.replace(/ #.*/, "");
  42. var indent = /^ *((:\s*)?-(\s*[^|>])?)?/.exec(line)[0]
  43. .replace(/\S\s*$/, "").length;
  44. var indentationIndicator = parseInt(/\d+[\s+-]*$/.exec(line));
  45. if (indentationIndicator) {
  46. indent += indentationIndicator - 1;
  47. this.next = "mlString";
  48. }
  49. else {
  50. this.next = "mlStringPre";
  51. }
  52. if (!stack.length) {
  53. stack.push(this.next);
  54. stack.push(indent);
  55. }
  56. else {
  57. stack[0] = this.next;
  58. stack[1] = indent;
  59. }
  60. return this.token;
  61. },
  62. next: "mlString"
  63. }, {
  64. token: "string",
  65. regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  66. }, {
  67. token: "constant.numeric",
  68. regex: /(\b|[+\-\.])[\d_]+(?:(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)(?=[^\d-\w]|$)$/
  69. }, {
  70. token: "constant.numeric",
  71. regex: /[+\-]?\.inf\b|NaN\b|0x[\dA-Fa-f_]+|0b[10_]+/
  72. }, {
  73. token: "constant.language.boolean",
  74. regex: "\\b(?:true|false|TRUE|FALSE|True|False|yes|no)\\b"
  75. }, {
  76. token: "paren.lparen",
  77. regex: "[[({]"
  78. }, {
  79. token: "paren.rparen",
  80. regex: "[\\])}]"
  81. }, {
  82. token: "text",
  83. regex: /[^\s,:\[\]\{\}]+/
  84. }
  85. ],
  86. "mlStringPre": [
  87. {
  88. token: "indent",
  89. regex: /^ *$/
  90. }, {
  91. token: "indent",
  92. regex: /^ */,
  93. onMatch: function (val, state, stack) {
  94. var curIndent = stack[1];
  95. if (curIndent >= val.length) {
  96. this.next = "start";
  97. stack.shift();
  98. stack.shift();
  99. }
  100. else {
  101. stack[1] = val.length - 1;
  102. this.next = stack[0] = "mlString";
  103. }
  104. return this.token;
  105. },
  106. next: "mlString"
  107. }, {
  108. defaultToken: "string"
  109. }
  110. ],
  111. "mlString": [
  112. {
  113. token: "indent",
  114. regex: /^ *$/
  115. }, {
  116. token: "indent",
  117. regex: /^ */,
  118. onMatch: function (val, state, stack) {
  119. var curIndent = stack[1];
  120. if (curIndent >= val.length) {
  121. this.next = "start";
  122. stack.splice(0);
  123. }
  124. else {
  125. this.next = "mlString";
  126. }
  127. return this.token;
  128. },
  129. next: "mlString"
  130. }, {
  131. token: "string",
  132. regex: '.+'
  133. }
  134. ]
  135. };
  136. this.normalizeRules();
  137. };
  138. oop.inherits(YamlHighlightRules, TextHighlightRules);
  139. exports.YamlHighlightRules = YamlHighlightRules;
  140. });
  141. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  142. var Range = require("../range").Range;
  143. var MatchingBraceOutdent = function () { };
  144. (function () {
  145. this.checkOutdent = function (line, input) {
  146. if (!/^\s+$/.test(line))
  147. return false;
  148. return /^\s*\}/.test(input);
  149. };
  150. this.autoOutdent = function (doc, row) {
  151. var line = doc.getLine(row);
  152. var match = line.match(/^(\s*\})/);
  153. if (!match)
  154. return 0;
  155. var column = match[1].length;
  156. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  157. if (!openBracePos || openBracePos.row == row)
  158. return 0;
  159. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  160. doc.replace(new Range(row, 0, row, column - 1), indent);
  161. };
  162. this.$getIndent = function (line) {
  163. return line.match(/^\s*/)[0];
  164. };
  165. }).call(MatchingBraceOutdent.prototype);
  166. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  167. });
  168. ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module){"use strict";
  169. var oop = require("../../lib/oop");
  170. var BaseFoldMode = require("./fold_mode").FoldMode;
  171. var Range = require("../../range").Range;
  172. var FoldMode = exports.FoldMode = function () { };
  173. oop.inherits(FoldMode, BaseFoldMode);
  174. (function () {
  175. this.getFoldWidgetRange = function (session, foldStyle, row) {
  176. var range = this.indentationBlock(session, row);
  177. if (range)
  178. return range;
  179. var re = /\S/;
  180. var line = session.getLine(row);
  181. var startLevel = line.search(re);
  182. if (startLevel == -1 || line[startLevel] != "#")
  183. return;
  184. var startColumn = line.length;
  185. var maxRow = session.getLength();
  186. var startRow = row;
  187. var endRow = row;
  188. while (++row < maxRow) {
  189. line = session.getLine(row);
  190. var level = line.search(re);
  191. if (level == -1)
  192. continue;
  193. if (line[level] != "#")
  194. break;
  195. endRow = row;
  196. }
  197. if (endRow > startRow) {
  198. var endColumn = session.getLine(endRow).length;
  199. return new Range(startRow, startColumn, endRow, endColumn);
  200. }
  201. };
  202. this.getFoldWidget = function (session, foldStyle, row) {
  203. var line = session.getLine(row);
  204. var indent = line.search(/\S/);
  205. var next = session.getLine(row + 1);
  206. var prev = session.getLine(row - 1);
  207. var prevIndent = prev.search(/\S/);
  208. var nextIndent = next.search(/\S/);
  209. if (indent == -1) {
  210. session.foldWidgets[row - 1] = prevIndent != -1 && prevIndent < nextIndent ? "start" : "";
  211. return "";
  212. }
  213. if (prevIndent == -1) {
  214. if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
  215. session.foldWidgets[row - 1] = "";
  216. session.foldWidgets[row + 1] = "";
  217. return "start";
  218. }
  219. }
  220. else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
  221. if (session.getLine(row - 2).search(/\S/) == -1) {
  222. session.foldWidgets[row - 1] = "start";
  223. session.foldWidgets[row + 1] = "";
  224. return "";
  225. }
  226. }
  227. if (prevIndent != -1 && prevIndent < indent)
  228. session.foldWidgets[row - 1] = "start";
  229. else
  230. session.foldWidgets[row - 1] = "";
  231. if (indent < nextIndent)
  232. return "start";
  233. else
  234. return "";
  235. };
  236. }).call(FoldMode.prototype);
  237. });
  238. ace.define("ace/mode/yaml",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/yaml_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/coffee","ace/worker/worker_client"], function(require, exports, module){"use strict";
  239. var oop = require("../lib/oop");
  240. var TextMode = require("./text").Mode;
  241. var YamlHighlightRules = require("./yaml_highlight_rules").YamlHighlightRules;
  242. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  243. var FoldMode = require("./folding/coffee").FoldMode;
  244. var WorkerClient = require("../worker/worker_client").WorkerClient;
  245. var Mode = function () {
  246. this.HighlightRules = YamlHighlightRules;
  247. this.$outdent = new MatchingBraceOutdent();
  248. this.foldingRules = new FoldMode();
  249. this.$behaviour = this.$defaultBehaviour;
  250. };
  251. oop.inherits(Mode, TextMode);
  252. (function () {
  253. this.lineCommentStart = ["#"];
  254. this.getNextLineIndent = function (state, line, tab) {
  255. var indent = this.$getIndent(line);
  256. if (state == "start") {
  257. var match = line.match(/^.*[\{\(\[]\s*$/);
  258. if (match) {
  259. indent += tab;
  260. }
  261. }
  262. return indent;
  263. };
  264. this.checkOutdent = function (state, line, input) {
  265. return this.$outdent.checkOutdent(line, input);
  266. };
  267. this.autoOutdent = function (state, doc, row) {
  268. this.$outdent.autoOutdent(doc, row);
  269. };
  270. this.createWorker = function (session) {
  271. var worker = new WorkerClient(["ace"], "ace/mode/yaml_worker", "YamlWorker");
  272. worker.attachToDocument(session.getDocument());
  273. worker.on("annotate", function (results) {
  274. session.setAnnotations(results.data);
  275. });
  276. worker.on("terminate", function () {
  277. session.clearAnnotations();
  278. });
  279. return worker;
  280. };
  281. this.$id = "ace/mode/yaml";
  282. }).call(Mode.prototype);
  283. exports.Mode = Mode;
  284. }); (function() {
  285. ace.require(["ace/mode/yaml"], function(m) {
  286. if (typeof module == "object" && typeof exports == "object" && module) {
  287. module.exports = m;
  288. }
  289. });
  290. })();