ruby-lsp-rails 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9abe40b8b01b5f0e7e81a3831b3da7fa57902d64f17cb0ce3a950d043d895ab
|
4
|
+
data.tar.gz: 02b60ff2b040617a25fea20d715066a17092459532f56dc08a4350997e1369bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e76db2c3f6ea300e1b7a935b958a60b18a322e5039f518a0ccbc4efe2dbe7c69f65401987c0969d9fff479e3526831600a24788f477cbd19d3a2d528dc63a293
|
7
|
+
data.tar.gz: 1556932fe8c67752607b15e2520c2f71c0c88c2e1a005c78c1c72b31e49a2efac9e38a9da499bb91478ea8f8386661a269c18ab300809823d80c519cf517afa1
|
@@ -29,24 +29,24 @@ module RubyLsp
|
|
29
29
|
sig do
|
30
30
|
override.params(
|
31
31
|
uri: URI::Generic,
|
32
|
-
|
32
|
+
dispatcher: Prism::Dispatcher,
|
33
33
|
message_queue: Thread::Queue,
|
34
34
|
).returns(T.nilable(Listener[T::Array[Interface::CodeLens]]))
|
35
35
|
end
|
36
|
-
def create_code_lens_listener(uri,
|
37
|
-
CodeLens.new(uri,
|
36
|
+
def create_code_lens_listener(uri, dispatcher, message_queue)
|
37
|
+
CodeLens.new(uri, dispatcher, message_queue)
|
38
38
|
end
|
39
39
|
|
40
40
|
sig do
|
41
41
|
override.params(
|
42
42
|
nesting: T::Array[String],
|
43
43
|
index: RubyIndexer::Index,
|
44
|
-
|
44
|
+
dispatcher: Prism::Dispatcher,
|
45
45
|
message_queue: Thread::Queue,
|
46
46
|
).returns(T.nilable(Listener[T.nilable(Interface::Hover)]))
|
47
47
|
end
|
48
|
-
def create_hover_listener(nesting, index,
|
49
|
-
Hover.new(client,
|
48
|
+
def create_hover_listener(nesting, index, dispatcher, message_queue)
|
49
|
+
Hover.new(client, nesting, index, dispatcher, message_queue)
|
50
50
|
end
|
51
51
|
|
52
52
|
sig { override.returns(String) }
|
@@ -42,17 +42,17 @@ module RubyLsp
|
|
42
42
|
sig { override.returns(ResponseType) }
|
43
43
|
attr_reader :_response
|
44
44
|
|
45
|
-
sig { params(uri: URI::Generic,
|
46
|
-
def initialize(uri,
|
45
|
+
sig { params(uri: URI::Generic, dispatcher: Prism::Dispatcher, message_queue: Thread::Queue).void }
|
46
|
+
def initialize(uri, dispatcher, message_queue)
|
47
47
|
@_response = T.let([], ResponseType)
|
48
48
|
@path = T.let(uri.to_standardized_path, T.nilable(String))
|
49
|
-
|
49
|
+
dispatcher.register(self, :on_call_node_enter, :on_class_node_enter, :on_def_node_enter)
|
50
50
|
|
51
|
-
super(
|
51
|
+
super(dispatcher, message_queue)
|
52
52
|
end
|
53
53
|
|
54
|
-
sig { params(node:
|
55
|
-
def
|
54
|
+
sig { params(node: Prism::CallNode).void }
|
55
|
+
def on_call_node_enter(node)
|
56
56
|
message_value = node.message
|
57
57
|
return unless message_value == "test"
|
58
58
|
|
@@ -62,15 +62,15 @@ module RubyLsp
|
|
62
62
|
first_argument = arguments.first
|
63
63
|
|
64
64
|
content = case first_argument
|
65
|
-
when
|
65
|
+
when Prism::StringConcatNode
|
66
66
|
left = first_argument.left
|
67
67
|
right = first_argument.right
|
68
68
|
# We only support two lines of concatenation on test names
|
69
|
-
if left.is_a?(
|
70
|
-
right.is_a?(
|
69
|
+
if left.is_a?(Prism::StringNode) &&
|
70
|
+
right.is_a?(Prism::StringNode)
|
71
71
|
left.content + right.content
|
72
72
|
end
|
73
|
-
when
|
73
|
+
when Prism::StringNode
|
74
74
|
first_argument.content
|
75
75
|
end
|
76
76
|
|
@@ -82,8 +82,8 @@ module RubyLsp
|
|
82
82
|
end
|
83
83
|
|
84
84
|
# Although uncommon, Rails tests can be written with the classic "def test_name" syntax.
|
85
|
-
sig { params(node:
|
86
|
-
def
|
85
|
+
sig { params(node: Prism::DefNode).void }
|
86
|
+
def on_def_node_enter(node)
|
87
87
|
method_name = node.name.to_s
|
88
88
|
if method_name.start_with?("test_")
|
89
89
|
line_number = node.location.start_line
|
@@ -92,8 +92,8 @@ module RubyLsp
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
sig { params(node:
|
96
|
-
def
|
95
|
+
sig { params(node: Prism::ClassNode).void }
|
96
|
+
def on_class_node_enter(node)
|
97
97
|
class_name = node.constant_path.slice
|
98
98
|
if class_name.end_with?("Test")
|
99
99
|
command = "#{BASE_COMMAND} #{@path}"
|
@@ -103,7 +103,7 @@ module RubyLsp
|
|
103
103
|
|
104
104
|
private
|
105
105
|
|
106
|
-
sig { params(node:
|
106
|
+
sig { params(node: Prism::Node, name: String, command: String, kind: Symbol).void }
|
107
107
|
def add_test_code_lens(node, name:, command:, kind:)
|
108
108
|
return unless @path
|
109
109
|
|
@@ -25,37 +25,57 @@ module RubyLsp
|
|
25
25
|
sig { override.returns(ResponseType) }
|
26
26
|
attr_reader :_response
|
27
27
|
|
28
|
-
sig
|
29
|
-
|
30
|
-
|
28
|
+
sig do
|
29
|
+
params(
|
30
|
+
client: RailsClient,
|
31
|
+
nesting: T::Array[String],
|
32
|
+
index: RubyIndexer::Index,
|
33
|
+
dispatcher: Prism::Dispatcher,
|
34
|
+
message_queue: Thread::Queue,
|
35
|
+
).void
|
36
|
+
end
|
37
|
+
def initialize(client, nesting, index, dispatcher, message_queue)
|
38
|
+
super(dispatcher, message_queue)
|
31
39
|
|
32
40
|
@_response = T.let(nil, ResponseType)
|
33
41
|
@client = client
|
34
|
-
|
42
|
+
@nesting = nesting
|
43
|
+
@index = index
|
44
|
+
dispatcher.register(self, :on_constant_path_node_enter, :on_constant_read_node_enter, :on_call_node_enter)
|
35
45
|
end
|
36
46
|
|
37
|
-
sig { params(node:
|
38
|
-
def
|
39
|
-
|
47
|
+
sig { params(node: Prism::ConstantPathNode).void }
|
48
|
+
def on_constant_path_node_enter(node)
|
49
|
+
entries = @index.resolve(node.slice, @nesting)
|
50
|
+
return unless entries
|
51
|
+
|
52
|
+
name = T.must(entries.first).name
|
53
|
+
content = +""
|
54
|
+
column_info = generate_column_content(name)
|
55
|
+
content << column_info if column_info
|
56
|
+
|
57
|
+
urls = Support::RailsDocumentClient.generate_rails_document_urls(name)
|
58
|
+
content << urls.join("\n\n") unless urls.empty?
|
59
|
+
return if content.empty?
|
60
|
+
|
61
|
+
contents = RubyLsp::Interface::MarkupContent.new(kind: "markdown", value: content)
|
62
|
+
@_response = RubyLsp::Interface::Hover.new(range: range_from_location(node.location), contents: contents)
|
40
63
|
end
|
41
64
|
|
42
|
-
sig { params(node:
|
43
|
-
def
|
44
|
-
|
45
|
-
return
|
65
|
+
sig { params(node: Prism::ConstantReadNode).void }
|
66
|
+
def on_constant_read_node_enter(node)
|
67
|
+
entries = @index.resolve(node.name.to_s, @nesting)
|
68
|
+
return unless entries
|
69
|
+
|
70
|
+
content = generate_column_content(T.must(entries.first).name)
|
71
|
+
return unless content
|
46
72
|
|
47
|
-
schema_file = model[:schema_file]
|
48
|
-
content = +""
|
49
|
-
if schema_file
|
50
|
-
content << "[Schema](#{URI::Generic.build(scheme: "file", path: schema_file)})\n\n"
|
51
|
-
end
|
52
|
-
content << model[:columns].map { |name, type| "**#{name}**: #{type}\n" }.join("\n")
|
53
73
|
contents = RubyLsp::Interface::MarkupContent.new(kind: "markdown", value: content)
|
54
|
-
@_response = RubyLsp::Interface::Hover.new(range:
|
74
|
+
@_response = RubyLsp::Interface::Hover.new(range: range_from_location(node.location), contents: contents)
|
55
75
|
end
|
56
76
|
|
57
|
-
sig { params(node:
|
58
|
-
def
|
77
|
+
sig { params(node: Prism::CallNode).void }
|
78
|
+
def on_call_node_enter(node)
|
59
79
|
message_value = node.message
|
60
80
|
message_loc = node.message_loc
|
61
81
|
|
@@ -66,7 +86,19 @@ module RubyLsp
|
|
66
86
|
|
67
87
|
private
|
68
88
|
|
69
|
-
sig { params(name: String
|
89
|
+
sig { params(name: String).returns(T.nilable(String)) }
|
90
|
+
def generate_column_content(name)
|
91
|
+
model = @client.model(name)
|
92
|
+
return if model.nil?
|
93
|
+
|
94
|
+
schema_file = model[:schema_file]
|
95
|
+
content = +""
|
96
|
+
content << "[Schema](#{URI::Generic.build(scheme: "file", path: schema_file)})\n\n" if schema_file
|
97
|
+
content << model[:columns].map { |name, type| "**#{name}**: #{type}\n" }.join("\n")
|
98
|
+
content
|
99
|
+
end
|
100
|
+
|
101
|
+
sig { params(name: String, location: Prism::Location).returns(T.nilable(Interface::Hover)) }
|
70
102
|
def generate_rails_document_link_hover(name, location)
|
71
103
|
urls = Support::RailsDocumentClient.generate_rails_document_urls(name)
|
72
104
|
return if urls.empty?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lsp-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,20 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.12.0
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.
|
36
|
+
version: 0.13.0
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
43
|
+
version: 0.12.0
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.13.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sorbet-runtime
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
rubygems_version: 3.4.
|
104
|
+
rubygems_version: 3.4.21
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: A Ruby LSP addon for Rails
|