Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
ErrorHighlight::Spotter#spot_op_cdecl
spot_op_cdecl
lib/error_highlight/base.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/error_highlight/base.rb, line 512
def spot_op_cdecl
nd_lhs, op, _nd_rhs = @node.children
*nd_parent_lhs, _const = nd_lhs.children
if @name == op
@snippet = @fetch[nd_lhs.last_lineno]
if @snippet.match(/\G\s*(#{ Regexp.quote(op) })=/, nd_lhs.last_column)
@beg_column = $~.begin(1)
@end_column = $~.end(1)
end
else
# constant access error
@end_column = nd_lhs.last_column
if nd_parent_lhs.empty? # example: ::C += 1
if nd_lhs.first_lineno == nd_lhs.last_lineno
@snippet = @fetch[nd_lhs.last_lineno]
@beg_column = nd_lhs.first_column
end
else # example: Foo::Bar::C += 1
if nd_parent_lhs.last.last_lineno == nd_lhs.last_lineno
@snippet = @fetch[nd_lhs.last_lineno]
@beg_column = nd_parent_lhs.last.last_column
end
end
end
end
Example:
Foo::Bar += 1 ^^^^^^^^
See also
#spot_opcall_for_name
#spot_vcall
#spot_opcall_for_args
also in
4.1 · 4.0 · 3.4 · 3.2 · 3.1