ruby-lsp 0.23.11 → 0.26.6
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 +2 -2
- data/VERSION +1 -1
- data/exe/ruby-lsp +10 -4
- data/exe/ruby-lsp-check +0 -4
- data/exe/ruby-lsp-launcher +46 -22
- data/exe/ruby-lsp-test-exec +6 -0
- data/lib/rubocop/cop/ruby_lsp/use_language_server_aliases.rb +1 -2
- data/lib/rubocop/cop/ruby_lsp/use_register_with_handler_method.rb +3 -6
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +85 -118
- data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +159 -183
- data/lib/ruby_indexer/lib/ruby_indexer/enhancement.rb +10 -14
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +130 -253
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +189 -285
- data/lib/ruby_indexer/lib/ruby_indexer/location.rb +4 -27
- data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +23 -27
- data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +31 -59
- data/lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb +58 -68
- data/lib/ruby_indexer/lib/ruby_indexer/uri.rb +17 -19
- data/lib/ruby_indexer/lib/ruby_indexer/visibility_scope.rb +7 -11
- data/lib/ruby_lsp/addon.rb +88 -86
- data/lib/ruby_lsp/base_server.rb +79 -65
- data/lib/ruby_lsp/client_capabilities.rb +16 -13
- data/lib/ruby_lsp/document.rb +205 -104
- data/lib/ruby_lsp/erb_document.rb +45 -47
- data/lib/ruby_lsp/global_state.rb +134 -86
- data/lib/ruby_lsp/internal.rb +8 -3
- data/lib/ruby_lsp/listeners/code_lens.rb +82 -89
- data/lib/ruby_lsp/listeners/completion.rb +81 -76
- data/lib/ruby_lsp/listeners/definition.rb +78 -72
- data/lib/ruby_lsp/listeners/document_highlight.rb +149 -151
- data/lib/ruby_lsp/listeners/document_link.rb +93 -86
- data/lib/ruby_lsp/listeners/document_symbol.rb +38 -52
- data/lib/ruby_lsp/listeners/folding_ranges.rb +40 -43
- data/lib/ruby_lsp/listeners/hover.rb +109 -117
- data/lib/ruby_lsp/listeners/inlay_hints.rb +8 -13
- data/lib/ruby_lsp/listeners/semantic_highlighting.rb +54 -56
- data/lib/ruby_lsp/listeners/signature_help.rb +12 -27
- data/lib/ruby_lsp/listeners/spec_style.rb +231 -0
- data/lib/ruby_lsp/listeners/test_discovery.rb +107 -0
- data/lib/ruby_lsp/listeners/test_style.rb +207 -95
- data/lib/ruby_lsp/node_context.rb +12 -39
- data/lib/ruby_lsp/rbs_document.rb +10 -11
- data/lib/ruby_lsp/requests/code_action_resolve.rb +92 -66
- data/lib/ruby_lsp/requests/code_actions.rb +34 -31
- data/lib/ruby_lsp/requests/code_lens.rb +31 -21
- data/lib/ruby_lsp/requests/completion.rb +8 -21
- data/lib/ruby_lsp/requests/completion_resolve.rb +14 -12
- data/lib/ruby_lsp/requests/definition.rb +8 -20
- data/lib/ruby_lsp/requests/diagnostics.rb +8 -11
- data/lib/ruby_lsp/requests/discover_tests.rb +20 -7
- data/lib/ruby_lsp/requests/document_highlight.rb +6 -16
- data/lib/ruby_lsp/requests/document_link.rb +6 -17
- data/lib/ruby_lsp/requests/document_symbol.rb +5 -8
- data/lib/ruby_lsp/requests/folding_ranges.rb +7 -15
- data/lib/ruby_lsp/requests/formatting.rb +6 -9
- data/lib/ruby_lsp/requests/go_to_relevant_file.rb +139 -0
- data/lib/ruby_lsp/requests/hover.rb +12 -25
- data/lib/ruby_lsp/requests/inlay_hints.rb +8 -19
- data/lib/ruby_lsp/requests/on_type_formatting.rb +32 -40
- data/lib/ruby_lsp/requests/prepare_rename.rb +5 -10
- data/lib/ruby_lsp/requests/prepare_type_hierarchy.rb +5 -15
- data/lib/ruby_lsp/requests/range_formatting.rb +5 -6
- data/lib/ruby_lsp/requests/references.rb +17 -57
- data/lib/ruby_lsp/requests/rename.rb +27 -51
- data/lib/ruby_lsp/requests/request.rb +13 -25
- data/lib/ruby_lsp/requests/selection_ranges.rb +7 -7
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +16 -35
- data/lib/ruby_lsp/requests/show_syntax_tree.rb +7 -8
- data/lib/ruby_lsp/requests/signature_help.rb +9 -27
- data/lib/ruby_lsp/requests/support/annotation.rb +4 -10
- data/lib/ruby_lsp/requests/support/common.rb +23 -61
- data/lib/ruby_lsp/requests/support/formatter.rb +16 -15
- data/lib/ruby_lsp/requests/support/package_url.rb +414 -0
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +27 -35
- data/lib/ruby_lsp/requests/support/rubocop_formatter.rb +13 -16
- data/lib/ruby_lsp/requests/support/rubocop_runner.rb +34 -36
- data/lib/ruby_lsp/requests/support/selection_range.rb +1 -3
- data/lib/ruby_lsp/requests/support/sorbet.rb +29 -38
- data/lib/ruby_lsp/requests/support/source_uri.rb +22 -33
- data/lib/ruby_lsp/requests/support/syntax_tree_formatter.rb +12 -19
- data/lib/ruby_lsp/requests/support/test_item.rb +16 -14
- data/lib/ruby_lsp/requests/type_hierarchy_supertypes.rb +5 -6
- data/lib/ruby_lsp/requests/workspace_symbol.rb +24 -16
- data/lib/ruby_lsp/response_builders/collection_response_builder.rb +6 -9
- data/lib/ruby_lsp/response_builders/document_symbol.rb +15 -21
- data/lib/ruby_lsp/response_builders/hover.rb +12 -18
- data/lib/ruby_lsp/response_builders/response_builder.rb +6 -7
- data/lib/ruby_lsp/response_builders/semantic_highlighting.rb +62 -91
- data/lib/ruby_lsp/response_builders/signature_help.rb +6 -8
- data/lib/ruby_lsp/response_builders/test_collection.rb +35 -13
- data/lib/ruby_lsp/ruby_document.rb +32 -98
- data/lib/ruby_lsp/scope.rb +7 -11
- data/lib/ruby_lsp/scripts/compose_bundle.rb +7 -5
- data/lib/ruby_lsp/server.rb +305 -198
- data/lib/ruby_lsp/setup_bundler.rb +160 -97
- data/lib/ruby_lsp/static_docs.rb +12 -7
- data/lib/ruby_lsp/store.rb +21 -49
- data/lib/ruby_lsp/test_helper.rb +3 -16
- data/lib/ruby_lsp/test_reporters/lsp_reporter.rb +241 -0
- data/lib/ruby_lsp/test_reporters/minitest_reporter.rb +145 -0
- data/lib/ruby_lsp/test_reporters/test_unit_reporter.rb +92 -0
- data/lib/ruby_lsp/type_inferrer.rb +13 -14
- data/lib/ruby_lsp/utils.rb +138 -93
- data/static_docs/break.md +103 -0
- metadata +15 -34
- data/lib/ruby_indexer/test/class_variables_test.rb +0 -140
- data/lib/ruby_indexer/test/classes_and_modules_test.rb +0 -745
- data/lib/ruby_indexer/test/configuration_test.rb +0 -239
- data/lib/ruby_indexer/test/constant_test.rb +0 -402
- data/lib/ruby_indexer/test/enhancements_test.rb +0 -325
- data/lib/ruby_indexer/test/global_variable_test.rb +0 -49
- data/lib/ruby_indexer/test/index_test.rb +0 -2186
- data/lib/ruby_indexer/test/instance_variables_test.rb +0 -240
- data/lib/ruby_indexer/test/method_test.rb +0 -947
- data/lib/ruby_indexer/test/prefix_tree_test.rb +0 -150
- data/lib/ruby_indexer/test/rbs_indexer_test.rb +0 -386
- data/lib/ruby_indexer/test/reference_finder_test.rb +0 -330
- data/lib/ruby_indexer/test/test_case.rb +0 -51
- data/lib/ruby_indexer/test/uri_test.rb +0 -72
- data/lib/ruby_lsp/load_sorbet.rb +0 -62
|
@@ -3,20 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
module RubyIndexer
|
|
5
5
|
class Location
|
|
6
|
-
extend T::Sig
|
|
7
|
-
|
|
8
6
|
class << self
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
sig do
|
|
12
|
-
params(
|
|
13
|
-
prism_location: Prism::Location,
|
|
14
|
-
code_units_cache: T.any(
|
|
15
|
-
T.proc.params(arg0: Integer).returns(Integer),
|
|
16
|
-
Prism::CodeUnitsCache,
|
|
17
|
-
),
|
|
18
|
-
).returns(T.attached_class)
|
|
19
|
-
end
|
|
7
|
+
#: (Prism::Location prism_location, (^(Integer arg0) -> Integer | Prism::CodeUnitsCache) code_units_cache) -> instance
|
|
20
8
|
def from_prism_location(prism_location, code_units_cache)
|
|
21
9
|
new(
|
|
22
10
|
prism_location.start_line,
|
|
@@ -27,17 +15,10 @@ module RubyIndexer
|
|
|
27
15
|
end
|
|
28
16
|
end
|
|
29
17
|
|
|
30
|
-
|
|
18
|
+
#: Integer
|
|
31
19
|
attr_reader :start_line, :end_line, :start_column, :end_column
|
|
32
20
|
|
|
33
|
-
|
|
34
|
-
params(
|
|
35
|
-
start_line: Integer,
|
|
36
|
-
end_line: Integer,
|
|
37
|
-
start_column: Integer,
|
|
38
|
-
end_column: Integer,
|
|
39
|
-
).void
|
|
40
|
-
end
|
|
21
|
+
#: (Integer start_line, Integer end_line, Integer start_column, Integer end_column) -> void
|
|
41
22
|
def initialize(start_line, end_line, start_column, end_column)
|
|
42
23
|
@start_line = start_line
|
|
43
24
|
@end_line = end_line
|
|
@@ -45,11 +26,7 @@ module RubyIndexer
|
|
|
45
26
|
@end_column = end_column
|
|
46
27
|
end
|
|
47
28
|
|
|
48
|
-
|
|
49
|
-
params(
|
|
50
|
-
other: T.any(Location, Prism::Location),
|
|
51
|
-
).returns(T::Boolean)
|
|
52
|
-
end
|
|
29
|
+
#: ((Location | Prism::Location) other) -> bool
|
|
53
30
|
def ==(other)
|
|
54
31
|
start_line == other.start_line &&
|
|
55
32
|
end_line == other.end_line &&
|
|
@@ -32,22 +32,21 @@ module RubyIndexer
|
|
|
32
32
|
# `Value` type.
|
|
33
33
|
#
|
|
34
34
|
# See https://en.wikipedia.org/wiki/Trie for more information
|
|
35
|
+
#: [Value]
|
|
35
36
|
class PrefixTree
|
|
36
|
-
|
|
37
|
-
extend T::Generic
|
|
38
|
-
|
|
39
|
-
Value = type_member
|
|
40
|
-
|
|
41
|
-
sig { void }
|
|
37
|
+
#: -> void
|
|
42
38
|
def initialize
|
|
43
|
-
@root =
|
|
39
|
+
@root = Node.new(
|
|
40
|
+
"",
|
|
41
|
+
"", #: as untyped
|
|
42
|
+
) #: Node[Value]
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
# Search the PrefixTree based on a given `prefix`. If `foo` is an entry in the tree, then searching for `fo` will
|
|
47
46
|
# return it as a result. The result is always an array of the type of value attribute to the generic `Value` type.
|
|
48
47
|
# Notice that if the `Value` is an array, this method will return an array of arrays, where each entry is the array
|
|
49
48
|
# of values for a given match
|
|
50
|
-
|
|
49
|
+
#: (String prefix) -> Array[Value]
|
|
51
50
|
def search(prefix)
|
|
52
51
|
node = find_node(prefix)
|
|
53
52
|
return [] unless node
|
|
@@ -56,7 +55,7 @@ module RubyIndexer
|
|
|
56
55
|
end
|
|
57
56
|
|
|
58
57
|
# Inserts a `value` using the given `key`
|
|
59
|
-
|
|
58
|
+
#: (String key, Value value) -> void
|
|
60
59
|
def insert(key, value)
|
|
61
60
|
node = @root
|
|
62
61
|
|
|
@@ -73,13 +72,13 @@ module RubyIndexer
|
|
|
73
72
|
|
|
74
73
|
# Deletes the entry identified by `key` from the tree. Notice that a partial match will still delete all entries
|
|
75
74
|
# that match it. For example, if the tree contains `foo` and we ask to delete `fo`, then `foo` will be deleted
|
|
76
|
-
|
|
75
|
+
#: (String key) -> void
|
|
77
76
|
def delete(key)
|
|
78
77
|
node = find_node(key)
|
|
79
78
|
return unless node
|
|
80
79
|
|
|
81
80
|
# Remove the node from the tree and then go up the parents to remove any of them with empty children
|
|
82
|
-
parent =
|
|
81
|
+
parent = node.parent #: Node[Value]?
|
|
83
82
|
|
|
84
83
|
while parent
|
|
85
84
|
parent.children.delete(node.key)
|
|
@@ -93,7 +92,7 @@ module RubyIndexer
|
|
|
93
92
|
private
|
|
94
93
|
|
|
95
94
|
# Find a node that matches the given `key`
|
|
96
|
-
|
|
95
|
+
#: (String key) -> Node[Value]?
|
|
97
96
|
def find_node(key)
|
|
98
97
|
node = @root
|
|
99
98
|
|
|
@@ -107,28 +106,24 @@ module RubyIndexer
|
|
|
107
106
|
node
|
|
108
107
|
end
|
|
109
108
|
|
|
109
|
+
#: [Value]
|
|
110
110
|
class Node
|
|
111
|
-
|
|
112
|
-
extend T::Generic
|
|
113
|
-
|
|
114
|
-
Value = type_member
|
|
115
|
-
|
|
116
|
-
sig { returns(T::Hash[String, Node[Value]]) }
|
|
111
|
+
#: Hash[String, Node[Value]]
|
|
117
112
|
attr_reader :children
|
|
118
113
|
|
|
119
|
-
|
|
114
|
+
#: String
|
|
120
115
|
attr_reader :key
|
|
121
116
|
|
|
122
|
-
|
|
117
|
+
#: Value
|
|
123
118
|
attr_accessor :value
|
|
124
119
|
|
|
125
|
-
|
|
120
|
+
#: bool
|
|
126
121
|
attr_accessor :leaf
|
|
127
122
|
|
|
128
|
-
|
|
123
|
+
#: Node[Value]?
|
|
129
124
|
attr_reader :parent
|
|
130
125
|
|
|
131
|
-
|
|
126
|
+
#: (String key, Value value, ?Node[Value]? parent) -> void
|
|
132
127
|
def initialize(key, value, parent = nil)
|
|
133
128
|
@key = key
|
|
134
129
|
@value = value
|
|
@@ -137,13 +132,14 @@ module RubyIndexer
|
|
|
137
132
|
@leaf = false
|
|
138
133
|
end
|
|
139
134
|
|
|
140
|
-
|
|
135
|
+
#: -> Array[Value]
|
|
141
136
|
def collect
|
|
142
137
|
result = []
|
|
143
|
-
|
|
138
|
+
stack = [self]
|
|
144
139
|
|
|
145
|
-
|
|
146
|
-
result.
|
|
140
|
+
while (node = stack.pop)
|
|
141
|
+
result << node.value if node.leaf
|
|
142
|
+
stack.concat(node.children.values)
|
|
147
143
|
end
|
|
148
144
|
|
|
149
145
|
result
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
module RubyIndexer
|
|
5
5
|
class RBSIndexer
|
|
6
|
-
|
|
6
|
+
HAS_UNTYPED_FUNCTION = !!defined?(RBS::Types::UntypedFunction) #: bool
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
sig { params(index: Index).void }
|
|
8
|
+
#: (Index index) -> void
|
|
11
9
|
def initialize(index)
|
|
12
10
|
@index = index
|
|
13
11
|
end
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
#: -> void
|
|
16
14
|
def index_ruby_core
|
|
17
15
|
loader = RBS::EnvironmentLoader.new
|
|
18
16
|
RBS::Environment.from_loader(loader).resolve_type_names
|
|
@@ -22,12 +20,7 @@ module RubyIndexer
|
|
|
22
20
|
end
|
|
23
21
|
end
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
params(
|
|
27
|
-
pathname: Pathname,
|
|
28
|
-
declarations: T::Array[RBS::AST::Declarations::Base],
|
|
29
|
-
).void
|
|
30
|
-
end
|
|
23
|
+
#: (Pathname pathname, Array[RBS::AST::Declarations::Base] declarations) -> void
|
|
31
24
|
def process_signature(pathname, declarations)
|
|
32
25
|
declarations.each do |declaration|
|
|
33
26
|
process_declaration(declaration, pathname)
|
|
@@ -36,7 +29,7 @@ module RubyIndexer
|
|
|
36
29
|
|
|
37
30
|
private
|
|
38
31
|
|
|
39
|
-
|
|
32
|
+
#: (RBS::AST::Declarations::Base declaration, Pathname pathname) -> void
|
|
40
33
|
def process_declaration(declaration, pathname)
|
|
41
34
|
case declaration
|
|
42
35
|
when RBS::AST::Declarations::Class, RBS::AST::Declarations::Module
|
|
@@ -51,9 +44,7 @@ module RubyIndexer
|
|
|
51
44
|
end
|
|
52
45
|
end
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
params(declaration: T.any(RBS::AST::Declarations::Class, RBS::AST::Declarations::Module), pathname: Pathname).void
|
|
56
|
-
end
|
|
47
|
+
#: ((RBS::AST::Declarations::Class | RBS::AST::Declarations::Module) declaration, Pathname pathname) -> void
|
|
57
48
|
def handle_class_or_module_declaration(declaration, pathname)
|
|
58
49
|
nesting = [declaration.name.name.to_s]
|
|
59
50
|
uri = URI::Generic.from_path(path: pathname.to_s)
|
|
@@ -61,9 +52,9 @@ module RubyIndexer
|
|
|
61
52
|
comments = comments_to_string(declaration)
|
|
62
53
|
entry = if declaration.is_a?(RBS::AST::Declarations::Class)
|
|
63
54
|
parent_class = declaration.super_class&.name&.name&.to_s
|
|
64
|
-
Entry::Class.new(nesting, uri, location, location, comments, parent_class)
|
|
55
|
+
Entry::Class.new(@index.configuration, nesting, uri, location, location, comments, parent_class)
|
|
65
56
|
else
|
|
66
|
-
Entry::Module.new(nesting, uri, location, location, comments)
|
|
57
|
+
Entry::Module.new(@index.configuration, nesting, uri, location, location, comments)
|
|
67
58
|
end
|
|
68
59
|
|
|
69
60
|
add_declaration_mixins_to_entry(declaration, entry)
|
|
@@ -83,7 +74,7 @@ module RubyIndexer
|
|
|
83
74
|
end
|
|
84
75
|
end
|
|
85
76
|
|
|
86
|
-
|
|
77
|
+
#: (RBS::Location rbs_location) -> RubyIndexer::Location
|
|
87
78
|
def to_ruby_indexer_location(rbs_location)
|
|
88
79
|
RubyIndexer::Location.new(
|
|
89
80
|
rbs_location.start_line,
|
|
@@ -93,12 +84,7 @@ module RubyIndexer
|
|
|
93
84
|
)
|
|
94
85
|
end
|
|
95
86
|
|
|
96
|
-
|
|
97
|
-
params(
|
|
98
|
-
declaration: T.any(RBS::AST::Declarations::Class, RBS::AST::Declarations::Module),
|
|
99
|
-
entry: Entry::Namespace,
|
|
100
|
-
).void
|
|
101
|
-
end
|
|
87
|
+
#: ((RBS::AST::Declarations::Class | RBS::AST::Declarations::Module) declaration, Entry::Namespace entry) -> void
|
|
102
88
|
def add_declaration_mixins_to_entry(declaration, entry)
|
|
103
89
|
declaration.each_mixin do |mixin|
|
|
104
90
|
name = mixin.name.name.to_s
|
|
@@ -114,37 +100,29 @@ module RubyIndexer
|
|
|
114
100
|
end
|
|
115
101
|
end
|
|
116
102
|
|
|
117
|
-
|
|
103
|
+
#: (RBS::AST::Members::MethodDefinition member, Entry::Namespace owner) -> void
|
|
118
104
|
def handle_method(member, owner)
|
|
119
105
|
name = member.name.name
|
|
120
|
-
uri = URI::Generic.from_path(path: member.location.buffer.name)
|
|
106
|
+
uri = URI::Generic.from_path(path: member.location.buffer.name.to_s)
|
|
121
107
|
location = to_ruby_indexer_location(member.location)
|
|
122
108
|
comments = comments_to_string(member)
|
|
123
109
|
|
|
124
|
-
visibility = case member.visibility
|
|
125
|
-
when :private
|
|
126
|
-
Entry::Visibility::PRIVATE
|
|
127
|
-
when :protected
|
|
128
|
-
Entry::Visibility::PROTECTED
|
|
129
|
-
else
|
|
130
|
-
Entry::Visibility::PUBLIC
|
|
131
|
-
end
|
|
132
|
-
|
|
133
110
|
real_owner = member.singleton? ? @index.existing_or_new_singleton_class(owner.name) : owner
|
|
134
111
|
signatures = signatures(member)
|
|
135
112
|
@index.add(Entry::Method.new(
|
|
113
|
+
@index.configuration,
|
|
136
114
|
name,
|
|
137
115
|
uri,
|
|
138
116
|
location,
|
|
139
117
|
location,
|
|
140
118
|
comments,
|
|
141
119
|
signatures,
|
|
142
|
-
visibility,
|
|
120
|
+
member.visibility || :public,
|
|
143
121
|
real_owner,
|
|
144
122
|
))
|
|
145
123
|
end
|
|
146
124
|
|
|
147
|
-
|
|
125
|
+
#: (RBS::AST::Members::MethodDefinition member) -> Array[Entry::Signature]
|
|
148
126
|
def signatures(member)
|
|
149
127
|
member.overloads.map do |overload|
|
|
150
128
|
parameters = process_overload(overload)
|
|
@@ -152,7 +130,7 @@ module RubyIndexer
|
|
|
152
130
|
end
|
|
153
131
|
end
|
|
154
132
|
|
|
155
|
-
|
|
133
|
+
#: (RBS::AST::Members::MethodDefinition::Overload overload) -> Array[Entry::Parameter]
|
|
156
134
|
def process_overload(overload)
|
|
157
135
|
function = overload.method_type.type
|
|
158
136
|
|
|
@@ -173,7 +151,7 @@ module RubyIndexer
|
|
|
173
151
|
end
|
|
174
152
|
end
|
|
175
153
|
|
|
176
|
-
|
|
154
|
+
#: (RBS::Types::Function function) -> Array[Entry::Parameter]
|
|
177
155
|
def parse_arguments(function)
|
|
178
156
|
parameters = []
|
|
179
157
|
parameters.concat(process_required_and_optional_positionals(function))
|
|
@@ -185,7 +163,7 @@ module RubyIndexer
|
|
|
185
163
|
parameters
|
|
186
164
|
end
|
|
187
165
|
|
|
188
|
-
|
|
166
|
+
#: (RBS::Types::Function function) -> Array[Entry::RequiredParameter]
|
|
189
167
|
def process_required_and_optional_positionals(function)
|
|
190
168
|
argument_offset = 0
|
|
191
169
|
|
|
@@ -209,14 +187,14 @@ module RubyIndexer
|
|
|
209
187
|
required + optional
|
|
210
188
|
end
|
|
211
189
|
|
|
212
|
-
|
|
190
|
+
#: (RBS::Types::Function function) -> Array[Entry::OptionalParameter]
|
|
213
191
|
def process_trailing_positionals(function)
|
|
214
192
|
function.trailing_positionals.map do |param|
|
|
215
193
|
Entry::OptionalParameter.new(name: param.name)
|
|
216
194
|
end
|
|
217
195
|
end
|
|
218
196
|
|
|
219
|
-
|
|
197
|
+
#: (RBS::Types::Function function) -> Entry::RestParameter
|
|
220
198
|
def process_rest_positionals(function)
|
|
221
199
|
rest = function.rest_positionals
|
|
222
200
|
|
|
@@ -225,21 +203,21 @@ module RubyIndexer
|
|
|
225
203
|
Entry::RestParameter.new(name: rest_name)
|
|
226
204
|
end
|
|
227
205
|
|
|
228
|
-
|
|
206
|
+
#: (RBS::Types::Function function) -> Array[Entry::KeywordParameter]
|
|
229
207
|
def process_required_keywords(function)
|
|
230
208
|
function.required_keywords.map do |name, _param|
|
|
231
209
|
Entry::KeywordParameter.new(name: name)
|
|
232
210
|
end
|
|
233
211
|
end
|
|
234
212
|
|
|
235
|
-
|
|
213
|
+
#: (RBS::Types::Function function) -> Array[Entry::OptionalKeywordParameter]
|
|
236
214
|
def process_optional_keywords(function)
|
|
237
215
|
function.optional_keywords.map do |name, _param|
|
|
238
216
|
Entry::OptionalKeywordParameter.new(name: name)
|
|
239
217
|
end
|
|
240
218
|
end
|
|
241
219
|
|
|
242
|
-
|
|
220
|
+
#: (RBS::Types::Function function) -> Entry::KeywordRestParameter
|
|
243
221
|
def process_rest_keywords(function)
|
|
244
222
|
param = function.rest_keywords
|
|
245
223
|
|
|
@@ -262,10 +240,11 @@ module RubyIndexer
|
|
|
262
240
|
# Complex::I = ... # Complex::I is a top-level constant
|
|
263
241
|
#
|
|
264
242
|
# And we need to handle their nesting differently.
|
|
265
|
-
|
|
243
|
+
#: (RBS::AST::Declarations::Constant declaration, Array[String] nesting, URI::Generic uri) -> void
|
|
266
244
|
def handle_constant(declaration, nesting, uri)
|
|
267
245
|
fully_qualified_name = [*nesting, declaration.name.name.to_s].join("::")
|
|
268
246
|
@index.add(Entry::Constant.new(
|
|
247
|
+
@index.configuration,
|
|
269
248
|
fully_qualified_name,
|
|
270
249
|
uri,
|
|
271
250
|
to_ruby_indexer_location(declaration.location),
|
|
@@ -273,7 +252,7 @@ module RubyIndexer
|
|
|
273
252
|
))
|
|
274
253
|
end
|
|
275
254
|
|
|
276
|
-
|
|
255
|
+
#: (RBS::AST::Declarations::Global declaration, Pathname pathname) -> void
|
|
277
256
|
def handle_global_variable(declaration, pathname)
|
|
278
257
|
name = declaration.name.to_s
|
|
279
258
|
uri = URI::Generic.from_path(path: pathname.to_s)
|
|
@@ -281,6 +260,7 @@ module RubyIndexer
|
|
|
281
260
|
comments = comments_to_string(declaration)
|
|
282
261
|
|
|
283
262
|
@index.add(Entry::GlobalVariable.new(
|
|
263
|
+
@index.configuration,
|
|
284
264
|
name,
|
|
285
265
|
uri,
|
|
286
266
|
location,
|
|
@@ -288,12 +268,13 @@ module RubyIndexer
|
|
|
288
268
|
))
|
|
289
269
|
end
|
|
290
270
|
|
|
291
|
-
|
|
271
|
+
#: (RBS::AST::Members::Alias member, Entry::Namespace owner_entry) -> void
|
|
292
272
|
def handle_signature_alias(member, owner_entry)
|
|
293
|
-
uri = URI::Generic.from_path(path: member.location.buffer.name)
|
|
273
|
+
uri = URI::Generic.from_path(path: member.location.buffer.name.to_s)
|
|
294
274
|
comments = comments_to_string(member)
|
|
295
275
|
|
|
296
276
|
entry = Entry::UnresolvedMethodAlias.new(
|
|
277
|
+
@index.configuration,
|
|
297
278
|
member.new_name.to_s,
|
|
298
279
|
member.old_name.to_s,
|
|
299
280
|
owner_entry,
|
|
@@ -305,16 +286,7 @@ module RubyIndexer
|
|
|
305
286
|
@index.add(entry)
|
|
306
287
|
end
|
|
307
288
|
|
|
308
|
-
|
|
309
|
-
params(declaration: T.any(
|
|
310
|
-
RBS::AST::Declarations::Class,
|
|
311
|
-
RBS::AST::Declarations::Module,
|
|
312
|
-
RBS::AST::Declarations::Constant,
|
|
313
|
-
RBS::AST::Declarations::Global,
|
|
314
|
-
RBS::AST::Members::MethodDefinition,
|
|
315
|
-
RBS::AST::Members::Alias,
|
|
316
|
-
)).returns(T.nilable(String))
|
|
317
|
-
end
|
|
289
|
+
#: ((RBS::AST::Declarations::Class | RBS::AST::Declarations::Module | RBS::AST::Declarations::Constant | RBS::AST::Declarations::Global | RBS::AST::Members::MethodDefinition | RBS::AST::Members::Alias) declaration) -> String?
|
|
318
290
|
def comments_to_string(declaration)
|
|
319
291
|
declaration.comment&.string
|
|
320
292
|
end
|