fc044cf204bd7f511182d4c654363401.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. ace.define("ace/mode/puppet_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 PuppetHighlightRules = function () {
  5. this.$rules = {
  6. "start": [
  7. {
  8. token: ['keyword.type.puppet', 'constant.class.puppet', 'keyword.inherits.puppet', 'constant.class.puppet'],
  9. regex: "^\\s*(class)(\\s+(?:[-_A-Za-z0-9\".]+::)*[-_A-Za-z0-9\".]+\\s*)(?:(inherits\\s*)(\\s+(?:[-_A-Za-z0-9\".]+::)*[-_A-Za-z0-9\".]+\\s*))?"
  10. },
  11. {
  12. token: ['storage.function.puppet', 'name.function.puppet', 'punctuation.lpar'],
  13. regex: "(^\\s*define)(\\s+[a-zA-Z0-9_:]+\\s*)(\\()",
  14. push: [{
  15. token: 'punctuation.rpar.puppet',
  16. regex: "\\)",
  17. next: 'pop'
  18. },
  19. { include: "constants" },
  20. { include: "variable" },
  21. { include: "strings" },
  22. { include: "operators" },
  23. { defaultToken: 'string' }]
  24. },
  25. {
  26. token: ["language.support.class", "keyword.operator"],
  27. regex: "\\b([a-zA-Z_]+)(\\s+=>)"
  28. },
  29. {
  30. token: ["exported.resource.puppet", "keyword.name.resource.puppet", "paren.lparen"],
  31. regex: "(\\@\\@)?(\\s*[a-zA-Z_]*)(\\s*\\{)"
  32. },
  33. {
  34. token: "qualified.variable.puppet",
  35. regex: "(\\$([a-z][a-z0-9_]*)?(::[a-z][a-z0-9_]*)*::[a-z0-9_][a-zA-Z0-9_]*)"
  36. },
  37. {
  38. token: "singleline.comment.puppet",
  39. regex: '#(.)*$'
  40. },
  41. {
  42. token: "multiline.comment.begin.puppet",
  43. regex: '^\\s*\\/\\*',
  44. push: "blockComment"
  45. },
  46. {
  47. token: "keyword.control.puppet",
  48. regex: "\\b(case|if|unless|else|elsif|in|default:|and|or)\\s+(?!::)"
  49. },
  50. {
  51. token: "keyword.control.puppet",
  52. regex: "\\b(import|default|inherits|include|require|contain|node|application|consumes|environment|site|function|produces)\\b"
  53. },
  54. {
  55. token: "support.function.puppet",
  56. regex: "\\b(lest|str2bool|escape|gsub|Timestamp|Timespan|with|alert|crit|debug|notice|sprintf|split|step|strftime|slice|shellquote|type|sha1|defined|scanf|reverse_each|regsubst|return|emerg|reduce|err|failed|fail|versioncmp|file|generate|then|info|realize|search|tag|tagged|template|epp|warning|hiera_include|each|assert_type|binary_file|create_resources|dig|digest|filter|lookup|find_file|fqdn_rand|hiera_array|hiera_hash|inline_epp|inline_template|map|match|md5|new|next)\\b"
  57. },
  58. {
  59. token: "constant.types.puppet",
  60. regex: "\\b(String|File|Package|Service|Class|Integer|Array|Catalogentry|Variant|Boolean|Undef|Number|Hash|Float|Numeric|NotUndef|Callable|Optional|Any|Regexp|Sensitive|Sensitive.new|Type|Resource|Default|Enum|Scalar|Collection|Data|Pattern|Tuple|Struct)\\b"
  61. },
  62. {
  63. token: "paren.lparen",
  64. regex: "[[({]"
  65. },
  66. {
  67. token: "paren.rparen",
  68. regex: "[\\])}]"
  69. },
  70. { include: "variable" },
  71. { include: "constants" },
  72. { include: "strings" },
  73. { include: "operators" },
  74. {
  75. token: "regexp.begin.string.puppet",
  76. regex: "\\s*(\\/(\\S)+)\\/"
  77. }
  78. ],
  79. blockComment: [{
  80. regex: "\\*\\/",
  81. token: "multiline.comment.end.puppet",
  82. next: "pop"
  83. }, {
  84. defaultToken: "comment"
  85. }],
  86. "constants": [
  87. {
  88. token: "constant.language.puppet",
  89. regex: "\\b(false|true|running|stopped|installed|purged|latest|file|directory|held|undef|present|absent|link|mounted|unmounted)\\b"
  90. }
  91. ],
  92. "variable": [
  93. {
  94. token: "variable.puppet",
  95. regex: "(\\$[a-z0-9_\{][a-zA-Z0-9_]*)"
  96. }
  97. ],
  98. "strings": [
  99. {
  100. token: "punctuation.quote.puppet",
  101. regex: "'",
  102. push: [{
  103. token: 'punctuation.quote.puppet',
  104. regex: "'",
  105. next: 'pop'
  106. },
  107. { include: "escaped_chars" },
  108. { defaultToken: 'string' }]
  109. },
  110. {
  111. token: "punctuation.quote.puppet",
  112. regex: '"',
  113. push: [{
  114. token: 'punctuation.quote.puppet',
  115. regex: '"',
  116. next: 'pop'
  117. },
  118. { include: "escaped_chars" },
  119. { include: "variable" },
  120. { defaultToken: 'string' }]
  121. }
  122. ],
  123. "escaped_chars": [
  124. {
  125. token: "constant.escaped_char.puppet",
  126. regex: "\\\\."
  127. }
  128. ],
  129. "operators": [
  130. {
  131. token: "keyword.operator",
  132. regex: "\\+\\.|\\-\\.|\\*\\.|\\/\\.|#|;;|\\+|\\-|\\*|\\*\\*\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|<-|=|::|,"
  133. }
  134. ]
  135. };
  136. this.normalizeRules();
  137. };
  138. oop.inherits(PuppetHighlightRules, TextHighlightRules);
  139. exports.PuppetHighlightRules = PuppetHighlightRules;
  140. });
  141. 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";
  142. var oop = require("../../lib/oop");
  143. var Range = require("../../range").Range;
  144. var BaseFoldMode = require("./fold_mode").FoldMode;
  145. var FoldMode = exports.FoldMode = function (commentRegex) {
  146. if (commentRegex) {
  147. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  148. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  149. }
  150. };
  151. oop.inherits(FoldMode, BaseFoldMode);
  152. (function () {
  153. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  154. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  155. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  156. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  157. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  158. this._getFoldWidgetBase = this.getFoldWidget;
  159. this.getFoldWidget = function (session, foldStyle, row) {
  160. var line = session.getLine(row);
  161. if (this.singleLineBlockCommentRe.test(line)) {
  162. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  163. return "";
  164. }
  165. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  166. if (!fw && this.startRegionRe.test(line))
  167. return "start"; // lineCommentRegionStart
  168. return fw;
  169. };
  170. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  171. var line = session.getLine(row);
  172. if (this.startRegionRe.test(line))
  173. return this.getCommentRegionBlock(session, line, row);
  174. var match = line.match(this.foldingStartMarker);
  175. if (match) {
  176. var i = match.index;
  177. if (match[1])
  178. return this.openingBracketBlock(session, match[1], row, i);
  179. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  180. if (range && !range.isMultiLine()) {
  181. if (forceMultiline) {
  182. range = this.getSectionRange(session, row);
  183. }
  184. else if (foldStyle != "all")
  185. range = null;
  186. }
  187. return range;
  188. }
  189. if (foldStyle === "markbegin")
  190. return;
  191. var match = line.match(this.foldingStopMarker);
  192. if (match) {
  193. var i = match.index + match[0].length;
  194. if (match[1])
  195. return this.closingBracketBlock(session, match[1], row, i);
  196. return session.getCommentFoldRange(row, i, -1);
  197. }
  198. };
  199. this.getSectionRange = function (session, row) {
  200. var line = session.getLine(row);
  201. var startIndent = line.search(/\S/);
  202. var startRow = row;
  203. var startColumn = line.length;
  204. row = row + 1;
  205. var endRow = row;
  206. var maxRow = session.getLength();
  207. while (++row < maxRow) {
  208. line = session.getLine(row);
  209. var indent = line.search(/\S/);
  210. if (indent === -1)
  211. continue;
  212. if (startIndent > indent)
  213. break;
  214. var subRange = this.getFoldWidgetRange(session, "all", row);
  215. if (subRange) {
  216. if (subRange.start.row <= startRow) {
  217. break;
  218. }
  219. else if (subRange.isMultiLine()) {
  220. row = subRange.end.row;
  221. }
  222. else if (startIndent == indent) {
  223. break;
  224. }
  225. }
  226. endRow = row;
  227. }
  228. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  229. };
  230. this.getCommentRegionBlock = function (session, line, row) {
  231. var startColumn = line.search(/\s*$/);
  232. var maxRow = session.getLength();
  233. var startRow = row;
  234. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  235. var depth = 1;
  236. while (++row < maxRow) {
  237. line = session.getLine(row);
  238. var m = re.exec(line);
  239. if (!m)
  240. continue;
  241. if (m[1])
  242. depth--;
  243. else
  244. depth++;
  245. if (!depth)
  246. break;
  247. }
  248. var endRow = row;
  249. if (endRow > startRow) {
  250. return new Range(startRow, startColumn, endRow, line.length);
  251. }
  252. };
  253. }).call(FoldMode.prototype);
  254. });
  255. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  256. var Range = require("../range").Range;
  257. var MatchingBraceOutdent = function () { };
  258. (function () {
  259. this.checkOutdent = function (line, input) {
  260. if (!/^\s+$/.test(line))
  261. return false;
  262. return /^\s*\}/.test(input);
  263. };
  264. this.autoOutdent = function (doc, row) {
  265. var line = doc.getLine(row);
  266. var match = line.match(/^(\s*\})/);
  267. if (!match)
  268. return 0;
  269. var column = match[1].length;
  270. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  271. if (!openBracePos || openBracePos.row == row)
  272. return 0;
  273. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  274. doc.replace(new Range(row, 0, row, column - 1), indent);
  275. };
  276. this.$getIndent = function (line) {
  277. return line.match(/^\s*/)[0];
  278. };
  279. }).call(MatchingBraceOutdent.prototype);
  280. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  281. });
  282. ace.define("ace/mode/puppet",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/puppet_highlight_rules","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle","ace/mode/matching_brace_outdent"], function(require, exports, module){"use strict";
  283. var oop = require("../lib/oop");
  284. var TextMode = require("./text").Mode;
  285. var PuppetHighlightRules = require("./puppet_highlight_rules").PuppetHighlightRules;
  286. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  287. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  288. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  289. var Mode = function () {
  290. TextMode.call(this);
  291. this.HighlightRules = PuppetHighlightRules;
  292. this.$outdent = new MatchingBraceOutdent();
  293. this.$behaviour = new CstyleBehaviour();
  294. this.foldingRules = new CStyleFoldMode();
  295. };
  296. oop.inherits(Mode, TextMode);
  297. (function () {
  298. this.lineCommentStart = "#";
  299. this.blockComment = { start: "/*", end: "*/" };
  300. this.$id = "ace/mode/puppet";
  301. }).call(Mode.prototype);
  302. exports.Mode = Mode;
  303. }); (function() {
  304. ace.require(["ace/mode/puppet"], function(m) {
  305. if (typeof module == "object" && typeof exports == "object" && module) {
  306. module.exports = m;
  307. }
  308. });
  309. })();