class RubyLsp::Requests::SignatureHelp

def adjust_for_nested_target(target, parent, position)

def adjust_for_nested_target(target, parent, position)
  # If the parent node is not a method call, then make no adjustments
  return target unless parent.is_a?(Prism::CallNode)
  # If the parent is a method call, but the target isn't, then return the parent
  return parent unless target.is_a?(Prism::CallNode)
  # If both are method calls, we check the arguments of the inner method call. If there are no arguments, then
  # we're providing signature help for the outer method call.
  #
  # If there are arguments, then we check if the arguments node covers the requested position. If it doesn't
  # cover, then we're providing signature help for the outer method call.
  arguments = target.arguments
  arguments.nil? || !node_covers?(arguments, position) ? parent : target
end