ruby-lsp 0.3.4 → 0.3.5
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 +4 -4
- data/VERSION +1 -1
- data/lib/ruby_lsp/requests/document_highlight.rb +5 -2
- data/lib/ruby_lsp/requests/document_link.rb +3 -3
- data/lib/ruby_lsp/requests/hover.rb +0 -2
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +38 -11
- data/lib/ruby_lsp/requests/support/rails_document_client.rb +1 -1
- data/lib/ruby_lsp/requests.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37a06a9c8be918e5c5a22986e68e378fc767f5c5becc46f79baa78d4b00c8c08
|
4
|
+
data.tar.gz: 4a79a4a39aaf59c49bddd6420e526246e31ade2a944ab314328f0a30da7661c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 698eaf5cf5d213f6a1ffce60e40f1a4e89d599132e1940699f3a98eb5de7b4141cb442338f97c3a35850a0ed239a52a8d27edaf8a59e7a1f169373a8c2fd9fa1
|
7
|
+
data.tar.gz: d5668dfd0c88482fbb6fab215b1782a2fcfc384504a485b8047fd28a99bb3b958de9bde80ecd213b30ae369bfb50d521c60d361e631d06e398f4efb5731e3158
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
@@ -27,11 +27,14 @@ module RubyLsp
|
|
27
27
|
|
28
28
|
sig { params(document: Document, position: Document::PositionShape).void }
|
29
29
|
def initialize(document, position)
|
30
|
+
super(document)
|
31
|
+
|
30
32
|
@highlights = T.let([], T::Array[LanguageServer::Protocol::Interface::DocumentHighlight])
|
31
33
|
position = Document::Scanner.new(document.source).find_position(position)
|
32
|
-
@target = T.let(find(T.must(document.tree), position), T.nilable(Support::HighlightTarget))
|
33
34
|
|
34
|
-
|
35
|
+
return unless document.parsed?
|
36
|
+
|
37
|
+
@target = T.let(find(T.must(document.tree), position), T.nilable(Support::HighlightTarget))
|
35
38
|
end
|
36
39
|
|
37
40
|
sig { override.returns(T.all(T::Array[LanguageServer::Protocol::Interface::DocumentHighlight], Object)) }
|
@@ -31,7 +31,7 @@ module RubyLsp
|
|
31
31
|
class << self
|
32
32
|
extend T::Sig
|
33
33
|
|
34
|
-
sig { returns(T::Hash[String, T::
|
34
|
+
sig { returns(T::Hash[String, T::Hash[String, T::Hash[String, String]]]) }
|
35
35
|
def gem_paths
|
36
36
|
@gem_paths ||= T.let(begin
|
37
37
|
lookup = {}
|
@@ -61,7 +61,7 @@ module RubyLsp
|
|
61
61
|
end
|
62
62
|
|
63
63
|
lookup
|
64
|
-
end, T.nilable(T::Hash[String, T::
|
64
|
+
end, T.nilable(T::Hash[String, T::Hash[String, T::Hash[String, String]]]))
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -88,7 +88,7 @@ module RubyLsp
|
|
88
88
|
return unless match
|
89
89
|
|
90
90
|
uri = T.cast(URI(match[0]), URI::Source)
|
91
|
-
gem_version = resolve_version(uri)
|
91
|
+
gem_version = T.must(resolve_version(uri))
|
92
92
|
file_path = self.class.gem_paths.dig(uri.gem_name, gem_version, uri.path)
|
93
93
|
return if file_path.nil?
|
94
94
|
|
@@ -20,6 +20,7 @@ module RubyLsp
|
|
20
20
|
# ```
|
21
21
|
class SemanticHighlighting < BaseRequest
|
22
22
|
extend T::Sig
|
23
|
+
include SyntaxTree::WithEnvironment
|
23
24
|
|
24
25
|
TOKEN_TYPES = T.let({
|
25
26
|
namespace: 0,
|
@@ -172,37 +173,52 @@ module RubyLsp
|
|
172
173
|
def visit_params(node)
|
173
174
|
node.keywords.each do |keyword,|
|
174
175
|
location = keyword.location
|
175
|
-
add_token(location_without_colon(location), :
|
176
|
+
add_token(location_without_colon(location), :parameter)
|
176
177
|
end
|
177
178
|
|
178
179
|
node.requireds.each do |required|
|
179
|
-
add_token(required.location, :
|
180
|
+
add_token(required.location, :parameter)
|
180
181
|
end
|
181
182
|
|
182
183
|
rest = node.keyword_rest
|
183
|
-
|
184
|
+
if rest && !rest.is_a?(SyntaxTree::ArgsForward)
|
185
|
+
name = rest.name
|
186
|
+
add_token(name.location, :parameter) if name
|
187
|
+
end
|
188
|
+
|
189
|
+
super
|
190
|
+
end
|
191
|
+
|
192
|
+
sig { override.params(node: SyntaxTree::Field).void }
|
193
|
+
def visit_field(node)
|
194
|
+
add_token(node.name.location, :method)
|
184
195
|
|
185
|
-
|
186
|
-
add_token(name.location, :variable) if name
|
196
|
+
super
|
187
197
|
end
|
188
198
|
|
189
199
|
sig { override.params(node: SyntaxTree::VarField).void }
|
190
200
|
def visit_var_field(node)
|
191
|
-
|
201
|
+
value = node.value
|
202
|
+
|
203
|
+
case value
|
192
204
|
when SyntaxTree::Ident
|
193
|
-
|
205
|
+
type = type_for_local(value)
|
206
|
+
add_token(value.location, type)
|
194
207
|
else
|
195
|
-
visit(
|
208
|
+
visit(value)
|
196
209
|
end
|
197
210
|
end
|
198
211
|
|
199
212
|
sig { override.params(node: SyntaxTree::VarRef).void }
|
200
213
|
def visit_var_ref(node)
|
201
|
-
|
214
|
+
value = node.value
|
215
|
+
|
216
|
+
case value
|
202
217
|
when SyntaxTree::Ident
|
203
|
-
|
218
|
+
type = type_for_local(value)
|
219
|
+
add_token(value.location, type)
|
204
220
|
else
|
205
|
-
visit(
|
221
|
+
visit(value)
|
206
222
|
end
|
207
223
|
end
|
208
224
|
|
@@ -263,6 +279,17 @@ module RubyLsp
|
|
263
279
|
def special_method?(method_name)
|
264
280
|
SPECIAL_RUBY_METHODS.include?(method_name)
|
265
281
|
end
|
282
|
+
|
283
|
+
sig { params(value: SyntaxTree::Ident).returns(Symbol) }
|
284
|
+
def type_for_local(value)
|
285
|
+
local = current_environment.find_local(value.value)
|
286
|
+
|
287
|
+
if local.nil? || local.type == :variable
|
288
|
+
:variable
|
289
|
+
else
|
290
|
+
:parameter
|
291
|
+
end
|
292
|
+
end
|
266
293
|
end
|
267
294
|
end
|
268
295
|
end
|
data/lib/ruby_lsp/requests.rb
CHANGED
@@ -39,6 +39,7 @@ module RubyLsp
|
|
39
39
|
autoload :SemanticTokenEncoder, "ruby_lsp/requests/support/semantic_token_encoder"
|
40
40
|
autoload :SyntaxErrorDiagnostic, "ruby_lsp/requests/support/syntax_error_diagnostic"
|
41
41
|
autoload :HighlightTarget, "ruby_lsp/requests/support/highlight_target"
|
42
|
+
autoload :RailsDocumentClient, "ruby_lsp/requests/support/rails_document_client"
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
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.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: language_server-protocol
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 4.0.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 4.0.2
|
55
55
|
description: An opinionated language server for Ruby
|
56
56
|
email:
|
57
57
|
- ruby@shopify.com
|