Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-terraform.js

raw symbols SCIP
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 });
172
173 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";
174 var oop = require("../../lib/oop");
175 var Range = require("../../range").Range;
176 var BaseFoldMode = require("./fold_mode").FoldMode;
177 var FoldMode = exports.FoldMode = function (commentRegex) {
178 if (commentRegex) {
179 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
180 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
181 }
182 };
183 oop.inherits(FoldMode, BaseFoldMode);
184 (function () {
185 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
186 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
187 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
188 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
189 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
190 this._getFoldWidgetBase = this.getFoldWidget;
191 this.getFoldWidget = function (session, foldStyle, row) {
192 var line = session.getLine(row);
193 if (this.singleLineBlockCommentRe.test(line)) {
194 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
195 return "";
196 }
197 var fw = this._getFoldWidgetBase(session, foldStyle, row);
198 if (!fw && this.startRegionRe.test(line))
199 return "start"; // lineCommentRegionStart
200 return fw;
201 };
202 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
203 var line = session.getLine(row);
204 if (this.startRegionRe.test(line))
205 return this.getCommentRegionBlock(session, line, row);
206 var match = line.match(this.foldingStartMarker);
207 if (match) {
208 var i = match.index;
209 if (match[1])
210 return this.openingBracketBlock(session, match[1], row, i);
211 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
212 if (range && !range.isMultiLine()) {
213 if (forceMultiline) {
214 range = this.getSectionRange(session, row);
215 }
216 else if (foldStyle != "all")
217 range = null;
218 }
219 return range;
220 }
221 if (foldStyle === "markbegin")
222 return;
223 var match = line.match(this.foldingStopMarker);
224 if (match) {
225 var i = match.index + match[0].length;
226 if (match[1])
227 return this.closingBracketBlock(session, match[1], row, i);
228 return session.getCommentFoldRange(row, i, -1);
229 }
230 };
231 this.getSectionRange = function (session, row) {
232 var line = session.getLine(row);
233 var startIndent = line.search(/\S/);
234 var startRow = row;
235 var startColumn = line.length;
236 row = row + 1;
237 var endRow = row;
238 var maxRow = session.getLength();
239 while (++row < maxRow) {
240 line = session.getLine(row);
241 var indent = line.search(/\S/);
242 if (indent === -1)
243 continue;
244 if (startIndent > indent)
245 break;
246 var subRange = this.getFoldWidgetRange(session, "all", row);
247 if (subRange) {
248 if (subRange.start.row <= startRow) {
249 break;
250 }
251 else if (subRange.isMultiLine()) {
252 row = subRange.end.row;
253 }
254 else if (startIndent == indent) {
255 break;
256 }
257 }
258 endRow = row;
259 }
260 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
261 };
262 this.getCommentRegionBlock = function (session, line, row) {
263 var startColumn = line.search(/\s*$/);
264 var maxRow = session.getLength();
265 var startRow = row;
266 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
267 var depth = 1;
268 while (++row < maxRow) {
269 line = session.getLine(row);
270 var m = re.exec(line);
271 if (!m)
272 continue;
273 if (m[1])
274 depth--;
275 else
276 depth++;
277 if (!depth)
278 break;
279 }
280 var endRow = row;
281 if (endRow > startRow) {
282 return new Range(startRow, startColumn, endRow, line.length);
283 }
284 };
285 }).call(FoldMode.prototype);
286
287 });
288
289 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
290 var Range = require("../range").Range;
291 var MatchingBraceOutdent = function () { };
292 (function () {
293 this.checkOutdent = function (line, input) {
294 if (!/^\s+$/.test(line))
295 return false;
296 return /^\s*\}/.test(input);
297 };
298 this.autoOutdent = function (doc, row) {
299 var line = doc.getLine(row);
300 var match = line.match(/^(\s*\})/);
301 if (!match)
302 return 0;
303 var column = match[1].length;
304 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
305 if (!openBracePos || openBracePos.row == row)
306 return 0;
307 var indent = this.$getIndent(doc.getLine(openBracePos.row));
308 doc.replace(new Range(row, 0, row, column - 1), indent);
309 };
310 this.$getIndent = function (line) {
311 return line.match(/^\s*/)[0];
312 };
313 }).call(MatchingBraceOutdent.prototype);
314 exports.MatchingBraceOutdent = MatchingBraceOutdent;
315
316 });
317
318 ace.define("ace/mode/terraform",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/terraform_highlight_rules","ace/mode/folding/cstyle","ace/mode/matching_brace_outdent"], function(require, exports, module){"use strict";
319 var oop = require("../lib/oop");
320 var TextMode = require("./text").Mode;
321 var TerraformHighlightRules = require("./terraform_highlight_rules").TerraformHighlightRules;
322 var CStyleFoldMode = require("./folding/cstyle").FoldMode;
323 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
324 var Mode = function () {
325 TextMode.call(this);
326 this.HighlightRules = TerraformHighlightRules;
327 this.$outdent = new MatchingBraceOutdent();
328 this.$behaviour = this.$defaultBehaviour;
329 this.foldingRules = new CStyleFoldMode();
330 };
331 oop.inherits(Mode, TextMode);
332 (function () {
333 this.lineCommentStart = ["#", "//"];
334 this.blockComment = { start: "/*", end: "*/" };
335 this.$id = "ace/mode/terraform";
336 }).call(Mode.prototype);
337 exports.Mode = Mode;
338
339 }); (function() {
340 ace.require(["ace/mode/terraform"], function(m) {
341 if (typeof module == "object" && typeof exports == "object" && module) {
342 module.exports = m;
343 }
344 });
345 })();
346