diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index a331799e..d6cb871e 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -47,15 +47,27 @@ RubyHighlightRules = function() { var docComment = new DocCommentHighlightRules(); + 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("|") + ); + var keywords = lang.arrayToMap( - ("alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|false|finally|for|" + - "if|in|module|next|not|or|redo|rescue|retry|return|self|super|then|true|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|" + + "if|in|__LINE__|module|next|not|or|redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield").split("|") ); var buildinConstants = lang.arrayToMap( - ("true|false|nil").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("|") + ); + var futureReserved = lang.arrayToMap([]); // regexp must not have capturing parentheses. Use (?:) instead. @@ -70,7 +82,7 @@ RubyHighlightRules = function() { docComment.getStartRule("doc-start"), { token : "comment", // multi line comment - regex : "^\=begin$", + regex : "^=begin", next : "comment" }, { token : "string.regexp", @@ -100,14 +112,18 @@ RubyHighlightRules = function() { regex : "(?:true|false)\\b" }, { token : function(value) { - if (value == "this") + if (value == "self") return "variable.language"; else if (keywords[value]) return "keyword"; else if (buildinConstants[value]) return "constant.language"; - else if (futureReserved[value]) - return "invalid.illegal"; + else if (builtinVariables[value]) + return "variable.language"; + else if (futureReserved[value]) + return "invalid.illegal"; + else if (builtinFunctions[value]) + return "support.function"; else if (value == "debugger") return "invalid.deprecated"; else @@ -133,7 +149,7 @@ RubyHighlightRules = function() { "comment" : [ { token : "comment", // closing comment - regex : "^\=end$", + regex : "^=end", next : "start" }, { token : "comment", // comment spanning whole line