ruby-lsp 0.21.1 → 0.21.2

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: c270ba4b6a7348ccb821e1bae776f4bd9ac704973b251791d2104d79861878c1
4
- data.tar.gz: 5d27d76eca727dca7e439aa177db04fb3ec17e1169c19a267ba2cffc8f9e19a3
3
+ metadata.gz: 03751a627d3f3b8d671f72c7533b14c5b74b21846fa8be6402a7d2e20f9cdefc
4
+ data.tar.gz: 948d342270018a4b92868cd0fe284cf7664a630c567c640a5c1c1e50c079e7a9
5
5
  SHA512:
6
- metadata.gz: 8502d09966be4e7ec79c276b4d078edc0f4e150c86ff24bb6e6f5b9c28e4f89393760983b7344c108e356a5bc79daa314806c69b81441338465b00f8bb693cc1
7
- data.tar.gz: 0d84c86826022c8e71311bef8070f8b5364cd45f10f242fcb5b8cf96f9dd391a9a45a034b264ee8b2cec236ce69257a1a102d9e769bbdf3b8c0dc9baff8650e9
6
+ metadata.gz: 42f13540d7a8bf5b87f85ea00a93581980c85ae662adbc5cbb62a180d1195fc0e701dae9dc329d36d6ae15a1c422ce9dd39b5af4ff06e10af6c1bc3608787d8d
7
+ data.tar.gz: b16dc974e8e6437d031763924d5fd6acfe4b2b028e7155ca7fb674585916cc805ea5285c1d849b8a0b6cdc958641e0689d75273d7ad67f0267a0fe6dfba55272
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.21.1
1
+ 0.21.2
@@ -10,7 +10,8 @@ module RubyLsp
10
10
  sig { returns(T::Boolean) }
11
11
  attr_reader :supports_watching_files,
12
12
  :supports_request_delegation,
13
- :window_show_message_supports_extra_properties
13
+ :window_show_message_supports_extra_properties,
14
+ :supports_progress
14
15
 
15
16
  sig { void }
16
17
  def initialize
@@ -28,6 +29,9 @@ module RubyLsp
28
29
 
29
30
  # Which resource operations the editor supports, like renaming files
30
31
  @supported_resource_operations = T.let([], T::Array[String])
32
+
33
+ # The editor supports displaying progress requests
34
+ @supports_progress = T.let(false, T::Boolean)
31
35
  end
32
36
 
33
37
  sig { params(capabilities: T::Hash[Symbol, T.untyped]).void }
@@ -50,6 +54,9 @@ module RubyLsp
50
54
  :additionalPropertiesSupport,
51
55
  )
52
56
  @window_show_message_supports_extra_properties = supports_additional_properties || false
57
+
58
+ progress = capabilities.dig(:window, :workDoneProgress)
59
+ @supports_progress = progress if progress
53
60
  end
54
61
 
55
62
  sig { returns(T::Boolean) }
@@ -81,8 +81,6 @@ module RubyLsp
81
81
  workspace_did_change_watched_files(message)
82
82
  when "workspace/symbol"
83
83
  workspace_symbol(message)
84
- when "window/showMessageRequest"
85
- window_show_message_request(message)
86
84
  when "rubyLsp/textDocument/showSyntaxTree"
87
85
  text_document_show_syntax_tree(message)
88
86
  when "rubyLsp/workspace/dependencies"
@@ -108,6 +106,8 @@ module RubyLsp
108
106
  )
109
107
  when "$/cancelRequest"
110
108
  @mutex.synchronize { @cancelled_requests << message[:params][:id] }
109
+ when nil
110
+ process_response(message) if message[:result]
111
111
  end
112
112
  rescue DelegateRequestError
113
113
  send_message(Error.new(id: message[:id], code: DelegateRequestError::CODE, message: "DELEGATE_REQUEST"))
@@ -140,6 +140,15 @@ module RubyLsp
140
140
  send_log_message("Error processing #{message[:method]}: #{e.full_message}", type: Constant::MessageType::ERROR)
141
141
  end
142
142
 
143
+ # Process responses to requests that were sent to the client
144
+ sig { params(message: T::Hash[Symbol, T.untyped]).void }
145
+ def process_response(message)
146
+ case message.dig(:result, :method)
147
+ when "window/showMessageRequest"
148
+ window_show_message_request(message)
149
+ end
150
+ end
151
+
143
152
  sig { params(include_project_addons: T::Boolean).void }
144
153
  def load_addons(include_project_addons: true)
145
154
  # If invoking Bundler.setup failed, then the load path will not be configured properly and trying to load add-ons
@@ -188,8 +197,6 @@ module RubyLsp
188
197
  client_name = options.dig(:clientInfo, :name)
189
198
  @store.client_name = client_name if client_name
190
199
 
191
- progress = options.dig(:capabilities, :window, :workDoneProgress)
192
- @store.supports_progress = progress.nil? ? true : progress
193
200
  configured_features = options.dig(:initializationOptions, :enabledFeatures)
194
201
 
195
202
  configured_hints = options.dig(:initializationOptions, :featuresConfiguration, :inlayHint)
@@ -1105,7 +1112,7 @@ module RubyLsp
1105
1112
 
1106
1113
  sig { params(id: String, title: String, percentage: Integer).void }
1107
1114
  def begin_progress(id, title, percentage: 0)
1108
- return unless @store.supports_progress
1115
+ return unless @global_state.client_capabilities.supports_progress
1109
1116
 
1110
1117
  send_message(Request.new(
1111
1118
  id: @current_request_id,
@@ -1113,52 +1120,21 @@ module RubyLsp
1113
1120
  params: Interface::WorkDoneProgressCreateParams.new(token: id),
1114
1121
  ))
1115
1122
 
1116
- send_message(Notification.new(
1117
- method: "$/progress",
1118
- params: Interface::ProgressParams.new(
1119
- token: id,
1120
- value: Interface::WorkDoneProgressBegin.new(
1121
- kind: "begin",
1122
- title: title,
1123
- percentage: percentage,
1124
- message: "#{percentage}% completed",
1125
- ),
1126
- ),
1127
- ))
1123
+ send_message(Notification.progress_begin(id, title, percentage: percentage, message: "#{percentage}% completed"))
1128
1124
  end
1129
1125
 
1130
1126
  sig { params(id: String, percentage: Integer).void }
1131
1127
  def progress(id, percentage)
1132
- return unless @store.supports_progress
1128
+ return unless @global_state.client_capabilities.supports_progress
1133
1129
 
1134
- send_message(
1135
- Notification.new(
1136
- method: "$/progress",
1137
- params: Interface::ProgressParams.new(
1138
- token: id,
1139
- value: Interface::WorkDoneProgressReport.new(
1140
- kind: "report",
1141
- percentage: percentage,
1142
- message: "#{percentage}% completed",
1143
- ),
1144
- ),
1145
- ),
1146
- )
1130
+ send_message(Notification.progress_report(id, percentage: percentage, message: "#{percentage}% completed"))
1147
1131
  end
1148
1132
 
1149
1133
  sig { params(id: String).void }
1150
1134
  def end_progress(id)
1151
- return unless @store.supports_progress
1135
+ return unless @global_state.client_capabilities.supports_progress
1152
1136
 
1153
- send_message(
1154
- Notification.new(
1155
- method: "$/progress",
1156
- params: Interface::ProgressParams.new(
1157
- token: id,
1158
- value: Interface::WorkDoneProgressEnd.new(kind: "end"),
1159
- ),
1160
- ),
1161
- )
1137
+ send_message(Notification.progress_end(id))
1162
1138
  rescue ClosedQueueError
1163
1139
  # If the server was killed and the message queue is already closed, there's no way to end the progress
1164
1140
  # notification
@@ -1226,11 +1202,14 @@ module RubyLsp
1226
1202
 
1227
1203
  sig { params(message: T::Hash[Symbol, T.untyped]).void }
1228
1204
  def window_show_message_request(message)
1229
- addon_name = message[:addon_name]
1205
+ result = message[:result]
1206
+ return unless result
1207
+
1208
+ addon_name = result[:addon_name]
1230
1209
  addon = Addon.addons.find { |addon| addon.name == addon_name }
1231
1210
  return unless addon
1232
1211
 
1233
- addon.handle_window_show_message_response(message[:title])
1212
+ addon.handle_window_show_message_response(result[:title])
1234
1213
  end
1235
1214
  end
1236
1215
  end
@@ -7,9 +7,6 @@ module RubyLsp
7
7
 
8
8
  class NonExistingDocumentError < StandardError; end
9
9
 
10
- sig { returns(T::Boolean) }
11
- attr_accessor :supports_progress
12
-
13
10
  sig { returns(T::Hash[Symbol, RequestConfig]) }
14
11
  attr_accessor :features_configuration
15
12
 
@@ -19,7 +16,6 @@ module RubyLsp
19
16
  sig { void }
20
17
  def initialize
21
18
  @state = T.let({}, T::Hash[String, Document[T.untyped]])
22
- @supports_progress = T.let(true, T::Boolean)
23
19
  @features_configuration = T.let(
24
20
  {
25
21
  inlayHint: RequestConfig.new({
@@ -87,6 +87,61 @@ module RubyLsp
87
87
  params: data,
88
88
  )
89
89
  end
90
+
91
+ sig do
92
+ params(
93
+ id: String,
94
+ title: String,
95
+ percentage: T.nilable(Integer),
96
+ message: T.nilable(String),
97
+ ).returns(Notification)
98
+ end
99
+ def progress_begin(id, title, percentage: nil, message: nil)
100
+ new(
101
+ method: "$/progress",
102
+ params: Interface::ProgressParams.new(
103
+ token: id,
104
+ value: Interface::WorkDoneProgressBegin.new(
105
+ kind: "begin",
106
+ title: title,
107
+ percentage: percentage,
108
+ message: message,
109
+ ),
110
+ ),
111
+ )
112
+ end
113
+
114
+ sig do
115
+ params(
116
+ id: String,
117
+ percentage: T.nilable(Integer),
118
+ message: T.nilable(String),
119
+ ).returns(Notification)
120
+ end
121
+ def progress_report(id, percentage: nil, message: nil)
122
+ new(
123
+ method: "$/progress",
124
+ params: Interface::ProgressParams.new(
125
+ token: id,
126
+ value: Interface::WorkDoneProgressReport.new(
127
+ kind: "report",
128
+ percentage: percentage,
129
+ message: message,
130
+ ),
131
+ ),
132
+ )
133
+ end
134
+
135
+ sig { params(id: String).returns(Notification) }
136
+ def progress_end(id)
137
+ Notification.new(
138
+ method: "$/progress",
139
+ params: Interface::ProgressParams.new(
140
+ token: id,
141
+ value: Interface::WorkDoneProgressEnd.new(kind: "end"),
142
+ ),
143
+ )
144
+ end
90
145
  end
91
146
 
92
147
  extend T::Sig
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.1
4
+ version: 0.21.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-31 00:00:00.000000000 Z
11
+ date: 2024-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: language_server-protocol