Projekt

Obecné

Profil

Stáhnout (15.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/apex_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules","ace/mode/doc_comment_highlight_rules"], function(require, exports, module) {
52
"use strict";
53

    
54
var oop = require("../lib/oop");
55
var TextHighlightRules = require("../mode/text_highlight_rules").TextHighlightRules;
56
var DocCommentHighlightRules = require("../mode/doc_comment_highlight_rules").DocCommentHighlightRules;
57

    
58
var ApexHighlightRules = function() {
59
    var mainKeywordMapper = this.createKeywordMapper({
60
        "variable.language": "activate|any|autonomous|begin|bigdecimal|byte|cast|char|collect|const"
61
             + "|end|exit|export|float|goto|group|having|hint|import|inner|into|join|loop|number|object|of|outer"
62
             + "|parallel|pragma|retrieve|returning|search|short|stat|synchronized|then|this_month"
63
             + "|transaction|type|when",
64
        "keyword": "private|protected|public|native|synchronized|abstract|threadsafe|transient|static|final"
65
             + "|and|array|as|asc|break|bulk|by|catch|class|commit|continue|convertcurrency"
66
             + "|delete|desc|do|else|enum|extends|false|final|finally|for|from|future|global"
67
             + "|if|implements|in|insert|instanceof|interface|last_90_days|last_month"
68
             + "|last_n_days|last_week|like|limit|list|map|merge|new|next_90_days|next_month|next_n_days"
69
             + "|next_week|not|null|nulls|on|or|override|package|return"
70
             + "|rollback|savepoint|select|set|sort|super|testmethod|this|this_week|throw|today"
71
             + "|tolabel|tomorrow|trigger|true|try|undelete|update|upsert|using|virtual|webservice"
72
             + "|where|while|yesterday|switch|case|default",
73
        "storage.type":
74
            "def|boolean|byte|char|short|int|float|pblob|date|datetime|decimal|double|id|integer|long|string|time|void|blob|Object",
75
        "constant.language":
76
            "true|false|null|after|before|count|excludes|first|includes|last|order|sharing|with",
77
        "support.function":
78
            "system|apex|label|apexpages|userinfo|schema"
79
    }, "identifier", true);
80
    function keywordMapper(value) {
81
        if (value.slice(-3) == "__c") return "support.function";
82
        return mainKeywordMapper(value);
83
    }
84
    
85
    function string(start, options) {
86
        return {
87
            regex: start + (options.multiline ? "" : "(?=.)"),
88
            token: "string.start",
89
            next: [{
90
                regex: options.escape,
91
                token: "character.escape"
92
            }, {
93
                regex: options.error,
94
                token: "error.invalid"
95
            }, {
96
                regex: start + (options.multiline ? "" : "|$"),
97
                token: "string.end",
98
                next: options.next || "start"
99
            }, {
100
                defaultToken: "string"
101
            }]
102
        };
103
    }
104
    
105
    function comments() {
106
        return [{
107
                token : "comment",
108
                regex : "\\/\\/(?=.)",
109
                next : [
110
                    DocCommentHighlightRules.getTagRule(),
111
                    {token : "comment", regex : "$|^", next : "start"},
112
                    {defaultToken : "comment", caseInsensitive: true}
113
                ]
114
            },
115
            DocCommentHighlightRules.getStartRule("doc-start"),
116
            {
117
                token : "comment", // multi line comment
118
                regex : /\/\*/,
119
                next : [
120
                    DocCommentHighlightRules.getTagRule(),
121
                    {token : "comment", regex : "\\*\\/", next : "start"},
122
                    {defaultToken : "comment", caseInsensitive: true}
123
                ]
124
            }
125
        ];
126
    }
127
    
128
    this.$rules = {
129
        start: [
130
            string("'", {
131
                escape: /\\[nb'"\\]/,
132
                error: /\\./,
133
                multiline: false
134
            }),
135
            comments("c"),
136
            {
137
                type: "decoration",
138
                token: [
139
                    "meta.package.apex",
140
                    "keyword.other.package.apex",
141
                    "meta.package.apex",
142
                    "storage.modifier.package.apex",
143
                    "meta.package.apex",
144
                    "punctuation.terminator.apex"
145
                ],
146
                regex: /^(\s*)(package)\b(?:(\s*)([^ ;$]+)(\s*)((?:;)?))?/
147
            }, {
148
                 regex: /@[a-zA-Z_$][a-zA-Z_$\d\u0080-\ufffe]*/,
149
                 token: "constant.language"
150
            },
151
            {
152
                regex: /[a-zA-Z_$][a-zA-Z_$\d\u0080-\ufffe]*/,
153
                token: keywordMapper
154
            },  
155
            {
156
                regex: "`#%",
157
                token: "error.invalid"
158
            }, {
159
                token : "constant.numeric", // float
160
                regex : /[+-]?\d+(?:(?:\.\d*)?(?:[LlDdEe][+-]?\d+)?)\b|\.\d+[LlDdEe]/
161
            }, {
162
                token : "keyword.operator",
163
                regex : /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
164
                next  : "start"
165
            }, {
166
                token : "punctuation.operator",
167
                regex : /[?:,;.]/,
168
                next  : "start"
169
            }, {
170
                token : "paren.lparen",
171
                regex : /[\[]/,
172
                next  : "maybe_soql",
173
                merge : false
174
            }, {
175
                token : "paren.lparen",
176
                regex : /[\[({]/,
177
                next  : "start",
178
                merge : false
179
            }, {
180
                token : "paren.rparen",
181
                regex : /[\])}]/,
182
                merge : false
183
            } 
184
        ], 
185
        maybe_soql: [{
186
            regex: /\s+/,
187
            token: "text"
188
        }, {
189
            regex: /(SELECT|FIND)\b/,
190
            token: "keyword",
191
            caseInsensitive: true,
192
            next: "soql"
193
        }, {
194
            regex: "",
195
            token: "none",
196
            next: "start"
197
        }],
198
        soql: [{
199
            regex: "(:?ASC|BY|CATEGORY|CUBE|DATA|DESC|END|FIND|FIRST|FOR|FROM|GROUP|HAVING|IN|LAST"
200
                + "|LIMIT|NETWORK|NULLS|OFFSET|ORDER|REFERENCE|RETURNING|ROLLUP|SCOPE|SELECT"
201
                + "|SNIPPET|TRACKING|TYPEOF|UPDATE|USING|VIEW|VIEWSTAT|WHERE|WITH|AND|OR)\\b",
202
            token: "keyword",
203
            caseInsensitive: true
204
        }, {
205
            regex: "(:?target_length|toLabel|convertCurrency|count|Contact|Account|User|FIELDS)\\b",
206
            token: "support.function",
207
            caseInsensitive: true
208
        }, {
209
            token : "paren.rparen",
210
            regex : /[\]]/,
211
            next  : "start",
212
            merge : false
213
        }, 
214
        string("'", {
215
            escape: /\\[nb'"\\]/,
216
            error: /\\./,
217
            multiline: false,
218
            next: "soql"
219
        }),
220
        string('"', {
221
            escape: /\\[nb'"\\]/,
222
            error: /\\./,
223
            multiline: false,
224
            next: "soql"
225
        }),
226
        {
227
            regex: /\\./,
228
            token: "character.escape"
229
        },
230
        {
231
            regex : /[\?\&\|\!\{\}\[\]\(\)\^\~\*\:\"\'\+\-\,\.=\\\/]/,
232
            token : "keyword.operator"
233
        }],
234
        
235
        "log-start" : [ {
236
            token : "timestamp.invisible",
237
            regex : /^[\d:.() ]+\|/, 
238
            next: "log-header"
239
        },  {
240
            token : "timestamp.invisible",
241
            regex : /^  (Number of|Maximum)[^:]*:/,
242
            next: "log-comment"
243
        }, {
244
            token : "invisible",
245
            regex : /^Execute Anonymous:/,
246
            next: "log-comment"
247
        },  {
248
            defaultToken: "text"
249
        }],
250
        "log-comment": [{
251
            token : "log-comment",
252
            regex : /.*$/,
253
            next: "log-start"
254
        }],
255
        "log-header": [{
256
            token : "timestamp.invisible",
257
            regex : /((USER_DEBUG|\[\d+\]|DEBUG)\|)+/
258
        },
259
        {
260
            token : "keyword",
261
            regex: "(?:EXECUTION_FINISHED|EXECUTION_STARTED|CODE_UNIT_STARTED"
262
                + "|CUMULATIVE_LIMIT_USAGE|LIMIT_USAGE_FOR_NS"
263
                + "|CUMULATIVE_LIMIT_USAGE_END|CODE_UNIT_FINISHED)"
264
        }, {
265
            regex: "",
266
            next: "log-start"
267
        }]
268
    };
269
    this.embedRules(DocCommentHighlightRules, "doc-",
270
        [ DocCommentHighlightRules.getEndRule("start") ]);
271
        
272

    
273
    this.normalizeRules();
274
};
275

    
276

    
277
oop.inherits(ApexHighlightRules, TextHighlightRules);
278

    
279
exports.ApexHighlightRules = ApexHighlightRules;
280
});
281

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

    
285
var oop = require("../../lib/oop");
286
var Range = require("../../range").Range;
287
var BaseFoldMode = require("./fold_mode").FoldMode;
288

    
289
var FoldMode = exports.FoldMode = function(commentRegex) {
290
    if (commentRegex) {
291
        this.foldingStartMarker = new RegExp(
292
            this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
293
        );
294
        this.foldingStopMarker = new RegExp(
295
            this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
296
        );
297
    }
298
};
299
oop.inherits(FoldMode, BaseFoldMode);
300

    
301
(function() {
302
    
303
    this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
304
    this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
305
    this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
306
    this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
307
    this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
308
    this._getFoldWidgetBase = this.getFoldWidget;
309
    this.getFoldWidget = function(session, foldStyle, row) {
310
        var line = session.getLine(row);
311
    
312
        if (this.singleLineBlockCommentRe.test(line)) {
313
            if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
314
                return "";
315
        }
316
    
317
        var fw = this._getFoldWidgetBase(session, foldStyle, row);
318
    
319
        if (!fw && this.startRegionRe.test(line))
320
            return "start"; // lineCommentRegionStart
321
    
322
        return fw;
323
    };
324

    
325
    this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
326
        var line = session.getLine(row);
327
        
328
        if (this.startRegionRe.test(line))
329
            return this.getCommentRegionBlock(session, line, row);
330
        
331
        var match = line.match(this.foldingStartMarker);
332
        if (match) {
333
            var i = match.index;
334

    
335
            if (match[1])
336
                return this.openingBracketBlock(session, match[1], row, i);
337
                
338
            var range = session.getCommentFoldRange(row, i + match[0].length, 1);
339
            
340
            if (range && !range.isMultiLine()) {
341
                if (forceMultiline) {
342
                    range = this.getSectionRange(session, row);
343
                } else if (foldStyle != "all")
344
                    range = null;
345
            }
346
            
347
            return range;
348
        }
349

    
350
        if (foldStyle === "markbegin")
351
            return;
352

    
353
        var match = line.match(this.foldingStopMarker);
354
        if (match) {
355
            var i = match.index + match[0].length;
356

    
357
            if (match[1])
358
                return this.closingBracketBlock(session, match[1], row, i);
359

    
360
            return session.getCommentFoldRange(row, i, -1);
361
        }
362
    };
363
    
364
    this.getSectionRange = function(session, row) {
365
        var line = session.getLine(row);
366
        var startIndent = line.search(/\S/);
367
        var startRow = row;
368
        var startColumn = line.length;
369
        row = row + 1;
370
        var endRow = row;
371
        var maxRow = session.getLength();
372
        while (++row < maxRow) {
373
            line = session.getLine(row);
374
            var indent = line.search(/\S/);
375
            if (indent === -1)
376
                continue;
377
            if  (startIndent > indent)
378
                break;
379
            var subRange = this.getFoldWidgetRange(session, "all", row);
380
            
381
            if (subRange) {
382
                if (subRange.start.row <= startRow) {
383
                    break;
384
                } else if (subRange.isMultiLine()) {
385
                    row = subRange.end.row;
386
                } else if (startIndent == indent) {
387
                    break;
388
                }
389
            }
390
            endRow = row;
391
        }
392
        
393
        return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
394
    };
395
    this.getCommentRegionBlock = function(session, line, row) {
396
        var startColumn = line.search(/\s*$/);
397
        var maxRow = session.getLength();
398
        var startRow = row;
399
        
400
        var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
401
        var depth = 1;
402
        while (++row < maxRow) {
403
            line = session.getLine(row);
404
            var m = re.exec(line);
405
            if (!m) continue;
406
            if (m[1]) depth--;
407
            else depth++;
408

    
409
            if (!depth) break;
410
        }
411

    
412
        var endRow = row;
413
        if (endRow > startRow) {
414
            return new Range(startRow, startColumn, endRow, line.length);
415
        }
416
    };
417

    
418
}).call(FoldMode.prototype);
419

    
420
});
421

    
422
ace.define("ace/mode/apex",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/apex_highlight_rules","ace/mode/folding/cstyle","ace/mode/behaviour/cstyle"], function(require, exports, module) {
423
"use strict";
424

    
425
var oop = require("../lib/oop");
426
var TextMode = require("../mode/text").Mode;
427
var ApexHighlightRules = require("./apex_highlight_rules").ApexHighlightRules;
428
var FoldMode = require("../mode/folding/cstyle").FoldMode;
429
var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour;
430

    
431
function ApexMode() {
432
    TextMode.call(this);
433

    
434
    this.HighlightRules = ApexHighlightRules;
435
    this.foldingRules = new FoldMode();
436
    this.$behaviour = new CstyleBehaviour();
437
}
438

    
439
oop.inherits(ApexMode, TextMode);
440

    
441
ApexMode.prototype.lineCommentStart = "//";
442

    
443
ApexMode.prototype.blockComment = {
444
    start: "/*",
445
    end: "*/"
446
};
447

    
448
exports.Mode = ApexMode;
449

    
450
});                (function() {
451
                    ace.require(["ace/mode/apex"], function(m) {
452
                        if (typeof module == "object" && typeof exports == "object" && module) {
453
                            module.exports = m;
454
                        }
455
                    });
456
                })();
457
            
(33-33/244)