1
|
ace.define("ace/mode/hjson_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
|
|
7
|
var HjsonHighlightRules = function() {
|
8
|
|
9
|
this.$rules = {
|
10
|
start: [{
|
11
|
include: "#comments"
|
12
|
}, {
|
13
|
include: "#rootObject"
|
14
|
}, {
|
15
|
include: "#value"
|
16
|
}],
|
17
|
"#array": [{
|
18
|
token: "paren.lparen",
|
19
|
regex: /\[/,
|
20
|
push: [{
|
21
|
token: "paren.rparen",
|
22
|
regex: /\]/,
|
23
|
next: "pop"
|
24
|
}, {
|
25
|
include: "#value"
|
26
|
}, {
|
27
|
include: "#comments"
|
28
|
}, {
|
29
|
token: "text",
|
30
|
regex: /,|$/
|
31
|
}, {
|
32
|
token: "invalid.illegal",
|
33
|
regex: /[^\s\]]/
|
34
|
}, {
|
35
|
defaultToken: "array"
|
36
|
}]
|
37
|
}],
|
38
|
"#comments": [{
|
39
|
token: [
|
40
|
"comment.punctuation",
|
41
|
"comment.line"
|
42
|
],
|
43
|
regex: /(#)(.*$)/
|
44
|
}, {
|
45
|
token: "comment.punctuation",
|
46
|
regex: /\/\*/,
|
47
|
push: [{
|
48
|
token: "comment.punctuation",
|
49
|
regex: /\*\//,
|
50
|
next: "pop"
|
51
|
}, {
|
52
|
defaultToken: "comment.block"
|
53
|
}]
|
54
|
}, {
|
55
|
token: [
|
56
|
"comment.punctuation",
|
57
|
"comment.line"
|
58
|
],
|
59
|
regex: /(\/\/)(.*$)/
|
60
|
}],
|
61
|
"#constant": [{
|
62
|
token: "constant",
|
63
|
regex: /\b(?:true|false|null)\b/
|
64
|
}],
|
65
|
"#keyname": [{
|
66
|
token: "keyword",
|
67
|
regex: /(?:[^,\{\[\}\]\s]+|"(?:[^"\\]|\\.)*")\s*(?=:)/
|
68
|
}],
|
69
|
"#mstring": [{
|
70
|
token: "string",
|
71
|
regex: /'''/,
|
72
|
push: [{
|
73
|
token: "string",
|
74
|
regex: /'''/,
|
75
|
next: "pop"
|
76
|
}, {
|
77
|
defaultToken: "string"
|
78
|
}]
|
79
|
}],
|
80
|
"#number": [{
|
81
|
token: "constant.numeric",
|
82
|
regex: /-?(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:[eE][+-]?\d+)?)?/,
|
83
|
comment: "handles integer and decimal numbers"
|
84
|
}],
|
85
|
"#object": [{
|
86
|
token: "paren.lparen",
|
87
|
regex: /\{/,
|
88
|
push: [{
|
89
|
token: "paren.rparen",
|
90
|
regex: /\}/,
|
91
|
next: "pop"
|
92
|
}, {
|
93
|
include: "#keyname"
|
94
|
}, {
|
95
|
include: "#value"
|
96
|
}, {
|
97
|
token: "text",
|
98
|
regex: /:/
|
99
|
}, {
|
100
|
token: "text",
|
101
|
regex: /,/
|
102
|
}, {
|
103
|
defaultToken: "paren"
|
104
|
}]
|
105
|
}],
|
106
|
"#rootObject": [{
|
107
|
token: "paren",
|
108
|
regex: /(?=\s*(?:[^,\{\[\}\]\s]+|"(?:[^"\\]|\\.)*")\s*:)/,
|
109
|
push: [{
|
110
|
token: "paren.rparen",
|
111
|
regex: /---none---/,
|
112
|
next: "pop"
|
113
|
}, {
|
114
|
include: "#keyname"
|
115
|
}, {
|
116
|
include: "#value"
|
117
|
}, {
|
118
|
token: "text",
|
119
|
regex: /:/
|
120
|
}, {
|
121
|
token: "text",
|
122
|
regex: /,/
|
123
|
}, {
|
124
|
defaultToken: "paren"
|
125
|
}]
|
126
|
}],
|
127
|
"#string": [{
|
128
|
token: "string",
|
129
|
regex: /"/,
|
130
|
push: [{
|
131
|
token: "string",
|
132
|
regex: /"/,
|
133
|
next: "pop"
|
134
|
}, {
|
135
|
token: "constant.language.escape",
|
136
|
regex: /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/
|
137
|
}, {
|
138
|
token: "invalid.illegal",
|
139
|
regex: /\\./
|
140
|
}, {
|
141
|
defaultToken: "string"
|
142
|
}]
|
143
|
}],
|
144
|
"#ustring": [{
|
145
|
token: "string",
|
146
|
regex: /\b[^:,0-9\-\{\[\}\]\s].*$/
|
147
|
}],
|
148
|
"#value": [{
|
149
|
include: "#constant"
|
150
|
}, {
|
151
|
include: "#number"
|
152
|
}, {
|
153
|
include: "#string"
|
154
|
}, {
|
155
|
include: "#array"
|
156
|
}, {
|
157
|
include: "#object"
|
158
|
}, {
|
159
|
include: "#comments"
|
160
|
}, {
|
161
|
include: "#mstring"
|
162
|
}, {
|
163
|
include: "#ustring"
|
164
|
}]
|
165
|
};
|
166
|
|
167
|
this.normalizeRules();
|
168
|
};
|
169
|
|
170
|
HjsonHighlightRules.metaData = {
|
171
|
fileTypes: ["hjson"],
|
172
|
foldingStartMarker: "(?x: # turn on extended mode\n ^ # a line beginning with\n \\s* # some optional space\n [{\\[] # the start of an object or array\n (?! # but not followed by\n .* # whatever\n [}\\]] # and the close of an object or array\n ,? # an optional comma\n \\s* # some optional space\n $ # at the end of the line\n )\n | # ...or...\n [{\\[] # the start of an object or array\n \\s* # some optional space\n $ # at the end of the line\n )",
|
173
|
foldingStopMarker: "(?x: # turn on extended mode\n ^ # a line beginning with\n \\s* # some optional space\n [}\\]] # and the close of an object or array\n )",
|
174
|
keyEquivalent: "^~J",
|
175
|
name: "Hjson",
|
176
|
scopeName: "source.hjson"
|
177
|
};
|
178
|
|
179
|
|
180
|
oop.inherits(HjsonHighlightRules, TextHighlightRules);
|
181
|
|
182
|
exports.HjsonHighlightRules = HjsonHighlightRules;
|
183
|
});
|
184
|
|
185
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
186
|
"use strict";
|
187
|
|
188
|
var oop = require("../../lib/oop");
|
189
|
var Range = require("../../range").Range;
|
190
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
191
|
|
192
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
193
|
if (commentRegex) {
|
194
|
this.foldingStartMarker = new RegExp(
|
195
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
196
|
);
|
197
|
this.foldingStopMarker = new RegExp(
|
198
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
199
|
);
|
200
|
}
|
201
|
};
|
202
|
oop.inherits(FoldMode, BaseFoldMode);
|
203
|
|
204
|
(function() {
|
205
|
|
206
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
207
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
208
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
209
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
210
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
211
|
this._getFoldWidgetBase = this.getFoldWidget;
|
212
|
this.getFoldWidget = function(session, foldStyle, row) {
|
213
|
var line = session.getLine(row);
|
214
|
|
215
|
if (this.singleLineBlockCommentRe.test(line)) {
|
216
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
217
|
return "";
|
218
|
}
|
219
|
|
220
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
221
|
|
222
|
if (!fw && this.startRegionRe.test(line))
|
223
|
return "start"; // lineCommentRegionStart
|
224
|
|
225
|
return fw;
|
226
|
};
|
227
|
|
228
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
229
|
var line = session.getLine(row);
|
230
|
|
231
|
if (this.startRegionRe.test(line))
|
232
|
return this.getCommentRegionBlock(session, line, row);
|
233
|
|
234
|
var match = line.match(this.foldingStartMarker);
|
235
|
if (match) {
|
236
|
var i = match.index;
|
237
|
|
238
|
if (match[1])
|
239
|
return this.openingBracketBlock(session, match[1], row, i);
|
240
|
|
241
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
242
|
|
243
|
if (range && !range.isMultiLine()) {
|
244
|
if (forceMultiline) {
|
245
|
range = this.getSectionRange(session, row);
|
246
|
} else if (foldStyle != "all")
|
247
|
range = null;
|
248
|
}
|
249
|
|
250
|
return range;
|
251
|
}
|
252
|
|
253
|
if (foldStyle === "markbegin")
|
254
|
return;
|
255
|
|
256
|
var match = line.match(this.foldingStopMarker);
|
257
|
if (match) {
|
258
|
var i = match.index + match[0].length;
|
259
|
|
260
|
if (match[1])
|
261
|
return this.closingBracketBlock(session, match[1], row, i);
|
262
|
|
263
|
return session.getCommentFoldRange(row, i, -1);
|
264
|
}
|
265
|
};
|
266
|
|
267
|
this.getSectionRange = function(session, row) {
|
268
|
var line = session.getLine(row);
|
269
|
var startIndent = line.search(/\S/);
|
270
|
var startRow = row;
|
271
|
var startColumn = line.length;
|
272
|
row = row + 1;
|
273
|
var endRow = row;
|
274
|
var maxRow = session.getLength();
|
275
|
while (++row < maxRow) {
|
276
|
line = session.getLine(row);
|
277
|
var indent = line.search(/\S/);
|
278
|
if (indent === -1)
|
279
|
continue;
|
280
|
if (startIndent > indent)
|
281
|
break;
|
282
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
283
|
|
284
|
if (subRange) {
|
285
|
if (subRange.start.row <= startRow) {
|
286
|
break;
|
287
|
} else if (subRange.isMultiLine()) {
|
288
|
row = subRange.end.row;
|
289
|
} else if (startIndent == indent) {
|
290
|
break;
|
291
|
}
|
292
|
}
|
293
|
endRow = row;
|
294
|
}
|
295
|
|
296
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
297
|
};
|
298
|
this.getCommentRegionBlock = function(session, line, row) {
|
299
|
var startColumn = line.search(/\s*$/);
|
300
|
var maxRow = session.getLength();
|
301
|
var startRow = row;
|
302
|
|
303
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
304
|
var depth = 1;
|
305
|
while (++row < maxRow) {
|
306
|
line = session.getLine(row);
|
307
|
var m = re.exec(line);
|
308
|
if (!m) continue;
|
309
|
if (m[1]) depth--;
|
310
|
else depth++;
|
311
|
|
312
|
if (!depth) break;
|
313
|
}
|
314
|
|
315
|
var endRow = row;
|
316
|
if (endRow > startRow) {
|
317
|
return new Range(startRow, startColumn, endRow, line.length);
|
318
|
}
|
319
|
};
|
320
|
|
321
|
}).call(FoldMode.prototype);
|
322
|
|
323
|
});
|
324
|
|
325
|
ace.define("ace/mode/hjson",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/hjson_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
|
326
|
"use strict";
|
327
|
|
328
|
var oop = require("../lib/oop");
|
329
|
var TextMode = require("./text").Mode;
|
330
|
var HjsonHighlightRules = require("./hjson_highlight_rules").HjsonHighlightRules;
|
331
|
var FoldMode = require("./folding/cstyle").FoldMode;
|
332
|
|
333
|
var Mode = function() {
|
334
|
this.HighlightRules = HjsonHighlightRules;
|
335
|
this.foldingRules = new FoldMode();
|
336
|
};
|
337
|
oop.inherits(Mode, TextMode);
|
338
|
|
339
|
(function() {
|
340
|
this.lineCommentStart = "//";
|
341
|
this.blockComment = { start: "/*", end: "*/" };
|
342
|
this.$id = "ace/mode/hjson";
|
343
|
}).call(Mode.prototype);
|
344
|
|
345
|
exports.Mode = Mode;
|
346
|
}); (function() {
|
347
|
ace.require(["ace/mode/hjson"], function(m) {
|
348
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
349
|
module.exports = m;
|
350
|
}
|
351
|
});
|
352
|
})();
|
353
|
|