Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
ErrorHighlight::Spotter#spot_attrasgn_for_args
spot_attrasgn_for_args
lib/error_highlight/base.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/error_highlight/base.rb, line 316
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)
@beg_column = $~.end(0)
if nd_recv.last_lineno == nd_args.last_lineno
@end_column = nd_args.last_column
end
elsif nd_args && nd_args.first_lineno == nd_args.last_lineno
@beg_column = nd_args.first_column
@end_column = nd_args.last_column
end
# TODO: support @arg
end
Example:
x.foo = 1
^
x[42] = 1
^^^^^^^
x[] = 1
^^^^^
See also
#spot
#spot_attrasgn_for_name
#fetch_line
#spot_call_for_args
also in
4.1 · 4.0 · 3.4 · 3.2 · 3.1