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