fb9eb8450ed17fce1ab64c6f239c0ed5.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. ace.define("ace/mode/jexl_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 JexlHighlightRules = function () {
  5. var keywords = "return|var|function|and|or|not|if|for|while|do|continue|break";
  6. var buildinConstants = "null";
  7. var supportFunc = "empty|size|new";
  8. var keywordMapper = this.createKeywordMapper({
  9. "keyword": keywords,
  10. "constant.language": buildinConstants,
  11. "support.function": supportFunc
  12. }, "identifier");
  13. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  14. "u[0-9a-fA-F]{4}|" + // unicode
  15. "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
  16. "|.)";
  17. this.$rules = {
  18. "start": [
  19. {
  20. token: "comment",
  21. regex: "\\/\\/.*$"
  22. }, {
  23. token: "comment",
  24. regex: "##.*$"
  25. }, {
  26. token: "comment", // multi line comment
  27. regex: "\\/\\*",
  28. next: "comment"
  29. }, {
  30. token: ["comment", "text"],
  31. regex: "(#pragma)(\\s.*$)"
  32. }, {
  33. token: "string", // single line
  34. regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  35. }, {
  36. token: "string", // single line
  37. regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  38. }, {
  39. token: "string", // multi line string
  40. regex: "`",
  41. push: [
  42. {
  43. token: "constant.language.escape",
  44. regex: escapedRe
  45. }, {
  46. token: "string",
  47. regex: "`",
  48. next: "pop"
  49. }, {
  50. token: "lparen", //interpolation
  51. regex: "\\${",
  52. push: [
  53. {
  54. token: "rparen",
  55. regex: "}",
  56. next: "pop"
  57. }, {
  58. include: "start"
  59. }
  60. ]
  61. }, {
  62. defaultToken: "string"
  63. }
  64. ]
  65. }, {
  66. token: "constant.numeric", // hex
  67. regex: /0(?:[xX][0-9a-fA-F][0-9a-fA-F_]*|[bB][01][01_]*)[LlSsDdFfYy]?\b/
  68. }, {
  69. token: "constant.numeric", // float
  70. regex: /[+-]?\d[\d_]*(?:(?:\.[\d_]*)?(?:[eE][+-]?[\d_]+)?)?[LlSsDdFfYy]?\b/
  71. }, {
  72. token: "constant.language.boolean",
  73. regex: "(?:true|false)\\b"
  74. }, {
  75. token: "string.regexp",
  76. regex: "~/",
  77. push: [
  78. {
  79. token: "constant.language.escape",
  80. regex: "\\\\/"
  81. }, {
  82. token: "string.regexp",
  83. regex: "$|/",
  84. next: "pop"
  85. }, {
  86. defaultToken: "string.regexp"
  87. }
  88. ]
  89. }, {
  90. token: keywordMapper,
  91. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  92. }, {
  93. token: "keyword.operator",
  94. regex: "&&|\\|\\||!|&|\\||\\^|~|\\?|:|\\?\\?|==|!=|<|<=|>|>=|=~|!~|=\\^|=\\$|!\\$|\\+|\\-|\\*|%|\\/|="
  95. }, {
  96. token: "lparen",
  97. regex: "[[({]"
  98. }, {
  99. token: "rparen",
  100. regex: "[\\])}]"
  101. }, {
  102. token: "text",
  103. regex: "\\s+"
  104. }, {
  105. token: "punctuation",
  106. regex: "[,.]"
  107. }, {
  108. token: "storage.type.annotation",
  109. regex: "@[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  110. }
  111. ],
  112. "comment": [
  113. {
  114. token: "comment",
  115. regex: "\\*\\/",
  116. next: "start"
  117. }, {
  118. defaultToken: "comment"
  119. }
  120. ]
  121. };
  122. this.normalizeRules();
  123. };
  124. oop.inherits(JexlHighlightRules, TextHighlightRules);
  125. exports.JexlHighlightRules = JexlHighlightRules;
  126. });
  127. 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";
  128. var oop = require("../../lib/oop");
  129. var Range = require("../../range").Range;
  130. var BaseFoldMode = require("./fold_mode").FoldMode;
  131. var FoldMode = exports.FoldMode = function (commentRegex) {
  132. if (commentRegex) {
  133. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  134. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  135. }
  136. };
  137. oop.inherits(FoldMode, BaseFoldMode);
  138. (function () {
  139. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  140. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  141. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  142. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  143. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  144. this._getFoldWidgetBase = this.getFoldWidget;
  145. this.getFoldWidget = function (session, foldStyle, row) {
  146. var line = session.getLine(row);
  147. if (this.singleLineBlockCommentRe.test(line)) {
  148. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  149. return "";
  150. }
  151. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  152. if (!fw && this.startRegionRe.test(line))
  153. return "start"; // lineCommentRegionStart
  154. return fw;
  155. };
  156. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  157. var line = session.getLine(row);
  158. if (this.startRegionRe.test(line))
  159. return this.getCommentRegionBlock(session, line, row);
  160. var match = line.match(this.foldingStartMarker);
  161. if (match) {
  162. var i = match.index;
  163. if (match[1])
  164. return this.openingBracketBlock(session, match[1], row, i);
  165. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  166. if (range && !range.isMultiLine()) {
  167. if (forceMultiline) {
  168. range = this.getSectionRange(session, row);
  169. }
  170. else if (foldStyle != "all")
  171. range = null;
  172. }
  173. return range;
  174. }
  175. if (foldStyle === "markbegin")
  176. return;
  177. var match = line.match(this.foldingStopMarker);
  178. if (match) {
  179. var i = match.index + match[0].length;
  180. if (match[1])
  181. return this.closingBracketBlock(session, match[1], row, i);
  182. return session.getCommentFoldRange(row, i, -1);
  183. }
  184. };
  185. this.getSectionRange = function (session, row) {
  186. var line = session.getLine(row);
  187. var startIndent = line.search(/\S/);
  188. var startRow = row;
  189. var startColumn = line.length;
  190. row = row + 1;
  191. var endRow = row;
  192. var maxRow = session.getLength();
  193. while (++row < maxRow) {
  194. line = session.getLine(row);
  195. var indent = line.search(/\S/);
  196. if (indent === -1)
  197. continue;
  198. if (startIndent > indent)
  199. break;
  200. var subRange = this.getFoldWidgetRange(session, "all", row);
  201. if (subRange) {
  202. if (subRange.start.row <= startRow) {
  203. break;
  204. }
  205. else if (subRange.isMultiLine()) {
  206. row = subRange.end.row;
  207. }
  208. else if (startIndent == indent) {
  209. break;
  210. }
  211. }
  212. endRow = row;
  213. }
  214. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  215. };
  216. this.getCommentRegionBlock = function (session, line, row) {
  217. var startColumn = line.search(/\s*$/);
  218. var maxRow = session.getLength();
  219. var startRow = row;
  220. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  221. var depth = 1;
  222. while (++row < maxRow) {
  223. line = session.getLine(row);
  224. var m = re.exec(line);
  225. if (!m)
  226. continue;
  227. if (m[1])
  228. depth--;
  229. else
  230. depth++;
  231. if (!depth)
  232. break;
  233. }
  234. var endRow = row;
  235. if (endRow > startRow) {
  236. return new Range(startRow, startColumn, endRow, line.length);
  237. }
  238. };
  239. }).call(FoldMode.prototype);
  240. });
  241. ace.define("ace/mode/jexl",["require","exports","module","ace/lib/oop","ace/mode/jexl_highlight_rules","ace/mode/text","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  242. var oop = require("../lib/oop");
  243. var JexlHighlightRules = require("./jexl_highlight_rules").JexlHighlightRules;
  244. var TextMode = require("./text").Mode;
  245. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  246. var Mode = function () {
  247. this.HighlightRules = JexlHighlightRules;
  248. this.$behaviour = this.$defaultBehaviour;
  249. this.foldingRules = new CStyleFoldMode();
  250. };
  251. oop.inherits(Mode, TextMode);
  252. (function () {
  253. this.lineCommentStart = ["//", "##"];
  254. this.blockComment = { start: "/*", end: "*/" };
  255. this.$id = "ace/mode/jexl";
  256. }).call(Mode.prototype);
  257. exports.Mode = Mode;
  258. }); (function() {
  259. ace.require(["ace/mode/jexl"], function(m) {
  260. if (typeof module == "object" && typeof exports == "object" && module) {
  261. module.exports = m;
  262. }
  263. });
  264. })();