Projekt

Obecné

Profil

Stáhnout (11.3 KB) Statistiky
| Větev: | Tag: | Revize:
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 : "text", // single quoted strings are not allowed
28
                regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
29
            }, {
30
                token : "comment", // comments are not allowed, but who cares?
31
                regex : "\\/\\/.*$"
32
            }, {
33
                token : "comment.start", // comments are not allowed, but who cares?
34
                regex : "\\/\\*",
35
                next  : "comment"
36
            }, {
37
                token : "paren.lparen",
38
                regex : "[[({]"
39
            }, {
40
                token : "paren.rparen",
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
};
71

    
72
oop.inherits(JsonHighlightRules, TextHighlightRules);
73

    
74
exports.JsonHighlightRules = JsonHighlightRules;
75
});
76

    
77
ace.define("ace/mode/json5_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/json_highlight_rules"], function(require, exports, module) {
78
"use strict";
79

    
80
var oop = require("../lib/oop");
81
var JsonHighlightRules = require("./json_highlight_rules").JsonHighlightRules;
82

    
83
var Json5HighlightRules = function() {
84
    JsonHighlightRules.call(this);
85

    
86
    var startRules = [{
87
        token : "variable",
88
        regex : /[a-zA-Z$_\u00a1-\uffff][\w$\u00a1-\uffff]*\s*(?=:)/
89
    }, {
90
        token : "variable",
91
        regex : /['](?:(?:\\.)|(?:[^'\\]))*?[']\s*(?=:)/
92
    }, {
93
        token : "constant.language.boolean",
94
        regex : /(?:null)\b/
95
    }, {
96
        token : "string",
97
        regex : /'/,
98
        next  : [{
99
            token : "constant.language.escape",
100
            regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\/bfnrt]|$)/,
101
            consumeLineEnd  : true
102
        }, {
103
            token : "string",
104
            regex : /'|$/,
105
            next  : "start"
106
        }, {
107
            defaultToken : "string"
108
        }]
109
    }, {
110
        token : "string",
111
        regex : /"(?![^"]*":)/,
112
        next  : [{
113
            token : "constant.language.escape",
114
            regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\/bfnrt]|$)/,
115
            consumeLineEnd  : true
116
        }, {
117
            token : "string",
118
            regex : /"|$/,
119
            next  : "start"
120
        }, {
121
            defaultToken : "string"
122
        }]
123
    }, {
124
        token : "constant.numeric",
125
        regex : /[+-]?(?:Infinity|NaN)\b/
126
    }];
127

    
128
    for (var key in this.$rules)
129
        this.$rules[key].unshift.apply(this.$rules[key], startRules);
130

    
131
    this.normalizeRules();
132
};
133

    
134
oop.inherits(Json5HighlightRules, JsonHighlightRules);
135

    
136
exports.Json5HighlightRules = Json5HighlightRules;
137
});
138

    
139
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
140
"use strict";
141

    
142
var Range = require("../range").Range;
143

    
144
var MatchingBraceOutdent = function() {};
145

    
146
(function() {
147

    
148
    this.checkOutdent = function(line, input) {
149
        if (! /^\s+$/.test(line))
150
            return false;
151

    
152
        return /^\s*\}/.test(input);
153
    };
154

    
155
    this.autoOutdent = function(doc, row) {
156
        var line = doc.getLine(row);
157
        var match = line.match(/^(\s*\})/);
158

    
159
        if (!match) return 0;
160

    
161
        var column = match[1].length;
162
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
163

    
164
        if (!openBracePos || openBracePos.row == row) return 0;
165

    
166
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
167
        doc.replace(new Range(row, 0, row, column-1), indent);
168
    };
169

    
170
    this.$getIndent = function(line) {
171
        return line.match(/^\s*/)[0];
172
    };
173

    
174
}).call(MatchingBraceOutdent.prototype);
175

    
176
exports.MatchingBraceOutdent = MatchingBraceOutdent;
177
});
178

    
179
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
180
"use strict";
181

    
182
var oop = require("../../lib/oop");
183
var Range = require("../../range").Range;
184
var BaseFoldMode = require("./fold_mode").FoldMode;
185

    
186
var FoldMode = exports.FoldMode = function(commentRegex) {
187
    if (commentRegex) {
188
        this.foldingStartMarker = new RegExp(
189
            this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
190
        );
191
        this.foldingStopMarker = new RegExp(
192
            this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
193
        );
194
    }
195
};
196
oop.inherits(FoldMode, BaseFoldMode);
197

    
198
(function() {
199
    
200
    this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
201
    this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
202
    this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
203
    this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
204
    this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
205
    this._getFoldWidgetBase = this.getFoldWidget;
206
    this.getFoldWidget = function(session, foldStyle, row) {
207
        var line = session.getLine(row);
208
    
209
        if (this.singleLineBlockCommentRe.test(line)) {
210
            if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
211
                return "";
212
        }
213
    
214
        var fw = this._getFoldWidgetBase(session, foldStyle, row);
215
    
216
        if (!fw && this.startRegionRe.test(line))
217
            return "start"; // lineCommentRegionStart
218
    
219
        return fw;
220
    };
221

    
222
    this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
223
        var line = session.getLine(row);
224
        
225
        if (this.startRegionRe.test(line))
226
            return this.getCommentRegionBlock(session, line, row);
227
        
228
        var match = line.match(this.foldingStartMarker);
229
        if (match) {
230
            var i = match.index;
231

    
232
            if (match[1])
233
                return this.openingBracketBlock(session, match[1], row, i);
234
                
235
            var range = session.getCommentFoldRange(row, i + match[0].length, 1);
236
            
237
            if (range && !range.isMultiLine()) {
238
                if (forceMultiline) {
239
                    range = this.getSectionRange(session, row);
240
                } else if (foldStyle != "all")
241
                    range = null;
242
            }
243
            
244
            return range;
245
        }
246

    
247
        if (foldStyle === "markbegin")
248
            return;
249

    
250
        var match = line.match(this.foldingStopMarker);
251
        if (match) {
252
            var i = match.index + match[0].length;
253

    
254
            if (match[1])
255
                return this.closingBracketBlock(session, match[1], row, i);
256

    
257
            return session.getCommentFoldRange(row, i, -1);
258
        }
259
    };
260
    
261
    this.getSectionRange = function(session, row) {
262
        var line = session.getLine(row);
263
        var startIndent = line.search(/\S/);
264
        var startRow = row;
265
        var startColumn = line.length;
266
        row = row + 1;
267
        var endRow = row;
268
        var maxRow = session.getLength();
269
        while (++row < maxRow) {
270
            line = session.getLine(row);
271
            var indent = line.search(/\S/);
272
            if (indent === -1)
273
                continue;
274
            if  (startIndent > indent)
275
                break;
276
            var subRange = this.getFoldWidgetRange(session, "all", row);
277
            
278
            if (subRange) {
279
                if (subRange.start.row <= startRow) {
280
                    break;
281
                } else if (subRange.isMultiLine()) {
282
                    row = subRange.end.row;
283
                } else if (startIndent == indent) {
284
                    break;
285
                }
286
            }
287
            endRow = row;
288
        }
289
        
290
        return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
291
    };
292
    this.getCommentRegionBlock = function(session, line, row) {
293
        var startColumn = line.search(/\s*$/);
294
        var maxRow = session.getLength();
295
        var startRow = row;
296
        
297
        var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
298
        var depth = 1;
299
        while (++row < maxRow) {
300
            line = session.getLine(row);
301
            var m = re.exec(line);
302
            if (!m) continue;
303
            if (m[1]) depth--;
304
            else depth++;
305

    
306
            if (!depth) break;
307
        }
308

    
309
        var endRow = row;
310
        if (endRow > startRow) {
311
            return new Range(startRow, startColumn, endRow, line.length);
312
        }
313
    };
314

    
315
}).call(FoldMode.prototype);
316

    
317
});
318

    
319
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/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
320
"use strict";
321

    
322
var oop = require("../lib/oop");
323
var TextMode = require("./text").Mode;
324
var HighlightRules = require("./json5_highlight_rules").Json5HighlightRules;
325
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
326
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
327
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
328

    
329
var Mode = function() {
330
    this.HighlightRules = HighlightRules;
331
    this.$outdent = new MatchingBraceOutdent();
332
    this.$behaviour = new CstyleBehaviour();
333
    this.foldingRules = new CStyleFoldMode();
334
};
335
oop.inherits(Mode, TextMode);
336

    
337
(function() {
338
    this.lineCommentStart = "//";
339
    this.blockComment = {start: "/*", end: "*/"};
340

    
341
    this.checkOutdent = function(state, line, input) {
342
        return this.$outdent.checkOutdent(line, input);
343
    };
344

    
345
    this.autoOutdent = function(state, doc, row) {
346
        this.$outdent.autoOutdent(doc, row);
347
    };
348

    
349
    this.$id = "ace/mode/json5";
350
}).call(Mode.prototype);
351

    
352
exports.Mode = Mode;
353
});                (function() {
354
                    ace.require(["ace/mode/json5"], function(m) {
355
                        if (typeof module == "object" && typeof exports == "object" && module) {
356
                            module.exports = m;
357
                        }
358
                    });
359
                })();
360
            
(98-98/244)