ruby-lsp 0.23.12 → 0.23.13
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/rubocop/cop/ruby_lsp/use_language_server_aliases.rb +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +31 -40
- data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +56 -22
- data/lib/ruby_indexer/lib/ruby_indexer/enhancement.rb +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +15 -18
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +8 -11
- data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +2 -2
- data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb +2 -2
- data/lib/ruby_indexer/test/configuration_test.rb +10 -1
- data/lib/ruby_indexer/test/method_test.rb +26 -0
- data/lib/ruby_indexer/test/rbs_indexer_test.rb +1 -1
- data/lib/ruby_lsp/addon.rb +12 -4
- data/lib/ruby_lsp/base_server.rb +19 -22
- data/lib/ruby_lsp/client_capabilities.rb +6 -6
- data/lib/ruby_lsp/document.rb +13 -13
- data/lib/ruby_lsp/erb_document.rb +7 -9
- data/lib/ruby_lsp/global_state.rb +21 -24
- data/lib/ruby_lsp/listeners/code_lens.rb +59 -48
- data/lib/ruby_lsp/listeners/completion.rb +2 -2
- data/lib/ruby_lsp/listeners/definition.rb +2 -2
- data/lib/ruby_lsp/listeners/document_highlight.rb +62 -80
- data/lib/ruby_lsp/listeners/document_link.rb +34 -43
- data/lib/ruby_lsp/listeners/document_symbol.rb +1 -1
- data/lib/ruby_lsp/listeners/folding_ranges.rb +1 -1
- data/lib/ruby_lsp/listeners/hover.rb +43 -52
- data/lib/ruby_lsp/listeners/inlay_hints.rb +1 -1
- data/lib/ruby_lsp/listeners/semantic_highlighting.rb +11 -14
- data/lib/ruby_lsp/listeners/signature_help.rb +2 -2
- data/lib/ruby_lsp/listeners/spec_style.rb +15 -59
- data/lib/ruby_lsp/listeners/test_discovery.rb +89 -0
- data/lib/ruby_lsp/listeners/test_style.rb +47 -81
- data/lib/ruby_lsp/node_context.rb +4 -4
- data/lib/ruby_lsp/rbs_document.rb +1 -1
- data/lib/ruby_lsp/requests/code_actions.rb +9 -12
- data/lib/ruby_lsp/requests/code_lens.rb +2 -4
- data/lib/ruby_lsp/requests/completion.rb +3 -5
- data/lib/ruby_lsp/requests/completion_resolve.rb +1 -1
- data/lib/ruby_lsp/requests/definition.rb +4 -5
- data/lib/ruby_lsp/requests/diagnostics.rb +2 -2
- data/lib/ruby_lsp/requests/discover_tests.rb +3 -2
- data/lib/ruby_lsp/requests/document_highlight.rb +2 -4
- data/lib/ruby_lsp/requests/document_link.rb +2 -4
- data/lib/ruby_lsp/requests/document_symbol.rb +1 -1
- data/lib/ruby_lsp/requests/folding_ranges.rb +3 -8
- data/lib/ruby_lsp/requests/formatting.rb +2 -2
- data/lib/ruby_lsp/requests/go_to_relevant_file.rb +3 -3
- data/lib/ruby_lsp/requests/hover.rb +2 -2
- data/lib/ruby_lsp/requests/inlay_hints.rb +2 -4
- data/lib/ruby_lsp/requests/on_type_formatting.rb +10 -13
- data/lib/ruby_lsp/requests/prepare_rename.rb +1 -1
- data/lib/ruby_lsp/requests/range_formatting.rb +2 -2
- data/lib/ruby_lsp/requests/references.rb +1 -1
- data/lib/ruby_lsp/requests/rename.rb +2 -2
- data/lib/ruby_lsp/requests/request.rb +2 -2
- data/lib/ruby_lsp/requests/selection_ranges.rb +2 -2
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +5 -7
- data/lib/ruby_lsp/requests/show_syntax_tree.rb +1 -1
- data/lib/ruby_lsp/requests/signature_help.rb +2 -2
- data/lib/ruby_lsp/requests/support/common.rb +1 -1
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +15 -21
- data/lib/ruby_lsp/requests/support/rubocop_formatter.rb +2 -2
- data/lib/ruby_lsp/requests/support/rubocop_runner.rb +12 -18
- data/lib/ruby_lsp/requests/support/sorbet.rb +28 -31
- data/lib/ruby_lsp/requests/support/source_uri.rb +11 -14
- data/lib/ruby_lsp/requests/support/syntax_tree_formatter.rb +5 -9
- data/lib/ruby_lsp/requests/support/test_item.rb +4 -9
- data/lib/ruby_lsp/requests/type_hierarchy_supertypes.rb +1 -1
- data/lib/ruby_lsp/requests/workspace_symbol.rb +1 -1
- data/lib/ruby_lsp/response_builders/collection_response_builder.rb +1 -1
- data/lib/ruby_lsp/response_builders/document_symbol.rb +2 -5
- data/lib/ruby_lsp/response_builders/hover.rb +5 -8
- data/lib/ruby_lsp/response_builders/semantic_highlighting.rb +41 -47
- data/lib/ruby_lsp/response_builders/signature_help.rb +1 -1
- data/lib/ruby_lsp/response_builders/test_collection.rb +1 -1
- data/lib/ruby_lsp/ruby_document.rb +7 -20
- data/lib/ruby_lsp/ruby_lsp_reporter_plugin.rb +7 -4
- data/lib/ruby_lsp/scope.rb +1 -1
- data/lib/ruby_lsp/server.rb +9 -1
- data/lib/ruby_lsp/setup_bundler.rb +36 -42
- data/lib/ruby_lsp/static_docs.rb +4 -7
- data/lib/ruby_lsp/store.rb +9 -12
- data/lib/ruby_lsp/test_reporter.rb +140 -4
- data/lib/ruby_lsp/test_unit_test_runner.rb +10 -8
- data/lib/ruby_lsp/utils.rb +10 -16
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e224f23084eccd6f7b441b6cf6ae2793fb9c73a0045bf36f8c1bbdf2b1f00445
|
4
|
+
data.tar.gz: 581749c8bd2ab362075e49940d364af6a237068e6107d340a2535043d7fdec37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5d7cb45c56ad5e9e92cba7a0012be7a1626044da4fbc936c413b7a8e5cb3cdd4463bf56dd35ef65feed10f0de363edd04702a4496572248e6e74ea9f720a373
|
7
|
+
data.tar.gz: 53639a355c1641e8b11d4e756a417ea9ee96421cb5a87090ffc94cd8f905d41ca3fa5111e4171a81fa62b452c23088895deca0e7eb52fd2e8fed82e1232d2d06
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.23.
|
1
|
+
0.23.13
|
@@ -29,7 +29,7 @@ module RuboCop
|
|
29
29
|
class UseLanguageServerAliases < RuboCop::Cop::Base
|
30
30
|
extend RuboCop::Cop::AutoCorrector
|
31
31
|
|
32
|
-
ALIASED_CONSTANTS =
|
32
|
+
ALIASED_CONSTANTS = [:Interface, :Transport, :Constant].freeze #: Array[Symbol]
|
33
33
|
|
34
34
|
MSG = "Use constant alias `%{constant}`."
|
35
35
|
|
@@ -3,16 +3,13 @@
|
|
3
3
|
|
4
4
|
module RubyIndexer
|
5
5
|
class Configuration
|
6
|
-
CONFIGURATION_SCHEMA =
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}.freeze,
|
14
|
-
T::Hash[String, T.untyped],
|
15
|
-
)
|
6
|
+
CONFIGURATION_SCHEMA = {
|
7
|
+
"excluded_gems" => Array,
|
8
|
+
"included_gems" => Array,
|
9
|
+
"excluded_patterns" => Array,
|
10
|
+
"included_patterns" => Array,
|
11
|
+
"excluded_magic_comments" => Array,
|
12
|
+
}.freeze #: Hash[String, untyped]
|
16
13
|
|
17
14
|
#: String
|
18
15
|
attr_writer :workspace_path
|
@@ -22,18 +19,15 @@ module RubyIndexer
|
|
22
19
|
|
23
20
|
#: -> void
|
24
21
|
def initialize
|
25
|
-
@workspace_path =
|
26
|
-
@encoding =
|
27
|
-
@excluded_gems =
|
28
|
-
@included_gems =
|
29
|
-
|
30
|
-
@excluded_patterns =
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
],
|
35
|
-
T::Array[String],
|
36
|
-
)
|
22
|
+
@workspace_path = Dir.pwd #: String
|
23
|
+
@encoding = Encoding::UTF_8 #: Encoding
|
24
|
+
@excluded_gems = initial_excluded_gems #: Array[String]
|
25
|
+
@included_gems = [] #: Array[String]
|
26
|
+
|
27
|
+
@excluded_patterns = [
|
28
|
+
"**/{test,spec}/**/{*_test.rb,test_*.rb,*_spec.rb}",
|
29
|
+
"**/fixtures/**/*",
|
30
|
+
] #: Array[String]
|
37
31
|
|
38
32
|
path = Bundler.settings["path"]
|
39
33
|
if path
|
@@ -45,23 +39,20 @@ module RubyIndexer
|
|
45
39
|
|
46
40
|
# We start the included patterns with only the non excluded directories so that we can avoid paying the price of
|
47
41
|
# traversing large directories that don't include Ruby files like `node_modules`
|
48
|
-
@included_patterns =
|
49
|
-
@excluded_magic_comments =
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
],
|
63
|
-
T::Array[String],
|
64
|
-
)
|
42
|
+
@included_patterns = ["{#{top_level_directories.join(",")}}/**/*.rb", "*.rb"] #: Array[String]
|
43
|
+
@excluded_magic_comments = [
|
44
|
+
"frozen_string_literal:",
|
45
|
+
"typed:",
|
46
|
+
"compiled:",
|
47
|
+
"encoding:",
|
48
|
+
"shareable_constant_value:",
|
49
|
+
"warn_indent:",
|
50
|
+
"rubocop:",
|
51
|
+
"nodoc:",
|
52
|
+
"doc:",
|
53
|
+
"coding:",
|
54
|
+
"warn_past_scope:",
|
55
|
+
] #: Array[String]
|
65
56
|
end
|
66
57
|
|
67
58
|
#: -> Array[URI::Generic]
|
@@ -177,7 +168,7 @@ module RubyIndexer
|
|
177
168
|
|
178
169
|
#: -> Regexp
|
179
170
|
def magic_comment_regex
|
180
|
-
@magic_comment_regex ||=
|
171
|
+
@magic_comment_regex ||= /^#\s*#{@excluded_magic_comments.join("|")}/ #: Regexp?
|
181
172
|
end
|
182
173
|
|
183
174
|
#: (Hash[String, untyped] config) -> void
|
@@ -3,8 +3,8 @@
|
|
3
3
|
|
4
4
|
module RubyIndexer
|
5
5
|
class DeclarationListener
|
6
|
-
OBJECT_NESTING =
|
7
|
-
BASIC_OBJECT_NESTING =
|
6
|
+
OBJECT_NESTING = ["Object"].freeze #: Array[String]
|
7
|
+
BASIC_OBJECT_NESTING = ["BasicObject"].freeze #: Array[String]
|
8
8
|
|
9
9
|
#: Array[String]
|
10
10
|
attr_reader :indexing_errors
|
@@ -13,28 +13,24 @@ module RubyIndexer
|
|
13
13
|
def initialize(index, dispatcher, parse_result, uri, collect_comments: false)
|
14
14
|
@index = index
|
15
15
|
@uri = uri
|
16
|
-
@enhancements =
|
17
|
-
@visibility_stack =
|
18
|
-
@comments_by_line =
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@
|
26
|
-
parse_result.code_units_cache(@index.configuration.encoding),
|
27
|
-
T.any(T.proc.params(arg0: Integer).returns(Integer), Prism::CodeUnitsCache),
|
28
|
-
)
|
29
|
-
@source_lines = T.let(parse_result.source.lines, T::Array[String])
|
16
|
+
@enhancements = Enhancement.all(self) #: Array[Enhancement]
|
17
|
+
@visibility_stack = [VisibilityScope.public_scope] #: Array[VisibilityScope]
|
18
|
+
@comments_by_line = parse_result.comments.to_h do |c|
|
19
|
+
[c.location.start_line, c]
|
20
|
+
end #: Hash[Integer, Prism::Comment]
|
21
|
+
@inside_def = false #: bool
|
22
|
+
@code_units_cache = parse_result
|
23
|
+
.code_units_cache(@index.configuration.encoding) #: (^(Integer arg0) -> Integer | Prism::CodeUnitsCache)
|
24
|
+
|
25
|
+
@source_lines = parse_result.source.lines #: Array[String]
|
30
26
|
|
31
27
|
# The nesting stack we're currently inside. Used to determine the fully qualified name of constants, but only
|
32
28
|
# stored by unresolved aliases which need the original nesting to be lazily resolved
|
33
|
-
@stack =
|
29
|
+
@stack = [] #: Array[String]
|
34
30
|
|
35
31
|
# A stack of namespace entries that represent where we currently are. Used to properly assign methods to an owner
|
36
|
-
@owner_stack =
|
37
|
-
@indexing_errors =
|
32
|
+
@owner_stack = [] #: Array[Entry::Namespace]
|
33
|
+
@indexing_errors = [] #: Array[String]
|
38
34
|
@collect_comments = collect_comments
|
39
35
|
|
40
36
|
dispatcher.register(
|
@@ -269,11 +265,11 @@ module RubyIndexer
|
|
269
265
|
when :include, :prepend, :extend
|
270
266
|
handle_module_operation(node, message)
|
271
267
|
when :public
|
272
|
-
|
268
|
+
handle_visibility_change(node, Entry::Visibility::PUBLIC)
|
273
269
|
when :protected
|
274
|
-
|
270
|
+
handle_visibility_change(node, Entry::Visibility::PROTECTED)
|
275
271
|
when :private
|
276
|
-
|
272
|
+
handle_visibility_change(node, Entry::Visibility::PRIVATE)
|
277
273
|
when :module_function
|
278
274
|
handle_module_function(node)
|
279
275
|
when :private_class_method
|
@@ -1038,5 +1034,43 @@ module RubyIndexer
|
|
1038
1034
|
|
1039
1035
|
name.split("::").last
|
1040
1036
|
end
|
1037
|
+
|
1038
|
+
#: (Prism::CallNode, Entry::Visibility) -> void
|
1039
|
+
def handle_visibility_change(node, visibility)
|
1040
|
+
owner = @owner_stack.last
|
1041
|
+
return unless owner
|
1042
|
+
|
1043
|
+
owner_name = owner.name
|
1044
|
+
method_names = string_or_symbol_argument_values(node)
|
1045
|
+
|
1046
|
+
if method_names.empty?
|
1047
|
+
@visibility_stack.push(VisibilityScope.new(visibility: visibility))
|
1048
|
+
return
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
method_names.each do |method_name|
|
1052
|
+
entries = @index.resolve_method(method_name, owner_name)
|
1053
|
+
next unless entries
|
1054
|
+
|
1055
|
+
entries.each do |entry|
|
1056
|
+
entry.visibility = visibility
|
1057
|
+
end
|
1058
|
+
end
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
#: (Prism::CallNode) -> Array[String]
|
1062
|
+
def string_or_symbol_argument_values(node)
|
1063
|
+
arguments = node.arguments&.arguments
|
1064
|
+
return [] unless arguments
|
1065
|
+
|
1066
|
+
arguments.filter_map do |argument|
|
1067
|
+
case argument
|
1068
|
+
when Prism::StringNode
|
1069
|
+
argument.content
|
1070
|
+
when Prism::SymbolNode
|
1071
|
+
argument.value
|
1072
|
+
end
|
1073
|
+
end
|
1074
|
+
end
|
1041
1075
|
end
|
1042
1076
|
end
|
@@ -30,7 +30,7 @@ module RubyIndexer
|
|
30
30
|
@name = name
|
31
31
|
@uri = uri
|
32
32
|
@comments = comments
|
33
|
-
@visibility =
|
33
|
+
@visibility = Visibility::PUBLIC #: Visibility
|
34
34
|
@location = location
|
35
35
|
end
|
36
36
|
|
@@ -137,7 +137,7 @@ module RubyIndexer
|
|
137
137
|
|
138
138
|
#: (Array[String] nesting, URI::Generic uri, Location location, Location name_location, String? comments) -> void
|
139
139
|
def initialize(nesting, uri, location, name_location, comments)
|
140
|
-
@name =
|
140
|
+
@name = nesting.join("::") #: String
|
141
141
|
# The original nesting where this namespace was discovered
|
142
142
|
@nesting = nesting
|
143
143
|
|
@@ -156,7 +156,7 @@ module RubyIndexer
|
|
156
156
|
# and prepended
|
157
157
|
#: -> Array[ModuleOperation]
|
158
158
|
def mixin_operations
|
159
|
-
@mixin_operations ||=
|
159
|
+
@mixin_operations ||= [] #: Array[ModuleOperation]?
|
160
160
|
end
|
161
161
|
|
162
162
|
#: -> Integer
|
@@ -251,7 +251,7 @@ module RubyIndexer
|
|
251
251
|
|
252
252
|
# A rest method parameter, e.g. `def foo(*a)`
|
253
253
|
class RestParameter < Parameter
|
254
|
-
DEFAULT_NAME =
|
254
|
+
DEFAULT_NAME = :"<anonymous splat>" #: Symbol
|
255
255
|
|
256
256
|
# @override
|
257
257
|
#: -> Symbol
|
@@ -262,7 +262,7 @@ module RubyIndexer
|
|
262
262
|
|
263
263
|
# A keyword rest method parameter, e.g. `def foo(**a)`
|
264
264
|
class KeywordRestParameter < Parameter
|
265
|
-
DEFAULT_NAME =
|
265
|
+
DEFAULT_NAME = :"<anonymous keyword splat>" #: Symbol
|
266
266
|
|
267
267
|
# @override
|
268
268
|
#: -> Symbol
|
@@ -273,7 +273,7 @@ module RubyIndexer
|
|
273
273
|
|
274
274
|
# A block method parameter, e.g. `def foo(&block)`
|
275
275
|
class BlockParameter < Parameter
|
276
|
-
DEFAULT_NAME =
|
276
|
+
DEFAULT_NAME = :"<anonymous block>" #: Symbol
|
277
277
|
|
278
278
|
class << self
|
279
279
|
#: -> BlockParameter
|
@@ -343,14 +343,11 @@ module RubyIndexer
|
|
343
343
|
# @override
|
344
344
|
#: -> Array[Signature]
|
345
345
|
def signatures
|
346
|
-
@signatures ||=
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
end,
|
352
|
-
T.nilable(T::Array[Signature]),
|
353
|
-
)
|
346
|
+
@signatures ||= begin
|
347
|
+
params = []
|
348
|
+
params << RequiredParameter.new(name: name.delete_suffix("=").to_sym) if name.end_with?("=")
|
349
|
+
[Entry::Signature.new(params)]
|
350
|
+
end #: Array[Signature]?
|
354
351
|
end
|
355
352
|
end
|
356
353
|
|
@@ -484,7 +481,7 @@ module RubyIndexer
|
|
484
481
|
)
|
485
482
|
|
486
483
|
@target = target
|
487
|
-
@owner =
|
484
|
+
@owner = unresolved_alias.owner #: Entry::Namespace?
|
488
485
|
end
|
489
486
|
|
490
487
|
#: -> String
|
@@ -539,10 +536,10 @@ module RubyIndexer
|
|
539
536
|
#: (Array[Prism::Node] arguments) -> bool
|
540
537
|
def matches?(arguments)
|
541
538
|
min_pos = 0
|
542
|
-
max_pos =
|
539
|
+
max_pos = 0 #: (Integer | Float)
|
543
540
|
names = []
|
544
|
-
has_forward =
|
545
|
-
has_keyword_rest =
|
541
|
+
has_forward = false #: bool
|
542
|
+
has_keyword_rest = false #: bool
|
546
543
|
|
547
544
|
@parameters.each do |param|
|
548
545
|
case param
|
@@ -57,10 +57,10 @@ module RubyIndexer
|
|
57
57
|
# "Foo" => [#<Entry::Class>, #<Entry::Class>],
|
58
58
|
# "Foo::Bar" => [#<Entry::Class>],
|
59
59
|
# }
|
60
|
-
@entries =
|
60
|
+
@entries = {} #: Hash[String, Array[Entry]]
|
61
61
|
|
62
62
|
# Holds all entries in the index using a prefix tree for searching based on prefixes to provide autocompletion
|
63
|
-
@entries_tree =
|
63
|
+
@entries_tree = PrefixTree[T::Array[Entry]].new #: PrefixTree[Array[Entry]]
|
64
64
|
|
65
65
|
# Holds references to where entries where discovered so that we can easily delete them
|
66
66
|
# {
|
@@ -68,23 +68,20 @@ module RubyIndexer
|
|
68
68
|
# "file:///my/project/bar.rb" => [#<Entry::Class>],
|
69
69
|
# "untitled:Untitled-1" => [#<Entry::Class>],
|
70
70
|
# }
|
71
|
-
@uris_to_entries =
|
71
|
+
@uris_to_entries = {} #: Hash[String, Array[Entry]]
|
72
72
|
|
73
73
|
# Holds all require paths for every indexed item so that we can provide autocomplete for requires
|
74
|
-
@require_paths_tree =
|
74
|
+
@require_paths_tree = PrefixTree[URI::Generic].new #: PrefixTree[URI::Generic]
|
75
75
|
|
76
76
|
# Holds the linearized ancestors list for every namespace
|
77
|
-
@ancestors =
|
77
|
+
@ancestors = {} #: Hash[String, Array[String]]
|
78
78
|
|
79
79
|
# Map of module name to included hooks that have to be executed when we include the given module
|
80
|
-
@included_hooks =
|
81
|
-
{},
|
82
|
-
T::Hash[String, T::Array[T.proc.params(index: Index, base: Entry::Namespace).void]],
|
83
|
-
)
|
80
|
+
@included_hooks = {} #: Hash[String, Array[^(Index index, Entry::Namespace base) -> void]]
|
84
81
|
|
85
|
-
@configuration =
|
82
|
+
@configuration = RubyIndexer::Configuration.new #: Configuration
|
86
83
|
|
87
|
-
@initial_indexing_completed =
|
84
|
+
@initial_indexing_completed = false #: bool
|
88
85
|
end
|
89
86
|
|
90
87
|
# Register an included `hook` that will be executed when `module_name` is included into any namespace
|
@@ -39,7 +39,7 @@ module RubyIndexer
|
|
39
39
|
|
40
40
|
#: -> void
|
41
41
|
def initialize
|
42
|
-
@root =
|
42
|
+
@root = Node.new("", "") #: Node[Value]
|
43
43
|
end
|
44
44
|
|
45
45
|
# Search the PrefixTree based on a given `prefix`. If `foo` is an entry in the tree, then searching for `fo` will
|
@@ -78,7 +78,7 @@ module RubyIndexer
|
|
78
78
|
return unless node
|
79
79
|
|
80
80
|
# Remove the node from the tree and then go up the parents to remove any of them with empty children
|
81
|
-
parent = T.
|
81
|
+
parent = T.must(node.parent) #: Node[Value]?
|
82
82
|
|
83
83
|
while parent
|
84
84
|
parent.children.delete(node.key)
|
@@ -66,8 +66,8 @@ module RubyIndexer
|
|
66
66
|
@index = index
|
67
67
|
@uri = uri
|
68
68
|
@include_declarations = include_declarations
|
69
|
-
@stack =
|
70
|
-
@references =
|
69
|
+
@stack = [] #: Array[String]
|
70
|
+
@references = [] #: Array[Reference]
|
71
71
|
|
72
72
|
dispatcher.register(
|
73
73
|
self,
|
@@ -147,17 +147,26 @@ module RubyIndexer
|
|
147
147
|
uris = @config.indexable_uris
|
148
148
|
assert(uris.none? { |uri| uri.full_path.start_with?(File.join(dir, "ignore")) })
|
149
149
|
|
150
|
+
# The regular default gem path is ~/.rubies/3.4.1/lib/ruby/3.4.0
|
151
|
+
# The alternative default gem path is ~/.rubies/3.4.1/lib/ruby/gems/3.4.0
|
152
|
+
# Here part_1 contains ~/.rubies/3.4.1/lib/ruby/ and part_2 contains 3.4.0, so that we can turn it into the
|
153
|
+
# alternative path
|
154
|
+
part_1, part_2 = Pathname.new(RbConfig::CONFIG["rubylibdir"]).split
|
155
|
+
other_default_gem_dir = part_1.join("gems").join(part_2).to_s
|
156
|
+
|
150
157
|
# After switching the workspace path, all indexable URIs will be found in one of these places:
|
151
158
|
# - The new workspace path
|
152
159
|
# - The Ruby LSP's own code (because Bundler is requiring the dependency from source)
|
153
160
|
# - Bundled gems
|
154
161
|
# - Default gems
|
162
|
+
# - Other default gem directory
|
155
163
|
assert(
|
156
164
|
uris.all? do |u|
|
157
165
|
u.full_path.start_with?(dir) ||
|
158
166
|
u.full_path.start_with?(File.join(Dir.pwd, "lib")) ||
|
159
167
|
u.full_path.start_with?(Bundler.bundle_path.to_s) ||
|
160
|
-
u.full_path.start_with?(RbConfig::CONFIG["rubylibdir"])
|
168
|
+
u.full_path.start_with?(RbConfig::CONFIG["rubylibdir"]) ||
|
169
|
+
u.full_path.start_with?(other_default_gem_dir)
|
161
170
|
end,
|
162
171
|
)
|
163
172
|
end
|
@@ -924,6 +924,32 @@ module RubyIndexer
|
|
924
924
|
RUBY
|
925
925
|
end
|
926
926
|
|
927
|
+
def test_changing_visibility_post_definition
|
928
|
+
index(<<~RUBY)
|
929
|
+
class Foo
|
930
|
+
def bar; end
|
931
|
+
private :bar
|
932
|
+
|
933
|
+
def baz; end
|
934
|
+
protected :baz
|
935
|
+
|
936
|
+
private
|
937
|
+
def qux; end
|
938
|
+
|
939
|
+
public :qux
|
940
|
+
end
|
941
|
+
RUBY
|
942
|
+
|
943
|
+
entry = T.must(@index["bar"].first)
|
944
|
+
assert_predicate(entry, :private?)
|
945
|
+
|
946
|
+
entry = T.must(@index["baz"].first)
|
947
|
+
assert_predicate(entry, :protected?)
|
948
|
+
|
949
|
+
entry = T.must(@index["qux"].first)
|
950
|
+
assert_predicate(entry, :public?)
|
951
|
+
end
|
952
|
+
|
927
953
|
private
|
928
954
|
|
929
955
|
#: (Entry::Method entry, String call_string) -> void
|
@@ -359,7 +359,7 @@ module RubyIndexer
|
|
359
359
|
assert_equal("all?", entry.old_name)
|
360
360
|
assert_equal("Array", entry.owner.name)
|
361
361
|
assert(entry.file_path.end_with?("core/array.rbs"))
|
362
|
-
|
362
|
+
refute_empty(entry.comments)
|
363
363
|
end
|
364
364
|
|
365
365
|
def test_indexing_untyped_functions
|
data/lib/ruby_lsp/addon.rb
CHANGED
@@ -25,10 +25,10 @@ module RubyLsp
|
|
25
25
|
|
26
26
|
abstract!
|
27
27
|
|
28
|
-
@addons =
|
29
|
-
@addon_classes =
|
28
|
+
@addons = [] #: Array[Addon]
|
29
|
+
@addon_classes = [] #: Array[singleton(Addon)]
|
30
30
|
# Add-on instances that have declared a handler to accept file watcher events
|
31
|
-
@file_watcher_addons =
|
31
|
+
@file_watcher_addons = [] #: Array[Addon]
|
32
32
|
|
33
33
|
AddonNotFoundError = Class.new(StandardError)
|
34
34
|
|
@@ -149,7 +149,7 @@ module RubyLsp
|
|
149
149
|
|
150
150
|
#: -> void
|
151
151
|
def initialize
|
152
|
-
@errors =
|
152
|
+
@errors = [] #: Array[StandardError]
|
153
153
|
end
|
154
154
|
|
155
155
|
#: (StandardError error) -> self
|
@@ -236,5 +236,13 @@ module RubyLsp
|
|
236
236
|
# @overridable
|
237
237
|
#: (ResponseBuilders::TestCollection response_builder, Prism::Dispatcher dispatcher, URI::Generic uri) -> void
|
238
238
|
def create_discover_tests_listener(response_builder, dispatcher, uri); end
|
239
|
+
|
240
|
+
# Resolves the minimal set of commands required to execute the requested tests. Add-ons are responsible for only
|
241
|
+
# handling items related to the framework they add support for and have discovered themselves
|
242
|
+
# @overridable
|
243
|
+
#: (Array[Hash[Symbol, untyped]]) -> Array[String]
|
244
|
+
def resolve_test_commands(items)
|
245
|
+
[]
|
246
|
+
end
|
239
247
|
end
|
240
248
|
end
|
data/lib/ruby_lsp/base_server.rb
CHANGED
@@ -10,28 +10,25 @@ module RubyLsp
|
|
10
10
|
|
11
11
|
#: (**untyped options) -> void
|
12
12
|
def initialize(**options)
|
13
|
-
@test_mode =
|
14
|
-
@setup_error =
|
15
|
-
@install_error =
|
16
|
-
@writer =
|
17
|
-
@reader =
|
18
|
-
@incoming_queue =
|
19
|
-
@outgoing_queue =
|
20
|
-
@cancelled_requests =
|
21
|
-
@worker =
|
22
|
-
@current_request_id =
|
23
|
-
@global_state =
|
24
|
-
@store =
|
25
|
-
@outgoing_dispatcher =
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
@global_state.synchronize { @writer.write(message.to_hash) }
|
30
|
-
end
|
13
|
+
@test_mode = options[:test_mode] #: bool?
|
14
|
+
@setup_error = options[:setup_error] #: StandardError?
|
15
|
+
@install_error = options[:install_error] #: StandardError?
|
16
|
+
@writer = Transport::Stdio::Writer.new #: Transport::Stdio::Writer
|
17
|
+
@reader = Transport::Stdio::Reader.new #: Transport::Stdio::Reader
|
18
|
+
@incoming_queue = Thread::Queue.new #: Thread::Queue
|
19
|
+
@outgoing_queue = Thread::Queue.new #: Thread::Queue
|
20
|
+
@cancelled_requests = [] #: Array[Integer]
|
21
|
+
@worker = new_worker #: Thread
|
22
|
+
@current_request_id = 1 #: Integer
|
23
|
+
@global_state = GlobalState.new #: GlobalState
|
24
|
+
@store = Store.new(@global_state) #: Store
|
25
|
+
@outgoing_dispatcher = Thread.new do
|
26
|
+
unless @test_mode
|
27
|
+
while (message = @outgoing_queue.pop)
|
28
|
+
@global_state.synchronize { @writer.write(message.to_hash) }
|
31
29
|
end
|
32
|
-
end
|
33
|
-
|
34
|
-
)
|
30
|
+
end
|
31
|
+
end #: Thread
|
35
32
|
|
36
33
|
Thread.main.priority = 1
|
37
34
|
|
@@ -148,7 +145,7 @@ module RubyLsp
|
|
148
145
|
#: -> Thread
|
149
146
|
def new_worker
|
150
147
|
Thread.new do
|
151
|
-
while (message =
|
148
|
+
while (message = @incoming_queue.pop)
|
152
149
|
id = message[:id]
|
153
150
|
|
154
151
|
# Check if the request was cancelled before trying to process it
|
@@ -16,24 +16,24 @@ module RubyLsp
|
|
16
16
|
def initialize
|
17
17
|
# The editor supports watching files. This requires two capabilities: dynamic registration and relative pattern
|
18
18
|
# support
|
19
|
-
@supports_watching_files =
|
19
|
+
@supports_watching_files = false #: bool
|
20
20
|
|
21
21
|
# The editor supports request delegation. This is an experimental capability since request delegation has not been
|
22
22
|
# standardized into the LSP spec yet
|
23
|
-
@supports_request_delegation =
|
23
|
+
@supports_request_delegation = false #: bool
|
24
24
|
|
25
25
|
# The editor supports extra arbitrary properties for `window/showMessageRequest`. Necessary for add-ons to show
|
26
26
|
# dialogs with user interactions
|
27
|
-
@window_show_message_supports_extra_properties =
|
27
|
+
@window_show_message_supports_extra_properties = false #: bool
|
28
28
|
|
29
29
|
# Which resource operations the editor supports, like renaming files
|
30
|
-
@supported_resource_operations =
|
30
|
+
@supported_resource_operations = [] #: Array[String]
|
31
31
|
|
32
32
|
# The editor supports displaying progress requests
|
33
|
-
@supports_progress =
|
33
|
+
@supports_progress = false #: bool
|
34
34
|
|
35
35
|
# The editor supports server initiated refresh for diagnostics
|
36
|
-
@supports_diagnostic_refresh =
|
36
|
+
@supports_diagnostic_refresh = false #: bool
|
37
37
|
end
|
38
38
|
|
39
39
|
#: (Hash[Symbol, untyped] capabilities) -> void
|