From 02881d024e42393a2ef1f0870768deefcdbc3e0a Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Sat, 27 Jul 2013 14:44:33 -0700 Subject: Remove colons from rbx regexps, separate from generic ones --- lib/method_source/code_helpers.rb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/method_source/code_helpers.rb b/lib/method_source/code_helpers.rb index 3b567b0..d555f5a 100644 --- a/lib/method_source/code_helpers.rb +++ b/lib/method_source/code_helpers.rb @@ -122,18 +122,33 @@ module MethodSource # An exception matcher that matches only subsets of SyntaxErrors that can be # fixed by adding more input to the buffer. module IncompleteExpression + GENERIC_REGEXPS = [ + /unexpected (\$end|end-of-file|end-of-input|END_OF_FILE)/, # mri, jruby, ruby-2.0, ironruby + /embedded document meets end of file/, # =begin + /unterminated (quoted string|string|regexp) meets end of file/ # "quoted string" is ironruby + ] + + RBX_REGEXPS = [ + /missing 'end' for/, /expecting '[})\]]'(?:$|:)/, + /can't find string ".*" anywhere before EOF/, /expecting keyword_end/, + /expecting kWHEN/ + ] + def self.===(ex) return false unless SyntaxError === ex case ex.message - when /unexpected (\$end|end-of-file|end-of-input|END_OF_FILE)/, # mri, jruby, ruby-2.0, ironruby - /embedded document meets end of file/, # =begin - /unterminated (quoted string|string|regexp) meets end of file/, # "quoted string" is ironruby - /missing 'end' for/, /: expecting '[})\]]'$/, /can't find string ".*" anywhere before EOF/, /: expecting keyword_end/, /expecting kWHEN/ # rbx + when *GENERIC_REGEXPS true + when *RBX_REGEXPS + rbx? else false end end + + def self.rbx? + RbConfig::CONFIG['ruby_install_name'] == 'rbx' + end end end end -- cgit v1.2.1