Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Oct 28, 2024
1 parent 76911b3 commit d7f9286
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
20 changes: 6 additions & 14 deletions lib/ruby_lsp/ruby_lsp_rails/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@

require "json"

# module ActionDispatch
# class MyRailtie < Rails::Railtie # :nodoc:
# initializer "my_railtie.configure", after: "action_dispatch.configure" do
# ActionDispatch::Routing::Mapper.route_source_locations = true
# end
# end
# end
ActionDispatch::Routing::Mapper.route_source_locations = true
Rails.application.routes.routes

# NOTE: We should avoid printing to stderr since it causes problems. We never read the standard error pipe from the
# client, so it will become full and eventually hang or crash. Instead, return a response with an `error` key.

# TODO: this helps but it still failing intermittently. Trying to understand what's going on.

module RubyLsp
module Rails
module Common
Expand Down Expand Up @@ -168,7 +161,7 @@ def resolve_route_info(requirements)

{ result: body }
else
{ result: "SL NIL" }
{ result: nil }
end
end

Expand All @@ -195,10 +188,9 @@ def route_location(name)
{ error: e.full_message(highlight: false) }
end
else
raise "NOT ENABLED"
# def route_location(name)
# { result: 444 }
# end
def route_location(name)
{ result: nil }
end
end

def resolve_database_info_from_model(model_name)
Expand Down
2 changes: 1 addition & 1 deletion test/ruby_lsp_rails/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def <(other)
@server.execute("route_location", { name: "user_path" })
puts response.inspect
location = response[:result][:location]
assert_match %r{test/dummy/config/routes.rb:4$}, location
assert_match %r{test/dummy/config/routes.rb:3$}, location
end

test "route location returns nil for invalid routes" do
Expand Down

0 comments on commit d7f9286

Please sign in to comment.