Skip to content

Commit

Permalink
Changes that work when you enter text within ()
Browse files Browse the repository at this point in the history
  • Loading branch information
ChallaHalla committed Nov 15, 2024
1 parent 334c73d commit 9c6a550
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
19 changes: 8 additions & 11 deletions lib/ruby_lsp/ruby_lsp_rails/completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,18 @@ def initialize(client, response_builder, node_context, dispatcher, uri)

sig { params(node: Prism::CallNode).void }
def on_call_node_enter(node)
$stderr.puts("Entrered call node")
if @node_context.call_node&.name == :where
handle_active_record_where_completions(node)
end
end

$stderr.puts(node.receiver&.name)
$stderr.puts(node.name)
$stderr.puts(node.opening_loc&.slice)
receiver_name = node.receiver&.name
return if receiver_name.nil?
private

resolved_class = @client.model(receiver_name)
sig { params(node: Prism::CallNode).void }
def handle_active_record_where_completions(node)
resolved_class = @client.model(@node_context.call_node.receiver&.name)
return if resolved_class.nil?

$stderr.puts("MADEIT")
$stderr.puts(node.message)
$stderr.puts(node.arguments)

resolved_class[:columns].each do |column|
@response_builder << Interface::CompletionItem.new(
label: column[0],
Expand Down
7 changes: 2 additions & 5 deletions test/dummy/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ class User < ApplicationRecord

attr_readonly :last_name

private

def foo
puts "test"
@last_name
end

def test
User.where(
end
end

0 comments on commit 9c6a550

Please sign in to comment.