Skip to content

Commit c5043be

Browse files
authored
Remove Rails doc DSL hover (#472)
1 parent 80a8c0b commit c5043be

File tree

4 files changed

+1
-212
lines changed

4 files changed

+1
-212
lines changed

lib/ruby_lsp/ruby_lsp_rails/hover.rb

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# typed: strict
22
# frozen_string_literal: true
33

4-
require_relative "support/rails_document_client"
5-
64
module RubyLsp
75
module Rails
86
# ![Hover demo](../../hover.gif)
@@ -34,7 +32,7 @@ def initialize(client, response_builder, node_context, global_state, dispatcher)
3432
@response_builder = response_builder
3533
@nesting = T.let(node_context.nesting, T::Array[String])
3634
@index = T.let(global_state.index, RubyIndexer::Index)
37-
dispatcher.register(self, :on_constant_path_node_enter, :on_constant_read_node_enter, :on_call_node_enter)
35+
dispatcher.register(self, :on_constant_path_node_enter, :on_constant_read_node_enter)
3836
end
3937

4038
sig { params(node: Prism::ConstantPathNode).void }
@@ -43,10 +41,7 @@ def on_constant_path_node_enter(node)
4341
return unless entries
4442

4543
name = T.must(entries.first).name
46-
4744
generate_column_content(name)
48-
49-
generate_rails_document_link_hover(name, node.location)
5045
end
5146

5247
sig { params(node: Prism::ConstantReadNode).void }
@@ -57,16 +52,6 @@ def on_constant_read_node_enter(node)
5752
generate_column_content(T.must(entries.first).name)
5853
end
5954

60-
sig { params(node: Prism::CallNode).void }
61-
def on_call_node_enter(node)
62-
message_value = node.message
63-
message_loc = node.message_loc
64-
65-
return unless message_value && message_loc
66-
67-
generate_rails_document_link_hover(message_value, message_loc)
68-
end
69-
7055
private
7156

7257
sig { params(name: String).void }
@@ -89,14 +74,6 @@ def generate_column_content(name)
8974
category: :documentation,
9075
)
9176
end
92-
93-
sig { params(name: String, location: Prism::Location).void }
94-
def generate_rails_document_link_hover(name, location)
95-
urls = Support::RailsDocumentClient.generate_rails_document_urls(name)
96-
return if urls.empty?
97-
98-
@response_builder.push(urls.join("\n\n"), category: :links)
99-
end
10077
end
10178
end
10279
end

lib/ruby_lsp/ruby_lsp_rails/support/rails_document_client.rb

Lines changed: 0 additions & 131 deletions
This file was deleted.

test/fixtures/search_index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/ruby_lsp_rails/hover_test.rb

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,6 @@
66
module RubyLsp
77
module Rails
88
class HoverTest < ActiveSupport::TestCase
9-
setup do
10-
body = File.read("#{__dir__}/../../test/fixtures/search_index.js")
11-
stub_request(:get, %r{https://api\.rubyonrails\.org/v.*/js/search_index\.js})
12-
.with(
13-
headers: {
14-
"Host" => "api.rubyonrails.org",
15-
"User-Agent" => %r{^ruby-lsp-rails\/.*$},
16-
},
17-
)
18-
.to_return(status: 200, body: body, headers: {})
19-
20-
# Build the Rails documents index ahead of time
21-
capture_io do
22-
Support::RailsDocumentClient.send(:search_index)
23-
end
24-
end
25-
269
test "hook returns model column information" do
2710
expected_response = {
2811
schema_file: "#{dummy_root}/db/schema.rb",
@@ -201,45 +184,6 @@ class User < ApplicationRecord
201184
refute_match(/Schema/, response.contents.value)
202185
end
203186

204-
test "shows documentation for routes DSLs" do
205-
value = hover_on_source("root 'projects#index'", { line: 0, character: 0 }).contents.value
206-
207-
assert_match(/\[Rails Document: `ActionDispatch::Routing::Mapper::Resources#root`\]/, value)
208-
assert_match(%r{\(https://api\.rubyonrails\.org/.*\.html#method-i-root\)}, value)
209-
end
210-
211-
test "shows documentation for controller DSLs" do
212-
value = hover_on_source("before_action :foo", { line: 0, character: 0 }).contents.value
213-
214-
assert_match(/\[Rails Document: `AbstractController::Callbacks::ClassMethods#before_action`\]/, value)
215-
assert_match(%r{\(https://api\.rubyonrails\.org/.*\.html#method-i-before_action\)}, value)
216-
end
217-
218-
test "shows documentation for job DSLs" do
219-
value = hover_on_source("queue_as :default", { line: 0, character: 0 }).contents.value
220-
221-
assert_match(/\[Rails Document: `ActiveJob::QueueName::ClassMethods#queue_as`\]/, value)
222-
assert_match(%r{\(https://api\.rubyonrails\.org/.*\.html#method-i-queue_as\)}, value)
223-
end
224-
225-
test "shows documentation for model DSLs" do
226-
value = hover_on_source("validate :foo", { line: 0, character: 0 }).contents.value
227-
228-
assert_match(/\[Rails Document: `ActiveModel::EachValidator#validate`\]/, value)
229-
assert_match(%r{\(https://api\.rubyonrails\.org/.*\.html#method-i-validate\)}, value)
230-
end
231-
232-
test "shows documentation for Rails constants" do
233-
value = hover_on_source(<<~RUBY, { line: 2, character: 14 }).contents.value
234-
class ActiveRecord::Base
235-
end
236-
ActiveRecord::Base
237-
RUBY
238-
239-
assert_match(/\[Rails Document: `ActiveRecord::Base`\]/, value)
240-
assert_match(%r{\(https://api\.rubyonrails\.org/.*Base\.html\)}, value)
241-
end
242-
243187
private
244188

245189
def hover_on_source(source, position)

0 commit comments

Comments
 (0)