Skip to content

Commit

Permalink
Rename method and hash for arg keys/values
Browse files Browse the repository at this point in the history
  • Loading branch information
ChallaHalla committed Dec 12, 2024
1 parent 62284ef commit 0306e19
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/ruby_lsp/ruby_lsp_rails/completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ 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, T::Boolean])

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)
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],
Expand All @@ -69,8 +69,8 @@ def handle_active_record_where_completions(node)
end

sig { params(arguments: T::Array[Prism::Node]).returns(T::Hash[String, T::Boolean]) }
def get_call_node_arguments(arguments:)
existing_args = {}
def index_call_node_args(arguments:)
indexed_call_node_args = {}
arguments.each do |argument|
next unless argument.is_a?(Prism::KeywordHashNode)

Expand All @@ -79,11 +79,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
Expand Down

0 comments on commit 0306e19

Please sign in to comment.