Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/json_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 JsonHighlightRules = function () {
5 this.$rules = {
6 "start": [
7 {
8 token: "variable", // single line
9 regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)'
10 }, {
11 token: "string", // single line
12 regex: '"',
13 next: "string"
14 }, {
15 token: "constant.numeric", // hex
16 regex: "0[xX][0-9a-fA-F]+\\b"
17 }, {
18 token: "constant.numeric", // float
19 regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
20 }, {
21 token: "constant.language.boolean",
22 regex: "(?:true|false)\\b"
23 }, {
24 token: "text", // single quoted strings are not allowed
25 regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
26 }, {
27 token: "comment", // comments are not allowed, but who cares?
28 regex: "\\/\\/.*$"
29 }, {
30 token: "comment.start", // comments are not allowed, but who cares?
31 regex: "\\/\\*",
32 next: "comment"
33 }, {
34 token: "paren.lparen",
35 regex: "[[({]"
36 }, {
37 token: "paren.rparen",
38 regex: "[\\])}]"
39 }, {
40 token: "punctuation.operator",
41 regex: /[,]/
42 }, {
43 token: "text",
44 regex: "\\s+"
45 }
46 ],
47 "string": [
48 {
49 token: "constant.language.escape",
50 regex: /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/
51 }, {
52 token: "string",
53 regex: '"|$',
54 next: "start"
55 }, {
56 defaultToken: "string"
57 }
58 ],
59 "comment": [
60 {
61 token: "comment.end", // comments are not allowed, but who cares?
62 regex: "\\*\\/",
63 next: "start"
64 }, {
65 defaultToken: "comment"
66 }
67 ]
68 };
69 };
70 oop.inherits(JsonHighlightRules, TextHighlightRules);
71 exports.JsonHighlightRules = JsonHighlightRules;
72
73 });
74
75 ace.define("ace/mode/json5_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/json_highlight_rules"], function(require, exports, module){"use strict";
76 var oop = require("../lib/oop");
77 var JsonHighlightRules = require("./json_highlight_rules").JsonHighlightRules;
78 var Json5HighlightRules = function () {
79 JsonHighlightRules.call(this);
80 var startRules = [{
81 token: "variable",
82 regex: /[a-zA-Z$_\u00a1-\uffff][\w$\u00a1-\uffff]*\s*(?=:)/
83 }, {
84 token: "variable",
85 regex: /['](?:(?:\\.)|(?:[^'\\]))*?[']\s*(?=:)/
86 }, {
87 token: "constant.language.boolean",
88 regex: /(?:null)\b/
89 }, {
90 token: "string",
91 regex: /'/,
92 next: [{
93 token: "constant.language.escape",
94 regex: /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\/bfnrt]|$)/,
95 consumeLineEnd: true
96 }, {
97 token: "string",
98 regex: /'|$/,
99 next: "start"
100 }, {
101 defaultToken: "string"
102 }]
103 }, {
104 token: "string",
105 regex: /"(?![^"]*":)/,
106 next: [{
107 token: "constant.language.escape",
108 regex: /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\/bfnrt]|$)/,
109 consumeLineEnd: true
110 }, {
111 token: "string",
112 regex: /"|$/,
113 next: "start"
114 }, {
115 defaultToken: "string"
116 }]
117 }, {
118 token: "constant.numeric",
119 regex: /[+-]?(?:Infinity|NaN)\b/
120 }];
121 for (var key in this.$rules)
122 this.$rules[key].unshift.apply(this.$rules[key], startRules);
123 this.normalizeRules();
124 };
125 oop.inherits(Json5HighlightRules, JsonHighlightRules);
126 exports.Json5HighlightRules = Json5HighlightRules;
127
128 });
129
130 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
131 var Range = require("../range").Range;
132 var MatchingBraceOutdent = function () { };
133 (function () {
134 this.checkOutdent = function (line, input) {
135 if (!/^\s+$/.test(line))
136 return false;
137 return /^\s*\}/.test(input);
138 };
139 this.autoOutdent = function (doc, row) {
140 var line = doc.getLine(row);
141 var match = line.match(/^(\s*\})/);
142 if (!match)
143 return 0;
144 var column = match[1].length;
145 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
146 if (!openBracePos || openBracePos.row == row)
147 return 0;
148 var indent = this.$getIndent(doc.getLine(openBracePos.row));
149 doc.replace(new Range(row, 0, row, column - 1), indent);
150 };
151 this.$getIndent = function (line) {
152 return line.match(/^\s*/)[0];
153 };
154 }).call(MatchingBraceOutdent.prototype);
155 exports.MatchingBraceOutdent = MatchingBraceOutdent;
156
157 });
158
159 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";
160 var oop = require("../../lib/oop");
161 var Range = require("../../range").Range;
162 var BaseFoldMode = require("./fold_mode").FoldMode;
163 var FoldMode = exports.FoldMode = function (commentRegex) {
164 if (commentRegex) {
165 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
166 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
167 }
168 };
169 oop.inherits(FoldMode, BaseFoldMode);
170 (function () {
171 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
172 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
173 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
174 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
175 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
176 this._getFoldWidgetBase = this.getFoldWidget;
177 this.getFoldWidget = function (session, foldStyle, row) {
178 var line = session.getLine(row);
179 if (this.singleLineBlockCommentRe.test(line)) {
180 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
181 return "";
182 }
183 var fw = this._getFoldWidgetBase(session, foldStyle, row);
184 if (!fw && this.startRegionRe.test(line))
185 return "start"; // lineCommentRegionStart
186 return fw;
187 };
188 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
189 var line = session.getLine(row);
190 if (this.startRegionRe.test(line))
191 return this.getCommentRegionBlock(session, line, row);
192 var match = line.match(this.foldingStartMarker);
193 if (match) {
194 var i = match.index;
195 if (match[1])
196 return this.openingBracketBlock(session, match[1], row, i);
197 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
198 if (range && !range.isMultiLine()) {
199 if (forceMultiline) {
200 range = this.getSectionRange(session, row);
201 }
202 else if (foldStyle != "all")
203 range = null;
204 }
205 return range;
206 }
207 if (foldStyle === "markbegin")
208 return;
209 var match = line.match(this.foldingStopMarker);
210 if (match) {
211 var i = match.index + match[0].length;
212 if (match[1])
213 return this.closingBracketBlock(session, match[1], row, i);
214 return session.getCommentFoldRange(row, i, -1);
215 }
216 };
217 this.getSectionRange = function (session, row) {
218 var line = session.getLine(row);
219 var startIndent = line.search(/\S/);
220 var startRow = row;
221 var startColumn = line.length;
222 row = row + 1;
223 var endRow = row;
224 var maxRow = session.getLength();
225 while (++row < maxRow) {
226 line = session.getLine(row);
227 var indent = line.search(/\S/);
228 if (indent === -1)
229 continue;
230 if (startIndent > indent)
231 break;
232 var subRange = this.getFoldWidgetRange(session, "all", row);
233 if (subRange) {
234 if (subRange.start.row <= startRow) {
235 break;
236 }
237 else if (subRange.isMultiLine()) {
238 row = subRange.end.row;
239 }
240 else if (startIndent == indent) {
241 break;
242 }
243 }
244 endRow = row;
245 }
246 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
247 };
248 this.getCommentRegionBlock = function (session, line, row) {
249 var startColumn = line.search(/\s*$/);
250 var maxRow = session.getLength();
251 var startRow = row;
252 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
253 var depth = 1;
254 while (++row < maxRow) {
255 line = session.getLine(row);
256 var m = re.exec(line);
257 if (!m)
258 continue;
259 if (m[1])
260 depth--;
261 else
262 depth++;
263 if (!depth)
264 break;
265 }
266 var endRow = row;
267 if (endRow > startRow) {
268 return new Range(startRow, startColumn, endRow, line.length);
269 }
270 };
271 }).call(FoldMode.prototype);
272
273 });
274
275 ace.define("ace/mode/json5",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/json5_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
276 var oop = require("../lib/oop");
277 var TextMode = require("./text").Mode;
278 var HighlightRules = require("./json5_highlight_rules").Json5HighlightRules;
279 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
280 var CStyleFoldMode = require("./folding/cstyle").FoldMode;
281 var Mode = function () {
282 this.HighlightRules = HighlightRules;
283 this.$outdent = new MatchingBraceOutdent();
284 this.$behaviour = this.$defaultBehaviour;
285 this.foldingRules = new CStyleFoldMode();
286 };
287 oop.inherits(Mode, TextMode);
288 (function () {
289 this.lineCommentStart = "//";
290 this.blockComment = { start: "/*", end: "*/" };
291 this.checkOutdent = function (state, line, input) {
292 return this.$outdent.checkOutdent(line, input);
293 };
294 this.autoOutdent = function (state, doc, row) {
295 this.$outdent.autoOutdent(doc, row);
296 };
297 this.$id = "ace/mode/json5";
298 }).call(Mode.prototype);
299 exports.Mode = Mode;
300
301 }); (function() {
302 ace.require(["ace/mode/json5"], function(m) {
303 if (typeof module == "object" && typeof exports == "object" && module) {
304 module.exports = m;
305 }
306 });
307 })();
308