solargraph 0.58.2 → 0.59.0.dev.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/.envrc +3 -0
- data/.github/workflows/linting.yml +4 -5
- data/.github/workflows/plugins.yml +40 -36
- data/.github/workflows/rspec.yml +45 -13
- data/.github/workflows/typecheck.yml +2 -2
- data/.gitignore +0 -1
- data/.rubocop_todo.yml +27 -49
- data/CHANGELOG.md +1 -7
- data/README.md +3 -3
- data/Rakefile +1 -0
- data/lib/solargraph/api_map/cache.rb +3 -3
- data/lib/solargraph/api_map/constants.rb +13 -3
- data/lib/solargraph/api_map/index.rb +22 -11
- data/lib/solargraph/api_map/source_to_yard.rb +13 -1
- data/lib/solargraph/api_map/store.rb +11 -8
- data/lib/solargraph/api_map.rb +105 -50
- data/lib/solargraph/complex_type/conformance.rb +176 -0
- data/lib/solargraph/complex_type/type_methods.rb +16 -2
- data/lib/solargraph/complex_type/unique_type.rb +170 -20
- data/lib/solargraph/complex_type.rb +119 -14
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +3 -1
- data/lib/solargraph/convention/data_definition.rb +4 -1
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +1 -0
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +1 -0
- data/lib/solargraph/convention/struct_definition.rb +5 -1
- data/lib/solargraph/diagnostics/require_not_found.rb +1 -0
- data/lib/solargraph/diagnostics/rubocop.rb +1 -0
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +2 -0
- data/lib/solargraph/diagnostics/type_check.rb +1 -0
- data/lib/solargraph/doc_map.rb +134 -373
- data/lib/solargraph/equality.rb +1 -1
- data/lib/solargraph/gem_pins.rb +14 -15
- data/lib/solargraph/language_server/host/diagnoser.rb +89 -89
- data/lib/solargraph/language_server/host/dispatch.rb +1 -0
- data/lib/solargraph/language_server/host/message_worker.rb +2 -1
- data/lib/solargraph/language_server/host/sources.rb +1 -0
- data/lib/solargraph/language_server/host.rb +6 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +2 -7
- data/lib/solargraph/language_server/message/extended/document.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/completion.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/definition.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/formatting.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +2 -0
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +2 -0
- data/lib/solargraph/library.rb +59 -13
- data/lib/solargraph/location.rb +9 -4
- data/lib/solargraph/logging.rb +21 -1
- data/lib/solargraph/parser/comment_ripper.rb +7 -0
- data/lib/solargraph/parser/flow_sensitive_typing.rb +330 -102
- data/lib/solargraph/parser/node_processor/base.rb +32 -2
- data/lib/solargraph/parser/node_processor.rb +7 -6
- data/lib/solargraph/parser/parser_gem/class_methods.rb +28 -10
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +31 -6
- data/lib/solargraph/parser/parser_gem/node_methods.rb +27 -7
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +4 -4
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +2 -0
- data/lib/solargraph/parser/parser_gem/node_processors/begin_node.rb +9 -0
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +11 -11
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +7 -0
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +36 -6
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +3 -2
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +3 -1
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +2 -2
- data/lib/solargraph/parser/parser_gem/node_processors/or_node.rb +22 -0
- data/lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +12 -7
- data/lib/solargraph/parser/parser_gem/node_processors/when_node.rb +23 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +5 -1
- data/lib/solargraph/parser/parser_gem/node_processors.rb +4 -0
- data/lib/solargraph/parser/region.rb +9 -3
- data/lib/solargraph/parser/snippet.rb +1 -1
- data/lib/solargraph/pin/base.rb +53 -21
- data/lib/solargraph/pin/base_variable.rb +312 -20
- data/lib/solargraph/pin/block.rb +26 -4
- data/lib/solargraph/pin/breakable.rb +5 -1
- data/lib/solargraph/pin/callable.rb +50 -3
- data/lib/solargraph/pin/closure.rb +2 -6
- data/lib/solargraph/pin/common.rb +20 -5
- data/lib/solargraph/pin/compound_statement.rb +55 -0
- data/lib/solargraph/pin/conversions.rb +2 -1
- data/lib/solargraph/pin/delegated_method.rb +15 -4
- data/lib/solargraph/pin/documenting.rb +1 -0
- data/lib/solargraph/pin/instance_variable.rb +5 -1
- data/lib/solargraph/pin/keyword.rb +0 -4
- data/lib/solargraph/pin/local_variable.rb +13 -57
- data/lib/solargraph/pin/method.rb +90 -42
- data/lib/solargraph/pin/method_alias.rb +8 -0
- data/lib/solargraph/pin/namespace.rb +7 -1
- data/lib/solargraph/pin/parameter.rb +76 -13
- data/lib/solargraph/pin/proxy_type.rb +2 -1
- data/lib/solargraph/pin/reference/override.rb +1 -1
- data/lib/solargraph/pin/reference/superclass.rb +2 -0
- data/lib/solargraph/pin/reference.rb +2 -0
- data/lib/solargraph/pin/search.rb +1 -0
- data/lib/solargraph/pin/signature.rb +8 -0
- data/lib/solargraph/pin/symbol.rb +1 -1
- data/lib/solargraph/pin/until.rb +1 -1
- data/lib/solargraph/pin/while.rb +1 -1
- data/lib/solargraph/pin.rb +2 -0
- data/lib/solargraph/pin_cache.rb +477 -57
- data/lib/solargraph/position.rb +12 -26
- data/lib/solargraph/range.rb +6 -6
- data/lib/solargraph/rbs_map/conversions.rb +33 -10
- data/lib/solargraph/rbs_map/core_map.rb +24 -17
- data/lib/solargraph/rbs_map/stdlib_map.rb +34 -5
- data/lib/solargraph/rbs_map.rb +74 -20
- data/lib/solargraph/shell.rb +73 -28
- data/lib/solargraph/source/chain/call.rb +52 -17
- data/lib/solargraph/source/chain/constant.rb +2 -0
- data/lib/solargraph/source/chain/hash.rb +1 -0
- data/lib/solargraph/source/chain/if.rb +1 -0
- data/lib/solargraph/source/chain/instance_variable.rb +22 -1
- data/lib/solargraph/source/chain/literal.rb +5 -0
- data/lib/solargraph/source/chain/or.rb +9 -1
- data/lib/solargraph/source/chain.rb +25 -22
- data/lib/solargraph/source/change.rb +9 -2
- data/lib/solargraph/source/cursor.rb +7 -1
- data/lib/solargraph/source/source_chainer.rb +13 -3
- data/lib/solargraph/source/updater.rb +4 -0
- data/lib/solargraph/source.rb +33 -7
- data/lib/solargraph/source_map/clip.rb +13 -2
- data/lib/solargraph/source_map/data.rb +4 -1
- data/lib/solargraph/source_map/mapper.rb +24 -1
- data/lib/solargraph/source_map.rb +14 -6
- data/lib/solargraph/type_checker/problem.rb +3 -1
- data/lib/solargraph/type_checker/rules.rb +75 -2
- data/lib/solargraph/type_checker.rb +111 -30
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +3 -1
- data/lib/solargraph/workspace/gemspecs.rb +367 -0
- data/lib/solargraph/workspace/require_paths.rb +1 -0
- data/lib/solargraph/workspace.rb +158 -16
- data/lib/solargraph/yard_map/helpers.rb +2 -1
- data/lib/solargraph/yard_map/mapper/to_method.rb +5 -1
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +1 -0
- data/lib/solargraph/yard_map/mapper.rb +5 -0
- data/lib/solargraph/yardoc.rb +33 -23
- data/lib/solargraph.rb +24 -3
- data/rbs/fills/rubygems/0/dependency.rbs +193 -0
- data/rbs/fills/tuple/tuple.rbs +28 -0
- data/rbs/shims/ast/0/node.rbs +1 -1
- data/rbs/shims/diff-lcs/1.5/diff-lcs.rbs +11 -0
- data/solargraph.gemspec +2 -1
- metadata +12 -7
- data/lib/solargraph/type_checker/checks.rb +0 -124
- data/lib/solargraph/type_checker/param_def.rb +0 -37
- data/lib/solargraph/yard_map/to_method.rb +0 -89
|
@@ -27,9 +27,11 @@ module Solargraph
|
|
|
27
27
|
# @param name [String] Namespace which may relative and not be rooted.
|
|
28
28
|
# @param gates [Array<Array<String>, String>] Namespaces to search while resolving the name
|
|
29
29
|
#
|
|
30
|
+
# @sg-ignore flow sensitive typing needs to eliminate literal from union with return if foo == :bar
|
|
30
31
|
# @return [String, nil] fully qualified namespace (i.e., is
|
|
31
32
|
# absolute, but will not start with ::)
|
|
32
33
|
def resolve(name, *gates)
|
|
34
|
+
# @sg-ignore Need to add nil check here
|
|
33
35
|
return store.get_path_pins(name[2..]).first&.path if name.start_with?('::')
|
|
34
36
|
|
|
35
37
|
flat = gates.flatten
|
|
@@ -86,6 +88,7 @@ module Solargraph
|
|
|
86
88
|
return unless fqns
|
|
87
89
|
pin = store.get_path_pins(fqns).first
|
|
88
90
|
if pin.is_a?(Pin::Constant)
|
|
91
|
+
# @sg-ignore Need to add nil check here
|
|
89
92
|
const = Solargraph::Parser::NodeMethods.unpack_name(pin.assignment)
|
|
90
93
|
return unless const
|
|
91
94
|
fqns = resolve(const, *pin.gates)
|
|
@@ -105,6 +108,7 @@ module Solargraph
|
|
|
105
108
|
|
|
106
109
|
# @param name [String]
|
|
107
110
|
# @param gates [Array<String>]
|
|
111
|
+
# @sg-ignore flow sensitive typing should be able to handle redefinition
|
|
108
112
|
# @return [String, nil]
|
|
109
113
|
def resolve_and_cache name, gates
|
|
110
114
|
cached_resolve[[name, gates]] = :in_process
|
|
@@ -125,6 +129,7 @@ module Solargraph
|
|
|
125
129
|
if resolved
|
|
126
130
|
base = [resolved]
|
|
127
131
|
else
|
|
132
|
+
# @sg-ignore flow sensitive typing needs better handling of ||= on lvars
|
|
128
133
|
return resolve(name, first) unless first.empty?
|
|
129
134
|
end
|
|
130
135
|
end
|
|
@@ -138,7 +143,7 @@ module Solargraph
|
|
|
138
143
|
# @param name [String]
|
|
139
144
|
# @param gates [Array<String>]
|
|
140
145
|
# @param internal [Boolean] True if the name is not the last in the namespace
|
|
141
|
-
# @return [Array(
|
|
146
|
+
# @return [Array(String, Array<String>), Array(nil, Array<String>), String]
|
|
142
147
|
def complex_resolve name, gates, internal
|
|
143
148
|
resolved = nil
|
|
144
149
|
gates.each.with_index do |gate, idx|
|
|
@@ -165,6 +170,7 @@ module Solargraph
|
|
|
165
170
|
here = "#{gate}::#{name}".sub(/^::/, '').sub(/::$/, '')
|
|
166
171
|
pin = store.get_path_pins(here).first
|
|
167
172
|
if pin.is_a?(Pin::Constant) && internal
|
|
173
|
+
# @sg-ignore Need to add nil check here
|
|
168
174
|
const = Solargraph::Parser::NodeMethods.unpack_name(pin.assignment)
|
|
169
175
|
return unless const
|
|
170
176
|
resolve(const, pin.gates)
|
|
@@ -197,13 +203,14 @@ module Solargraph
|
|
|
197
203
|
# will start the search in the specified context until it finds a
|
|
198
204
|
# match for the namespace.
|
|
199
205
|
#
|
|
200
|
-
# @param namespace [String
|
|
206
|
+
# @param namespace [String] The namespace to
|
|
201
207
|
# match
|
|
202
208
|
# @param context_namespace [String] The context namespace in which the
|
|
203
209
|
# tag was referenced; start from here to resolve the name
|
|
204
210
|
# @return [String, nil] fully qualified namespace
|
|
205
211
|
def qualify_namespace namespace, context_namespace = ''
|
|
206
212
|
if namespace.start_with?('::')
|
|
213
|
+
# @sg-ignore Need to add nil check here
|
|
207
214
|
inner_qualify(namespace[2..], '', Set.new)
|
|
208
215
|
else
|
|
209
216
|
inner_qualify(namespace, context_namespace, Set.new)
|
|
@@ -249,7 +256,7 @@ module Solargraph
|
|
|
249
256
|
end
|
|
250
257
|
end
|
|
251
258
|
|
|
252
|
-
# @param fqns [String]
|
|
259
|
+
# @param fqns [String, nil]
|
|
253
260
|
# @param visibility [Array<Symbol>]
|
|
254
261
|
# @param skip [Set<String>]
|
|
255
262
|
# @return [Array<Solargraph::Pin::Namespace, Solargraph::Pin::Constant>]
|
|
@@ -259,17 +266,20 @@ module Solargraph
|
|
|
259
266
|
result = []
|
|
260
267
|
|
|
261
268
|
store.get_prepends(fqns).each do |pre|
|
|
269
|
+
# @sg-ignore Need to add nil check here
|
|
262
270
|
pre_fqns = resolve(pre.name, pre.closure.gates - skip.to_a)
|
|
263
271
|
result.concat inner_get_constants(pre_fqns, [:public], skip)
|
|
264
272
|
end
|
|
265
273
|
result.concat(store.get_constants(fqns, visibility).sort { |a, b| a.name <=> b.name })
|
|
266
274
|
store.get_includes(fqns).each do |pin|
|
|
275
|
+
# @sg-ignore Need to add nil check here
|
|
267
276
|
inc_fqns = resolve(pin.name, pin.closure.gates - skip.to_a)
|
|
268
277
|
result.concat inner_get_constants(inc_fqns, [:public], skip)
|
|
269
278
|
end
|
|
270
279
|
sc_ref = store.get_superclass(fqns)
|
|
271
280
|
if sc_ref
|
|
272
281
|
fqsc = dereference(sc_ref)
|
|
282
|
+
# @sg-ignore Need to add nil check here
|
|
273
283
|
result.concat inner_get_constants(fqsc, [:public], skip) unless %w[Object BasicObject].include?(fqsc)
|
|
274
284
|
end
|
|
275
285
|
result
|
|
@@ -40,13 +40,13 @@ module Solargraph
|
|
|
40
40
|
# @param klass [Class<generic<T>>]
|
|
41
41
|
# @return [Set<generic<T>>]
|
|
42
42
|
def pins_by_class klass
|
|
43
|
-
# @type [Set<
|
|
43
|
+
# @type [Set<generic<T>>]
|
|
44
44
|
s = Set.new
|
|
45
45
|
# @sg-ignore need to support destructured args in blocks
|
|
46
46
|
@pin_select_cache[klass] ||= pin_class_hash.each_with_object(s) { |(key, o), n| n.merge(o) if key <= klass }
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
# @return [Hash{String => Array<
|
|
49
|
+
# @return [Hash{String => Array<Pin::Reference::Include>}]
|
|
50
50
|
def include_references
|
|
51
51
|
# @param h [String]
|
|
52
52
|
# @param k [Array<String>]
|
|
@@ -60,21 +60,21 @@ module Solargraph
|
|
|
60
60
|
@include_reference_pins ||= Hash.new { |h, k| h[k] = [] }
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
# @return [Hash{String => Array<
|
|
63
|
+
# @return [Hash{String => Array<Pin::Reference::Extend>}]
|
|
64
64
|
def extend_references
|
|
65
65
|
# @param h [String]
|
|
66
66
|
# @param k [Array<String>]
|
|
67
67
|
@extend_references ||= Hash.new { |h, k| h[k] = [] }
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
# @return [Hash{String => Array<
|
|
70
|
+
# @return [Hash{String => Array<Pin::Reference::Prepend>}]
|
|
71
71
|
def prepend_references
|
|
72
72
|
# @param h [String]
|
|
73
73
|
# @param k [Array<String>]
|
|
74
74
|
@prepend_references ||= Hash.new { |h, k| h[k] = [] }
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
# @return [Hash{String => Array<
|
|
77
|
+
# @return [Hash{String => Array<Pin::Reference::Superclass>}]
|
|
78
78
|
def superclass_references
|
|
79
79
|
# @param h [String]
|
|
80
80
|
# @param k [Array<String>]
|
|
@@ -138,7 +138,7 @@ module Solargraph
|
|
|
138
138
|
|
|
139
139
|
# @generic T
|
|
140
140
|
# @param klass [Class<generic<T>>]
|
|
141
|
-
# @param hash [Hash{String => generic<T
|
|
141
|
+
# @param hash [Hash{String => Array<generic<T>>}]
|
|
142
142
|
#
|
|
143
143
|
# @return [void]
|
|
144
144
|
def map_references klass, hash
|
|
@@ -150,6 +150,7 @@ module Solargraph
|
|
|
150
150
|
|
|
151
151
|
# @return [void]
|
|
152
152
|
def map_overrides
|
|
153
|
+
# @todo should complain when type for 'ovr' is not provided
|
|
153
154
|
# @param ovr [Pin::Reference::Override]
|
|
154
155
|
pins_by_class(Pin::Reference::Override).each do |ovr|
|
|
155
156
|
logger.debug { "ApiMap::Index#map_overrides: Looking at override #{ovr} for #{ovr.name}" }
|
|
@@ -160,16 +161,27 @@ module Solargraph
|
|
|
160
161
|
path_pin_hash[pin.path.sub(/#initialize/, '.new')].first
|
|
161
162
|
end
|
|
162
163
|
(ovr.tags.map(&:tag_name) + ovr.delete).uniq.each do |tag|
|
|
164
|
+
# @sg-ignore Wrong argument type for
|
|
165
|
+
# YARD::Docstring#delete_tags: name expected String,
|
|
166
|
+
# received String, Symbol - delete_tags is ok with a
|
|
167
|
+
# _ToS, but we should fix anyway
|
|
163
168
|
pin.docstring.delete_tags tag
|
|
169
|
+
# @sg-ignore Wrong argument type for
|
|
170
|
+
# YARD::Docstring#delete_tags: name expected String,
|
|
171
|
+
# received String, Symbol - delete_tags is ok with a
|
|
172
|
+
# _ToS, but we should fix anyway
|
|
164
173
|
new_pin.docstring.delete_tags tag if new_pin
|
|
165
174
|
end
|
|
166
175
|
ovr.tags.each do |tag|
|
|
167
176
|
pin.docstring.add_tag(tag)
|
|
168
177
|
redefine_return_type pin, tag
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
178
|
+
pin.reset_generated!
|
|
179
|
+
|
|
180
|
+
next unless new_pin
|
|
181
|
+
|
|
182
|
+
new_pin.docstring.add_tag(tag)
|
|
183
|
+
redefine_return_type new_pin, tag
|
|
184
|
+
new_pin.reset_generated!
|
|
173
185
|
end
|
|
174
186
|
end
|
|
175
187
|
end
|
|
@@ -186,7 +198,6 @@ module Solargraph
|
|
|
186
198
|
pin.signatures.each do |sig|
|
|
187
199
|
sig.instance_variable_set(:@return_type, ComplexType.try_parse(tag.type))
|
|
188
200
|
end
|
|
189
|
-
pin.reset_generated!
|
|
190
201
|
end
|
|
191
202
|
end
|
|
192
203
|
end
|
|
@@ -6,6 +6,9 @@ module Solargraph
|
|
|
6
6
|
|
|
7
7
|
# Get the YARD CodeObject at the specified path.
|
|
8
8
|
#
|
|
9
|
+
# @sg-ignore Declared return type generic<T>, nil does not match
|
|
10
|
+
# inferred type ::YARD::CodeObjects::Base, nil for
|
|
11
|
+
# Solargraph::ApiMap::SourceToYard#code_object_at
|
|
9
12
|
# @generic T
|
|
10
13
|
# @param path [String]
|
|
11
14
|
# @param klass [Class<generic<T>>]
|
|
@@ -34,13 +37,17 @@ module Solargraph
|
|
|
34
37
|
if pin.type == :class
|
|
35
38
|
# @param obj [YARD::CodeObjects::RootObject]
|
|
36
39
|
code_object_map[pin.path] ||= YARD::CodeObjects::ClassObject.new(root_code_object, pin.path) { |obj|
|
|
40
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
37
41
|
next if pin.location.nil? || pin.location.filename.nil?
|
|
42
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
38
43
|
obj.add_file(pin.location.filename, pin.location.range.start.line, !pin.comments.empty?)
|
|
39
44
|
}
|
|
40
45
|
else
|
|
41
46
|
# @param obj [YARD::CodeObjects::RootObject]
|
|
42
47
|
code_object_map[pin.path] ||= YARD::CodeObjects::ModuleObject.new(root_code_object, pin.path) { |obj|
|
|
48
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
43
49
|
next if pin.location.nil? || pin.location.filename.nil?
|
|
50
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
44
51
|
obj.add_file(pin.location.filename, pin.location.range.start.line, !pin.comments.empty?)
|
|
45
52
|
}
|
|
46
53
|
end
|
|
@@ -57,7 +64,6 @@ module Solargraph
|
|
|
57
64
|
code_object = code_object_map[ref.type.to_s]
|
|
58
65
|
next unless code_object
|
|
59
66
|
extend_object.class_mixins.push code_object
|
|
60
|
-
# @todo add spec showing why this next line is necessary
|
|
61
67
|
extend_object.instance_mixins.push code_object
|
|
62
68
|
end
|
|
63
69
|
end
|
|
@@ -67,14 +73,20 @@ module Solargraph
|
|
|
67
73
|
next
|
|
68
74
|
end
|
|
69
75
|
|
|
76
|
+
# @sg-ignore Need to add nil check here
|
|
70
77
|
# @param obj [YARD::CodeObjects::RootObject]
|
|
71
78
|
code_object_map[pin.path] ||= YARD::CodeObjects::MethodObject.new(code_object_at(pin.namespace, YARD::CodeObjects::NamespaceObject), pin.name, pin.scope) { |obj|
|
|
79
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
72
80
|
next if pin.location.nil? || pin.location.filename.nil?
|
|
81
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
73
82
|
obj.add_file pin.location.filename, pin.location.range.start.line
|
|
74
83
|
}
|
|
75
84
|
method_object = code_object_at(pin.path, YARD::CodeObjects::MethodObject)
|
|
85
|
+
# @sg-ignore Need to add nil check here
|
|
76
86
|
method_object.docstring = pin.docstring
|
|
87
|
+
# @sg-ignore Need to add nil check here
|
|
77
88
|
method_object.visibility = pin.visibility || :public
|
|
89
|
+
# @sg-ignore Need to add nil check here
|
|
78
90
|
method_object.parameters = pin.parameters.map do |p|
|
|
79
91
|
[p.full_name, p.asgn_code]
|
|
80
92
|
end
|
|
@@ -34,6 +34,7 @@ module Solargraph
|
|
|
34
34
|
@fqns_pins_map = nil
|
|
35
35
|
return catalog(pinsets) if changed == 0
|
|
36
36
|
|
|
37
|
+
# @sg-ignore Need to add nil check here
|
|
37
38
|
pinsets[changed..].each_with_index do |pins, idx|
|
|
38
39
|
@pinsets[changed + idx] = pins
|
|
39
40
|
@indexes[changed + idx] = if pins.empty?
|
|
@@ -60,7 +61,7 @@ module Solargraph
|
|
|
60
61
|
# @return [Enumerable<Solargraph::Pin::Namespace, Solargraph::Pin::Constant>]
|
|
61
62
|
def get_constants fqns, visibility = [:public]
|
|
62
63
|
namespace_children(fqns).select { |pin|
|
|
63
|
-
# @sg-ignore flow
|
|
64
|
+
# @sg-ignore flow sensitive typing not smart enough to handle this case
|
|
64
65
|
!pin.name.empty? && (pin.is_a?(Pin::Namespace) || pin.is_a?(Pin::Constant)) && visibility.include?(pin.visibility)
|
|
65
66
|
}
|
|
66
67
|
end
|
|
@@ -71,7 +72,6 @@ module Solargraph
|
|
|
71
72
|
# @return [Enumerable<Solargraph::Pin::Method>]
|
|
72
73
|
def get_methods fqns, scope: :instance, visibility: [:public]
|
|
73
74
|
all_pins = namespace_children(fqns).select do |pin|
|
|
74
|
-
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
75
75
|
pin.is_a?(Pin::Method) && pin.scope == scope && visibility.include?(pin.visibility)
|
|
76
76
|
end
|
|
77
77
|
GemPins.combine_method_pins_by_path(all_pins)
|
|
@@ -80,8 +80,8 @@ module Solargraph
|
|
|
80
80
|
BOOLEAN_SUPERCLASS_PIN = Pin::Reference::Superclass.new(name: 'Boolean', closure: Pin::ROOT_PIN, source: :solargraph)
|
|
81
81
|
OBJECT_SUPERCLASS_PIN = Pin::Reference::Superclass.new(name: 'Object', closure: Pin::ROOT_PIN, source: :solargraph)
|
|
82
82
|
|
|
83
|
-
# @param fqns [String]
|
|
84
|
-
# @return [Pin::Reference::Superclass]
|
|
83
|
+
# @param fqns [String, nil]
|
|
84
|
+
# @return [Pin::Reference::Superclass, nil]
|
|
85
85
|
def get_superclass fqns
|
|
86
86
|
return nil if fqns.nil? || fqns.empty?
|
|
87
87
|
return BOOLEAN_SUPERCLASS_PIN if %w[TrueClass FalseClass].include?(fqns)
|
|
@@ -126,7 +126,7 @@ module Solargraph
|
|
|
126
126
|
index.path_pin_hash[path]
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
-
# @param fqns [String]
|
|
129
|
+
# @param fqns [String, nil]
|
|
130
130
|
# @param scope [Symbol] :class or :instance
|
|
131
131
|
# @return [Enumerable<Solargraph::Pin::Base>]
|
|
132
132
|
def get_instance_variables(fqns, scope = :instance)
|
|
@@ -199,7 +199,7 @@ module Solargraph
|
|
|
199
199
|
index.pins_by_class klass
|
|
200
200
|
end
|
|
201
201
|
|
|
202
|
-
# @param fqns [String]
|
|
202
|
+
# @param fqns [String, nil]
|
|
203
203
|
# @return [Array<Solargraph::Pin::Namespace>]
|
|
204
204
|
def fqns_pins fqns
|
|
205
205
|
return [] if fqns.nil?
|
|
@@ -244,8 +244,11 @@ module Solargraph
|
|
|
244
244
|
next if refs.nil?
|
|
245
245
|
# @param ref [String]
|
|
246
246
|
refs.map(&:type).map(&:to_s).each do |ref|
|
|
247
|
+
# @sg-ignore flow sensitive typing should be able to handle redefinition
|
|
247
248
|
next if ref.nil? || ref.empty? || visited.include?(ref)
|
|
249
|
+
# @sg-ignore flow sensitive typing should be able to handle redefinition
|
|
248
250
|
ancestors << ref
|
|
251
|
+
# @sg-ignore flow sensitive typing should be able to handle redefinition
|
|
249
252
|
queue << ref
|
|
250
253
|
end
|
|
251
254
|
end
|
|
@@ -275,7 +278,7 @@ module Solargraph
|
|
|
275
278
|
|
|
276
279
|
# @param pinsets [Array<Array<Pin::Base>>]
|
|
277
280
|
#
|
|
278
|
-
# @return [
|
|
281
|
+
# @return [true]
|
|
279
282
|
def catalog pinsets
|
|
280
283
|
@pinsets = pinsets
|
|
281
284
|
# @type [Array<Index>]
|
|
@@ -308,7 +311,7 @@ module Solargraph
|
|
|
308
311
|
index.pins_by_class(Pin::Symbol)
|
|
309
312
|
end
|
|
310
313
|
|
|
311
|
-
# @return [Hash{String => Array<
|
|
314
|
+
# @return [Hash{String => Array<Pin::Reference::Superclass>}]
|
|
312
315
|
def superclass_references
|
|
313
316
|
index.superclass_references
|
|
314
317
|
end
|