ruby-lsp-rails 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7d6af6475f53648fe445527ec54ec22c5ba94df79ad5da635520f2937d8d25e
|
4
|
+
data.tar.gz: 1977cf0285fe9d29f7b4b4eeccbe8b7d57887e5aa0d2ecac64f5b3ea0519fa01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 443fc7b9ba824d4ce578d503ed1269cc94ef3626a8fbdd7a1b81c2b1e8fc88e91692fb7e3210be510bbe3852efb2e97522aad13f75446f30128e51bdd211e924
|
7
|
+
data.tar.gz: 1adb0fe993a8a3cb3b8d0ad1d4ff40c5eaf550bc71126e1080b2a3cc84238bcb42631ed37f1efa69d4c8f18adb04b23d2006691e02ba39bca2aa1cf107d4a249
|
@@ -91,7 +91,7 @@ module RubyLsp
|
|
91
91
|
def create_discover_tests_listener(response_builder, dispatcher, uri)
|
92
92
|
return unless @global_state
|
93
93
|
|
94
|
-
RailsTestStyle.new(
|
94
|
+
RailsTestStyle.new(response_builder, @global_state, dispatcher, uri)
|
95
95
|
end
|
96
96
|
|
97
97
|
# @override
|
@@ -75,7 +75,7 @@ module RubyLsp
|
|
75
75
|
include Requests::Support::Common
|
76
76
|
include ActiveSupportTestCaseHelper
|
77
77
|
|
78
|
-
#: (RunnerClient
|
78
|
+
#: (RunnerClient, GlobalState, ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens], URI::Generic, Prism::Dispatcher) -> void
|
79
79
|
def initialize(client, global_state, response_builder, uri, dispatcher)
|
80
80
|
@client = client
|
81
81
|
@global_state = global_state
|
@@ -98,8 +98,10 @@ module RubyLsp
|
|
98
98
|
|
99
99
|
#: (Prism::CallNode node) -> void
|
100
100
|
def on_call_node_enter(node)
|
101
|
-
|
101
|
+
# Remove this method once the rollout is complete
|
102
|
+
return if @global_state.enabled_feature?(:fullTestDiscovery)
|
102
103
|
|
104
|
+
content = extract_test_case_name(node)
|
103
105
|
return unless content
|
104
106
|
|
105
107
|
line_number = node.location.start_line
|
@@ -110,12 +112,15 @@ module RubyLsp
|
|
110
112
|
# Although uncommon, Rails tests can be written with the classic "def test_name" syntax.
|
111
113
|
#: (Prism::DefNode node) -> void
|
112
114
|
def on_def_node_enter(node)
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
# Remove this entire unless block once the rollout is complete
|
116
|
+
unless @global_state.enabled_feature?(:fullTestDiscovery)
|
117
|
+
method_name = node.name.to_s
|
118
|
+
|
119
|
+
if method_name.start_with?("test_")
|
120
|
+
line_number = node.location.start_line
|
121
|
+
command = "#{test_command} #{@path}:#{line_number}"
|
122
|
+
add_test_code_lens(node, name: method_name, command: command, kind: :example)
|
123
|
+
end
|
119
124
|
end
|
120
125
|
|
121
126
|
if controller?
|
@@ -134,7 +139,8 @@ module RubyLsp
|
|
134
139
|
# back in a controller context. This part is used in other places in the LSP
|
135
140
|
@constant_name_stack << [class_name, superclass_name]
|
136
141
|
|
137
|
-
if
|
142
|
+
# Remove this entire if block once the rollout is complete
|
143
|
+
if class_name.end_with?("Test") && !@global_state.enabled_feature?(:fullTestDiscovery)
|
138
144
|
fully_qualified_name = @constant_name_stack.map(&:first).join("::")
|
139
145
|
command = "#{test_command} #{@path} --name \"/#{Shellwords.escape(fully_qualified_name)}(#|::)/\""
|
140
146
|
add_test_code_lens(node, name: class_name, command: command, kind: :group)
|
@@ -155,6 +161,8 @@ module RubyLsp
|
|
155
161
|
if class_name.end_with?("Test")
|
156
162
|
@group_id_stack.pop
|
157
163
|
end
|
164
|
+
# Remove everything but the `@constant_name_stack.pop` once the rollout is complete
|
165
|
+
return if @global_state.enabled_feature?(:fullTestDiscovery)
|
158
166
|
|
159
167
|
@constant_name_stack.pop
|
160
168
|
end
|
@@ -50,10 +50,12 @@ module RubyLsp
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
#: (
|
54
|
-
def initialize(
|
53
|
+
#: (ResponseBuilders::TestCollection response_builder, GlobalState global_state, Prism::Dispatcher dispatcher, URI::Generic uri) -> void
|
54
|
+
def initialize(response_builder, global_state, dispatcher, uri)
|
55
55
|
super(response_builder, global_state, dispatcher, uri)
|
56
56
|
|
57
|
+
@parent_stack = [@response_builder] #: Array[(Requests::Support::TestItem | ResponseBuilders::TestCollection)?]
|
58
|
+
|
57
59
|
dispatcher.register(
|
58
60
|
self,
|
59
61
|
:on_class_node_enter,
|
@@ -74,11 +76,33 @@ module RubyLsp
|
|
74
76
|
framework: :rails,
|
75
77
|
)
|
76
78
|
|
77
|
-
|
79
|
+
last_test_group.add(test_item)
|
80
|
+
@response_builder.add_code_lens(test_item)
|
81
|
+
@parent_stack << test_item
|
82
|
+
else
|
83
|
+
@parent_stack << nil
|
78
84
|
end
|
79
85
|
end
|
80
86
|
end
|
81
87
|
|
88
|
+
#: (Prism::ClassNode node) -> void
|
89
|
+
def on_class_node_leave(node)
|
90
|
+
@parent_stack.pop
|
91
|
+
super
|
92
|
+
end
|
93
|
+
|
94
|
+
#: (Prism::ModuleNode node) -> void
|
95
|
+
def on_module_node_enter(node)
|
96
|
+
@parent_stack << nil
|
97
|
+
super
|
98
|
+
end
|
99
|
+
|
100
|
+
#: (Prism::ModuleNode node) -> void
|
101
|
+
def on_module_node_leave(node)
|
102
|
+
@parent_stack.pop
|
103
|
+
super
|
104
|
+
end
|
105
|
+
|
82
106
|
#: (Prism::CallNode node) -> void
|
83
107
|
def on_call_node_enter(node)
|
84
108
|
return unless node.name == :test
|
@@ -124,26 +148,24 @@ module RubyLsp
|
|
124
148
|
|
125
149
|
#: (Prism::Node node, String test_name) -> void
|
126
150
|
def add_test_item(node, test_name)
|
127
|
-
|
128
|
-
return unless
|
151
|
+
parent = @parent_stack.last
|
152
|
+
return unless parent.is_a?(Requests::Support::TestItem)
|
129
153
|
|
130
|
-
|
131
|
-
"#{
|
154
|
+
example_item = Requests::Support::TestItem.new(
|
155
|
+
"#{parent.id}##{test_name}",
|
132
156
|
test_name,
|
133
157
|
@uri,
|
134
158
|
range_from_node(node),
|
135
159
|
framework: :rails,
|
136
|
-
)
|
160
|
+
)
|
161
|
+
parent.add(example_item)
|
162
|
+
@response_builder.add_code_lens(example_item)
|
137
163
|
end
|
138
164
|
|
139
|
-
#: -> Requests::Support::TestItem
|
140
|
-
def
|
141
|
-
|
142
|
-
|
143
|
-
# If we're finding a test method, but for the wrong framework, then the group test item will not have been
|
144
|
-
# previously pushed and thus we return early and avoid adding items for a framework this listener is not
|
145
|
-
# interested in
|
146
|
-
@response_builder[current_group_name]
|
165
|
+
#: -> (Requests::Support::TestItem | ResponseBuilders::TestCollection)
|
166
|
+
def last_test_group
|
167
|
+
index = @parent_stack.rindex { |i| i } #: as !nil
|
168
|
+
@parent_stack[index] #: as Requests::Support::TestItem | ResponseBuilders::TestCollection
|
147
169
|
end
|
148
170
|
end
|
149
171
|
end
|
@@ -17,7 +17,7 @@ module RubyLsp
|
|
17
17
|
@supports_progress = supports_progress
|
18
18
|
end
|
19
19
|
|
20
|
-
#: (percentage: Integer?, message: String?) -> void
|
20
|
+
#: (?percentage: Integer?, ?message: String?) -> void
|
21
21
|
def report(percentage: nil, message: nil)
|
22
22
|
return unless @supports_progress
|
23
23
|
return unless percentage || message
|
@@ -40,7 +40,7 @@ module RubyLsp
|
|
40
40
|
|
41
41
|
# Log a message to the editor's output panel. The type is the number of the message type, which can be found in
|
42
42
|
# the specification https://microsoft.github.io/language-server-protocol/specification/#messageType
|
43
|
-
#: (String, type: Integer) -> void
|
43
|
+
#: (String, ?type: Integer) -> void
|
44
44
|
def log_message(message, type: 4)
|
45
45
|
send_notification({ method: "window/logMessage", params: { type: type, message: message } })
|
46
46
|
end
|
@@ -86,7 +86,7 @@ module RubyLsp
|
|
86
86
|
log_message("Request #{notification_name} failed:\n#{e.full_message(highlight: false)}")
|
87
87
|
end
|
88
88
|
|
89
|
-
#: (String, String, percentage: Integer?, message: String?) -> void
|
89
|
+
#: (String, String, ?percentage: Integer?, ?message: String?) -> void
|
90
90
|
def begin_progress(id, title, percentage: nil, message: nil)
|
91
91
|
return unless capabilities[:supports_progress]
|
92
92
|
|
@@ -112,7 +112,7 @@ module RubyLsp
|
|
112
112
|
})
|
113
113
|
end
|
114
114
|
|
115
|
-
#: (String, percentage: Integer?, message: String?) -> void
|
115
|
+
#: (String, ?percentage: Integer?, ?message: String?) -> void
|
116
116
|
def report_progress(id, percentage: nil, message: nil)
|
117
117
|
return unless capabilities[:supports_progress]
|
118
118
|
|
@@ -142,7 +142,7 @@ module RubyLsp
|
|
142
142
|
})
|
143
143
|
end
|
144
144
|
|
145
|
-
#: (String, String, percentage: Integer?, message: String?) { (Progress) -> void } -> void
|
145
|
+
#: (String, String, ?percentage: Integer?, ?message: String?) { (Progress) -> void } -> void
|
146
146
|
def with_progress(id, title, percentage: nil, message: nil, &block)
|
147
147
|
progress_block = Progress.new(stderr, id, capabilities[:supports_progress])
|
148
148
|
return block.call(progress_block) unless capabilities[:supports_progress]
|
@@ -231,12 +231,12 @@ module RubyLsp
|
|
231
231
|
end
|
232
232
|
|
233
233
|
class IOWrapper < SimpleDelegator
|
234
|
-
#: (untyped) -> void
|
234
|
+
#: (*untyped) -> void
|
235
235
|
def puts(*args)
|
236
236
|
args.each { |arg| log("#{arg}\n") }
|
237
237
|
end
|
238
238
|
|
239
|
-
#: (untyped) -> void
|
239
|
+
#: (*untyped) -> void
|
240
240
|
def print(*args)
|
241
241
|
args.each { |arg| log(arg.to_s) }
|
242
242
|
end
|
@@ -255,7 +255,7 @@ module RubyLsp
|
|
255
255
|
class Server < ServerComponent
|
256
256
|
include Common
|
257
257
|
|
258
|
-
#: (IO | StringIO, IO | StringIO, bool, Hash[Symbol | String, untyped]) -> void
|
258
|
+
#: (?stdout: IO | StringIO, ?stderr: IO | StringIO, ?override_default_output_device: bool, ?capabilities: Hash[Symbol | String, untyped]) -> void
|
259
259
|
def initialize(stdout: $stdout, stderr: $stderr, override_default_output_device: true, capabilities: {})
|
260
260
|
# Grab references to the original pipes so that we can change the default output device further down
|
261
261
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lsp-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
@@ -15,7 +15,7 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 0.23.
|
18
|
+
version: 0.23.18
|
19
19
|
- - "<"
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 0.24.0
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.23.
|
28
|
+
version: 0.23.18
|
29
29
|
- - "<"
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: 0.24.0
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
|
-
rubygems_version: 3.6.
|
82
|
+
rubygems_version: 3.6.9
|
83
83
|
specification_version: 4
|
84
84
|
summary: A Ruby LSP addon for Rails
|
85
85
|
test_files: []
|