Debian Codegraph @

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

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