From 7077b8b9aa174259485aff8515db79fa9e2b7d56 Mon Sep 17 00:00:00 2001 From: Siddarth Challa Date: Thu, 12 Dec 2024 00:31:09 -0500 Subject: [PATCH] rename method for indexing arguments of call node --- lib/ruby_lsp/ruby_lsp_rails/completion.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/ruby_lsp/ruby_lsp_rails/completion.rb b/lib/ruby_lsp/ruby_lsp_rails/completion.rb index db8d518b..7e53cb87 100644 --- a/lib/ruby_lsp/ruby_lsp_rails/completion.rb +++ b/lib/ruby_lsp/ruby_lsp_rails/completion.rb @@ -45,16 +45,17 @@ def handle_active_record_where_completions(node) return if resolved_class.nil? arguments = T.must(@node_context.call_node).arguments&.arguments - existing_args = T.let({}, T::Hash[String, T::Boolean]) + indexed_call_node_args = T.let({}, T::Hash[String, Prism::Node]) if arguments&.is_a?(Array) - existing_args = get_call_node_arguments(arguments: arguments) - return if existing_args.values.any? { |v| v == node } + indexed_call_node_args = index_call_node_args(arguments: arguments) + binding.irb + return if indexed_call_node_args.values.any? { |v| v == node } end resolved_class[:columns].each do |column| next unless column[0].start_with?(node.name.to_s) - next if existing_args.key?(column[0]) + next if indexed_call_node_args.key?(column[0]) @response_builder << Interface::CompletionItem.new( label: column[0], @@ -68,9 +69,9 @@ def handle_active_record_where_completions(node) end end - sig { params(arguments: T::Array[Prism::Node]).returns(T::Hash[String, T::Boolean]) } - def get_call_node_arguments(arguments:) - existing_args = {} + sig { params(arguments: T::Array[Prism::Node]).returns(T::Hash[String, Prism::Node]) } + def index_call_node_args(arguments:) + indexed_call_node_args = {} arguments.each do |argument| next unless argument.is_a?(Prism::KeywordHashNode) @@ -79,11 +80,11 @@ def get_call_node_arguments(arguments:) key = e.key if key.is_a?(Prism::SymbolNode) - existing_args[key.value] = e.value + indexed_call_node_args[key.value] = e.value end end end - existing_args + indexed_call_node_args end end end