49429bb63ec76564dabe9c3abd7e5df7.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. ace.define("ace/mode/terraform_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 TerraformHighlightRules = function () {
  5. this.$rules = {
  6. "start": [
  7. {
  8. token: ['storage.function.terraform'],
  9. regex: '\\b(output|resource|data|variable|module|export)\\b'
  10. },
  11. {
  12. token: "variable.terraform",
  13. regex: "\\$\\s",
  14. push: [
  15. {
  16. token: "keyword.terraform",
  17. regex: "(-var-file|-var)"
  18. },
  19. {
  20. token: "variable.terraform",
  21. regex: "\\n|$",
  22. next: "pop"
  23. },
  24. { include: "strings" },
  25. { include: "variables" },
  26. { include: "operators" },
  27. { defaultToken: "text" }
  28. ]
  29. },
  30. {
  31. token: "language.support.class",
  32. regex: "\\b(timeouts|provider|connection|provisioner|lifecycleprovider|atlas)\\b"
  33. },
  34. {
  35. token: "singleline.comment.terraform",
  36. regex: '#.*$'
  37. },
  38. {
  39. token: "singleline.comment.terraform",
  40. regex: '//.*$'
  41. },
  42. {
  43. token: "multiline.comment.begin.terraform",
  44. regex: /\/\*/,
  45. push: "blockComment"
  46. },
  47. {
  48. token: "storage.function.terraform",
  49. regex: "^\\s*(locals|terraform)\\s*{"
  50. },
  51. {
  52. token: "paren.lparen",
  53. regex: "[[({]"
  54. },
  55. {
  56. token: "paren.rparen",
  57. regex: "[\\])}]"
  58. },
  59. { include: "constants" },
  60. { include: "strings" },
  61. { include: "operators" },
  62. { include: "variables" }
  63. ],
  64. blockComment: [{
  65. regex: /\*\//,
  66. token: "multiline.comment.end.terraform",
  67. next: "pop"
  68. }, {
  69. defaultToken: "comment"
  70. }],
  71. "constants": [
  72. {
  73. token: "constant.language.terraform",
  74. regex: "\\b(true|false|yes|no|on|off|EOF)\\b"
  75. },
  76. {
  77. token: "constant.numeric.terraform",
  78. regex: "(\\b([0-9]+)([kKmMgG]b?)?\\b)|(\\b(0x[0-9A-Fa-f]+)([kKmMgG]b?)?\\b)"
  79. }
  80. ],
  81. "variables": [
  82. {
  83. token: ["variable.assignment.terraform", "keyword.operator"],
  84. regex: "\\b([a-zA-Z_]+)(\\s*=)"
  85. }
  86. ],
  87. "interpolated_variables": [
  88. {
  89. token: "variable.terraform",
  90. regex: "\\b(var|self|count|path|local)\\b(?:\\.*[a-zA-Z_-]*)?"
  91. }
  92. ],
  93. "strings": [
  94. {
  95. token: "punctuation.quote.terraform",
  96. regex: "'",
  97. push: [{
  98. token: 'punctuation.quote.terraform',
  99. regex: "'",
  100. next: 'pop'
  101. },
  102. { include: "escaped_chars" },
  103. { defaultToken: 'string' }]
  104. },
  105. {
  106. token: "punctuation.quote.terraform",
  107. regex: '"',
  108. push: [{
  109. token: 'punctuation.quote.terraform',
  110. regex: '"',
  111. next: 'pop'
  112. },
  113. { include: "interpolation" },
  114. { include: "escaped_chars" },
  115. { defaultToken: 'string' }]
  116. }
  117. ],
  118. "escaped_chars": [
  119. {
  120. token: "constant.escaped_char.terraform",
  121. regex: "\\\\."
  122. }
  123. ],
  124. "operators": [
  125. {
  126. token: "keyword.operator",
  127. regex: "\\?|:|==|!=|>|<|>=|<=|&&|\\|\\\||!|%|&|\\*|\\+|\\-|/|="
  128. }
  129. ],
  130. "interpolation": [
  131. {
  132. token: "punctuation.interpolated.begin.terraform",
  133. regex: "\\$?\\$\\{",
  134. push: [{
  135. token: "punctuation.interpolated.end.terraform",
  136. regex: "\\}",
  137. next: "pop"
  138. },
  139. { include: "interpolated_variables" },
  140. { include: "operators" },
  141. { include: "constants" },
  142. { include: "strings" },
  143. { include: "functions" },
  144. { include: "parenthesis" },
  145. { defaultToken: "punctuation" }
  146. ]
  147. }
  148. ],
  149. "functions": [
  150. {
  151. token: "keyword.function.terraform",
  152. regex: "\\b(abs|basename|base64decode|base64encode|base64gzip|base64sha256|base64sha512|bcrypt|ceil|chomp|chunklist|cidrhost|cidrnetmask|cidrsubnet|coalesce|coalescelist|compact|concat|contains|dirname|distinct|element|file|floor|flatten|format|formatlist|indent|index|join|jsonencode|keys|length|list|log|lookup|lower|map|matchkeys|max|merge|min|md5|pathexpand|pow|replace|rsadecrypt|sha1|sha256|sha512|signum|slice|sort|split|substr|timestamp|timeadd|title|transpose|trimspace|upper|urlencode|uuid|values|zipmap)\\b"
  153. }
  154. ],
  155. "parenthesis": [
  156. {
  157. token: "paren.lparen",
  158. regex: "\\["
  159. },
  160. {
  161. token: "paren.rparen",
  162. regex: "\\]"
  163. }
  164. ]
  165. };
  166. this.normalizeRules();
  167. };
  168. oop.inherits(TerraformHighlightRules, TextHighlightRules);
  169. exports.TerraformHighlightRules = TerraformHighlightRules;
  170. });
  171. 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";
  172. var oop = require("../../lib/oop");
  173. var Range = require("../../range").Range;
  174. var BaseFoldMode = require("./fold_mode").FoldMode;
  175. var FoldMode = exports.FoldMode = function (commentRegex) {
  176. if (commentRegex) {
  177. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  178. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  179. }
  180. };
  181. oop.inherits(FoldMode, BaseFoldMode);
  182. (function () {
  183. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  184. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  185. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  186. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  187. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  188. this._getFoldWidgetBase = this.getFoldWidget;
  189. this.getFoldWidget = function (session, foldStyle, row) {
  190. var line = session.getLine(row);
  191. if (this.singleLineBlockCommentRe.test(line)) {
  192. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  193. return "";
  194. }
  195. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  196. if (!fw && this.startRegionRe.test(line))
  197. return "start"; // lineCommentRegionStart
  198. return fw;
  199. };
  200. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  201. var line = session.getLine(row);
  202. if (this.startRegionRe.test(line))
  203. return this.getCommentRegionBlock(session, line, row);
  204. var match = line.match(this.foldingStartMarker);
  205. if (match) {
  206. var i = match.index;
  207. if (match[1])
  208. return this.openingBracketBlock(session, match[1], row, i);
  209. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  210. if (range && !range.isMultiLine()) {
  211. if (forceMultiline) {
  212. range = this.getSectionRange(session, row);
  213. }
  214. else if (foldStyle != "all")
  215. range = null;
  216. }
  217. return range;
  218. }
  219. if (foldStyle === "markbegin")
  220. return;
  221. var match = line.match(this.foldingStopMarker);
  222. if (match) {
  223. var i = match.index + match[0].length;
  224. if (match[1])
  225. return this.closingBracketBlock(session, match[1], row, i);
  226. return session.getCommentFoldRange(row, i, -1);
  227. }
  228. };
  229. this.getSectionRange = function (session, row) {
  230. var line = session.getLine(row);
  231. var startIndent = line.search(/\S/);
  232. var startRow = row;
  233. var startColumn = line.length;
  234. row = row + 1;
  235. var endRow = row;
  236. var maxRow = session.getLength();
  237. while (++row < maxRow) {
  238. line = session.getLine(row);
  239. var indent = line.search(/\S/);
  240. if (indent === -1)
  241. continue;
  242. if (startIndent > indent)
  243. break;
  244. var subRange = this.getFoldWidgetRange(session, "all", row);
  245. if (subRange) {
  246. if (subRange.start.row <= startRow) {
  247. break;
  248. }
  249. else if (subRange.isMultiLine()) {
  250. row = subRange.end.row;
  251. }
  252. else if (startIndent == indent) {
  253. break;
  254. }
  255. }
  256. endRow = row;
  257. }
  258. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  259. };
  260. this.getCommentRegionBlock = function (session, line, row) {
  261. var startColumn = line.search(/\s*$/);
  262. var maxRow = session.getLength();
  263. var startRow = row;
  264. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  265. var depth = 1;
  266. while (++row < maxRow) {
  267. line = session.getLine(row);
  268. var m = re.exec(line);
  269. if (!m)
  270. continue;
  271. if (m[1])
  272. depth--;
  273. else
  274. depth++;
  275. if (!depth)
  276. break;
  277. }
  278. var endRow = row;
  279. if (endRow > startRow) {
  280. return new Range(startRow, startColumn, endRow, line.length);
  281. }
  282. };
  283. }).call(FoldMode.prototype);
  284. });
  285. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  286. var Range = require("../range").Range;
  287. var MatchingBraceOutdent = function () { };
  288. (function () {
  289. this.checkOutdent = function (line, input) {
  290. if (!/^\s+$/.test(line))
  291. return false;
  292. return /^\s*\}/.test(input);
  293. };
  294. this.autoOutdent = function (doc, row) {
  295. var line = doc.getLine(row);
  296. var match = line.match(/^(\s*\})/);
  297. if (!match)
  298. return 0;
  299. var column = match[1].length;
  300. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  301. if (!openBracePos || openBracePos.row == row)
  302. return 0;
  303. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  304. doc.replace(new Range(row, 0, row, column - 1), indent);
  305. };
  306. this.$getIndent = function (line) {
  307. return line.match(/^\s*/)[0];
  308. };
  309. }).call(MatchingBraceOutdent.prototype);
  310. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  311. });
  312. ace.define("ace/mode/terraform",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/terraform_highlight_rules","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle","ace/mode/matching_brace_outdent"], function(require, exports, module){"use strict";
  313. var oop = require("../lib/oop");
  314. var TextMode = require("./text").Mode;
  315. var TerraformHighlightRules = require("./terraform_highlight_rules").TerraformHighlightRules;
  316. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  317. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  318. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  319. var Mode = function () {
  320. TextMode.call(this);
  321. this.HighlightRules = TerraformHighlightRules;
  322. this.$outdent = new MatchingBraceOutdent();
  323. this.$behaviour = new CstyleBehaviour();
  324. this.foldingRules = new CStyleFoldMode();
  325. };
  326. oop.inherits(Mode, TextMode);
  327. (function () {
  328. this.lineCommentStart = ["#", "//"];
  329. this.blockComment = { start: "/*", end: "*/" };
  330. this.$id = "ace/mode/terraform";
  331. }).call(Mode.prototype);
  332. exports.Mode = Mode;
  333. }); (function() {
  334. ace.require(["ace/mode/terraform"], function(m) {
  335. if (typeof module == "object" && typeof exports == "object" && module) {
  336. module.exports = m;
  337. }
  338. });
  339. })();