/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to js/ace/mode-dart.js

  • Committer: Gustav Hatvigsson
  • Date: 2013-05-31 06:15:46 UTC
  • mfrom: (90.1.20 lenasys2)
  • Revision ID: gustav.hartvigsson@gmail.com-20130531061546-vj8z28sq375kvghq
Merged Jonsson:s changes:
Fixed the layout on cms index so the arrows and dots marks expanded objects.
Fixed so the course content is sorted by course occasion and not by name

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ***** BEGIN LICENSE BLOCK *****
 
2
 * Distributed under the BSD license:
 
3
 *
 
4
 * Copyright (c) 2012, Ajax.org B.V.
 
5
 * All rights reserved.
 
6
 * 
 
7
 * Redistribution and use in source and binary forms, with or without
 
8
 * modification, are permitted provided that the following conditions are met:
 
9
 *     * Redistributions of source code must retain the above copyright
 
10
 *       notice, this list of conditions and the following disclaimer.
 
11
 *     * Redistributions in binary form must reproduce the above copyright
 
12
 *       notice, this list of conditions and the following disclaimer in the
 
13
 *       documentation and/or other materials provided with the distribution.
 
14
 *     * Neither the name of Ajax.org B.V. nor the
 
15
 *       names of its contributors may be used to endorse or promote products
 
16
 *       derived from this software without specific prior written permission.
 
17
 * 
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 
19
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
21
 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
 
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
27
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
28
 *
 
29
 *
 
30
 * Contributor(s):
 
31
 * 
 
32
 *
 
33
 *
 
34
 * ***** END LICENSE BLOCK ***** */
 
35
 
 
36
define('ace/mode/dart', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/dart_highlight_rules', 'ace/mode/folding/cstyle'], function(require, exports, module) {
 
37
 
 
38
 
 
39
var oop = require("../lib/oop");
 
40
var TextMode = require("./text").Mode;
 
41
var Tokenizer = require("../tokenizer").Tokenizer;
 
42
var DartHighlightRules = require("./dart_highlight_rules").DartHighlightRules;
 
43
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
 
44
 
 
45
var Mode = function() {
 
46
    var highlighter = new DartHighlightRules();
 
47
    this.foldingRules = new CStyleFoldMode();
 
48
 
 
49
    this.$tokenizer = new Tokenizer(highlighter.getRules());
 
50
};
 
51
oop.inherits(Mode, TextMode);
 
52
 
 
53
(function() {
 
54
    this.lineCommentStart = "//";
 
55
    this.blockComment = {start: "/*", end: "*/"};
 
56
}).call(Mode.prototype);
 
57
 
 
58
exports.Mode = Mode;
 
59
});
 
60
 
 
61
 
 
62
define('ace/mode/dart_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
 
63
 
 
64
 
 
65
var oop = require("../lib/oop");
 
66
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 
67
 
 
68
var DartHighlightRules = function() {
 
69
 
 
70
    var constantLanguage = "true|false|null";
 
71
    var variableLanguage = "this|super";
 
72
    var keywordControl = "try|catch|finally|throw|break|case|continue|default|do|else|for|if|in|return|switch|while|new";
 
73
    var keywordDeclaration = "abstract|class|extends|external|factory|implements|interface|get|native|operator|set|typedef";
 
74
    var storageModifier = "static|final|const";
 
75
    var storageType = "void|bool|num|int|double|Dynamic|var|String";
 
76
 
 
77
    var keywordMapper = this.createKeywordMapper({
 
78
        "constant.language.dart": constantLanguage,
 
79
        "variable.language.dart": variableLanguage,
 
80
        "keyword.control.dart": keywordControl,
 
81
        "keyword.declaration.dart": keywordDeclaration,
 
82
        "storage.modifier.dart": storageModifier,
 
83
        "storage.type.primitive.dart": storageType
 
84
    }, "identifier");
 
85
 
 
86
    var stringfill = {
 
87
        token : "string",
 
88
        regex : ".+"
 
89
    };
 
90
 
 
91
    this.$rules = 
 
92
        {
 
93
    "start": [
 
94
        {
 
95
            token : "comment",
 
96
            regex : /\/\/.*$/
 
97
        },
 
98
        {
 
99
            token : "comment", // multi line comment
 
100
            regex : /\/\*/,
 
101
            next : "comment"
 
102
        },
 
103
        {
 
104
            token: ["meta.preprocessor.script.dart"],
 
105
            regex: "^(#!.*)$"
 
106
        },
 
107
        {
 
108
            token: "keyword.other.import.dart",
 
109
            regex: "#(?:\\b)(?:library|import|source|resource)(?:\\b)"
 
110
        },
 
111
        {
 
112
            token : ["keyword.other.import.dart", "text"],
 
113
            regex : "(?:\\b)(prefix)(\\s*:)"
 
114
        },
 
115
        {
 
116
            regex: "\\bas\\b",
 
117
            token: "keyword.cast.dart"
 
118
        },
 
119
        {
 
120
            regex: "\\?|:",
 
121
            token: "keyword.control.ternary.dart"
 
122
        },
 
123
        {
 
124
            regex: "(?:\\b)(is\\!?)(?:\\b)",
 
125
            token: ["keyword.operator.dart"]
 
126
        },
 
127
        {
 
128
            regex: "(<<|>>>?|~|\\^|\\||&)",
 
129
            token: ["keyword.operator.bitwise.dart"]
 
130
        },
 
131
        {
 
132
            regex: "((?:&|\\^|\\||<<|>>>?)=)",
 
133
            token: ["keyword.operator.assignment.bitwise.dart"]
 
134
        },
 
135
        {
 
136
            regex: "(===?|!==?|<=?|>=?)",
 
137
            token: ["keyword.operator.comparison.dart"]
 
138
        },
 
139
        {
 
140
            regex: "((?:[+*/%-]|\\~)=)",
 
141
            token: ["keyword.operator.assignment.arithmetic.dart"]
 
142
        },
 
143
        {
 
144
            regex: "=",
 
145
            token: "keyword.operator.assignment.dart"
 
146
        },
 
147
        {
 
148
            token : "string",
 
149
            regex : "'''",
 
150
            next : "qdoc"
 
151
        }, 
 
152
        {
 
153
            token : "string",
 
154
            regex : '"""',
 
155
            next : "qqdoc"
 
156
        }, 
 
157
        {
 
158
            token : "string",
 
159
            regex : "'",
 
160
            next : "qstring"
 
161
        }, 
 
162
        {
 
163
            token : "string",
 
164
            regex : '"',
 
165
            next : "qqstring"
 
166
        }, 
 
167
        {
 
168
            regex: "(\\-\\-|\\+\\+)",
 
169
            token: ["keyword.operator.increment-decrement.dart"]
 
170
        },
 
171
        {
 
172
            regex: "(\\-|\\+|\\*|\\/|\\~\\/|%)",
 
173
            token: ["keyword.operator.arithmetic.dart"]
 
174
        },
 
175
        {
 
176
            regex: "(!|&&|\\|\\|)",
 
177
            token: ["keyword.operator.logical.dart"]
 
178
        },
 
179
        {
 
180
            token : "constant.numeric", // hex
 
181
            regex : "0[xX][0-9a-fA-F]+\\b"
 
182
        }, 
 
183
        {
 
184
            token : "constant.numeric", // float
 
185
            regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
 
186
        }, 
 
187
        {
 
188
            token : keywordMapper,
 
189
            regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
 
190
        }
 
191
    ],
 
192
    "comment" : [
 
193
        {
 
194
            token : "comment", // closing comment
 
195
            regex : ".*?\\*\\/",
 
196
            next : "start"
 
197
        }, {
 
198
            token : "comment", // comment spanning whole line
 
199
            regex : ".+"
 
200
        }
 
201
    ],
 
202
    "qdoc" : [
 
203
        {
 
204
            token : "string",
 
205
            regex : ".*?'''",
 
206
            next : "start"
 
207
        }, stringfill],
 
208
 
 
209
    "qqdoc" : [
 
210
        {
 
211
            token : "string",
 
212
            regex : '.*?"""',
 
213
            next : "start"
 
214
        }, stringfill],
 
215
 
 
216
    "qstring" : [
 
217
        {
 
218
            token : "string",
 
219
            regex : "[^\\\\']*(?:\\\\.[^\\\\']*)*'",
 
220
            next : "start"
 
221
        }, stringfill],
 
222
 
 
223
    "qqstring" : [
 
224
        {
 
225
            token : "string",
 
226
            regex : '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
 
227
            next : "start"
 
228
        }, stringfill]
 
229
}
 
230
 
 
231
};
 
232
 
 
233
oop.inherits(DartHighlightRules, TextHighlightRules);
 
234
 
 
235
exports.DartHighlightRules = DartHighlightRules;
 
236
});
 
237
 
 
238
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
 
239
 
 
240
 
 
241
var oop = require("../../lib/oop");
 
242
var Range = require("../../range").Range;
 
243
var BaseFoldMode = require("./fold_mode").FoldMode;
 
244
 
 
245
var FoldMode = exports.FoldMode = function(commentRegex) {
 
246
    if (commentRegex) {
 
247
        this.foldingStartMarker = new RegExp(
 
248
            this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
 
249
        );
 
250
        this.foldingStopMarker = new RegExp(
 
251
            this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
 
252
        );
 
253
    }
 
254
};
 
255
oop.inherits(FoldMode, BaseFoldMode);
 
256
 
 
257
(function() {
 
258
 
 
259
    this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
 
260
    this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
 
261
 
 
262
    this.getFoldWidgetRange = function(session, foldStyle, row) {
 
263
        var line = session.getLine(row);
 
264
        var match = line.match(this.foldingStartMarker);
 
265
        if (match) {
 
266
            var i = match.index;
 
267
 
 
268
            if (match[1])
 
269
                return this.openingBracketBlock(session, match[1], row, i);
 
270
 
 
271
            return session.getCommentFoldRange(row, i + match[0].length, 1);
 
272
        }
 
273
 
 
274
        if (foldStyle !== "markbeginend")
 
275
            return;
 
276
 
 
277
        var match = line.match(this.foldingStopMarker);
 
278
        if (match) {
 
279
            var i = match.index + match[0].length;
 
280
 
 
281
            if (match[1])
 
282
                return this.closingBracketBlock(session, match[1], row, i);
 
283
 
 
284
            return session.getCommentFoldRange(row, i, -1);
 
285
        }
 
286
    };
 
287
 
 
288
}).call(FoldMode.prototype);
 
289
 
 
290
});