Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
ErrorHighlight::Spotter#spot_op_asgn2_for_name
spot_op_asgn2_for_name
lib/error_highlight/base.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/error_highlight/base.rb, line 545
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)
case @name
when attr
@beg_column = $~.begin(1)
@end_column = $~.begin(2)
when op
@beg_column = $~.begin(3)
@end_column = $~.end(3)
when :"#{ attr }="
@beg_column = $~.begin(1)
@end_column = $~.end(4)
end
end
end
Example:
x.foo += 42
^^^ (for foo)
x.foo += 42
^ (for +)
x.foo += 42
^^^^^^^ (for foo=)
See also
#spot_op_asgn2_for_args
#spot_opcall_for_args
#spot_op_asgn1_for_name
#spot_opcall_for_name
also in
4.1 · 4.0 · 3.3 · 3.2 · 3.1