File tree Expand file tree Collapse file tree 2 files changed +8
-20
lines changed
lib/ruby_lsp/ruby_lsp_rails Expand file tree Collapse file tree 2 files changed +8
-20
lines changed Original file line number Diff line number Diff line change 3
3
4
4
require "json"
5
5
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
13
8
14
9
# NOTE: We should avoid printing to stderr since it causes problems. We never read the standard error pipe from the
15
10
# client, so it will become full and eventually hang or crash. Instead, return a response with an `error` key.
16
11
17
- # TODO: this helps but it still failing intermittently. Trying to understand what's going on.
18
-
19
12
module RubyLsp
20
13
module Rails
21
14
module Common
@@ -168,7 +161,7 @@ def resolve_route_info(requirements)
168
161
169
162
{ result : body }
170
163
else
171
- { result : "SL NIL" }
164
+ { result : nil }
172
165
end
173
166
end
174
167
@@ -195,10 +188,9 @@ def route_location(name)
195
188
{ error : e . full_message ( highlight : false ) }
196
189
end
197
190
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
202
194
end
203
195
204
196
def resolve_database_info_from_model ( model_name )
@@ -262,8 +254,4 @@ def active_record_model?(const)
262
254
end
263
255
end
264
256
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"
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ def <(other)
117
117
@server . execute ( "route_location" , { name : "user_path" } )
118
118
puts response . inspect
119
119
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
121
121
end
122
122
123
123
test "route location returns nil for invalid routes" do
You can’t perform that action at this time.
0 commit comments