cf90a0e6a2989274c84edd1dc44db5e1.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. ace.define("ace/mode/hjson_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){/* This file was autogenerated from Hjson.tmLanguage (uuid: ) */
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var HjsonHighlightRules = function () {
  6. this.$rules = {
  7. start: [{
  8. include: "#comments"
  9. }, {
  10. include: "#rootObject"
  11. }, {
  12. include: "#value"
  13. }],
  14. "#array": [{
  15. token: "paren.lparen",
  16. regex: /\[/,
  17. push: [{
  18. token: "paren.rparen",
  19. regex: /\]/,
  20. next: "pop"
  21. }, {
  22. include: "#value"
  23. }, {
  24. include: "#comments"
  25. }, {
  26. token: "text",
  27. regex: /,|$/
  28. }, {
  29. token: "invalid.illegal",
  30. regex: /[^\s\]]/
  31. }, {
  32. defaultToken: "array"
  33. }]
  34. }],
  35. "#comments": [{
  36. token: [
  37. "comment.punctuation",
  38. "comment.line"
  39. ],
  40. regex: /(#)(.*$)/
  41. }, {
  42. token: "comment.punctuation",
  43. regex: /\/\*/,
  44. push: [{
  45. token: "comment.punctuation",
  46. regex: /\*\//,
  47. next: "pop"
  48. }, {
  49. defaultToken: "comment.block"
  50. }]
  51. }, {
  52. token: [
  53. "comment.punctuation",
  54. "comment.line"
  55. ],
  56. regex: /(\/\/)(.*$)/
  57. }],
  58. "#constant": [{
  59. token: "constant",
  60. regex: /\b(?:true|false|null)\b/
  61. }],
  62. "#keyname": [{
  63. token: "keyword",
  64. regex: /(?:[^,\{\[\}\]\s]+|"(?:[^"\\]|\\.)*")\s*(?=:)/
  65. }],
  66. "#mstring": [{
  67. token: "string",
  68. regex: /'''/,
  69. push: [{
  70. token: "string",
  71. regex: /'''/,
  72. next: "pop"
  73. }, {
  74. defaultToken: "string"
  75. }]
  76. }],
  77. "#number": [{
  78. token: "constant.numeric",
  79. regex: /-?(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:[eE][+-]?\d+)?)?/,
  80. comment: "handles integer and decimal numbers"
  81. }],
  82. "#object": [{
  83. token: "paren.lparen",
  84. regex: /\{/,
  85. push: [{
  86. token: "paren.rparen",
  87. regex: /\}/,
  88. next: "pop"
  89. }, {
  90. include: "#keyname"
  91. }, {
  92. include: "#value"
  93. }, {
  94. token: "text",
  95. regex: /:/
  96. }, {
  97. token: "text",
  98. regex: /,/
  99. }, {
  100. defaultToken: "paren"
  101. }]
  102. }],
  103. "#rootObject": [{
  104. token: "paren",
  105. regex: /(?=\s*(?:[^,\{\[\}\]\s]+|"(?:[^"\\]|\\.)*")\s*:)/,
  106. push: [{
  107. token: "paren.rparen",
  108. regex: /---none---/,
  109. next: "pop"
  110. }, {
  111. include: "#keyname"
  112. }, {
  113. include: "#value"
  114. }, {
  115. token: "text",
  116. regex: /:/
  117. }, {
  118. token: "text",
  119. regex: /,/
  120. }, {
  121. defaultToken: "paren"
  122. }]
  123. }],
  124. "#string": [{
  125. token: "string",
  126. regex: /"/,
  127. push: [{
  128. token: "string",
  129. regex: /"/,
  130. next: "pop"
  131. }, {
  132. token: "constant.language.escape",
  133. regex: /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/
  134. }, {
  135. token: "invalid.illegal",
  136. regex: /\\./
  137. }, {
  138. defaultToken: "string"
  139. }]
  140. }],
  141. "#ustring": [{
  142. token: "string",
  143. regex: /\b[^:,0-9\-\{\[\}\]\s].*$/
  144. }],
  145. "#value": [{
  146. include: "#constant"
  147. }, {
  148. include: "#number"
  149. }, {
  150. include: "#string"
  151. }, {
  152. include: "#array"
  153. }, {
  154. include: "#object"
  155. }, {
  156. include: "#comments"
  157. }, {
  158. include: "#mstring"
  159. }, {
  160. include: "#ustring"
  161. }]
  162. };
  163. this.normalizeRules();
  164. };
  165. HjsonHighlightRules.metaData = {
  166. fileTypes: ["hjson"],
  167. foldingStartMarker: "(?x: # turn on extended mode\n ^ # a line beginning with\n \\s* # some optional space\n [{\\[] # the start of an object or array\n (?! # but not followed by\n .* # whatever\n [}\\]] # and the close of an object or array\n ,? # an optional comma\n \\s* # some optional space\n $ # at the end of the line\n )\n | # ...or...\n [{\\[] # the start of an object or array\n \\s* # some optional space\n $ # at the end of the line\n )",
  168. foldingStopMarker: "(?x: # turn on extended mode\n ^ # a line beginning with\n \\s* # some optional space\n [}\\]] # and the close of an object or array\n )",
  169. keyEquivalent: "^~J",
  170. name: "Hjson",
  171. scopeName: "source.hjson"
  172. };
  173. oop.inherits(HjsonHighlightRules, TextHighlightRules);
  174. exports.HjsonHighlightRules = HjsonHighlightRules;
  175. });
  176. 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";
  177. var oop = require("../../lib/oop");
  178. var Range = require("../../range").Range;
  179. var BaseFoldMode = require("./fold_mode").FoldMode;
  180. var FoldMode = exports.FoldMode = function (commentRegex) {
  181. if (commentRegex) {
  182. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  183. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  184. }
  185. };
  186. oop.inherits(FoldMode, BaseFoldMode);
  187. (function () {
  188. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  189. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  190. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  191. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  192. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  193. this._getFoldWidgetBase = this.getFoldWidget;
  194. this.getFoldWidget = function (session, foldStyle, row) {
  195. var line = session.getLine(row);
  196. if (this.singleLineBlockCommentRe.test(line)) {
  197. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  198. return "";
  199. }
  200. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  201. if (!fw && this.startRegionRe.test(line))
  202. return "start"; // lineCommentRegionStart
  203. return fw;
  204. };
  205. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  206. var line = session.getLine(row);
  207. if (this.startRegionRe.test(line))
  208. return this.getCommentRegionBlock(session, line, row);
  209. var match = line.match(this.foldingStartMarker);
  210. if (match) {
  211. var i = match.index;
  212. if (match[1])
  213. return this.openingBracketBlock(session, match[1], row, i);
  214. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  215. if (range && !range.isMultiLine()) {
  216. if (forceMultiline) {
  217. range = this.getSectionRange(session, row);
  218. }
  219. else if (foldStyle != "all")
  220. range = null;
  221. }
  222. return range;
  223. }
  224. if (foldStyle === "markbegin")
  225. return;
  226. var match = line.match(this.foldingStopMarker);
  227. if (match) {
  228. var i = match.index + match[0].length;
  229. if (match[1])
  230. return this.closingBracketBlock(session, match[1], row, i);
  231. return session.getCommentFoldRange(row, i, -1);
  232. }
  233. };
  234. this.getSectionRange = function (session, row) {
  235. var line = session.getLine(row);
  236. var startIndent = line.search(/\S/);
  237. var startRow = row;
  238. var startColumn = line.length;
  239. row = row + 1;
  240. var endRow = row;
  241. var maxRow = session.getLength();
  242. while (++row < maxRow) {
  243. line = session.getLine(row);
  244. var indent = line.search(/\S/);
  245. if (indent === -1)
  246. continue;
  247. if (startIndent > indent)
  248. break;
  249. var subRange = this.getFoldWidgetRange(session, "all", row);
  250. if (subRange) {
  251. if (subRange.start.row <= startRow) {
  252. break;
  253. }
  254. else if (subRange.isMultiLine()) {
  255. row = subRange.end.row;
  256. }
  257. else if (startIndent == indent) {
  258. break;
  259. }
  260. }
  261. endRow = row;
  262. }
  263. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  264. };
  265. this.getCommentRegionBlock = function (session, line, row) {
  266. var startColumn = line.search(/\s*$/);
  267. var maxRow = session.getLength();
  268. var startRow = row;
  269. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  270. var depth = 1;
  271. while (++row < maxRow) {
  272. line = session.getLine(row);
  273. var m = re.exec(line);
  274. if (!m)
  275. continue;
  276. if (m[1])
  277. depth--;
  278. else
  279. depth++;
  280. if (!depth)
  281. break;
  282. }
  283. var endRow = row;
  284. if (endRow > startRow) {
  285. return new Range(startRow, startColumn, endRow, line.length);
  286. }
  287. };
  288. }).call(FoldMode.prototype);
  289. });
  290. ace.define("ace/mode/hjson",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/hjson_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  291. var oop = require("../lib/oop");
  292. var TextMode = require("./text").Mode;
  293. var HjsonHighlightRules = require("./hjson_highlight_rules").HjsonHighlightRules;
  294. var FoldMode = require("./folding/cstyle").FoldMode;
  295. var Mode = function () {
  296. this.HighlightRules = HjsonHighlightRules;
  297. this.foldingRules = new FoldMode();
  298. };
  299. oop.inherits(Mode, TextMode);
  300. (function () {
  301. this.lineCommentStart = "//";
  302. this.blockComment = { start: "/*", end: "*/" };
  303. this.$id = "ace/mode/hjson";
  304. }).call(Mode.prototype);
  305. exports.Mode = Mode;
  306. }); (function() {
  307. ace.require(["ace/mode/hjson"], function(m) {
  308. if (typeof module == "object" && typeof exports == "object" && module) {
  309. module.exports = m;
  310. }
  311. });
  312. })();