ruby-lsp 0.11.2 → 0.12.1
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/exe/ruby-lsp +11 -2
- data/exe/ruby-lsp-check +2 -1
- data/exe/ruby-lsp-doctor +15 -0
- data/lib/rubocop/cop/ruby_lsp/use_register_with_handler_method.rb +125 -0
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +10 -2
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +205 -0
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +23 -106
- data/lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +6 -6
- data/lib/ruby_indexer/lib/ruby_indexer/visitor.rb +101 -49
- data/lib/ruby_indexer/ruby_indexer.rb +4 -3
- data/lib/ruby_indexer/test/classes_and_modules_test.rb +49 -16
- data/lib/ruby_indexer/test/constant_test.rb +99 -36
- data/lib/ruby_indexer/test/index_test.rb +1 -1
- data/lib/ruby_indexer/test/method_test.rb +73 -0
- data/lib/ruby_indexer/test/test_case.rb +5 -1
- data/lib/ruby_lsp/addon.rb +8 -8
- data/lib/ruby_lsp/document.rb +14 -14
- data/lib/ruby_lsp/executor.rb +89 -53
- data/lib/ruby_lsp/internal.rb +7 -2
- data/lib/ruby_lsp/listener.rb +6 -6
- data/lib/ruby_lsp/requests/base_request.rb +1 -9
- data/lib/ruby_lsp/requests/code_action_resolve.rb +3 -3
- data/lib/ruby_lsp/requests/code_lens.rb +47 -31
- data/lib/ruby_lsp/requests/completion.rb +83 -32
- data/lib/ruby_lsp/requests/definition.rb +21 -15
- data/lib/ruby_lsp/requests/diagnostics.rb +1 -1
- data/lib/ruby_lsp/requests/document_highlight.rb +508 -31
- data/lib/ruby_lsp/requests/document_link.rb +24 -17
- data/lib/ruby_lsp/requests/document_symbol.rb +42 -42
- data/lib/ruby_lsp/requests/folding_ranges.rb +83 -77
- data/lib/ruby_lsp/requests/hover.rb +22 -17
- data/lib/ruby_lsp/requests/inlay_hints.rb +6 -6
- data/lib/ruby_lsp/requests/selection_ranges.rb +13 -105
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +92 -92
- data/lib/ruby_lsp/requests/support/annotation.rb +3 -3
- data/lib/ruby_lsp/requests/support/common.rb +5 -5
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +21 -7
- data/lib/ruby_lsp/requests/support/rubocop_runner.rb +19 -0
- data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +10 -7
- data/lib/ruby_lsp/requests/support/sorbet.rb +28 -28
- data/lib/ruby_lsp/requests/workspace_symbol.rb +4 -4
- data/lib/ruby_lsp/requests.rb +0 -1
- data/lib/ruby_lsp/setup_bundler.rb +26 -17
- metadata +20 -17
- data/lib/ruby_lsp/event_emitter.rb +0 -351
- data/lib/ruby_lsp/requests/support/highlight_target.rb +0 -118
@@ -43,15 +43,18 @@ module RubyLsp
|
|
43
43
|
def compute_delta(token)
|
44
44
|
row = token.location.start_line - 1
|
45
45
|
column = token.location.start_column
|
46
|
-
delta_line = row - @current_row
|
47
46
|
|
48
|
-
|
49
|
-
|
47
|
+
begin
|
48
|
+
delta_line = row - @current_row
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
delta_column = column
|
51
|
+
delta_column -= @current_column if delta_line == 0
|
52
|
+
|
53
|
+
[delta_line, delta_column, token.length, token.type, encode_modifiers(token.modifier)]
|
54
|
+
ensure
|
55
|
+
@current_row = row
|
56
|
+
@current_column = column
|
57
|
+
end
|
55
58
|
end
|
56
59
|
|
57
60
|
# Encode an array of modifiers to positions onto a bit flag
|
@@ -10,39 +10,39 @@ module RubyLsp
|
|
10
10
|
|
11
11
|
ANNOTATIONS = T.let(
|
12
12
|
{
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
13
|
+
abstract!: Annotation.new(arity: 0),
|
14
|
+
absurd: Annotation.new(arity: 1, receiver: true),
|
15
|
+
all: Annotation.new(arity: (2..), receiver: true),
|
16
|
+
any: Annotation.new(arity: (2..), receiver: true),
|
17
|
+
assert_type!: Annotation.new(arity: 2, receiver: true),
|
18
|
+
attached_class: Annotation.new(arity: 0, receiver: true),
|
19
|
+
bind: Annotation.new(arity: 2, receiver: true),
|
20
|
+
cast: Annotation.new(arity: 2, receiver: true),
|
21
|
+
class_of: Annotation.new(arity: 1, receiver: true),
|
22
|
+
enums: Annotation.new(arity: 0),
|
23
|
+
interface!: Annotation.new(arity: 0),
|
24
|
+
let: Annotation.new(arity: 2, receiver: true),
|
25
|
+
mixes_in_class_methods: Annotation.new(arity: 1),
|
26
|
+
must: Annotation.new(arity: 1, receiver: true),
|
27
|
+
must_because: Annotation.new(arity: 1, receiver: true),
|
28
|
+
nilable: Annotation.new(arity: 1, receiver: true),
|
29
|
+
noreturn: Annotation.new(arity: 0, receiver: true),
|
30
|
+
requires_ancestor: Annotation.new(arity: 0),
|
31
|
+
reveal_type: Annotation.new(arity: 1, receiver: true),
|
32
|
+
sealed!: Annotation.new(arity: 0),
|
33
|
+
self_type: Annotation.new(arity: 0, receiver: true),
|
34
|
+
sig: Annotation.new(arity: 0),
|
35
|
+
type_member: Annotation.new(arity: (0..1)),
|
36
|
+
type_template: Annotation.new(arity: 0),
|
37
|
+
unsafe: Annotation.new(arity: 1),
|
38
|
+
untyped: Annotation.new(arity: 0, receiver: true),
|
39
39
|
},
|
40
|
-
T::Hash[
|
40
|
+
T::Hash[Symbol, Annotation],
|
41
41
|
)
|
42
42
|
|
43
43
|
sig do
|
44
44
|
params(
|
45
|
-
node:
|
45
|
+
node: Prism::CallNode,
|
46
46
|
).returns(T::Boolean)
|
47
47
|
end
|
48
48
|
def annotation?(node)
|
@@ -73,14 +73,14 @@ module RubyLsp
|
|
73
73
|
|
74
74
|
private
|
75
75
|
|
76
|
-
sig { params(entry: RubyIndexer::
|
76
|
+
sig { params(entry: RubyIndexer::Entry).returns(T.nilable(Integer)) }
|
77
77
|
def kind_for_entry(entry)
|
78
78
|
case entry
|
79
|
-
when RubyIndexer::
|
79
|
+
when RubyIndexer::Entry::Class
|
80
80
|
Constant::SymbolKind::CLASS
|
81
|
-
when RubyIndexer::
|
81
|
+
when RubyIndexer::Entry::Module
|
82
82
|
Constant::SymbolKind::NAMESPACE
|
83
|
-
when RubyIndexer::
|
83
|
+
when RubyIndexer::Entry::Constant
|
84
84
|
Constant::SymbolKind::CONSTANT
|
85
85
|
end
|
86
86
|
end
|
data/lib/ruby_lsp/requests.rb
CHANGED
@@ -51,7 +51,6 @@ module RubyLsp
|
|
51
51
|
autoload :SemanticTokenEncoder, "ruby_lsp/requests/support/semantic_token_encoder"
|
52
52
|
autoload :Annotation, "ruby_lsp/requests/support/annotation"
|
53
53
|
autoload :Sorbet, "ruby_lsp/requests/support/sorbet"
|
54
|
-
autoload :HighlightTarget, "ruby_lsp/requests/support/highlight_target"
|
55
54
|
autoload :RailsDocumentClient, "ruby_lsp/requests/support/rails_document_client"
|
56
55
|
autoload :Common, "ruby_lsp/requests/support/common"
|
57
56
|
autoload :FormatterRunner, "ruby_lsp/requests/support/formatter_runner"
|
@@ -20,17 +20,11 @@ module RubyLsp
|
|
20
20
|
|
21
21
|
FOUR_HOURS = T.let(4 * 60 * 60, Integer)
|
22
22
|
|
23
|
-
sig { params(project_path: String,
|
24
|
-
def initialize(project_path,
|
23
|
+
sig { params(project_path: String, options: T.untyped).void }
|
24
|
+
def initialize(project_path, **options)
|
25
25
|
@project_path = project_path
|
26
|
-
@branch = branch
|
27
|
-
|
28
|
-
# Custom bundle paths
|
29
|
-
@custom_dir = T.let(Pathname.new(".ruby-lsp").expand_path(Dir.pwd), Pathname)
|
30
|
-
@custom_gemfile = T.let(@custom_dir + "Gemfile", Pathname)
|
31
|
-
@custom_lockfile = T.let(@custom_dir + "Gemfile.lock", Pathname)
|
32
|
-
@lockfile_hash_path = T.let(@custom_dir + "main_lockfile_hash", Pathname)
|
33
|
-
@last_updated_path = T.let(@custom_dir + "last_updated", Pathname)
|
26
|
+
@branch = T.let(options[:branch], T.nilable(String))
|
27
|
+
@experimental = T.let(options[:experimental], T.nilable(T::Boolean))
|
34
28
|
|
35
29
|
# Regular bundle paths
|
36
30
|
@gemfile = T.let(
|
@@ -43,12 +37,21 @@ module RubyLsp
|
|
43
37
|
)
|
44
38
|
@lockfile = T.let(@gemfile ? Bundler.default_lockfile : nil, T.nilable(Pathname))
|
45
39
|
|
40
|
+
@gemfile_name = T.let(@gemfile&.basename&.to_s || "Gemfile", String)
|
41
|
+
|
42
|
+
# Custom bundle paths
|
43
|
+
@custom_dir = T.let(Pathname.new(".ruby-lsp").expand_path(Dir.pwd), Pathname)
|
44
|
+
@custom_gemfile = T.let(@custom_dir + @gemfile_name, Pathname)
|
45
|
+
@custom_lockfile = T.let(@custom_dir + (@lockfile&.basename || "Gemfile.lock"), Pathname)
|
46
|
+
@lockfile_hash_path = T.let(@custom_dir + "main_lockfile_hash", Pathname)
|
47
|
+
@last_updated_path = T.let(@custom_dir + "last_updated", Pathname)
|
48
|
+
|
46
49
|
@dependencies = T.let(load_dependencies, T::Hash[String, T.untyped])
|
47
50
|
end
|
48
51
|
|
49
|
-
#
|
50
|
-
# server
|
51
|
-
sig { returns([String, T.nilable(String)]) }
|
52
|
+
# Sets up the custom bundle and returns the `BUNDLE_GEMFILE`, `BUNDLE_PATH` and `BUNDLE_APP_CONFIG` that should be
|
53
|
+
# used for running the server
|
54
|
+
sig { returns([String, T.nilable(String), T.nilable(String)]) }
|
52
55
|
def setup!
|
53
56
|
raise BundleNotLocked if @gemfile&.exist? && !@lockfile&.exist?
|
54
57
|
|
@@ -118,7 +121,7 @@ module RubyLsp
|
|
118
121
|
# If there's a top level Gemfile, we want to evaluate from the custom bundle. We get the source from the top level
|
119
122
|
# Gemfile, so if there isn't one we need to add a default source
|
120
123
|
if @gemfile&.exist?
|
121
|
-
parts << "eval_gemfile(File.expand_path(\"
|
124
|
+
parts << "eval_gemfile(File.expand_path(\"../#{@gemfile_name}\", __dir__))"
|
122
125
|
else
|
123
126
|
parts.unshift('source "https://rubygems.org"')
|
124
127
|
end
|
@@ -156,7 +159,7 @@ module RubyLsp
|
|
156
159
|
dependencies
|
157
160
|
end
|
158
161
|
|
159
|
-
sig { params(bundle_gemfile: T.nilable(Pathname)).returns([String, T.nilable(String)]) }
|
162
|
+
sig { params(bundle_gemfile: T.nilable(Pathname)).returns([String, T.nilable(String), T.nilable(String)]) }
|
160
163
|
def run_bundle_install(bundle_gemfile = @gemfile)
|
161
164
|
# If the user has a custom bundle path configured, we need to ensure that we will use the absolute and not
|
162
165
|
# relative version of it when running `bundle install`. This is necessary to avoid installing the gems under the
|
@@ -170,6 +173,9 @@ module RubyLsp
|
|
170
173
|
env["BUNDLE_GEMFILE"] = bundle_gemfile.to_s
|
171
174
|
env["BUNDLE_PATH"] = expanded_path if expanded_path
|
172
175
|
|
176
|
+
local_config_path = File.join(Dir.pwd, ".bundle")
|
177
|
+
env["BUNDLE_APP_CONFIG"] = local_config_path if Dir.exist?(local_config_path)
|
178
|
+
|
173
179
|
# If both `ruby-lsp` and `debug` are already in the Gemfile, then we shouldn't try to upgrade them or else we'll
|
174
180
|
# produce undesired source control changes. If the custom bundle was just created and either `ruby-lsp` or `debug`
|
175
181
|
# weren't a part of the Gemfile, then we need to run `bundle install` for the first time to generate the
|
@@ -185,7 +191,9 @@ module RubyLsp
|
|
185
191
|
command.prepend("(")
|
186
192
|
command << " && bundle update "
|
187
193
|
command << "ruby-lsp " unless @dependencies["ruby-lsp"]
|
188
|
-
command << "debug" unless @dependencies["debug"]
|
194
|
+
command << "debug " unless @dependencies["debug"]
|
195
|
+
command << "--pre" if @experimental
|
196
|
+
command.delete_suffix!(" ")
|
189
197
|
command << ")"
|
190
198
|
|
191
199
|
@last_updated_path.write(Time.now.iso8601)
|
@@ -199,8 +207,9 @@ module RubyLsp
|
|
199
207
|
|
200
208
|
# Add bundle update
|
201
209
|
warn("Ruby LSP> Running bundle install for the custom bundle. This may take a while...")
|
210
|
+
warn("Ruby LSP> Command: #{command}")
|
202
211
|
system(env, command)
|
203
|
-
[bundle_gemfile.to_s, expanded_path]
|
212
|
+
[bundle_gemfile.to_s, expanded_path, env["BUNDLE_APP_CONFIG"]]
|
204
213
|
end
|
205
214
|
|
206
215
|
sig { returns(T::Boolean) }
|
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.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: language_server-protocol
|
@@ -25,45 +25,46 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.17.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: prism
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.15.1
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0.16'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
41
|
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
43
|
+
version: 0.15.1
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.16'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
48
|
+
name: sorbet-runtime
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - ">="
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
- - "<"
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: '0.13'
|
53
|
+
version: 0.5.5685
|
51
54
|
type: :runtime
|
52
55
|
prerelease: false
|
53
56
|
version_requirements: !ruby/object:Gem::Requirement
|
54
57
|
requirements:
|
55
58
|
- - ">="
|
56
59
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
-
- - "<"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0.13'
|
60
|
+
version: 0.5.5685
|
61
61
|
description: An opinionated language server for Ruby
|
62
62
|
email:
|
63
63
|
- ruby@shopify.com
|
64
64
|
executables:
|
65
65
|
- ruby-lsp
|
66
66
|
- ruby-lsp-check
|
67
|
+
- ruby-lsp-doctor
|
67
68
|
extensions: []
|
68
69
|
extra_rdoc_files: []
|
69
70
|
files:
|
@@ -72,10 +73,13 @@ files:
|
|
72
73
|
- VERSION
|
73
74
|
- exe/ruby-lsp
|
74
75
|
- exe/ruby-lsp-check
|
76
|
+
- exe/ruby-lsp-doctor
|
75
77
|
- lib/core_ext/uri.rb
|
76
78
|
- lib/rubocop/cop/ruby_lsp/use_language_server_aliases.rb
|
79
|
+
- lib/rubocop/cop/ruby_lsp/use_register_with_handler_method.rb
|
77
80
|
- lib/ruby-lsp.rb
|
78
81
|
- lib/ruby_indexer/lib/ruby_indexer/configuration.rb
|
82
|
+
- lib/ruby_indexer/lib/ruby_indexer/entry.rb
|
79
83
|
- lib/ruby_indexer/lib/ruby_indexer/index.rb
|
80
84
|
- lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
|
81
85
|
- lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb
|
@@ -85,12 +89,12 @@ files:
|
|
85
89
|
- lib/ruby_indexer/test/configuration_test.rb
|
86
90
|
- lib/ruby_indexer/test/constant_test.rb
|
87
91
|
- lib/ruby_indexer/test/index_test.rb
|
92
|
+
- lib/ruby_indexer/test/method_test.rb
|
88
93
|
- lib/ruby_indexer/test/prefix_tree_test.rb
|
89
94
|
- lib/ruby_indexer/test/test_case.rb
|
90
95
|
- lib/ruby_lsp/addon.rb
|
91
96
|
- lib/ruby_lsp/check_docs.rb
|
92
97
|
- lib/ruby_lsp/document.rb
|
93
|
-
- lib/ruby_lsp/event_emitter.rb
|
94
98
|
- lib/ruby_lsp/executor.rb
|
95
99
|
- lib/ruby_lsp/internal.rb
|
96
100
|
- lib/ruby_lsp/listener.rb
|
@@ -118,7 +122,6 @@ files:
|
|
118
122
|
- lib/ruby_lsp/requests/support/common.rb
|
119
123
|
- lib/ruby_lsp/requests/support/dependency_detector.rb
|
120
124
|
- lib/ruby_lsp/requests/support/formatter_runner.rb
|
121
|
-
- lib/ruby_lsp/requests/support/highlight_target.rb
|
122
125
|
- lib/ruby_lsp/requests/support/rubocop_diagnostic.rb
|
123
126
|
- lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
|
124
127
|
- lib/ruby_lsp/requests/support/rubocop_formatting_runner.rb
|
@@ -153,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
156
|
- !ruby/object:Gem::Version
|
154
157
|
version: '0'
|
155
158
|
requirements: []
|
156
|
-
rubygems_version: 3.4.
|
159
|
+
rubygems_version: 3.4.21
|
157
160
|
signing_key:
|
158
161
|
specification_version: 4
|
159
162
|
summary: An opinionated language server for Ruby
|