1
|
ace.define("ace/mode/puppet_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function (require, exports, module) {
|
2
|
"use strict";
|
3
|
|
4
|
var oop = require("../lib/oop");
|
5
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
6
|
var PuppetHighlightRules = function () {
|
7
|
this.$rules = {
|
8
|
"start": [
|
9
|
{
|
10
|
token: ['keyword.type.puppet', 'constant.class.puppet', 'keyword.inherits.puppet', 'constant.class.puppet'],
|
11
|
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*))?"
|
12
|
},
|
13
|
{
|
14
|
token: ['storage.function.puppet', 'name.function.puppet', 'punctuation.lpar'],
|
15
|
regex: "(^\\s*define)(\\s+[a-zA-Z0-9_:]+\\s*)(\\()",
|
16
|
push:
|
17
|
[{
|
18
|
token: 'punctuation.rpar.puppet',
|
19
|
regex: "\\)",
|
20
|
next: 'pop'
|
21
|
},
|
22
|
{include: "constants"},
|
23
|
{include: "variable"},
|
24
|
{include: "strings"},
|
25
|
{include: "operators"},
|
26
|
{defaultToken: 'string'}]
|
27
|
},
|
28
|
{
|
29
|
token: ["language.support.class", "keyword.operator"],
|
30
|
regex: "\\b([a-zA-Z_]+)(\\s+=>)"
|
31
|
},
|
32
|
{
|
33
|
token: ["exported.resource.puppet", "keyword.name.resource.puppet", "paren.lparen"],
|
34
|
regex: "(\\@\\@)?(\\s*[a-zA-Z_]*)(\\s*\\{)"
|
35
|
},
|
36
|
{
|
37
|
token: "qualified.variable.puppet",
|
38
|
regex: "(\\$([a-z][a-z0-9_]*)?(::[a-z][a-z0-9_]*)*::[a-z0-9_][a-zA-Z0-9_]*)"
|
39
|
},
|
40
|
|
41
|
{
|
42
|
token: "singleline.comment.puppet",
|
43
|
regex: '#(.)*$'
|
44
|
},
|
45
|
{
|
46
|
token: "multiline.comment.begin.puppet",
|
47
|
regex: '^\\s*\\/\\*\\s*$',
|
48
|
push: "blockComment"
|
49
|
},
|
50
|
{
|
51
|
token: "keyword.control.puppet",
|
52
|
regex: "\\b(case|if|unless|else|elsif|in|default:|and|or)\\s+(?!::)"
|
53
|
},
|
54
|
{
|
55
|
token: "keyword.control.puppet",
|
56
|
regex: "\\b(import|default|inherits|include|require|contain|node|application|consumes|environment|site|function|produces)\\b"
|
57
|
},
|
58
|
{
|
59
|
token: "support.function.puppet",
|
60
|
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"
|
61
|
},
|
62
|
{
|
63
|
token: "constant.types.puppet",
|
64
|
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"
|
65
|
},
|
66
|
|
67
|
{
|
68
|
token: "paren.lparen",
|
69
|
regex: "[[({]"
|
70
|
},
|
71
|
{
|
72
|
token: "paren.rparen",
|
73
|
regex: "[\\])}]"
|
74
|
},
|
75
|
{include: "variable"},
|
76
|
{include: "constants"},
|
77
|
{include: "strings"},
|
78
|
{include: "operators"},
|
79
|
{
|
80
|
token: "regexp.begin.string.puppet",
|
81
|
regex: "\\s*(\\/(\\S)+)\\/"
|
82
|
}
|
83
|
],
|
84
|
blockComment: [{
|
85
|
regex: "^\\s*\\/\\*\\s*$",
|
86
|
token: "multiline.comment.begin.puppet",
|
87
|
push: "blockComment"
|
88
|
}, {
|
89
|
regex: "^\\s*\\*\\/\\s*$",
|
90
|
token: "multiline.comment.end.puppet",
|
91
|
next: "pop"
|
92
|
}, {
|
93
|
defaultToken: "comment"
|
94
|
}],
|
95
|
"constants": [
|
96
|
{
|
97
|
token: "constant.language.puppet",
|
98
|
regex: "\\b(false|true|running|stopped|installed|purged|latest|file|directory|held|undef|present|absent|link|mounted|unmounted)\\b"
|
99
|
}
|
100
|
],
|
101
|
"variable": [
|
102
|
{
|
103
|
token: "variable.puppet",
|
104
|
regex: "(\\$[a-z0-9_\{][a-zA-Z0-9_]*)"
|
105
|
}
|
106
|
],
|
107
|
"strings": [
|
108
|
{
|
109
|
token: "punctuation.quote.puppet",
|
110
|
regex: "'",
|
111
|
push:
|
112
|
[{
|
113
|
token: 'punctuation.quote.puppet',
|
114
|
regex: "'",
|
115
|
next: 'pop'
|
116
|
},
|
117
|
{include: "escaped_chars"},
|
118
|
{defaultToken: 'string'}]
|
119
|
},
|
120
|
{
|
121
|
token: "punctuation.quote.puppet",
|
122
|
regex: '"',
|
123
|
push:
|
124
|
[{
|
125
|
token: 'punctuation.quote.puppet',
|
126
|
regex: '"',
|
127
|
next: 'pop'
|
128
|
},
|
129
|
{include: "escaped_chars"},
|
130
|
{include: "variable"},
|
131
|
{defaultToken: 'string'}]
|
132
|
}
|
133
|
],
|
134
|
"escaped_chars": [
|
135
|
{
|
136
|
token: "constant.escaped_char.puppet",
|
137
|
regex: "\\\\."
|
138
|
}
|
139
|
],
|
140
|
"operators": [
|
141
|
{
|
142
|
token: "keyword.operator",
|
143
|
regex: "\\+\\.|\\-\\.|\\*\\.|\\/\\.|#|;;|\\+|\\-|\\*|\\*\\*\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|<-|=|::|,"
|
144
|
}
|
145
|
]
|
146
|
};
|
147
|
this.normalizeRules();
|
148
|
};
|
149
|
|
150
|
|
151
|
oop.inherits(PuppetHighlightRules, TextHighlightRules);
|
152
|
|
153
|
exports.PuppetHighlightRules = PuppetHighlightRules;
|
154
|
});
|
155
|
|
156
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
157
|
"use strict";
|
158
|
|
159
|
var oop = require("../../lib/oop");
|
160
|
var Range = require("../../range").Range;
|
161
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
162
|
|
163
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
164
|
if (commentRegex) {
|
165
|
this.foldingStartMarker = new RegExp(
|
166
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
167
|
);
|
168
|
this.foldingStopMarker = new RegExp(
|
169
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
170
|
);
|
171
|
}
|
172
|
};
|
173
|
oop.inherits(FoldMode, BaseFoldMode);
|
174
|
|
175
|
(function() {
|
176
|
|
177
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
178
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
179
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
180
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
181
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
182
|
this._getFoldWidgetBase = this.getFoldWidget;
|
183
|
this.getFoldWidget = function(session, foldStyle, row) {
|
184
|
var line = session.getLine(row);
|
185
|
|
186
|
if (this.singleLineBlockCommentRe.test(line)) {
|
187
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
188
|
return "";
|
189
|
}
|
190
|
|
191
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
192
|
|
193
|
if (!fw && this.startRegionRe.test(line))
|
194
|
return "start"; // lineCommentRegionStart
|
195
|
|
196
|
return fw;
|
197
|
};
|
198
|
|
199
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
200
|
var line = session.getLine(row);
|
201
|
|
202
|
if (this.startRegionRe.test(line))
|
203
|
return this.getCommentRegionBlock(session, line, row);
|
204
|
|
205
|
var match = line.match(this.foldingStartMarker);
|
206
|
if (match) {
|
207
|
var i = match.index;
|
208
|
|
209
|
if (match[1])
|
210
|
return this.openingBracketBlock(session, match[1], row, i);
|
211
|
|
212
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
213
|
|
214
|
if (range && !range.isMultiLine()) {
|
215
|
if (forceMultiline) {
|
216
|
range = this.getSectionRange(session, row);
|
217
|
} else if (foldStyle != "all")
|
218
|
range = null;
|
219
|
}
|
220
|
|
221
|
return range;
|
222
|
}
|
223
|
|
224
|
if (foldStyle === "markbegin")
|
225
|
return;
|
226
|
|
227
|
var match = line.match(this.foldingStopMarker);
|
228
|
if (match) {
|
229
|
var i = match.index + match[0].length;
|
230
|
|
231
|
if (match[1])
|
232
|
return this.closingBracketBlock(session, match[1], row, i);
|
233
|
|
234
|
return session.getCommentFoldRange(row, i, -1);
|
235
|
}
|
236
|
};
|
237
|
|
238
|
this.getSectionRange = function(session, row) {
|
239
|
var line = session.getLine(row);
|
240
|
var startIndent = line.search(/\S/);
|
241
|
var startRow = row;
|
242
|
var startColumn = line.length;
|
243
|
row = row + 1;
|
244
|
var endRow = row;
|
245
|
var maxRow = session.getLength();
|
246
|
while (++row < maxRow) {
|
247
|
line = session.getLine(row);
|
248
|
var indent = line.search(/\S/);
|
249
|
if (indent === -1)
|
250
|
continue;
|
251
|
if (startIndent > indent)
|
252
|
break;
|
253
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
254
|
|
255
|
if (subRange) {
|
256
|
if (subRange.start.row <= startRow) {
|
257
|
break;
|
258
|
} else if (subRange.isMultiLine()) {
|
259
|
row = subRange.end.row;
|
260
|
} else if (startIndent == indent) {
|
261
|
break;
|
262
|
}
|
263
|
}
|
264
|
endRow = row;
|
265
|
}
|
266
|
|
267
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
268
|
};
|
269
|
this.getCommentRegionBlock = function(session, line, row) {
|
270
|
var startColumn = line.search(/\s*$/);
|
271
|
var maxRow = session.getLength();
|
272
|
var startRow = row;
|
273
|
|
274
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
275
|
var depth = 1;
|
276
|
while (++row < maxRow) {
|
277
|
line = session.getLine(row);
|
278
|
var m = re.exec(line);
|
279
|
if (!m) continue;
|
280
|
if (m[1]) depth--;
|
281
|
else depth++;
|
282
|
|
283
|
if (!depth) break;
|
284
|
}
|
285
|
|
286
|
var endRow = row;
|
287
|
if (endRow > startRow) {
|
288
|
return new Range(startRow, startColumn, endRow, line.length);
|
289
|
}
|
290
|
};
|
291
|
|
292
|
}).call(FoldMode.prototype);
|
293
|
|
294
|
});
|
295
|
|
296
|
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
297
|
"use strict";
|
298
|
|
299
|
var Range = require("../range").Range;
|
300
|
|
301
|
var MatchingBraceOutdent = function() {};
|
302
|
|
303
|
(function() {
|
304
|
|
305
|
this.checkOutdent = function(line, input) {
|
306
|
if (! /^\s+$/.test(line))
|
307
|
return false;
|
308
|
|
309
|
return /^\s*\}/.test(input);
|
310
|
};
|
311
|
|
312
|
this.autoOutdent = function(doc, row) {
|
313
|
var line = doc.getLine(row);
|
314
|
var match = line.match(/^(\s*\})/);
|
315
|
|
316
|
if (!match) return 0;
|
317
|
|
318
|
var column = match[1].length;
|
319
|
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
320
|
|
321
|
if (!openBracePos || openBracePos.row == row) return 0;
|
322
|
|
323
|
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
324
|
doc.replace(new Range(row, 0, row, column-1), indent);
|
325
|
};
|
326
|
|
327
|
this.$getIndent = function(line) {
|
328
|
return line.match(/^\s*/)[0];
|
329
|
};
|
330
|
|
331
|
}).call(MatchingBraceOutdent.prototype);
|
332
|
|
333
|
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
334
|
});
|
335
|
|
336
|
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) {
|
337
|
"use strict";
|
338
|
|
339
|
var oop = require("../lib/oop");
|
340
|
var TextMode = require("./text").Mode;
|
341
|
var PuppetHighlightRules = require("./puppet_highlight_rules").PuppetHighlightRules;
|
342
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
343
|
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
344
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
345
|
|
346
|
var Mode = function () {
|
347
|
TextMode.call(this);
|
348
|
this.HighlightRules = PuppetHighlightRules;
|
349
|
this.$outdent = new MatchingBraceOutdent();
|
350
|
this.$behaviour = new CstyleBehaviour();
|
351
|
this.foldingRules = new CStyleFoldMode();
|
352
|
};
|
353
|
|
354
|
oop.inherits(Mode, TextMode);
|
355
|
|
356
|
|
357
|
(function () {
|
358
|
this.$id = "ace/mode/puppet";
|
359
|
}).call(Mode.prototype);
|
360
|
|
361
|
exports.Mode = Mode;
|
362
|
}); (function() {
|
363
|
ace.require(["ace/mode/puppet"], function(m) {
|
364
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
365
|
module.exports = m;
|
366
|
}
|
367
|
});
|
368
|
})();
|
369
|
|