instance method
ErrorHighlight::Spotter#prism_spot_call_for_args
prism_spot_call_for_args
lib/error_highlight/base.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/error_highlight/base.rb, line 785
def prism_spot_call_for_args
# Disallow highlighting arguments if there are no arguments.
return if @node.arguments.nil?
# Explicitly turn off foo.() syntax because error_highlight expects this
# to not work.
return nil if @node.name == :call && @node.message_loc.nil?
if @node.name == :[]= && @node.opening == "[" && (@node.arguments&.arguments || []).length == 1
prism_location(@node.opening_loc.copy(start_offset: @node.opening_loc.start_offset + 1).join(@node.arguments.location))
else
prism_location(@node.arguments.location)
end
end
Example:
x.foo(42)
^^
x[42]
^^
x.foo = 1
^
x[42] = 1
^^^^^^^
x[] = 1
^^^^^
x + 1
^
foo(42)
^^
foo 42
^^