Merge remote branch 'upstream/master'
This commit is contained in:
commit
979c16705e
3 changed files with 88 additions and 9 deletions
|
|
@ -41,6 +41,7 @@ var oop = require("pilot/oop");
|
|||
var TextMode = require("ace/mode/text").Mode;
|
||||
var JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||
var CssMode = require("ace/mode/css").Mode;
|
||||
var RubyMode = require("ace/mode/ruby").Mode;
|
||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||
var HtmlHighlightRules = require("ace/mode/html_highlight_rules").HtmlHighlightRules;
|
||||
|
||||
|
|
@ -49,6 +50,7 @@ var Mode = function() {
|
|||
|
||||
this.$js = new JavaScriptMode();
|
||||
this.$css = new CssMode();
|
||||
this.$ruby = new RubyMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
|
|
@ -91,6 +93,12 @@ oop.inherits(Mode, TextMode);
|
|||
args[0] = split[1];
|
||||
return this.$css[method].apply(this.$css, args);
|
||||
}
|
||||
|
||||
var split = state.split("ruby-");
|
||||
if (!split[0] && split[1]) {
|
||||
args[0] = split[1];
|
||||
return this.$ruby[method].apply(this.$ruby, args);
|
||||
}
|
||||
|
||||
return defaultHandler ? defaultHandler() : undefined;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ define(function(require, exports, module) {
|
|||
var oop = require("pilot/oop");
|
||||
var CssHighlightRules = require("ace/mode/css_highlight_rules").CssHighlightRules;
|
||||
var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules;
|
||||
var RubyHighlightRules = require("ace/mode/ruby_highlight_rules").RubyHighlightRules;
|
||||
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var HtmlHighlightRules = function() {
|
||||
|
|
@ -67,6 +68,10 @@ var HtmlHighlightRules = function() {
|
|||
token : "text",
|
||||
regex : "<(?=\s*style)",
|
||||
next : "css"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "<(?=\s*%)",
|
||||
next : "ruby"
|
||||
}, {
|
||||
token : "text", // opening tag
|
||||
regex : "<\\/?",
|
||||
|
|
@ -115,6 +120,24 @@ var HtmlHighlightRules = function() {
|
|||
regex : "'.*?'"
|
||||
} ],
|
||||
|
||||
ruby : [ {
|
||||
token : "text",
|
||||
regex : ".",
|
||||
next : "ruby-start"
|
||||
}, {
|
||||
token : "keyword",
|
||||
regex : "[-_a-zA-Z0-9:]+"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '".*?"'
|
||||
}, {
|
||||
token : "string",
|
||||
regex : "'.*?'"
|
||||
} ],
|
||||
|
||||
tag : [ {
|
||||
token : "text",
|
||||
regex : ">",
|
||||
|
|
@ -174,6 +197,14 @@ var HtmlHighlightRules = function() {
|
|||
regex: "<\\/(?=style)",
|
||||
next: "tag"
|
||||
});
|
||||
|
||||
var rubyRules = new RubyHighlightRules().getRules();
|
||||
this.addRules(rubyRules, "ruby-");
|
||||
this.$rules["ruby-start"].unshift({
|
||||
token: "text",
|
||||
regex: "%>",
|
||||
next: "tag"
|
||||
});
|
||||
};
|
||||
|
||||
oop.inherits(HtmlHighlightRules, TextHighlightRules);
|
||||
|
|
|
|||
|
|
@ -45,24 +45,52 @@ var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightR
|
|||
var RubyHighlightRules = function() {
|
||||
|
||||
var builtinFunctions = lang.arrayToMap(
|
||||
("abort|Array|at_exit|autoload|binding|block_given?|callcc|caller|catch|chomp|chomp!|chop|chop!|eval|exec|exit|exit!" +
|
||||
"fail|Float|fork|format|gets|global_variables|gsub|gsub!|Integer|lambda|load|local_variables|loop|open|p|print|" +
|
||||
"printf|proc|putc|puts|raise|rand|readline|readlines|require|scan|select|set_trace_func|sleep|split|sprintf|srand|" +
|
||||
"String|syscall|system|sub|sub!|test|throw|trace_var|trap|untrace_var|" +
|
||||
"atan2|cos|exp|frexp|ldexp|log|log10|sin|sqrt|tan").split("|")
|
||||
("abort|Array|assert|assert_equal|assert_not_equal|assert_same|assert_not_same|" +
|
||||
"assert_nil|assert_not_nil|assert_match|assert_no_match|assert_in_delta|assert_throws|" +
|
||||
"assert_raise|assert_nothing_raised|assert_instance_of|assert_kind_of|assert_respond_to|" +
|
||||
"assert_operator|assert_send|assert_difference|assert_no_difference|assert_recognizes|" +
|
||||
"assert_generates|assert_response|assert_redirected_to|assert_template|assert_select|" +
|
||||
"assert_select_email|assert_select_rjs|assert_select_encoded|css_select|at_exit|" +
|
||||
"attr|attr_writer|attr_reader|attr_accessor|attr_accessible|autoload|binding|block_given?|callcc|" +
|
||||
"caller|catch|chomp|chomp!|chop|chop!|defined?|delete_via_redirect|eval|exec|exit|" +
|
||||
"exit!|fail|Float|flunk|follow_redirect!|fork|form_for|form_tag|format|gets|global_variables|gsub|" +
|
||||
"gsub!|get_via_redirect|h|host!|https?|https!|include|Integer|lambda|link_to|" +
|
||||
"link_to_unless_current|link_to_function|link_to_remote|load|local_variables|loop|open|open_session|" +
|
||||
"p|print|printf|proc|putc|puts|post_via_redirect|put_via_redirect|raise|rand|" +
|
||||
"raw|readline|readlines|redirect?|request_via_redirect|require|scan|select|" +
|
||||
"set_trace_func|sleep|split|sprintf|srand|String|stylesheet_link_tag|syscall|system|sub|sub!|test|" +
|
||||
"throw|trace_var|trap|untrace_var|atan2|cos|exp|frexp|ldexp|log|log10|sin|sqrt|tan|" +
|
||||
"render|javascript_include_tag|csrf_meta_tag|label_tag|text_field_tag|submit_tag|check_box_tag|" +
|
||||
"content_tag|radio_button_tag|text_area_tag|password_field_tag|hidden_field_tag|" +
|
||||
"fields_for|select_tag|options_for_select|options_from_collection_for_select|collection_select|" +
|
||||
"time_zone_select|select_date|select_time|select_datetime|date_select|time_select|datetime_select|" +
|
||||
"select_year|select_month|select_day|select_hour|select_minute|select_second|file_field_tag|" +
|
||||
"file_field|respond_to|skip_before_filter|around_filter|after_filter|verify|" +
|
||||
"protect_from_forgery|rescue_from|helper_method|redirect_to|before_filter|" +
|
||||
"send_data|send_file|validates_presence_of|validates_uniqueness_of|validates_length_of|" +
|
||||
"validates_format_of|validates_acceptance_of|validates_associated|validates_exclusion_of|" +
|
||||
"validates_inclusion_of|validates_numericality_of|validates_with|validates_each|" +
|
||||
"authenticate_or_request_with_http_basic|authenticate_or_request_with_http_digest|" +
|
||||
"filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" +
|
||||
"translate|localize|extract_locale_from_tld|t|l|caches_page|expire_page|caches_action|expire_action|" +
|
||||
"cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" +
|
||||
"has_many|has_one|belongs_to|has_and_belongs_to_many").split("|")
|
||||
);
|
||||
|
||||
var keywords = lang.arrayToMap(
|
||||
("alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|__FILE__|finally|for|" +
|
||||
"if|in|__LINE__|module|next|not|or|redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield").split("|")
|
||||
("alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" +
|
||||
"__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" +
|
||||
"redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield").split("|")
|
||||
);
|
||||
|
||||
var buildinConstants = lang.arrayToMap(
|
||||
("true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING").split("|")
|
||||
("true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" +
|
||||
"RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING").split("|")
|
||||
);
|
||||
|
||||
var builtinVariables = lang.arrayToMap(
|
||||
("\$DEBUG|\$defout|\$FILENAME|\$LOAD_PATH|\$SAFE|\$stdin|\$stdout|\$stderr|\$VERBOSE").split("|")
|
||||
("\$DEBUG|\$defout|\$FILENAME|\$LOAD_PATH|\$SAFE|\$stdin|\$stdout|\$stderr|\$VERBOSE|" +
|
||||
"$!|root_url|flash|session|cookies|params|request|response|logger").split("|")
|
||||
);
|
||||
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
|
|
@ -86,6 +114,18 @@ var RubyHighlightRules = function() {
|
|||
}, {
|
||||
token : "string", // single line
|
||||
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
||||
}, {
|
||||
token : "string", // backtick string
|
||||
regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]"
|
||||
}, {
|
||||
token : "variable.instancce", // instance variable
|
||||
regex : "@{1,2}(?:[a-zA-Z_]|\d)+"
|
||||
}, {
|
||||
token : "variable.class", // class name
|
||||
regex : "[A-Z](?:[a-zA-Z_]|\d)+"
|
||||
}, {
|
||||
token : "string", // symbol
|
||||
regex : "[:](?:[a-zA-Z]|\d)+"
|
||||
}, {
|
||||
token : "constant.numeric", // hex
|
||||
regex : "0[xX][0-9a-fA-F]+\\b"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue