diff options
author | Masataka Pocke Kuwabara <kuwabara@pocke.me> | 2021-07-08 20:13:42 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-07-31 22:15:16 +0900 |
commit | 242f024bcbff6c46edd84a03365fa99ebd8eb524 (patch) | |
tree | 8f736ddd8f381c7ed347a14c83412e7ad3751ac7 /lib | |
parent | 4ab5281601c7c652db749d79b4833d755d563b09 (diff) | |
download | ruby-242f024bcbff6c46edd84a03365fa99ebd8eb524.tar.gz |
[ruby/error_highlight] Keep it work if paren exists after receiver
https://github.com/ruby/error_highlight/commit/b79d679bbd
Diffstat (limited to 'lib')
-rw-r--r-- | lib/error_highlight/base.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/error_highlight/base.rb b/lib/error_highlight/base.rb index 696df76ff9..8392979e24 100644 --- a/lib/error_highlight/base.rb +++ b/lib/error_highlight/base.rb @@ -148,7 +148,7 @@ module ErrorHighlight nd_recv, mid, nd_args = @node.children lineno = nd_recv.last_lineno lines = @fetch[lineno, @node.last_lineno] - if mid == :[] && lines.match(/\G\s*(\[(?:\s*\])?)/, nd_recv.last_column) + if mid == :[] && lines.match(/\G[\s)]*(\[(?:\s*\])?)/, nd_recv.last_column) @beg_column = $~.begin(1) @snippet = lines[/.*\n/] @beg_lineno = @end_lineno = lineno @@ -157,11 +157,11 @@ module ErrorHighlight @end_column = $~.end(0) end else - if lines.match(/\G\s*?\[\s*\]/, nd_recv.last_column) + if lines.match(/\G[\s)]*?\[\s*\]/, nd_recv.last_column) @end_column = $~.end(0) end end - elsif lines.match(/\G\s*?(\&?\.)(\s*?)(#{ Regexp.quote(mid) }).*\n/, nd_recv.last_column) + elsif lines.match(/\G[\s)]*?(\&?\.)(\s*?)(#{ Regexp.quote(mid) }).*\n/, nd_recv.last_column) lines = $` + $& @beg_column = $~.begin($2.include?("\n") ? 3 : 1) @end_column = $~.end(3) @@ -207,16 +207,16 @@ module ErrorHighlight nd_recv, mid, nd_args = @node.children *nd_args, _nd_last_arg, _nil = nd_args.children fetch_line(nd_recv.last_lineno) - if mid == :[]= && @snippet.match(/\G\s*(\[)/, nd_recv.last_column) + if mid == :[]= && @snippet.match(/\G[\s)]*(\[)/, nd_recv.last_column) @beg_column = $~.begin(1) args_last_column = $~.end(0) if nd_args.last && nd_recv.last_lineno == nd_args.last.last_lineno args_last_column = nd_args.last.last_column end - if @snippet.match(/\s*\]\s*=/, args_last_column) + if @snippet.match(/[\s)]*\]\s*=/, args_last_column) @end_column = $~.end(0) end - elsif @snippet.match(/\G\s*(\.\s*#{ Regexp.quote(mid.to_s.sub(/=\z/, "")) }\s*=)/, nd_recv.last_column) + elsif @snippet.match(/\G[\s)]*(\.\s*#{ Regexp.quote(mid.to_s.sub(/=\z/, "")) }\s*=)/, nd_recv.last_column) @beg_column = $~.begin(1) @end_column = $~.end(1) end @@ -232,7 +232,7 @@ module ErrorHighlight def spot_attrasgn_for_args nd_recv, mid, nd_args = @node.children fetch_line(nd_recv.last_lineno) - if mid == :[]= && @snippet.match(/\G\s*\[/, nd_recv.last_column) + if mid == :[]= && @snippet.match(/\G[\s)]*\[/, nd_recv.last_column) @beg_column = $~.end(0) if nd_recv.last_lineno == nd_args.last_lineno @end_column = nd_args.last_column @@ -254,7 +254,7 @@ module ErrorHighlight fetch_line(nd_recv.last_lineno) if nd_arg # binary operator - if @snippet.match(/\G\s*(#{ Regexp.quote(op) })/, nd_recv.last_column) + if @snippet.match(/\G[\s)]*(#{ Regexp.quote(op) })/, nd_recv.last_column) @beg_column = $~.begin(1) @end_column = $~.end(1) end @@ -330,7 +330,7 @@ module ErrorHighlight def spot_op_asgn1_for_name nd_recv, op, nd_args, _nd_rhs = @node.children fetch_line(nd_recv.last_lineno) - if @snippet.match(/\G\s*(\[)/, nd_recv.last_column) + if @snippet.match(/\G[\s)]*(\[)/, nd_recv.last_column) bracket_beg_column = $~.begin(1) args_last_column = $~.end(0) if nd_args && nd_recv.last_lineno == nd_args.last_lineno @@ -377,7 +377,7 @@ module ErrorHighlight def spot_op_asgn2_for_name nd_recv, _qcall, attr, op, _nd_rhs = @node.children fetch_line(nd_recv.last_lineno) - if @snippet.match(/\G\s*(\.)\s*#{ Regexp.quote(attr) }()\s*(#{ Regexp.quote(op) })(=)/, nd_recv.last_column) + if @snippet.match(/\G[\s)]*(\.)\s*#{ Regexp.quote(attr) }()\s*(#{ Regexp.quote(op) })(=)/, nd_recv.last_column) case @name when attr @beg_column = $~.begin(1) |