ruby-lsp 0.14.6 → 0.16.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/README.md +1 -1
- data/VERSION +1 -1
- data/exe/ruby-lsp +1 -16
- data/exe/ruby-lsp-check +13 -22
- data/exe/ruby-lsp-doctor +9 -0
- data/lib/ruby_indexer/lib/ruby_indexer/collector.rb +14 -1
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +11 -23
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +32 -8
- data/lib/ruby_indexer/lib/ruby_indexer/location.rb +26 -0
- data/lib/ruby_indexer/ruby_indexer.rb +1 -0
- data/lib/ruby_indexer/test/classes_and_modules_test.rb +46 -0
- data/lib/ruby_indexer/test/configuration_test.rb +2 -11
- data/lib/ruby_lsp/addon.rb +18 -9
- data/lib/ruby_lsp/base_server.rb +149 -0
- data/lib/ruby_lsp/document.rb +6 -11
- data/lib/ruby_lsp/global_state.rb +180 -0
- data/lib/ruby_lsp/internal.rb +4 -1
- data/lib/ruby_lsp/listeners/code_lens.rb +22 -13
- data/lib/ruby_lsp/listeners/completion.rb +13 -14
- data/lib/ruby_lsp/listeners/definition.rb +14 -6
- data/lib/ruby_lsp/listeners/document_symbol.rb +91 -3
- data/lib/ruby_lsp/listeners/hover.rb +6 -5
- data/lib/ruby_lsp/listeners/signature_help.rb +7 -4
- data/lib/ruby_lsp/load_sorbet.rb +62 -0
- data/lib/ruby_lsp/requests/code_lens.rb +3 -2
- data/lib/ruby_lsp/requests/completion.rb +15 -4
- data/lib/ruby_lsp/requests/completion_resolve.rb +56 -0
- data/lib/ruby_lsp/requests/definition.rb +11 -4
- data/lib/ruby_lsp/requests/diagnostics.rb +8 -11
- data/lib/ruby_lsp/requests/document_symbol.rb +3 -3
- data/lib/ruby_lsp/requests/formatting.rb +7 -43
- data/lib/ruby_lsp/requests/hover.rb +4 -4
- data/lib/ruby_lsp/requests/request.rb +2 -0
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +7 -4
- data/lib/ruby_lsp/requests/signature_help.rb +4 -3
- data/lib/ruby_lsp/requests/support/common.rb +16 -5
- data/lib/ruby_lsp/requests/support/formatter.rb +26 -0
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +1 -1
- data/lib/ruby_lsp/requests/support/rubocop_formatter.rb +47 -0
- data/lib/ruby_lsp/requests/support/rubocop_runner.rb +4 -0
- data/lib/ruby_lsp/requests/support/{syntax_tree_formatting_runner.rb → syntax_tree_formatter.rb} +13 -6
- data/lib/ruby_lsp/requests/workspace_symbol.rb +5 -4
- data/lib/ruby_lsp/requests.rb +3 -1
- data/lib/ruby_lsp/response_builders/semantic_highlighting.rb +36 -13
- data/lib/ruby_lsp/server.rb +763 -142
- data/lib/ruby_lsp/setup_bundler.rb +13 -1
- data/lib/ruby_lsp/store.rb +3 -15
- data/lib/ruby_lsp/test_helper.rb +52 -0
- data/lib/ruby_lsp/utils.rb +68 -33
- metadata +16 -13
- data/lib/ruby_lsp/executor.rb +0 -614
- data/lib/ruby_lsp/requests/support/dependency_detector.rb +0 -93
- data/lib/ruby_lsp/requests/support/formatter_runner.rb +0 -18
- data/lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb +0 -34
- data/lib/ruby_lsp/requests/support/rubocop_formatting_runner.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcd4426f17d6d429be733a9adcdf799e23c29689ad5fb69f9b9f7b3cd334bf9b
|
4
|
+
data.tar.gz: 071d5c37e1acf83c07a5b48e85a3bc4a18fb63a20b54ff191158799cf4320803
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9edc44ec74f5f5d9b5f15fb7d22501126eb8f6bec3d9a69b3061946b369ecb0e453e45e9a0dc9df1482117dc738f7bd66005e2dcd0cd46e3aaad6f6658283766
|
7
|
+
data.tar.gz: c4f9ddb4da9373544b2456632a0fb76bdbca5e5ddf5e874b0e6ab4f6aae13ad8b17ef9482873b37ae33bc7ec797faebde76bf5a6e9d86e6a4ddf798b4eb9f0df
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ The Ruby LSP features include
|
|
29
29
|
- Debugging support
|
30
30
|
- Running and debugging tests through VS Code's UI
|
31
31
|
- Go to definition for classes, modules, constants and required files
|
32
|
-
- Showing
|
32
|
+
- Showing documentation on hover for classes, modules and constants
|
33
33
|
- Completion for classes, modules, constants and require paths
|
34
34
|
- Fuzzy search classes, modules and constants anywhere in the project and its dependencies (workspace symbol)
|
35
35
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.16.5
|
data/exe/ruby-lsp
CHANGED
@@ -68,22 +68,7 @@ if ENV["BUNDLE_GEMFILE"].nil?
|
|
68
68
|
exit exec(env, "bundle exec ruby-lsp #{original_args.join(" ")}")
|
69
69
|
end
|
70
70
|
|
71
|
-
require "
|
72
|
-
|
73
|
-
begin
|
74
|
-
T::Configuration.default_checked_level = :never
|
75
|
-
# Suppresses call validation errors
|
76
|
-
T::Configuration.call_validation_error_handler = ->(*) {}
|
77
|
-
# Suppresses errors caused by T.cast, T.let, T.must, etc.
|
78
|
-
T::Configuration.inline_type_error_handler = ->(*) {}
|
79
|
-
# Suppresses errors caused by incorrect parameter ordering
|
80
|
-
T::Configuration.sig_validation_error_handler = ->(*) {}
|
81
|
-
rescue
|
82
|
-
# Need this rescue so that if another gem has
|
83
|
-
# already set the checked level by the time we
|
84
|
-
# get to it, we don't fail outright.
|
85
|
-
nil
|
86
|
-
end
|
71
|
+
require "ruby_lsp/load_sorbet"
|
87
72
|
|
88
73
|
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
|
89
74
|
require "ruby_lsp/internal"
|
data/exe/ruby-lsp-check
CHANGED
@@ -3,16 +3,7 @@
|
|
3
3
|
|
4
4
|
# This executable checks if all automatic LSP requests run successfully on every Ruby file under the current directory
|
5
5
|
|
6
|
-
require "
|
7
|
-
|
8
|
-
begin
|
9
|
-
T::Configuration.default_checked_level = :never
|
10
|
-
T::Configuration.call_validation_error_handler = ->(*) {}
|
11
|
-
T::Configuration.inline_type_error_handler = ->(*) {}
|
12
|
-
T::Configuration.sig_validation_error_handler = ->(*) {}
|
13
|
-
rescue
|
14
|
-
nil
|
15
|
-
end
|
6
|
+
require "ruby_lsp/load_sorbet"
|
16
7
|
|
17
8
|
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
|
18
9
|
require "ruby_lsp/internal"
|
@@ -24,30 +15,30 @@ files = Dir.glob("#{Dir.pwd}/**/*.rb")
|
|
24
15
|
puts "Verifying that all automatic LSP requests execute successfully. This may take a while..."
|
25
16
|
|
26
17
|
errors = {}
|
27
|
-
|
28
|
-
message_queue = Thread::Queue.new
|
29
|
-
RubyLsp::Addon.load_addons(message_queue)
|
30
|
-
executor = RubyLsp::Executor.new(store, message_queue)
|
18
|
+
server = RubyLsp::Server.new(test_mode: true)
|
31
19
|
|
32
20
|
files.each_with_index do |file, index|
|
33
21
|
uri = URI("file://#{file}")
|
34
|
-
|
22
|
+
server.process_message({
|
23
|
+
method: "textDocument/didOpen",
|
24
|
+
params: { textDocument: { uri: uri, text: File.read(file), version: 1 } },
|
25
|
+
})
|
35
26
|
|
36
27
|
# Executing any of the automatic requests will execute all of them, so here we just pick one
|
37
|
-
|
28
|
+
server.process_message({
|
29
|
+
id: 1,
|
38
30
|
method: "textDocument/documentSymbol",
|
39
|
-
params: { textDocument: { uri: uri
|
31
|
+
params: { textDocument: { uri: uri } },
|
40
32
|
})
|
41
33
|
|
42
|
-
|
43
|
-
errors[file] =
|
34
|
+
result = server.pop_response
|
35
|
+
errors[file] = result.message if result.is_a?(RubyLsp::Error)
|
44
36
|
ensure
|
45
|
-
|
37
|
+
server.process_message({ method: "textDocument/didClose", params: { textDocument: { uri: uri } } })
|
38
|
+
server.pop_response
|
46
39
|
print("\033[M\033[0KCompleted #{index + 1}/#{files.length}") unless ENV["CI"]
|
47
40
|
end
|
48
|
-
|
49
41
|
puts "\n"
|
50
|
-
message_queue.close
|
51
42
|
|
52
43
|
# Indexing
|
53
44
|
puts "Verifying that indexing executes successfully. This may take a while..."
|
data/exe/ruby-lsp-doctor
CHANGED
@@ -4,6 +4,15 @@
|
|
4
4
|
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
|
5
5
|
require "ruby_lsp/internal"
|
6
6
|
|
7
|
+
if File.exist?(".index.yml")
|
8
|
+
begin
|
9
|
+
config = YAML.parse_file(".index.yml").to_ruby
|
10
|
+
rescue => e
|
11
|
+
abort("Error parsing config: #{e.message}")
|
12
|
+
end
|
13
|
+
RubyIndexer.configuration.apply_config(config)
|
14
|
+
end
|
15
|
+
|
7
16
|
index = RubyIndexer::Index.new
|
8
17
|
|
9
18
|
puts "Globbing for indexable files"
|
@@ -154,6 +154,8 @@ module RubyIndexer
|
|
154
154
|
handle_attribute(node, reader: true, writer: true)
|
155
155
|
when :include
|
156
156
|
handle_include(node)
|
157
|
+
when :prepend
|
158
|
+
handle_prepend(node)
|
157
159
|
end
|
158
160
|
end
|
159
161
|
|
@@ -355,6 +357,16 @@ module RubyIndexer
|
|
355
357
|
|
356
358
|
sig { params(node: Prism::CallNode).void }
|
357
359
|
def handle_include(node)
|
360
|
+
handle_module_operation(node, :included_modules)
|
361
|
+
end
|
362
|
+
|
363
|
+
sig { params(node: Prism::CallNode).void }
|
364
|
+
def handle_prepend(node)
|
365
|
+
handle_module_operation(node, :prepended_modules)
|
366
|
+
end
|
367
|
+
|
368
|
+
sig { params(node: Prism::CallNode, operation: Symbol).void }
|
369
|
+
def handle_module_operation(node, operation)
|
358
370
|
return unless @current_owner
|
359
371
|
|
360
372
|
arguments = node.arguments&.arguments
|
@@ -369,7 +381,8 @@ module RubyIndexer
|
|
369
381
|
# If a constant path reference is dynamic or missing parts, we can't
|
370
382
|
# index it
|
371
383
|
end
|
372
|
-
@current_owner.included_modules.
|
384
|
+
collection = operation == :included_modules ? @current_owner.included_modules : @current_owner.prepended_modules
|
385
|
+
collection.concat(names)
|
373
386
|
end
|
374
387
|
end
|
375
388
|
end
|
@@ -43,20 +43,6 @@ module RubyIndexer
|
|
43
43
|
)
|
44
44
|
end
|
45
45
|
|
46
|
-
sig { void }
|
47
|
-
def load_config
|
48
|
-
return unless File.exist?(".index.yml")
|
49
|
-
|
50
|
-
config = YAML.parse_file(".index.yml")
|
51
|
-
return unless config
|
52
|
-
|
53
|
-
config_hash = config.to_ruby
|
54
|
-
validate_config!(config_hash)
|
55
|
-
apply_config(config_hash)
|
56
|
-
rescue Psych::SyntaxError => e
|
57
|
-
raise e, "Syntax error while loading .index.yml configuration: #{e.message}"
|
58
|
-
end
|
59
|
-
|
60
46
|
sig { returns(T::Array[IndexablePath]) }
|
61
47
|
def indexables
|
62
48
|
excluded_gems = @excluded_gems - @included_gems
|
@@ -158,6 +144,17 @@ module RubyIndexer
|
|
158
144
|
@magic_comment_regex ||= T.let(/^#\s*#{@excluded_magic_comments.join("|")}/, T.nilable(Regexp))
|
159
145
|
end
|
160
146
|
|
147
|
+
sig { params(config: T::Hash[String, T.untyped]).void }
|
148
|
+
def apply_config(config)
|
149
|
+
validate_config!(config)
|
150
|
+
|
151
|
+
@excluded_gems.concat(config["excluded_gems"]) if config["excluded_gems"]
|
152
|
+
@included_gems.concat(config["included_gems"]) if config["included_gems"]
|
153
|
+
@excluded_patterns.concat(config["excluded_patterns"]) if config["excluded_patterns"]
|
154
|
+
@included_patterns.concat(config["included_patterns"]) if config["included_patterns"]
|
155
|
+
@excluded_magic_comments.concat(config["excluded_magic_comments"]) if config["excluded_magic_comments"]
|
156
|
+
end
|
157
|
+
|
161
158
|
private
|
162
159
|
|
163
160
|
sig { params(config: T::Hash[String, T.untyped]).void }
|
@@ -175,15 +172,6 @@ module RubyIndexer
|
|
175
172
|
raise ArgumentError, errors.join("\n") if errors.any?
|
176
173
|
end
|
177
174
|
|
178
|
-
sig { params(config: T::Hash[String, T.untyped]).void }
|
179
|
-
def apply_config(config)
|
180
|
-
@excluded_gems.concat(config["excluded_gems"]) if config["excluded_gems"]
|
181
|
-
@included_gems.concat(config["included_gems"]) if config["included_gems"]
|
182
|
-
@excluded_patterns.concat(config["excluded_patterns"]) if config["excluded_patterns"]
|
183
|
-
@included_patterns.concat(config["included_patterns"]) if config["included_patterns"]
|
184
|
-
@excluded_magic_comments.concat(config["excluded_magic_comments"]) if config["excluded_magic_comments"]
|
185
|
-
end
|
186
|
-
|
187
175
|
sig { returns(T::Array[String]) }
|
188
176
|
def initial_excluded_gems
|
189
177
|
excluded, others = Bundler.definition.dependencies.partition do |dependency|
|
@@ -11,7 +11,7 @@ module RubyIndexer
|
|
11
11
|
sig { returns(String) }
|
12
12
|
attr_reader :file_path
|
13
13
|
|
14
|
-
sig { returns(
|
14
|
+
sig { returns(RubyIndexer::Location) }
|
15
15
|
attr_reader :location
|
16
16
|
|
17
17
|
sig { returns(T::Array[String]) }
|
@@ -20,13 +20,33 @@ module RubyIndexer
|
|
20
20
|
sig { returns(Symbol) }
|
21
21
|
attr_accessor :visibility
|
22
22
|
|
23
|
-
sig
|
23
|
+
sig do
|
24
|
+
params(
|
25
|
+
name: String,
|
26
|
+
file_path: String,
|
27
|
+
location: T.any(Prism::Location, RubyIndexer::Location),
|
28
|
+
comments: T::Array[String],
|
29
|
+
).void
|
30
|
+
end
|
24
31
|
def initialize(name, file_path, location, comments)
|
25
32
|
@name = name
|
26
33
|
@file_path = file_path
|
27
|
-
@location = location
|
28
34
|
@comments = comments
|
29
35
|
@visibility = T.let(:public, Symbol)
|
36
|
+
|
37
|
+
@location = T.let(
|
38
|
+
if location.is_a?(Prism::Location)
|
39
|
+
Location.new(
|
40
|
+
location.start_line,
|
41
|
+
location.end_line,
|
42
|
+
location.start_column,
|
43
|
+
location.end_column,
|
44
|
+
)
|
45
|
+
else
|
46
|
+
location
|
47
|
+
end,
|
48
|
+
RubyIndexer::Location,
|
49
|
+
)
|
30
50
|
end
|
31
51
|
|
32
52
|
sig { returns(String) }
|
@@ -43,17 +63,21 @@ module RubyIndexer
|
|
43
63
|
sig { returns(T::Array[String]) }
|
44
64
|
attr_accessor :included_modules
|
45
65
|
|
66
|
+
sig { returns(T::Array[String]) }
|
67
|
+
attr_accessor :prepended_modules
|
68
|
+
|
46
69
|
sig do
|
47
70
|
params(
|
48
71
|
name: String,
|
49
72
|
file_path: String,
|
50
|
-
location: Prism::Location,
|
73
|
+
location: T.any(Prism::Location, RubyIndexer::Location),
|
51
74
|
comments: T::Array[String],
|
52
75
|
).void
|
53
76
|
end
|
54
77
|
def initialize(name, file_path, location, comments)
|
55
78
|
super(name, file_path, location, comments)
|
56
79
|
@included_modules = T.let([], T::Array[String])
|
80
|
+
@prepended_modules = T.let([], T::Array[String])
|
57
81
|
end
|
58
82
|
|
59
83
|
sig { returns(String) }
|
@@ -77,7 +101,7 @@ module RubyIndexer
|
|
77
101
|
params(
|
78
102
|
name: String,
|
79
103
|
file_path: String,
|
80
|
-
location: Prism::Location,
|
104
|
+
location: T.any(Prism::Location, RubyIndexer::Location),
|
81
105
|
comments: T::Array[String],
|
82
106
|
parent_class: T.nilable(String),
|
83
107
|
).void
|
@@ -177,7 +201,7 @@ module RubyIndexer
|
|
177
201
|
params(
|
178
202
|
name: String,
|
179
203
|
file_path: String,
|
180
|
-
location: Prism::Location,
|
204
|
+
location: T.any(Prism::Location, RubyIndexer::Location),
|
181
205
|
comments: T::Array[String],
|
182
206
|
owner: T.nilable(Entry::Namespace),
|
183
207
|
).void
|
@@ -215,7 +239,7 @@ module RubyIndexer
|
|
215
239
|
params(
|
216
240
|
name: String,
|
217
241
|
file_path: String,
|
218
|
-
location: Prism::Location,
|
242
|
+
location: T.any(Prism::Location, RubyIndexer::Location),
|
219
243
|
comments: T::Array[String],
|
220
244
|
parameters_node: T.nilable(Prism::ParametersNode),
|
221
245
|
owner: T.nilable(Entry::Namespace),
|
@@ -345,7 +369,7 @@ module RubyIndexer
|
|
345
369
|
nesting: T::Array[String],
|
346
370
|
name: String,
|
347
371
|
file_path: String,
|
348
|
-
location: Prism::Location,
|
372
|
+
location: T.any(Prism::Location, RubyIndexer::Location),
|
349
373
|
comments: T::Array[String],
|
350
374
|
).void
|
351
375
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module RubyIndexer
|
5
|
+
class Location
|
6
|
+
extend T::Sig
|
7
|
+
|
8
|
+
sig { returns(Integer) }
|
9
|
+
attr_reader :start_line, :end_line, :start_column, :end_column
|
10
|
+
|
11
|
+
sig do
|
12
|
+
params(
|
13
|
+
start_line: Integer,
|
14
|
+
end_line: Integer,
|
15
|
+
start_column: Integer,
|
16
|
+
end_column: Integer,
|
17
|
+
).void
|
18
|
+
end
|
19
|
+
def initialize(start_line, end_line, start_column, end_column)
|
20
|
+
@start_line = start_line
|
21
|
+
@end_line = end_line
|
22
|
+
@start_column = start_column
|
23
|
+
@end_column = end_column
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -10,6 +10,7 @@ require "ruby_indexer/lib/ruby_indexer/index"
|
|
10
10
|
require "ruby_indexer/lib/ruby_indexer/entry"
|
11
11
|
require "ruby_indexer/lib/ruby_indexer/configuration"
|
12
12
|
require "ruby_indexer/lib/ruby_indexer/prefix_tree"
|
13
|
+
require "ruby_indexer/lib/ruby_indexer/location"
|
13
14
|
|
14
15
|
module RubyIndexer
|
15
16
|
@configuration = T.let(Configuration.new, Configuration)
|
@@ -327,5 +327,51 @@ module RubyIndexer
|
|
327
327
|
constant_path_references = T.must(@index["ConstantPathReferences"][0])
|
328
328
|
assert_equal(["Foo::Bar", "Foo::Bar2"], constant_path_references.included_modules)
|
329
329
|
end
|
330
|
+
|
331
|
+
def test_keeping_track_of_prepended_modules
|
332
|
+
index(<<~RUBY)
|
333
|
+
class Foo
|
334
|
+
# valid syntaxes that we can index
|
335
|
+
prepend A1
|
336
|
+
self.prepend A2
|
337
|
+
prepend A3, A4
|
338
|
+
self.prepend A5, A6
|
339
|
+
|
340
|
+
# valid syntaxes that we cannot index because of their dynamic nature
|
341
|
+
prepend some_variable_or_method_call
|
342
|
+
self.prepend some_variable_or_method_call
|
343
|
+
|
344
|
+
def something
|
345
|
+
prepend A7 # We should not index this because of this dynamic nature
|
346
|
+
end
|
347
|
+
|
348
|
+
# Valid inner class syntax definition with its own modules prepended
|
349
|
+
class Qux
|
350
|
+
prepend Corge
|
351
|
+
self.prepend Corge
|
352
|
+
prepend Baz
|
353
|
+
|
354
|
+
prepend some_variable_or_method_call
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
class ConstantPathReferences
|
359
|
+
prepend Foo::Bar
|
360
|
+
self.prepend Foo::Bar2
|
361
|
+
|
362
|
+
prepend dynamic::Bar
|
363
|
+
prepend Foo::
|
364
|
+
end
|
365
|
+
RUBY
|
366
|
+
|
367
|
+
foo = T.must(@index["Foo"][0])
|
368
|
+
assert_equal(["A1", "A2", "A3", "A4", "A5", "A6"], foo.prepended_modules)
|
369
|
+
|
370
|
+
qux = T.must(@index["Foo::Qux"][0])
|
371
|
+
assert_equal(["Corge", "Corge", "Baz"], qux.prepended_modules)
|
372
|
+
|
373
|
+
constant_path_references = T.must(@index["ConstantPathReferences"][0])
|
374
|
+
assert_equal(["Foo::Bar", "Foo::Bar2"], constant_path_references.prepended_modules)
|
375
|
+
end
|
330
376
|
end
|
331
377
|
end
|
@@ -10,7 +10,7 @@ module RubyIndexer
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_load_configuration_executes_configure_block
|
13
|
-
@config.
|
13
|
+
@config.apply_config({ "excluded_patterns" => ["**/test/fixtures/**/*.rb"] })
|
14
14
|
indexables = @config.indexables
|
15
15
|
|
16
16
|
assert(indexables.none? { |indexable| indexable.full_path.include?("test/fixtures") })
|
@@ -21,7 +21,6 @@ module RubyIndexer
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_indexables_only_includes_gem_require_paths
|
24
|
-
@config.load_config
|
25
24
|
indexables = @config.indexables
|
26
25
|
|
27
26
|
Bundler.locked_gems.specs.each do |lazy_spec|
|
@@ -35,7 +34,6 @@ module RubyIndexer
|
|
35
34
|
end
|
36
35
|
|
37
36
|
def test_indexables_does_not_include_default_gem_path_when_in_bundle
|
38
|
-
@config.load_config
|
39
37
|
indexables = @config.indexables
|
40
38
|
|
41
39
|
assert(
|
@@ -44,7 +42,6 @@ module RubyIndexer
|
|
44
42
|
end
|
45
43
|
|
46
44
|
def test_indexables_includes_default_gems
|
47
|
-
@config.load_config
|
48
45
|
indexables = @config.indexables.map(&:full_path)
|
49
46
|
|
50
47
|
assert_includes(indexables, "#{RbConfig::CONFIG["rubylibdir"]}/pathname.rb")
|
@@ -53,7 +50,6 @@ module RubyIndexer
|
|
53
50
|
end
|
54
51
|
|
55
52
|
def test_indexables_includes_project_files
|
56
|
-
@config.load_config
|
57
53
|
indexables = @config.indexables.map(&:full_path)
|
58
54
|
|
59
55
|
Dir.glob("#{Dir.pwd}/lib/**/*.rb").each do |path|
|
@@ -66,7 +62,6 @@ module RubyIndexer
|
|
66
62
|
def test_indexables_avoids_duplicates_if_bundle_path_is_inside_project
|
67
63
|
Bundler.settings.set_global("path", "vendor/bundle")
|
68
64
|
config = Configuration.new
|
69
|
-
config.load_config
|
70
65
|
|
71
66
|
assert_includes(config.instance_variable_get(:@excluded_patterns), "#{Dir.pwd}/vendor/bundle/**/*.rb")
|
72
67
|
ensure
|
@@ -74,7 +69,6 @@ module RubyIndexer
|
|
74
69
|
end
|
75
70
|
|
76
71
|
def test_indexables_does_not_include_gems_own_installed_files
|
77
|
-
@config.load_config
|
78
72
|
indexables = @config.indexables
|
79
73
|
|
80
74
|
assert(
|
@@ -95,17 +89,14 @@ module RubyIndexer
|
|
95
89
|
end
|
96
90
|
|
97
91
|
def test_paths_are_unique
|
98
|
-
@config.load_config
|
99
92
|
indexables = @config.indexables
|
100
93
|
|
101
94
|
assert_equal(indexables.uniq.length, indexables.length)
|
102
95
|
end
|
103
96
|
|
104
97
|
def test_configuration_raises_for_unknown_keys
|
105
|
-
Psych::Nodes::Document.any_instance.expects(:to_ruby).returns({ "unknown_config" => 123 })
|
106
|
-
|
107
98
|
assert_raises(ArgumentError) do
|
108
|
-
@config.
|
99
|
+
@config.apply_config({ "unknown_config" => 123 })
|
109
100
|
end
|
110
101
|
end
|
111
102
|
|
data/lib/ruby_lsp/addon.rb
CHANGED
@@ -50,8 +50,8 @@ module RubyLsp
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# Discovers and loads all addons. Returns the list of activated addons
|
53
|
-
sig { params(
|
54
|
-
def load_addons(
|
53
|
+
sig { params(global_state: GlobalState, outgoing_queue: Thread::Queue).returns(T::Array[Addon]) }
|
54
|
+
def load_addons(global_state, outgoing_queue)
|
55
55
|
# Require all addons entry points, which should be placed under
|
56
56
|
# `some_gem/lib/ruby_lsp/your_gem_name/addon.rb`
|
57
57
|
Gem.find_files("ruby_lsp/**/addon.rb").each do |addon|
|
@@ -67,7 +67,7 @@ module RubyLsp
|
|
67
67
|
# Activate each one of the discovered addons. If any problems occur in the addons, we don't want to
|
68
68
|
# fail to boot the server
|
69
69
|
addons.each do |addon|
|
70
|
-
addon.activate(
|
70
|
+
addon.activate(global_state, outgoing_queue)
|
71
71
|
rescue => e
|
72
72
|
addon.add_error(e)
|
73
73
|
end
|
@@ -105,8 +105,8 @@ module RubyLsp
|
|
105
105
|
|
106
106
|
# Each addon should implement `MyAddon#activate` and use to perform any sort of initialization, such as
|
107
107
|
# reading information into memory or even spawning a separate process
|
108
|
-
sig { abstract.params(
|
109
|
-
def activate(
|
108
|
+
sig { abstract.params(global_state: GlobalState, outgoing_queue: Thread::Queue).void }
|
109
|
+
def activate(global_state, outgoing_queue); end
|
110
110
|
|
111
111
|
# Each addon should implement `MyAddon#deactivate` and use to perform any clean up, like shutting down a
|
112
112
|
# child process
|
@@ -132,11 +132,10 @@ module RubyLsp
|
|
132
132
|
overridable.params(
|
133
133
|
response_builder: ResponseBuilders::Hover,
|
134
134
|
nesting: T::Array[String],
|
135
|
-
index: RubyIndexer::Index,
|
136
135
|
dispatcher: Prism::Dispatcher,
|
137
136
|
).void
|
138
137
|
end
|
139
|
-
def create_hover_listener(response_builder, nesting,
|
138
|
+
def create_hover_listener(response_builder, nesting, dispatcher); end
|
140
139
|
|
141
140
|
# Creates a new DocumentSymbol listener. This method is invoked on every DocumentSymbol request
|
142
141
|
sig do
|
@@ -161,10 +160,20 @@ module RubyLsp
|
|
161
160
|
response_builder: ResponseBuilders::CollectionResponseBuilder[Interface::Location],
|
162
161
|
uri: URI::Generic,
|
163
162
|
nesting: T::Array[String],
|
164
|
-
index: RubyIndexer::Index,
|
165
163
|
dispatcher: Prism::Dispatcher,
|
166
164
|
).void
|
167
165
|
end
|
168
|
-
def create_definition_listener(response_builder, uri, nesting,
|
166
|
+
def create_definition_listener(response_builder, uri, nesting, dispatcher); end
|
167
|
+
|
168
|
+
# Creates a new Completion listener. This method is invoked on every Completion request
|
169
|
+
sig do
|
170
|
+
overridable.params(
|
171
|
+
response_builder: ResponseBuilders::CollectionResponseBuilder[Interface::CompletionItem],
|
172
|
+
nesting: T::Array[String],
|
173
|
+
dispatcher: Prism::Dispatcher,
|
174
|
+
uri: URI::Generic,
|
175
|
+
).void
|
176
|
+
end
|
177
|
+
def create_completion_listener(response_builder, nesting, dispatcher, uri); end
|
169
178
|
end
|
170
179
|
end
|