Projekt

Obecné

Profil

Stáhnout (12.3 KB) Statistiky
| Větev: | Tag: | Revize:
1
ace.define("ace/mode/doc_comment_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 DocCommentHighlightRules = function() {
8
    this.$rules = {
9
        "start" : [ {
10
            token : "comment.doc.tag",
11
            regex : "@[\\w\\d_]+" // TODO: fix email addresses
12
        }, 
13
        DocCommentHighlightRules.getTagRule(),
14
        {
15
            defaultToken : "comment.doc",
16
            caseInsensitive: true
17
        }]
18
    };
19
};
20

    
21
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
22

    
23
DocCommentHighlightRules.getTagRule = function(start) {
24
    return {
25
        token : "comment.doc.tag.storage.type",
26
        regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
27
    };
28
};
29

    
30
DocCommentHighlightRules.getStartRule = function(start) {
31
    return {
32
        token : "comment.doc", // doc comment
33
        regex : "\\/\\*(?=\\*)",
34
        next  : start
35
    };
36
};
37

    
38
DocCommentHighlightRules.getEndRule = function (start) {
39
    return {
40
        token : "comment.doc", // closing comment
41
        regex : "\\*\\/",
42
        next  : start
43
    };
44
};
45

    
46

    
47
exports.DocCommentHighlightRules = DocCommentHighlightRules;
48

    
49
});
50

    
51
ace.define("ace/mode/haxe_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
52
"use strict";
53

    
54
var oop = require("../lib/oop");
55

    
56
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
57
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
58

    
59
var HaxeHighlightRules = function() {
60

    
61
    var keywords = (
62
        "break|case|cast|catch|class|continue|default|else|enum|extends|for|function|if|implements|import|in|inline|interface|new|override|package|private|public|return|static|super|switch|this|throw|trace|try|typedef|untyped|var|while|Array|Void|Bool|Int|UInt|Float|Dynamic|String|List|Hash|IntHash|Error|Unknown|Type|Std"
63
    );
64

    
65
    var buildinConstants = (
66
        "null|true|false"
67
    );
68

    
69
    var keywordMapper = this.createKeywordMapper({
70
        "variable.language": "this",
71
        "keyword": keywords,
72
        "constant.language": buildinConstants
73
    }, "identifier");
74

    
75
    this.$rules = {
76
        "start" : [
77
            {
78
                token : "comment",
79
                regex : "\\/\\/.*$"
80
            },
81
            DocCommentHighlightRules.getStartRule("doc-start"),
82
            {
83
                token : "comment", // multi line comment
84
                regex : "\\/\\*",
85
                next : "comment"
86
            }, {
87
                token : "string.regexp",
88
                regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
89
            }, {
90
                token : "string", // single line
91
                regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
92
            }, {
93
                token : "string", // single line
94
                regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
95
            }, {
96
                token : "constant.numeric", // hex
97
                regex : "0[xX][0-9a-fA-F]+\\b"
98
            }, {
99
                token : "constant.numeric", // float
100
                regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
101
            }, {
102
                token : "constant.language.boolean",
103
                regex : "(?:true|false)\\b"
104
            }, {
105
                token : keywordMapper,
106
                regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
107
            }, {
108
                token : "keyword.operator",
109
                regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
110
            }, {
111
                token : "punctuation.operator",
112
                regex : "\\?|\\:|\\,|\\;|\\."
113
            }, {
114
                token : "paren.lparen",
115
                regex : "[[({<]"
116
            }, {
117
                token : "paren.rparen",
118
                regex : "[\\])}>]"
119
            }, {
120
                token : "text",
121
                regex : "\\s+"
122
            }
123
        ],
124
        "comment" : [
125
            {
126
                token : "comment", // closing comment
127
                regex : "\\*\\/",
128
                next : "start"
129
            }, {
130
                defaultToken : "comment"
131
            }
132
        ]
133
    };
134

    
135
    this.embedRules(DocCommentHighlightRules, "doc-",
136
        [ DocCommentHighlightRules.getEndRule("start") ]);
137
};
138

    
139
oop.inherits(HaxeHighlightRules, TextHighlightRules);
140

    
141
exports.HaxeHighlightRules = HaxeHighlightRules;
142
});
143

    
144
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
145
"use strict";
146

    
147
var Range = require("../range").Range;
148

    
149
var MatchingBraceOutdent = function() {};
150

    
151
(function() {
152

    
153
    this.checkOutdent = function(line, input) {
154
        if (! /^\s+$/.test(line))
155
            return false;
156

    
157
        return /^\s*\}/.test(input);
158
    };
159

    
160
    this.autoOutdent = function(doc, row) {
161
        var line = doc.getLine(row);
162
        var match = line.match(/^(\s*\})/);
163

    
164
        if (!match) return 0;
165

    
166
        var column = match[1].length;
167
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
168

    
169
        if (!openBracePos || openBracePos.row == row) return 0;
170

    
171
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
172
        doc.replace(new Range(row, 0, row, column-1), indent);
173
    };
174

    
175
    this.$getIndent = function(line) {
176
        return line.match(/^\s*/)[0];
177
    };
178

    
179
}).call(MatchingBraceOutdent.prototype);
180

    
181
exports.MatchingBraceOutdent = MatchingBraceOutdent;
182
});
183

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

    
187
var oop = require("../../lib/oop");
188
var Range = require("../../range").Range;
189
var BaseFoldMode = require("./fold_mode").FoldMode;
190

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

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

    
227
    this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
228
        var line = session.getLine(row);
229
        
230
        if (this.startRegionRe.test(line))
231
            return this.getCommentRegionBlock(session, line, row);
232
        
233
        var match = line.match(this.foldingStartMarker);
234
        if (match) {
235
            var i = match.index;
236

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

    
252
        if (foldStyle === "markbegin")
253
            return;
254

    
255
        var match = line.match(this.foldingStopMarker);
256
        if (match) {
257
            var i = match.index + match[0].length;
258

    
259
            if (match[1])
260
                return this.closingBracketBlock(session, match[1], row, i);
261

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

    
311
            if (!depth) break;
312
        }
313

    
314
        var endRow = row;
315
        if (endRow > startRow) {
316
            return new Range(startRow, startColumn, endRow, line.length);
317
        }
318
    };
319

    
320
}).call(FoldMode.prototype);
321

    
322
});
323

    
324
ace.define("ace/mode/haxe",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/haxe_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
325
"use strict";
326

    
327
var oop = require("../lib/oop");
328
var TextMode = require("./text").Mode;
329
var HaxeHighlightRules = require("./haxe_highlight_rules").HaxeHighlightRules;
330
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
331
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
332
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
333

    
334
var Mode = function() {
335
    this.HighlightRules = HaxeHighlightRules;
336
    
337
    this.$outdent = new MatchingBraceOutdent();
338
    this.$behaviour = new CstyleBehaviour();
339
    this.foldingRules = new CStyleFoldMode();
340
};
341
oop.inherits(Mode, TextMode);
342

    
343
(function() {
344
    this.lineCommentStart = "//";
345
    this.blockComment = {start: "/*", end: "*/"};
346
    
347
    this.getNextLineIndent = function(state, line, tab) {
348
        var indent = this.$getIndent(line);
349

    
350
        var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
351
        var tokens = tokenizedLine.tokens;
352

    
353
        if (tokens.length && tokens[tokens.length-1].type == "comment") {
354
            return indent;
355
        }
356

    
357
        if (state == "start") {
358
            var match = line.match(/^.*[\{\(\[]\s*$/);
359
            if (match) {
360
                indent += tab;
361
            }
362
        }
363

    
364
        return indent;
365
    };
366

    
367
    this.checkOutdent = function(state, line, input) {
368
        return this.$outdent.checkOutdent(line, input);
369
    };
370

    
371
    this.autoOutdent = function(state, doc, row) {
372
        this.$outdent.autoOutdent(doc, row);
373
    };
374

    
375
    this.$id = "ace/mode/haxe";
376
}).call(Mode.prototype);
377

    
378
exports.Mode = Mode;
379
});                (function() {
380
                    ace.require(["ace/mode/haxe"], function(m) {
381
                        if (typeof module == "object" && typeof exports == "object" && module) {
382
                            module.exports = m;
383
                        }
384
                    });
385
                })();
386
            
(86-86/244)