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
|
@@ -7,6 +7,7 @@ module Solargraph
|
|
|
7
7
|
class SendNode < Parser::NodeProcessor::Base
|
|
8
8
|
include ParserGem::NodeMethods
|
|
9
9
|
|
|
10
|
+
# @sg-ignore @override is adding, not overriding
|
|
10
11
|
def process
|
|
11
12
|
# @sg-ignore Variable type could not be inferred for method_name
|
|
12
13
|
# @type [Symbol]
|
|
@@ -53,6 +54,7 @@ module Solargraph
|
|
|
53
54
|
# @return [void]
|
|
54
55
|
def process_visibility
|
|
55
56
|
if (node.children.length > 2)
|
|
57
|
+
# @sg-ignore Need to add nil check here
|
|
56
58
|
node.children[2..-1].each do |child|
|
|
57
59
|
# @sg-ignore Variable type could not be inferred for method_name
|
|
58
60
|
# @type [Symbol]
|
|
@@ -82,6 +84,7 @@ module Solargraph
|
|
|
82
84
|
|
|
83
85
|
# @return [void]
|
|
84
86
|
def process_attribute
|
|
87
|
+
# @sg-ignore Need to add nil check here
|
|
85
88
|
node.children[2..-1].each do |a|
|
|
86
89
|
loc = get_node_location(node)
|
|
87
90
|
clos = region.closure
|
|
@@ -122,6 +125,7 @@ module Solargraph
|
|
|
122
125
|
def process_include
|
|
123
126
|
if node.children[2].is_a?(AST::Node) && node.children[2].type == :const
|
|
124
127
|
cp = region.closure
|
|
128
|
+
# @sg-ignore Need to add nil check here
|
|
125
129
|
node.children[2..-1].each do |i|
|
|
126
130
|
type = region.scope == :class ? Pin::Reference::Extend : Pin::Reference::Include
|
|
127
131
|
pins.push type.new(
|
|
@@ -138,6 +142,7 @@ module Solargraph
|
|
|
138
142
|
def process_prepend
|
|
139
143
|
if node.children[2].is_a?(AST::Node) && node.children[2].type == :const
|
|
140
144
|
cp = region.closure
|
|
145
|
+
# @sg-ignore Need to add nil check here
|
|
141
146
|
node.children[2..-1].each do |i|
|
|
142
147
|
pins.push Pin::Reference::Prepend.new(
|
|
143
148
|
location: get_node_location(i),
|
|
@@ -151,6 +156,7 @@ module Solargraph
|
|
|
151
156
|
|
|
152
157
|
# @return [void]
|
|
153
158
|
def process_extend
|
|
159
|
+
# @sg-ignore Need to add nil check here
|
|
154
160
|
node.children[2..-1].each do |i|
|
|
155
161
|
loc = get_node_location(node)
|
|
156
162
|
if i.type == :self
|
|
@@ -193,6 +199,7 @@ module Solargraph
|
|
|
193
199
|
# @todo Smelly instance variable access
|
|
194
200
|
region.instance_variable_set(:@visibility, :module_function)
|
|
195
201
|
elsif node.children[2].type == :sym || node.children[2].type == :str
|
|
202
|
+
# @sg-ignore Need to add nil check here
|
|
196
203
|
node.children[2..-1].each do |x|
|
|
197
204
|
cn = x.children[0].to_s
|
|
198
205
|
# @type [Pin::Method, nil]
|
|
@@ -221,23 +228,21 @@ module Solargraph
|
|
|
221
228
|
node: ref.node,
|
|
222
229
|
source: :parser)
|
|
223
230
|
pins.push mm, cm
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
231
|
+
ivars.select{|pin| pin.is_a?(Pin::InstanceVariable) && pin.closure.path == ref.path}.each do |ivar|
|
|
232
|
+
ivars.delete ivar
|
|
233
|
+
ivars.push Solargraph::Pin::InstanceVariable.new(
|
|
227
234
|
location: ivar.location,
|
|
228
235
|
closure: cm,
|
|
229
236
|
name: ivar.name,
|
|
230
237
|
comments: ivar.comments,
|
|
231
|
-
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
232
238
|
assignment: ivar.assignment,
|
|
233
239
|
source: :parser
|
|
234
240
|
)
|
|
235
|
-
|
|
241
|
+
ivars.push Solargraph::Pin::InstanceVariable.new(
|
|
236
242
|
location: ivar.location,
|
|
237
243
|
closure: mm,
|
|
238
244
|
name: ivar.name,
|
|
239
245
|
comments: ivar.comments,
|
|
240
|
-
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
241
246
|
assignment: ivar.assignment,
|
|
242
247
|
source: :parser
|
|
243
248
|
)
|
|
@@ -245,7 +250,7 @@ module Solargraph
|
|
|
245
250
|
end
|
|
246
251
|
end
|
|
247
252
|
elsif node.children[2].type == :def
|
|
248
|
-
NodeProcessor.process node.children[2], region.update(visibility: :module_function), pins, locals
|
|
253
|
+
NodeProcessor.process node.children[2], region.update(visibility: :module_function), pins, locals, ivars
|
|
249
254
|
end
|
|
250
255
|
end
|
|
251
256
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
module NodeProcessors
|
|
7
|
+
class WhenNode < Parser::NodeProcessor::Base
|
|
8
|
+
include ParserGem::NodeMethods
|
|
9
|
+
|
|
10
|
+
def process
|
|
11
|
+
pins.push Solargraph::Pin::CompoundStatement.new(
|
|
12
|
+
location: get_node_location(node),
|
|
13
|
+
closure: region.closure,
|
|
14
|
+
node: node,
|
|
15
|
+
source: :parser,
|
|
16
|
+
)
|
|
17
|
+
process_children
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -8,7 +8,11 @@ module Solargraph
|
|
|
8
8
|
include ParserGem::NodeMethods
|
|
9
9
|
|
|
10
10
|
def process
|
|
11
|
-
|
|
11
|
+
FlowSensitiveTyping.new(locals,
|
|
12
|
+
ivars,
|
|
13
|
+
enclosing_breakable_pin,
|
|
14
|
+
enclosing_compound_statement_pin).process_while(node)
|
|
15
|
+
|
|
12
16
|
# Note - this should not be considered a block, as the
|
|
13
17
|
# while statement doesn't create a closure - e.g.,
|
|
14
18
|
# variables created inside can be seen from outside as
|
|
@@ -27,8 +27,10 @@ module Solargraph
|
|
|
27
27
|
autoload :SymNode, 'solargraph/parser/parser_gem/node_processors/sym_node'
|
|
28
28
|
autoload :ResbodyNode, 'solargraph/parser/parser_gem/node_processors/resbody_node'
|
|
29
29
|
autoload :UntilNode, 'solargraph/parser/parser_gem/node_processors/until_node'
|
|
30
|
+
autoload :WhenNode, 'solargraph/parser/parser_gem/node_processors/when_node'
|
|
30
31
|
autoload :WhileNode, 'solargraph/parser/parser_gem/node_processors/while_node'
|
|
31
32
|
autoload :AndNode, 'solargraph/parser/parser_gem/node_processors/and_node'
|
|
33
|
+
autoload :OrNode, 'solargraph/parser/parser_gem/node_processors/or_node'
|
|
32
34
|
end
|
|
33
35
|
end
|
|
34
36
|
|
|
@@ -63,8 +65,10 @@ module Solargraph
|
|
|
63
65
|
register :op_asgn, ParserGem::NodeProcessors::OpasgnNode
|
|
64
66
|
register :sym, ParserGem::NodeProcessors::SymNode
|
|
65
67
|
register :until, ParserGem::NodeProcessors::UntilNode
|
|
68
|
+
register :when, ParserGem::NodeProcessors::WhenNode
|
|
66
69
|
register :while, ParserGem::NodeProcessors::WhileNode
|
|
67
70
|
register :and, ParserGem::NodeProcessors::AndNode
|
|
71
|
+
register :or, ParserGem::NodeProcessors::OrNode
|
|
68
72
|
end
|
|
69
73
|
end
|
|
70
74
|
end
|
|
@@ -22,7 +22,6 @@ module Solargraph
|
|
|
22
22
|
attr_reader :lvars
|
|
23
23
|
|
|
24
24
|
# @param source [Source]
|
|
25
|
-
# @param namespace [String]
|
|
26
25
|
# @param closure [Pin::Closure, nil]
|
|
27
26
|
# @param scope [Symbol, nil]
|
|
28
27
|
# @param visibility [Symbol]
|
|
@@ -30,18 +29,25 @@ module Solargraph
|
|
|
30
29
|
def initialize source: Solargraph::Source.load_string(''), closure: nil,
|
|
31
30
|
scope: nil, visibility: :public, lvars: []
|
|
32
31
|
@source = source
|
|
33
|
-
# @closure = closure
|
|
34
32
|
@closure = closure || Pin::Namespace.new(name: '', location: source.location, source: :parser)
|
|
35
33
|
@scope = scope
|
|
36
34
|
@visibility = visibility
|
|
37
35
|
@lvars = lvars
|
|
38
36
|
end
|
|
39
37
|
|
|
40
|
-
# @return [String]
|
|
38
|
+
# @return [String, nil]
|
|
41
39
|
def filename
|
|
42
40
|
source.filename
|
|
43
41
|
end
|
|
44
42
|
|
|
43
|
+
# @return [Pin::Namespace, nil]
|
|
44
|
+
def namespace_pin
|
|
45
|
+
ns = closure
|
|
46
|
+
# @sg-ignore flow sensitive typing needs to handle while
|
|
47
|
+
ns = ns.closure while ns && !ns.is_a?(Pin::Namespace)
|
|
48
|
+
ns
|
|
49
|
+
end
|
|
50
|
+
|
|
45
51
|
# Generate a new Region with the provided attribute changes.
|
|
46
52
|
#
|
|
47
53
|
# @param closure [Pin::Closure, nil]
|
data/lib/solargraph/pin/base.rb
CHANGED
|
@@ -41,7 +41,7 @@ module Solargraph
|
|
|
41
41
|
# @param type_location [Solargraph::Location, nil]
|
|
42
42
|
# @param closure [Solargraph::Pin::Closure, nil]
|
|
43
43
|
# @param name [String]
|
|
44
|
-
# @param comments [String]
|
|
44
|
+
# @param comments [String, nil]
|
|
45
45
|
# @param source [Symbol, nil]
|
|
46
46
|
# @param docstring [YARD::Docstring, nil]
|
|
47
47
|
# @param directives [::Array<YARD::Tags::Directive>, nil]
|
|
@@ -57,6 +57,9 @@ module Solargraph
|
|
|
57
57
|
@docstring = docstring
|
|
58
58
|
@directives = directives
|
|
59
59
|
@combine_priority = combine_priority
|
|
60
|
+
# @type [ComplexType, ComplexType::UniqueType, nil]
|
|
61
|
+
@binder = nil
|
|
62
|
+
|
|
60
63
|
|
|
61
64
|
assert_source_provided
|
|
62
65
|
assert_location_provided
|
|
@@ -72,7 +75,6 @@ module Solargraph
|
|
|
72
75
|
# @return [Pin::Closure, nil]
|
|
73
76
|
def closure
|
|
74
77
|
Solargraph.assert_or_log(:closure, "Closure not set on #{self.class} #{name.inspect} from #{source.inspect}") unless @closure
|
|
75
|
-
# @type [Pin::Closure, nil]
|
|
76
78
|
@closure
|
|
77
79
|
end
|
|
78
80
|
|
|
@@ -81,7 +83,6 @@ module Solargraph
|
|
|
81
83
|
#
|
|
82
84
|
# @return [self]
|
|
83
85
|
def combine_with(other, attrs={})
|
|
84
|
-
raise "tried to combine #{other.class} with #{self.class}" unless other.class == self.class
|
|
85
86
|
priority_choice = choose_priority(other)
|
|
86
87
|
return priority_choice unless priority_choice.nil?
|
|
87
88
|
|
|
@@ -92,7 +93,7 @@ module Solargraph
|
|
|
92
93
|
location: location,
|
|
93
94
|
type_location: type_location,
|
|
94
95
|
name: combined_name,
|
|
95
|
-
closure:
|
|
96
|
+
closure: combine_closure(other),
|
|
96
97
|
comments: choose_longer(other, :comments),
|
|
97
98
|
source: :combined,
|
|
98
99
|
docstring: choose(other, :docstring),
|
|
@@ -140,14 +141,22 @@ module Solargraph
|
|
|
140
141
|
end
|
|
141
142
|
|
|
142
143
|
# @param other [self]
|
|
144
|
+
#
|
|
143
145
|
# @return [::Array<YARD::Tags::Directive>, nil]
|
|
144
146
|
def combine_directives(other)
|
|
145
147
|
return self.directives if other.directives.empty?
|
|
146
148
|
return other.directives if directives.empty?
|
|
147
|
-
|
|
149
|
+
(directives + other.directives).uniq
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# @param other [self]
|
|
153
|
+
# @return [Pin::Closure, nil]
|
|
154
|
+
def combine_closure(other)
|
|
155
|
+
choose_pin_attr_with_same_name(other, :closure)
|
|
148
156
|
end
|
|
149
157
|
|
|
150
158
|
# @param other [self]
|
|
159
|
+
# @sg-ignore @type should override probed type
|
|
151
160
|
# @return [String]
|
|
152
161
|
def combine_name(other)
|
|
153
162
|
if needs_consistent_name? || other.needs_consistent_name?
|
|
@@ -170,6 +179,9 @@ module Solargraph
|
|
|
170
179
|
# Same with @directives, @macros, @maybe_directives, which
|
|
171
180
|
# regenerate docstring
|
|
172
181
|
@deprecated = nil
|
|
182
|
+
@context = nil
|
|
183
|
+
@binder = nil
|
|
184
|
+
@path = nil
|
|
173
185
|
reset_conversions
|
|
174
186
|
end
|
|
175
187
|
|
|
@@ -189,6 +201,10 @@ module Solargraph
|
|
|
189
201
|
other.return_type
|
|
190
202
|
elsif other.return_type.undefined?
|
|
191
203
|
return_type
|
|
204
|
+
elsif return_type.erased_version_of?(other.return_type)
|
|
205
|
+
other.return_type
|
|
206
|
+
elsif other.return_type.erased_version_of?(return_type)
|
|
207
|
+
return_type
|
|
192
208
|
elsif dodgy_return_type_source? && !other.dodgy_return_type_source?
|
|
193
209
|
other.return_type
|
|
194
210
|
elsif other.dodgy_return_type_source? && !dodgy_return_type_source?
|
|
@@ -203,9 +219,12 @@ module Solargraph
|
|
|
203
219
|
end
|
|
204
220
|
end
|
|
205
221
|
|
|
222
|
+
# @sg-ignore need boolish support for ? methods
|
|
206
223
|
def dodgy_return_type_source?
|
|
207
224
|
# uses a lot of 'Object' instead of 'self'
|
|
208
|
-
location&.filename&.include?('core_ext/object/')
|
|
225
|
+
location&.filename&.include?('core_ext/object/') ||
|
|
226
|
+
# ditto
|
|
227
|
+
location&.filename&.include?('stdlib/date/0/date.rbs')
|
|
209
228
|
end
|
|
210
229
|
|
|
211
230
|
# when choices are arbitrary, make sure the choice is consistent
|
|
@@ -213,11 +232,13 @@ module Solargraph
|
|
|
213
232
|
# @param other [Pin::Base]
|
|
214
233
|
# @param attr [::Symbol]
|
|
215
234
|
#
|
|
216
|
-
# @
|
|
235
|
+
# @sg-ignore
|
|
236
|
+
# @return [undefined, nil]
|
|
217
237
|
def choose(other, attr)
|
|
218
238
|
results = [self, other].map(&attr).compact
|
|
219
239
|
# true and false are different classes and can't be sorted
|
|
220
240
|
return true if results.any? { |r| r == true || r == false }
|
|
241
|
+
return results.first if results.any? { |r| r.is_a? AST::Node }
|
|
221
242
|
results.min
|
|
222
243
|
rescue
|
|
223
244
|
STDERR.puts("Problem handling #{attr} for \n#{self.inspect}\n and \n#{other.inspect}\n\n#{self.send(attr).inspect} vs #{other.send(attr).inspect}")
|
|
@@ -250,6 +271,7 @@ module Solargraph
|
|
|
250
271
|
end
|
|
251
272
|
end
|
|
252
273
|
|
|
274
|
+
# @sg-ignore need boolish support for ? methods
|
|
253
275
|
def rbs_location?
|
|
254
276
|
type_location&.rbs?
|
|
255
277
|
end
|
|
@@ -309,7 +331,11 @@ module Solargraph
|
|
|
309
331
|
# @sg-ignore
|
|
310
332
|
# @return [undefined]
|
|
311
333
|
def assert_same(other, attr)
|
|
312
|
-
|
|
334
|
+
if other.nil?
|
|
335
|
+
Solargraph.assert_or_log("combine_with_#{attr}_nil".to_sym,
|
|
336
|
+
"Other was passed in nil in assert_same on #{self}")
|
|
337
|
+
return send(attr)
|
|
338
|
+
end
|
|
313
339
|
val1 = send(attr)
|
|
314
340
|
val2 = other.send(attr)
|
|
315
341
|
return val1 if val1 == val2
|
|
@@ -358,8 +384,11 @@ module Solargraph
|
|
|
358
384
|
[
|
|
359
385
|
# maximize number of gates, as types in other combined pins may
|
|
360
386
|
# depend on those gates
|
|
387
|
+
|
|
388
|
+
# @sg-ignore Need better handling of #compact
|
|
361
389
|
closure.gates.length,
|
|
362
390
|
# use basename so that results don't vary system to system
|
|
391
|
+
# @sg-ignore Need better handling of #compact
|
|
363
392
|
File.basename(closure.best_location.to_s)
|
|
364
393
|
]
|
|
365
394
|
end
|
|
@@ -376,7 +405,7 @@ module Solargraph
|
|
|
376
405
|
end
|
|
377
406
|
|
|
378
407
|
# @param generics_to_resolve [Enumerable<String>]
|
|
379
|
-
# @param return_type_context [ComplexType, nil]
|
|
408
|
+
# @param return_type_context [ComplexType, ComplexType::UniqueType, nil]
|
|
380
409
|
# @param context [ComplexType]
|
|
381
410
|
# @param resolved_generic_values [Hash{String => ComplexType}]
|
|
382
411
|
# @return [self]
|
|
@@ -418,6 +447,7 @@ module Solargraph
|
|
|
418
447
|
# @return [String, nil]
|
|
419
448
|
def filename
|
|
420
449
|
return nil if location.nil?
|
|
450
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
421
451
|
location.filename
|
|
422
452
|
end
|
|
423
453
|
|
|
@@ -453,11 +483,16 @@ module Solargraph
|
|
|
453
483
|
# @return [Boolean]
|
|
454
484
|
def nearly? other
|
|
455
485
|
self.class == other.class &&
|
|
486
|
+
# @sg-ignore Translate to something flow sensitive typing understands
|
|
456
487
|
name == other.name &&
|
|
488
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
457
489
|
(closure == other.closure || (closure && closure.nearly?(other.closure))) &&
|
|
490
|
+
# @sg-ignore Translate to something flow sensitive typing understands
|
|
458
491
|
(comments == other.comments ||
|
|
492
|
+
# @sg-ignore Translate to something flow sensitive typing understands
|
|
459
493
|
(((maybe_directives? == false && other.maybe_directives? == false) || compare_directives(directives, other.directives)) &&
|
|
460
|
-
|
|
494
|
+
# @sg-ignore Translate to something flow sensitive typing understands
|
|
495
|
+
compare_docstring_tags(docstring, other.docstring))
|
|
461
496
|
)
|
|
462
497
|
end
|
|
463
498
|
|
|
@@ -484,6 +519,7 @@ module Solargraph
|
|
|
484
519
|
@docstring ||= Solargraph::Source.parse_docstring('').to_docstring
|
|
485
520
|
end
|
|
486
521
|
|
|
522
|
+
# @sg-ignore parse_comments will always set @directives
|
|
487
523
|
# @return [::Array<YARD::Tags::Directive>]
|
|
488
524
|
def directives
|
|
489
525
|
parse_comments unless @directives
|
|
@@ -520,7 +556,7 @@ module Solargraph
|
|
|
520
556
|
# provided ApiMap.
|
|
521
557
|
#
|
|
522
558
|
# @param api_map [ApiMap]
|
|
523
|
-
# @return [ComplexType]
|
|
559
|
+
# @return [ComplexType, ComplexType::UniqueType]
|
|
524
560
|
def typify api_map
|
|
525
561
|
return_type.qualify(api_map, *(closure&.gates || ['']))
|
|
526
562
|
end
|
|
@@ -528,16 +564,16 @@ module Solargraph
|
|
|
528
564
|
# Infer the pin's return type via static code analysis.
|
|
529
565
|
#
|
|
530
566
|
# @param api_map [ApiMap]
|
|
531
|
-
# @return [ComplexType]
|
|
567
|
+
# @return [ComplexType, ComplexType::UniqueType]
|
|
532
568
|
def probe api_map
|
|
533
569
|
typify api_map
|
|
534
570
|
end
|
|
535
571
|
|
|
536
572
|
# @deprecated Use #typify and/or #probe instead
|
|
537
573
|
# @param api_map [ApiMap]
|
|
538
|
-
# @return [ComplexType]
|
|
574
|
+
# @return [ComplexType, ComplexType::UniqueType]
|
|
539
575
|
def infer api_map
|
|
540
|
-
Solargraph
|
|
576
|
+
Solargraph.assert_or_log(:pin_infer, 'WARNING: Pin #infer methods are deprecated. Use #typify or #probe instead.')
|
|
541
577
|
type = typify(api_map)
|
|
542
578
|
return type unless type.undefined?
|
|
543
579
|
probe api_map
|
|
@@ -568,7 +604,7 @@ module Solargraph
|
|
|
568
604
|
# the return type and the #proxied? setting, the proxy should be a clone
|
|
569
605
|
# of the original.
|
|
570
606
|
#
|
|
571
|
-
# @param return_type [ComplexType]
|
|
607
|
+
# @param return_type [ComplexType, ComplexType::UniqueType, nil]
|
|
572
608
|
# @return [self]
|
|
573
609
|
def proxy return_type
|
|
574
610
|
result = dup
|
|
@@ -618,7 +654,7 @@ module Solargraph
|
|
|
618
654
|
|
|
619
655
|
# @return [String]
|
|
620
656
|
def inner_desc
|
|
621
|
-
closure_info = closure&.
|
|
657
|
+
closure_info = closure&.name.inspect
|
|
622
658
|
binder_info = binder&.desc
|
|
623
659
|
"name=#{name.inspect} return_type=#{type_desc}, context=#{context.rooted_tags}, closure=#{closure_info}, binder=#{binder_info}"
|
|
624
660
|
end
|
|
@@ -646,10 +682,6 @@ module Solargraph
|
|
|
646
682
|
end
|
|
647
683
|
end
|
|
648
684
|
|
|
649
|
-
# @return [void]
|
|
650
|
-
def reset_generated!
|
|
651
|
-
end
|
|
652
|
-
|
|
653
685
|
protected
|
|
654
686
|
|
|
655
687
|
# @return [Boolean]
|
|
@@ -658,7 +690,7 @@ module Solargraph
|
|
|
658
690
|
# @return [Boolean]
|
|
659
691
|
attr_writer :proxied
|
|
660
692
|
|
|
661
|
-
# @return [ComplexType]
|
|
693
|
+
# @return [ComplexType, ComplexType::UniqueType, nil]
|
|
662
694
|
attr_writer :return_type
|
|
663
695
|
|
|
664
696
|
attr_writer :docstring
|