2322c0d73cf4169df003976804566079.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. ace.define("ace/mode/json_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 JsonHighlightRules = function () {
  5. this.$rules = {
  6. "start": [
  7. {
  8. token: "variable",
  9. regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)'
  10. }, {
  11. token: "string",
  12. regex: '"',
  13. next: "string"
  14. }, {
  15. token: "constant.numeric",
  16. regex: "0[xX][0-9a-fA-F]+\\b"
  17. }, {
  18. token: "constant.numeric",
  19. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  20. }, {
  21. token: "constant.language.boolean",
  22. regex: "(?:true|false)\\b"
  23. }, {
  24. token: "text",
  25. regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  26. }, {
  27. token: "comment",
  28. regex: "\\/\\/.*$"
  29. }, {
  30. token: "comment.start",
  31. regex: "\\/\\*",
  32. next: "comment"
  33. }, {
  34. token: "paren.lparen",
  35. regex: "[[({]"
  36. }, {
  37. token: "paren.rparen",
  38. regex: "[\\])}]"
  39. }, {
  40. token: "punctuation.operator",
  41. regex: /[,]/
  42. }, {
  43. token: "text",
  44. regex: "\\s+"
  45. }
  46. ],
  47. "string": [
  48. {
  49. token: "constant.language.escape",
  50. regex: /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/
  51. }, {
  52. token: "string",
  53. regex: '"|$',
  54. next: "start"
  55. }, {
  56. defaultToken: "string"
  57. }
  58. ],
  59. "comment": [
  60. {
  61. token: "comment.end",
  62. regex: "\\*\\/",
  63. next: "start"
  64. }, {
  65. defaultToken: "comment"
  66. }
  67. ]
  68. };
  69. };
  70. oop.inherits(JsonHighlightRules, TextHighlightRules);
  71. exports.JsonHighlightRules = JsonHighlightRules;
  72. });
  73. ace.define("ace/mode/json5_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/json_highlight_rules"], function(require, exports, module){"use strict";
  74. var oop = require("../lib/oop");
  75. var JsonHighlightRules = require("./json_highlight_rules").JsonHighlightRules;
  76. var Json5HighlightRules = function () {
  77. JsonHighlightRules.call(this);
  78. var startRules = [{
  79. token: "variable",
  80. regex: /[a-zA-Z$_\u00a1-\uffff][\w$\u00a1-\uffff]*\s*(?=:)/
  81. }, {
  82. token: "variable",
  83. regex: /['](?:(?:\\.)|(?:[^'\\]))*?[']\s*(?=:)/
  84. }, {
  85. token: "constant.language.boolean",
  86. regex: /(?:null)\b/
  87. }, {
  88. token: "string",
  89. regex: /'/,
  90. next: [{
  91. token: "constant.language.escape",
  92. regex: /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\/bfnrt]|$)/,
  93. consumeLineEnd: true
  94. }, {
  95. token: "string",
  96. regex: /'|$/,
  97. next: "start"
  98. }, {
  99. defaultToken: "string"
  100. }]
  101. }, {
  102. token: "string",
  103. regex: /"(?![^"]*":)/,
  104. next: [{
  105. token: "constant.language.escape",
  106. regex: /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\/bfnrt]|$)/,
  107. consumeLineEnd: true
  108. }, {
  109. token: "string",
  110. regex: /"|$/,
  111. next: "start"
  112. }, {
  113. defaultToken: "string"
  114. }]
  115. }, {
  116. token: "constant.numeric",
  117. regex: /[+-]?(?:Infinity|NaN)\b/
  118. }];
  119. for (var key in this.$rules)
  120. this.$rules[key].unshift.apply(this.$rules[key], startRules);
  121. this.normalizeRules();
  122. };
  123. oop.inherits(Json5HighlightRules, JsonHighlightRules);
  124. exports.Json5HighlightRules = Json5HighlightRules;
  125. });
  126. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  127. var Range = require("../range").Range;
  128. var MatchingBraceOutdent = function () { };
  129. (function () {
  130. this.checkOutdent = function (line, input) {
  131. if (!/^\s+$/.test(line))
  132. return false;
  133. return /^\s*\}/.test(input);
  134. };
  135. this.autoOutdent = function (doc, row) {
  136. var line = doc.getLine(row);
  137. var match = line.match(/^(\s*\})/);
  138. if (!match)
  139. return 0;
  140. var column = match[1].length;
  141. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  142. if (!openBracePos || openBracePos.row == row)
  143. return 0;
  144. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  145. doc.replace(new Range(row, 0, row, column - 1), indent);
  146. };
  147. this.$getIndent = function (line) {
  148. return line.match(/^\s*/)[0];
  149. };
  150. }).call(MatchingBraceOutdent.prototype);
  151. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  152. });
  153. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
  154. var oop = require("../../lib/oop");
  155. var Range = require("../../range").Range;
  156. var BaseFoldMode = require("./fold_mode").FoldMode;
  157. var FoldMode = exports.FoldMode = function (commentRegex) {
  158. if (commentRegex) {
  159. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  160. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  161. }
  162. };
  163. oop.inherits(FoldMode, BaseFoldMode);
  164. (function () {
  165. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  166. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  167. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  168. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  169. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  170. this._getFoldWidgetBase = this.getFoldWidget;
  171. this.getFoldWidget = function (session, foldStyle, row) {
  172. var line = session.getLine(row);
  173. if (this.singleLineBlockCommentRe.test(line)) {
  174. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  175. return "";
  176. }
  177. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  178. if (!fw && this.startRegionRe.test(line))
  179. return "start"; // lineCommentRegionStart
  180. return fw;
  181. };
  182. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  183. var line = session.getLine(row);
  184. if (this.startRegionRe.test(line))
  185. return this.getCommentRegionBlock(session, line, row);
  186. var match = line.match(this.foldingStartMarker);
  187. if (match) {
  188. var i = match.index;
  189. if (match[1])
  190. return this.openingBracketBlock(session, match[1], row, i);
  191. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  192. if (range && !range.isMultiLine()) {
  193. if (forceMultiline) {
  194. range = this.getSectionRange(session, row);
  195. }
  196. else if (foldStyle != "all")
  197. range = null;
  198. }
  199. return range;
  200. }
  201. if (foldStyle === "markbegin")
  202. return;
  203. var match = line.match(this.foldingStopMarker);
  204. if (match) {
  205. var i = match.index + match[0].length;
  206. if (match[1])
  207. return this.closingBracketBlock(session, match[1], row, i);
  208. return session.getCommentFoldRange(row, i, -1);
  209. }
  210. };
  211. this.getSectionRange = function (session, row) {
  212. var line = session.getLine(row);
  213. var startIndent = line.search(/\S/);
  214. var startRow = row;
  215. var startColumn = line.length;
  216. row = row + 1;
  217. var endRow = row;
  218. var maxRow = session.getLength();
  219. while (++row < maxRow) {
  220. line = session.getLine(row);
  221. var indent = line.search(/\S/);
  222. if (indent === -1)
  223. continue;
  224. if (startIndent > indent)
  225. break;
  226. var subRange = this.getFoldWidgetRange(session, "all", row);
  227. if (subRange) {
  228. if (subRange.start.row <= startRow) {
  229. break;
  230. }
  231. else if (subRange.isMultiLine()) {
  232. row = subRange.end.row;
  233. }
  234. else if (startIndent == indent) {
  235. break;
  236. }
  237. }
  238. endRow = row;
  239. }
  240. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  241. };
  242. this.getCommentRegionBlock = function (session, line, row) {
  243. var startColumn = line.search(/\s*$/);
  244. var maxRow = session.getLength();
  245. var startRow = row;
  246. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  247. var depth = 1;
  248. while (++row < maxRow) {
  249. line = session.getLine(row);
  250. var m = re.exec(line);
  251. if (!m)
  252. continue;
  253. if (m[1])
  254. depth--;
  255. else
  256. depth++;
  257. if (!depth)
  258. break;
  259. }
  260. var endRow = row;
  261. if (endRow > startRow) {
  262. return new Range(startRow, startColumn, endRow, line.length);
  263. }
  264. };
  265. }).call(FoldMode.prototype);
  266. });
  267. ace.define("ace/mode/json5",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/json5_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  268. var oop = require("../lib/oop");
  269. var TextMode = require("./text").Mode;
  270. var HighlightRules = require("./json5_highlight_rules").Json5HighlightRules;
  271. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  272. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  273. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  274. var Mode = function () {
  275. this.HighlightRules = HighlightRules;
  276. this.$outdent = new MatchingBraceOutdent();
  277. this.$behaviour = new CstyleBehaviour();
  278. this.foldingRules = new CStyleFoldMode();
  279. };
  280. oop.inherits(Mode, TextMode);
  281. (function () {
  282. this.lineCommentStart = "//";
  283. this.blockComment = { start: "/*", end: "*/" };
  284. this.checkOutdent = function (state, line, input) {
  285. return this.$outdent.checkOutdent(line, input);
  286. };
  287. this.autoOutdent = function (state, doc, row) {
  288. this.$outdent.autoOutdent(doc, row);
  289. };
  290. this.$id = "ace/mode/json5";
  291. }).call(Mode.prototype);
  292. exports.Mode = Mode;
  293. }); (function() {
  294. ace.require(["ace/mode/json5"], function(m) {
  295. if (typeof module == "object" && typeof exports == "object" && module) {
  296. module.exports = m;
  297. }
  298. });
  299. })();