corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 define("ace/mode/ruby_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 var constantOtherSymbol = exports.constantOtherSymbol = {
7 token : "constant.other.symbol.ruby", // symbol
8 regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?"
9 };
10  
11 var qString = exports.qString = {
12 token : "string", // single line
13 regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
14 };
15  
16 var qqString = exports.qqString = {
17 token : "string", // single line
18 regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
19 };
20  
21 var tString = exports.tString = {
22 token : "string", // backtick string
23 regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]"
24 };
25  
26 var constantNumericHex = exports.constantNumericHex = {
27 token : "constant.numeric", // hex
28 regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b"
29 };
30  
31 var constantNumericFloat = exports.constantNumericFloat = {
32 token : "constant.numeric", // float
33 regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b"
34 };
35  
36 var RubyHighlightRules = function() {
37  
38 var builtinFunctions = (
39 "abort|Array|assert|assert_equal|assert_not_equal|assert_same|assert_not_same|" +
40 "assert_nil|assert_not_nil|assert_match|assert_no_match|assert_in_delta|assert_throws|" +
41 "assert_raise|assert_nothing_raised|assert_instance_of|assert_kind_of|assert_respond_to|" +
42 "assert_operator|assert_send|assert_difference|assert_no_difference|assert_recognizes|" +
43 "assert_generates|assert_response|assert_redirected_to|assert_template|assert_select|" +
44 "assert_select_email|assert_select_rjs|assert_select_encoded|css_select|at_exit|" +
45 "attr|attr_writer|attr_reader|attr_accessor|attr_accessible|autoload|binding|block_given?|callcc|" +
46 "caller|catch|chomp|chomp!|chop|chop!|defined?|delete_via_redirect|eval|exec|exit|" +
47 "exit!|fail|Float|flunk|follow_redirect!|fork|form_for|form_tag|format|gets|global_variables|gsub|" +
48 "gsub!|get_via_redirect|host!|https?|https!|include|Integer|lambda|link_to|" +
49 "link_to_unless_current|link_to_function|link_to_remote|load|local_variables|loop|open|open_session|" +
50 "p|print|printf|proc|putc|puts|post_via_redirect|put_via_redirect|raise|rand|" +
51 "raw|readline|readlines|redirect?|request_via_redirect|require|scan|select|" +
52 "set_trace_func|sleep|split|sprintf|srand|String|stylesheet_link_tag|syscall|system|sub|sub!|test|" +
53 "throw|trace_var|trap|untrace_var|atan2|cos|exp|frexp|ldexp|log|log10|sin|sqrt|tan|" +
54 "render|javascript_include_tag|csrf_meta_tag|label_tag|text_field_tag|submit_tag|check_box_tag|" +
55 "content_tag|radio_button_tag|text_area_tag|password_field_tag|hidden_field_tag|" +
56 "fields_for|select_tag|options_for_select|options_from_collection_for_select|collection_select|" +
57 "time_zone_select|select_date|select_time|select_datetime|date_select|time_select|datetime_select|" +
58 "select_year|select_month|select_day|select_hour|select_minute|select_second|file_field_tag|" +
59 "file_field|respond_to|skip_before_filter|around_filter|after_filter|verify|" +
60 "protect_from_forgery|rescue_from|helper_method|redirect_to|before_filter|" +
61 "send_data|send_file|validates_presence_of|validates_uniqueness_of|validates_length_of|" +
62 "validates_format_of|validates_acceptance_of|validates_associated|validates_exclusion_of|" +
63 "validates_inclusion_of|validates_numericality_of|validates_with|validates_each|" +
64 "authenticate_or_request_with_http_basic|authenticate_or_request_with_http_digest|" +
65 "filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" +
66 "translate|localize|extract_locale_from_tld|caches_page|expire_page|caches_action|expire_action|" +
67 "cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" +
68 "has_many|has_one|belongs_to|has_and_belongs_to_many"
69 );
70  
71 var keywords = (
72 "alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" +
73 "__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" +
74 "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield"
75 );
76  
77 var buildinConstants = (
78 "true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" +
79 "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING"
80 );
81  
82 var builtinVariables = (
83 "$DEBUG|$defout|$FILENAME|$LOAD_PATH|$SAFE|$stdin|$stdout|$stderr|$VERBOSE|" +
84 "$!|root_url|flash|session|cookies|params|request|response|logger|self"
85 );
86  
87 var keywordMapper = this.$keywords = this.createKeywordMapper({
88 "keyword": keywords,
89 "constant.language": buildinConstants,
90 "variable.language": builtinVariables,
91 "support.function": builtinFunctions,
92 "invalid.deprecated": "debugger" // TODO is this a remnant from js mode?
93 }, "identifier");
94  
95 this.$rules = {
96 "start" : [
97 {
98 token : "comment",
99 regex : "#.*$"
100 }, {
101 token : "comment", // multi line comment
102 regex : "^=begin(?:$|\\s.*$)",
103 next : "comment"
104 }, {
105 token : "string.regexp",
106 regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
107 },
108  
109 [{
110 regex: "[{}]", onMatch: function(val, state, stack) {
111 this.next = val == "{" ? this.nextState : "";
112 if (val == "{" && stack.length) {
113 stack.unshift("start", state);
114 return "paren.lparen";
115 }
116 if (val == "}" && stack.length) {
117 stack.shift();
118 this.next = stack.shift();
119 if (this.next.indexOf("string") != -1)
120 return "paren.end";
121 }
122 return val == "{" ? "paren.lparen" : "paren.rparen";
123 },
124 nextState: "start"
125 }, {
126 token : "string.start",
127 regex : /"/,
128 push : [{
129 token : "constant.language.escape",
130 regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/
131 }, {
132 token : "paren.start",
133 regex : /#{/,
134 push : "start"
135 }, {
136 token : "string.end",
137 regex : /"/,
138 next : "pop"
139 }, {
140 defaultToken: "string"
141 }]
142 }, {
143 token : "string.start",
144 regex : /`/,
145 push : [{
146 token : "constant.language.escape",
147 regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/
148 }, {
149 token : "paren.start",
150 regex : /#{/,
151 push : "start"
152 }, {
153 token : "string.end",
154 regex : /`/,
155 next : "pop"
156 }, {
157 defaultToken: "string"
158 }]
159 }, {
160 token : "string.start",
161 regex : /'/,
162 push : [{
163 token : "constant.language.escape",
164 regex : /\\['\\]/
165 }, {
166 token : "string.end",
167 regex : /'/,
168 next : "pop"
169 }, {
170 defaultToken: "string"
171 }]
172 }],
173  
174 {
175 token : "text", // namespaces aren't symbols
176 regex : "::"
177 }, {
178 token : "variable.instance", // instance variable
179 regex : "@{1,2}[a-zA-Z_\\d]+"
180 }, {
181 token : "support.class", // class name
182 regex : "[A-Z][a-zA-Z_\\d]+"
183 },
184  
185 constantOtherSymbol,
186 constantNumericHex,
187 constantNumericFloat,
188  
189 {
190 token : "constant.language.boolean",
191 regex : "(?:true|false)\\b"
192 }, {
193 token : keywordMapper,
194 regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
195 }, {
196 token : "punctuation.separator.key-value",
197 regex : "=>"
198 }, {
199 stateName: "heredoc",
200 onMatch : function(value, currentState, stack) {
201 var next = value[2] == '-' ? "indentedHeredoc" : "heredoc";
202 var tokens = value.split(this.splitRegex);
203 stack.push(next, tokens[3]);
204 return [
205 {type:"constant", value: tokens[1]},
206 {type:"string", value: tokens[2]},
207 {type:"support.class", value: tokens[3]},
208 {type:"string", value: tokens[4]}
209 ];
210 },
211 regex : "(<<-?)(['\"`]?)([\\w]+)(['\"`]?)",
212 rules: {
213 heredoc: [{
214 onMatch: function(value, currentState, stack) {
215 if (value === stack[1]) {
216 stack.shift();
217 stack.shift();
218 this.next = stack[0] || "start";
219 return "support.class";
220 }
221 this.next = "";
222 return "string";
223 },
224 regex: ".*$",
225 next: "start"
226 }],
227 indentedHeredoc: [{
228 token: "string",
229 regex: "^ +"
230 }, {
231 onMatch: function(value, currentState, stack) {
232 if (value === stack[1]) {
233 stack.shift();
234 stack.shift();
235 this.next = stack[0] || "start";
236 return "support.class";
237 }
238 this.next = "";
239 return "string";
240 },
241 regex: ".*$",
242 next: "start"
243 }]
244 }
245 }, {
246 regex : "$",
247 token : "empty",
248 next : function(currentState, stack) {
249 if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc")
250 return stack[0];
251 return currentState;
252 }
253 }, {
254 token : "string.character",
255 regex : "\\B\\?."
256 }, {
257 token : "keyword.operator",
258 regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
259 }, {
260 token : "paren.lparen",
261 regex : "[[({]"
262 }, {
263 token : "paren.rparen",
264 regex : "[\\])}]"
265 }, {
266 token : "text",
267 regex : "\\s+"
268 }
269 ],
270 "comment" : [
271 {
272 token : "comment", // closing comment
273 regex : "^=end(?:$|\\s.*$)",
274 next : "start"
275 }, {
276 token : "comment", // comment spanning whole line
277 regex : ".+"
278 }
279 ]
280 };
281  
282 this.normalizeRules();
283 };
284  
285 oop.inherits(RubyHighlightRules, TextHighlightRules);
286  
287 exports.RubyHighlightRules = RubyHighlightRules;
288 });
289  
290 define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
291 "use strict";
292  
293 var Range = require("../range").Range;
294  
295 var MatchingBraceOutdent = function() {};
296  
297 (function() {
298  
299 this.checkOutdent = function(line, input) {
300 if (! /^\s+$/.test(line))
301 return false;
302  
303 return /^\s*\}/.test(input);
304 };
305  
306 this.autoOutdent = function(doc, row) {
307 var line = doc.getLine(row);
308 var match = line.match(/^(\s*\})/);
309  
310 if (!match) return 0;
311  
312 var column = match[1].length;
313 var openBracePos = doc.findMatchingBracket({row: row, column: column});
314  
315 if (!openBracePos || openBracePos.row == row) return 0;
316  
317 var indent = this.$getIndent(doc.getLine(openBracePos.row));
318 doc.replace(new Range(row, 0, row, column-1), indent);
319 };
320  
321 this.$getIndent = function(line) {
322 return line.match(/^\s*/)[0];
323 };
324  
325 }).call(MatchingBraceOutdent.prototype);
326  
327 exports.MatchingBraceOutdent = MatchingBraceOutdent;
328 });
329  
330 define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
331 "use strict";
332  
333 var oop = require("../../lib/oop");
334 var BaseFoldMode = require("./fold_mode").FoldMode;
335 var Range = require("../../range").Range;
336  
337 var FoldMode = exports.FoldMode = function() {};
338 oop.inherits(FoldMode, BaseFoldMode);
339  
340 (function() {
341  
342 this.getFoldWidgetRange = function(session, foldStyle, row) {
343 var range = this.indentationBlock(session, row);
344 if (range)
345 return range;
346  
347 var re = /\S/;
348 var line = session.getLine(row);
349 var startLevel = line.search(re);
350 if (startLevel == -1 || line[startLevel] != "#")
351 return;
352  
353 var startColumn = line.length;
354 var maxRow = session.getLength();
355 var startRow = row;
356 var endRow = row;
357  
358 while (++row < maxRow) {
359 line = session.getLine(row);
360 var level = line.search(re);
361  
362 if (level == -1)
363 continue;
364  
365 if (line[level] != "#")
366 break;
367  
368 endRow = row;
369 }
370  
371 if (endRow > startRow) {
372 var endColumn = session.getLine(endRow).length;
373 return new Range(startRow, startColumn, endRow, endColumn);
374 }
375 };
376 this.getFoldWidget = function(session, foldStyle, row) {
377 var line = session.getLine(row);
378 var indent = line.search(/\S/);
379 var next = session.getLine(row + 1);
380 var prev = session.getLine(row - 1);
381 var prevIndent = prev.search(/\S/);
382 var nextIndent = next.search(/\S/);
383  
384 if (indent == -1) {
385 session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
386 return "";
387 }
388 if (prevIndent == -1) {
389 if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
390 session.foldWidgets[row - 1] = "";
391 session.foldWidgets[row + 1] = "";
392 return "start";
393 }
394 } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
395 if (session.getLine(row - 2).search(/\S/) == -1) {
396 session.foldWidgets[row - 1] = "start";
397 session.foldWidgets[row + 1] = "";
398 return "";
399 }
400 }
401  
402 if (prevIndent!= -1 && prevIndent < indent)
403 session.foldWidgets[row - 1] = "start";
404 else
405 session.foldWidgets[row - 1] = "";
406  
407 if (indent < nextIndent)
408 return "start";
409 else
410 return "";
411 };
412  
413 }).call(FoldMode.prototype);
414  
415 });
416  
417 define("ace/mode/ruby",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ruby_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/coffee"], function(require, exports, module) {
418 "use strict";
419  
420 var oop = require("../lib/oop");
421 var TextMode = require("./text").Mode;
422 var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules;
423 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
424 var Range = require("../range").Range;
425 var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
426 var FoldMode = require("./folding/coffee").FoldMode;
427  
428 var Mode = function() {
429 this.HighlightRules = RubyHighlightRules;
430 this.$outdent = new MatchingBraceOutdent();
431 this.$behaviour = new CstyleBehaviour();
432 this.foldingRules = new FoldMode();
433 };
434 oop.inherits(Mode, TextMode);
435  
436 (function() {
437  
438  
439 this.lineCommentStart = "#";
440  
441 this.getNextLineIndent = function(state, line, tab) {
442 var indent = this.$getIndent(line);
443  
444 var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
445 var tokens = tokenizedLine.tokens;
446  
447 if (tokens.length && tokens[tokens.length-1].type == "comment") {
448 return indent;
449 }
450  
451 if (state == "start") {
452 var match = line.match(/^.*[\{\(\[]\s*$/);
453 var startingClassOrMethod = line.match(/^\s*(class|def|module)\s.*$/);
454 var startingDoBlock = line.match(/.*do(\s*|\s+\|.*\|\s*)$/);
455 var startingConditional = line.match(/^\s*(if|else|when)\s*/)
456 if (match || startingClassOrMethod || startingDoBlock || startingConditional) {
457 indent += tab;
458 }
459 }
460  
461 return indent;
462 };
463  
464 this.checkOutdent = function(state, line, input) {
465 return /^\s+(end|else)$/.test(line + input) || this.$outdent.checkOutdent(line, input);
466 };
467  
468 this.autoOutdent = function(state, session, row) {
469 var line = session.getLine(row);
470 if (/}/.test(line))
471 return this.$outdent.autoOutdent(session, row);
472 var indent = this.$getIndent(line);
473 var prevLine = session.getLine(row - 1);
474 var prevIndent = this.$getIndent(prevLine);
475 var tab = session.getTabString();
476 if (prevIndent.length <= indent.length) {
477 if (indent.slice(-tab.length) == tab)
478 session.remove(new Range(row, indent.length-tab.length, row, indent.length));
479 }
480 };
481  
482 this.$id = "ace/mode/ruby";
483 }).call(Mode.prototype);
484  
485 exports.Mode = Mode;
486 });