Skip to content

Commit 99aa3ed

Browse files
committed
wip
1 parent 76911b3 commit 99aa3ed

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

lib/ruby_lsp/ruby_lsp_rails/server.rb

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,12 @@
33

44
require "json"
55

6-
# module ActionDispatch
7-
# class MyRailtie < Rails::Railtie # :nodoc:
8-
# initializer "my_railtie.configure", after: "action_dispatch.configure" do
9-
# ActionDispatch::Routing::Mapper.route_source_locations = true
10-
# end
11-
# end
12-
# end
6+
ActionDispatch::Routing::Mapper.route_source_locations = true
7+
Rails.application.routes.routes
138

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

17-
# TODO: this helps but it still failing intermittently. Trying to understand what's going on.
18-
1912
module RubyLsp
2013
module Rails
2114
module Common
@@ -168,7 +161,7 @@ def resolve_route_info(requirements)
168161

169162
{ result: body }
170163
else
171-
{ result: "SL NIL" }
164+
{ result: nil }
172165
end
173166
end
174167

@@ -195,10 +188,9 @@ def route_location(name)
195188
{ error: e.full_message(highlight: false) }
196189
end
197190
else
198-
raise "NOT ENABLED"
199-
# def route_location(name)
200-
# { result: 444 }
201-
# end
191+
def route_location(name)
192+
{ result: nil }
193+
end
202194
end
203195

204196
def resolve_database_info_from_model(model_name)
@@ -262,8 +254,4 @@ def active_record_model?(const)
262254
end
263255
end
264256

265-
if ARGV.first == "start"
266-
ActionDispatch::Routing::Mapper.route_source_locations = true
267-
RubyLsp::Rails::Server.new.start
268-
ActionDispatch::Routing::Mapper.route_source_locations = true
269-
end
257+
RubyLsp::Rails::Server.new.start if ARGV.first == "start"

test/ruby_lsp_rails/server_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def <(other)
117117
@server.execute("route_location", { name: "user_path" })
118118
puts response.inspect
119119
location = response[:result][:location]
120-
assert_match %r{test/dummy/config/routes.rb:4$}, location
120+
assert_match %r{test/dummy/config/routes.rb:3$}, location
121121
end
122122

123123
test "route location returns nil for invalid routes" do

0 commit comments

Comments
 (0)