instance method
ErrorHighlight::Spotter#spot_op_cdecl
spot_op_cdecl
lib/error_highlight/base.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/error_highlight/base.rb, line 630
def spot_op_cdecl
nd_lhs, op, _nd_rhs = @node.children
*nd_parent_lhs, _const = nd_lhs.children
if @name == op
fetch_line(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
fetch_line(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
fetch_line(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 · 3.4 · 3.3 · 3.2 · 3.1