Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-json.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/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
76 var Range = require("../range").Range;
77 var MatchingBraceOutdent = function () { };
78 (function () {
79 this.checkOutdent = function (line, input) {
80 if (!/^\s+$/.test(line))
81 return false;
82 return /^\s*\}/.test(input);
83 };
84 this.autoOutdent = function (doc, row) {
85 var line = doc.getLine(row);
86 var match = line.match(/^(\s*\})/);
87 if (!match)
88 return 0;
89 var column = match[1].length;
90 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
91 if (!openBracePos || openBracePos.row == row)
92 return 0;
93 var indent = this.$getIndent(doc.getLine(openBracePos.row));
94 doc.replace(new Range(row, 0, row, column - 1), indent);
95 };
96 this.$getIndent = function (line) {
97 return line.match(/^\s*/)[0];
98 };
99 }).call(MatchingBraceOutdent.prototype);
100 exports.MatchingBraceOutdent = MatchingBraceOutdent;
101
102 });
103
104 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";
105 var oop = require("../../lib/oop");
106 var Range = require("../../range").Range;
107 var BaseFoldMode = require("./fold_mode").FoldMode;
108 var FoldMode = exports.FoldMode = function (commentRegex) {
109 if (commentRegex) {
110 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
111 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
112 }
113 };
114 oop.inherits(FoldMode, BaseFoldMode);
115 (function () {
116 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
117 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
118 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
119 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
120 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
121 this._getFoldWidgetBase = this.getFoldWidget;
122 this.getFoldWidget = function (session, foldStyle, row) {
123 var line = session.getLine(row);
124 if (this.singleLineBlockCommentRe.test(line)) {
125 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
126 return "";
127 }
128 var fw = this._getFoldWidgetBase(session, foldStyle, row);
129 if (!fw && this.startRegionRe.test(line))
130 return "start"; // lineCommentRegionStart
131 return fw;
132 };
133 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
134 var line = session.getLine(row);
135 if (this.startRegionRe.test(line))
136 return this.getCommentRegionBlock(session, line, row);
137 var match = line.match(this.foldingStartMarker);
138 if (match) {
139 var i = match.index;
140 if (match[1])
141 return this.openingBracketBlock(session, match[1], row, i);
142 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
143 if (range && !range.isMultiLine()) {
144 if (forceMultiline) {
145 range = this.getSectionRange(session, row);
146 }
147 else if (foldStyle != "all")
148 range = null;
149 }
150 return range;
151 }
152 if (foldStyle === "markbegin")
153 return;
154 var match = line.match(this.foldingStopMarker);
155 if (match) {
156 var i = match.index + match[0].length;
157 if (match[1])
158 return this.closingBracketBlock(session, match[1], row, i);
159 return session.getCommentFoldRange(row, i, -1);
160 }
161 };
162 this.getSectionRange = function (session, row) {
163 var line = session.getLine(row);
164 var startIndent = line.search(/\S/);
165 var startRow = row;
166 var startColumn = line.length;
167 row = row + 1;
168 var endRow = row;
169 var maxRow = session.getLength();
170 while (++row < maxRow) {
171 line = session.getLine(row);
172 var indent = line.search(/\S/);
173 if (indent === -1)
174 continue;
175 if (startIndent > indent)
176 break;
177 var subRange = this.getFoldWidgetRange(session, "all", row);
178 if (subRange) {
179 if (subRange.start.row <= startRow) {
180 break;
181 }
182 else if (subRange.isMultiLine()) {
183 row = subRange.end.row;
184 }
185 else if (startIndent == indent) {
186 break;
187 }
188 }
189 endRow = row;
190 }
191 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
192 };
193 this.getCommentRegionBlock = function (session, line, row) {
194 var startColumn = line.search(/\s*$/);
195 var maxRow = session.getLength();
196 var startRow = row;
197 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
198 var depth = 1;
199 while (++row < maxRow) {
200 line = session.getLine(row);
201 var m = re.exec(line);
202 if (!m)
203 continue;
204 if (m[1])
205 depth--;
206 else
207 depth++;
208 if (!depth)
209 break;
210 }
211 var endRow = row;
212 if (endRow > startRow) {
213 return new Range(startRow, startColumn, endRow, line.length);
214 }
215 };
216 }).call(FoldMode.prototype);
217
218 });
219
220 ace.define("ace/mode/json",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/json_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle","ace/worker/worker_client"], function(require, exports, module){"use strict";
221 var oop = require("../lib/oop");
222 var TextMode = require("./text").Mode;
223 var HighlightRules = require("./json_highlight_rules").JsonHighlightRules;
224 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
225 var CStyleFoldMode = require("./folding/cstyle").FoldMode;
226 var WorkerClient = require("../worker/worker_client").WorkerClient;
227 var Mode = function () {
228 this.HighlightRules = HighlightRules;
229 this.$outdent = new MatchingBraceOutdent();
230 this.$behaviour = this.$defaultBehaviour;
231 this.foldingRules = new CStyleFoldMode();
232 };
233 oop.inherits(Mode, TextMode);
234 (function () {
235 this.lineCommentStart = "//";
236 this.blockComment = { start: "/*", end: "*/" };
237 this.getNextLineIndent = function (state, line, tab) {
238 var indent = this.$getIndent(line);
239 if (state == "start") {
240 var match = line.match(/^.*[\{\(\[]\s*$/);
241 if (match) {
242 indent += tab;
243 }
244 }
245 return indent;
246 };
247 this.checkOutdent = function (state, line, input) {
248 return this.$outdent.checkOutdent(line, input);
249 };
250 this.autoOutdent = function (state, doc, row) {
251 this.$outdent.autoOutdent(doc, row);
252 };
253 this.createWorker = function (session) {
254 var worker = new WorkerClient(["ace"], "ace/mode/json_worker", "JsonWorker");
255 worker.attachToDocument(session.getDocument());
256 worker.on("annotate", function (e) {
257 session.setAnnotations(e.data);
258 });
259 worker.on("terminate", function () {
260 session.clearAnnotations();
261 });
262 return worker;
263 };
264 this.$id = "ace/mode/json";
265 }).call(Mode.prototype);
266 exports.Mode = Mode;
267
268 }); (function() {
269 ace.require(["ace/mode/json"], function(m) {
270 if (typeof module == "object" && typeof exports == "object" && module) {
271 module.exports = m;
272 }
273 });
274 })();
275