instance method
ErrorHighlight::Spotter#prism_spot_index_operator_write_for_name
prism_spot_index_operator_write_for_name
lib/error_highlight/base.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/error_highlight/base.rb, line 849
def prism_spot_index_operator_write_for_name
case @name
when :[]
prism_location(@node.opening_loc.join(@node.closing_loc))
when :[]=
prism_location(@node.opening_loc.join(@node.closing_loc).adjoin("="))
else
# Explicitly turn off foo[] += 1 syntax when the operator is not on
# the same line because error_highlight expects this to not work.
return nil if @node.binary_operator_loc.start_line != @node.opening_loc.start_line
prism_location(@node.binary_operator_loc.chop)
end
end
Example:
x[1] += 42
^^^ (for [])
x[1] += 42
^ (for +)
x[1] += 42
^^^^^^ (for []=)