instance method
ErrorHighlight::Spotter#spot_op_asgn1_for_name
spot_op_asgn1_for_name
lib/error_highlight/base.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/error_highlight/base.rb, line 531
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)
bracket_beg_column = $~.begin(1)
args_last_column = $~.end(0)
if nd_args && nd_recv.last_lineno == nd_args.last_lineno
args_last_column = nd_args.last_column
end
if @snippet.match(/\s*\](\s*)(#{ Regexp.quote(op) })=()/, args_last_column)
case @name
when :[], :[]=
@beg_column = bracket_beg_column
@end_column = $~.begin(@name == :[] ? 1 : 3)
when op
@beg_column = $~.begin(2)
@end_column = $~.end(2)
end
end
end
end
Example:
x[1] += 42
^^^ (for [])
x[1] += 42
^ (for +)
x[1] += 42
^^^^^^ (for []=)
See also
#spot_op_asgn1_for_args
#spot_op_asgn2_for_args
#spot_lambda
#spot_op_asgn2_for_name
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1