solargraph 0.58.3 → 0.60.0
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 +12 -5
- data/.github/workflows/plugins.yml +54 -34
- data/.github/workflows/rspec.yml +18 -28
- data/.github/workflows/typecheck.yml +6 -3
- data/.rubocop.yml +39 -6
- data/.rubocop_todo.yml +53 -966
- data/CHANGELOG.md +35 -0
- data/Gemfile +6 -1
- data/README.md +3 -3
- data/Rakefile +26 -23
- data/bin/solargraph +2 -1
- data/lib/solargraph/api_map/cache.rb +3 -3
- data/lib/solargraph/api_map/constants.rb +12 -3
- data/lib/solargraph/api_map/index.rb +42 -20
- data/lib/solargraph/api_map/source_to_yard.rb +22 -9
- data/lib/solargraph/api_map/store.rb +61 -36
- data/lib/solargraph/api_map.rb +192 -78
- data/lib/solargraph/bench.rb +2 -3
- data/lib/solargraph/complex_type/conformance.rb +176 -0
- data/lib/solargraph/complex_type/type_methods.rb +31 -18
- data/lib/solargraph/complex_type/unique_type.rb +225 -63
- data/lib/solargraph/complex_type.rb +177 -59
- data/lib/solargraph/convention/active_support_concern.rb +111 -111
- data/lib/solargraph/convention/base.rb +50 -50
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +1 -1
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +7 -5
- data/lib/solargraph/convention/data_definition.rb +5 -2
- data/lib/solargraph/convention/gemfile.rb +1 -1
- data/lib/solargraph/convention/gemspec.rb +1 -1
- data/lib/solargraph/convention/rakefile.rb +1 -1
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +2 -1
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +4 -3
- data/lib/solargraph/convention/struct_definition.rb +8 -4
- data/lib/solargraph/convention.rb +2 -2
- data/lib/solargraph/converters/dd.rb +2 -0
- data/lib/solargraph/converters/dl.rb +2 -0
- data/lib/solargraph/converters/dt.rb +2 -0
- data/lib/solargraph/converters/misc.rb +2 -0
- data/lib/solargraph/diagnostics/require_not_found.rb +1 -0
- data/lib/solargraph/diagnostics/rubocop.rb +11 -10
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +5 -3
- data/lib/solargraph/diagnostics/type_check.rb +11 -10
- data/lib/solargraph/diagnostics/update_errors.rb +4 -8
- data/lib/solargraph/diagnostics.rb +55 -55
- data/lib/solargraph/doc_map.rb +39 -39
- data/lib/solargraph/environ.rb +52 -52
- data/lib/solargraph/equality.rb +4 -4
- data/lib/solargraph/gem_pins.rb +4 -15
- data/lib/solargraph/language_server/error_codes.rb +10 -10
- data/lib/solargraph/language_server/host/diagnoser.rb +1 -1
- data/lib/solargraph/language_server/host/dispatch.rb +3 -3
- data/lib/solargraph/language_server/host/message_worker.rb +4 -3
- data/lib/solargraph/language_server/host/sources.rb +2 -1
- data/lib/solargraph/language_server/host.rb +35 -28
- data/lib/solargraph/language_server/message/base.rb +1 -1
- data/lib/solargraph/language_server/message/client/register_capability.rb +1 -3
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +6 -8
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +12 -18
- data/lib/solargraph/language_server/message/extended/document.rb +1 -0
- data/lib/solargraph/language_server/message/extended/document_gems.rb +7 -7
- data/lib/solargraph/language_server/message/extended/download_core.rb +2 -1
- data/lib/solargraph/language_server/message/extended/environment.rb +25 -25
- data/lib/solargraph/language_server/message/extended/search.rb +1 -1
- data/lib/solargraph/language_server/message/initialize.rb +20 -14
- data/lib/solargraph/language_server/message/initialized.rb +28 -28
- data/lib/solargraph/language_server/message/text_document/completion.rb +10 -8
- data/lib/solargraph/language_server/message/text_document/definition.rb +41 -32
- data/lib/solargraph/language_server/message/text_document/document_highlight.rb +17 -10
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +29 -19
- data/lib/solargraph/language_server/message/text_document/formatting.rb +8 -6
- data/lib/solargraph/language_server/message/text_document/hover.rb +5 -5
- data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +13 -6
- data/lib/solargraph/language_server/message/text_document/references.rb +17 -10
- data/lib/solargraph/language_server/message/text_document/rename.rb +20 -13
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +3 -2
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +25 -17
- data/lib/solargraph/language_server/message/text_document.rb +28 -28
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +34 -28
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +38 -30
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +23 -17
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +27 -17
- data/lib/solargraph/language_server/message.rb +1 -1
- data/lib/solargraph/language_server/progress.rb +143 -143
- data/lib/solargraph/language_server/request.rb +4 -2
- data/lib/solargraph/language_server/transport/adapter.rb +68 -68
- data/lib/solargraph/language_server/transport/data_reader.rb +11 -13
- data/lib/solargraph/language_server/uri_helpers.rb +2 -2
- data/lib/solargraph/language_server.rb +20 -20
- data/lib/solargraph/library.rb +57 -38
- data/lib/solargraph/location.rb +17 -14
- data/lib/solargraph/logging.rb +22 -4
- data/lib/solargraph/page.rb +1 -1
- data/lib/solargraph/parser/comment_ripper.rb +19 -4
- data/lib/solargraph/parser/flow_sensitive_typing.rb +324 -108
- data/lib/solargraph/parser/node_processor/base.rb +34 -4
- data/lib/solargraph/parser/node_processor.rb +8 -7
- data/lib/solargraph/parser/parser_gem/class_methods.rb +30 -14
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +51 -25
- data/lib/solargraph/parser/parser_gem/node_methods.rb +222 -72
- data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +4 -4
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +13 -11
- 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 -12
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +36 -36
- data/lib/solargraph/parser/parser_gem/node_processors/cvasgn_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +10 -3
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +9 -8
- data/lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +36 -6
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +5 -3
- 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/namespace_node.rb +64 -40
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +3 -3
- 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 +4 -5
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +124 -113
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +20 -20
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/when_node.rb +23 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +6 -2
- data/lib/solargraph/parser/parser_gem/node_processors.rb +4 -0
- data/lib/solargraph/parser/parser_gem.rb +2 -0
- data/lib/solargraph/parser/region.rb +9 -3
- data/lib/solargraph/parser/snippet.rb +3 -1
- data/lib/solargraph/parser.rb +2 -0
- data/lib/solargraph/pin/base.rb +156 -84
- data/lib/solargraph/pin/base_variable.rb +273 -24
- data/lib/solargraph/pin/block.rb +29 -6
- data/lib/solargraph/pin/breakable.rb +7 -1
- data/lib/solargraph/pin/callable.rb +67 -23
- data/lib/solargraph/pin/closure.rb +7 -10
- data/lib/solargraph/pin/common.rb +36 -6
- data/lib/solargraph/pin/compound_statement.rb +55 -0
- data/lib/solargraph/pin/constant.rb +3 -5
- data/lib/solargraph/pin/conversions.rb +10 -4
- data/lib/solargraph/pin/delegated_method.rb +19 -8
- data/lib/solargraph/pin/documenting.rb +4 -2
- data/lib/solargraph/pin/instance_variable.rb +5 -1
- data/lib/solargraph/pin/keyword.rb +0 -4
- data/lib/solargraph/pin/local_variable.rb +15 -59
- data/lib/solargraph/pin/method.rb +205 -111
- data/lib/solargraph/pin/method_alias.rb +8 -0
- data/lib/solargraph/pin/namespace.rb +19 -12
- data/lib/solargraph/pin/parameter.rb +102 -36
- data/lib/solargraph/pin/proxy_type.rb +4 -1
- data/lib/solargraph/pin/reference/override.rb +1 -1
- data/lib/solargraph/pin/reference/require.rb +14 -14
- data/lib/solargraph/pin/reference/superclass.rb +2 -0
- data/lib/solargraph/pin/reference/type_alias.rb +16 -0
- data/lib/solargraph/pin/reference.rb +20 -0
- data/lib/solargraph/pin/search.rb +8 -7
- data/lib/solargraph/pin/signature.rb +15 -12
- data/lib/solargraph/pin/singleton.rb +11 -11
- data/lib/solargraph/pin/symbol.rb +2 -1
- data/lib/solargraph/pin/until.rb +2 -4
- data/lib/solargraph/pin/while.rb +2 -4
- data/lib/solargraph/pin.rb +2 -0
- data/lib/solargraph/pin_cache.rb +22 -19
- data/lib/solargraph/position.rb +17 -10
- data/lib/solargraph/range.rb +16 -15
- data/lib/solargraph/rbs_map/conversions.rb +278 -191
- data/lib/solargraph/rbs_map/core_fills.rb +18 -11
- data/lib/solargraph/rbs_map/core_map.rb +24 -17
- data/lib/solargraph/rbs_map/stdlib_map.rb +33 -5
- data/lib/solargraph/rbs_map.rb +76 -32
- data/lib/solargraph/rbs_translator.rb +206 -0
- data/lib/solargraph/server_methods.rb +1 -1
- data/lib/solargraph/shell.rb +330 -71
- data/lib/solargraph/source/chain/array.rb +3 -12
- data/lib/solargraph/source/chain/block_symbol.rb +13 -13
- data/lib/solargraph/source/chain/block_variable.rb +13 -13
- data/lib/solargraph/source/chain/call.rb +91 -119
- data/lib/solargraph/source/chain/class_variable.rb +1 -1
- data/lib/solargraph/source/chain/constant.rb +5 -1
- data/lib/solargraph/source/chain/global_variable.rb +1 -1
- data/lib/solargraph/source/chain/hash.rb +8 -5
- data/lib/solargraph/source/chain/head.rb +19 -19
- data/lib/solargraph/source/chain/if.rb +12 -10
- data/lib/solargraph/source/chain/instance_variable.rb +24 -1
- data/lib/solargraph/source/chain/link.rb +12 -22
- data/lib/solargraph/source/chain/literal.rb +22 -15
- data/lib/solargraph/source/chain/or.rb +10 -4
- data/lib/solargraph/source/chain/q_call.rb +2 -0
- data/lib/solargraph/source/chain/variable.rb +3 -1
- data/lib/solargraph/source/chain/z_super.rb +1 -3
- data/lib/solargraph/source/chain.rb +51 -38
- data/lib/solargraph/source/change.rb +12 -5
- data/lib/solargraph/source/cursor.rb +33 -18
- data/lib/solargraph/source/encoding_fixes.rb +6 -7
- data/lib/solargraph/source/source_chainer.rb +56 -32
- data/lib/solargraph/source/updater.rb +5 -1
- data/lib/solargraph/source.rb +59 -35
- data/lib/solargraph/source_map/clip.rb +54 -30
- data/lib/solargraph/source_map/data.rb +4 -1
- data/lib/solargraph/source_map/mapper.rb +28 -131
- data/lib/solargraph/source_map.rb +35 -9
- data/lib/solargraph/type_checker/problem.rb +3 -1
- data/lib/solargraph/type_checker/rules.rb +81 -8
- data/lib/solargraph/type_checker.rb +196 -122
- data/lib/solargraph/version.rb +19 -1
- data/lib/solargraph/workspace/config.rb +14 -11
- data/lib/solargraph/workspace/gemspecs.rb +367 -0
- data/lib/solargraph/workspace/require_paths.rb +1 -0
- data/lib/solargraph/workspace.rb +50 -28
- data/lib/solargraph/yard_map/cache.rb +25 -25
- data/lib/solargraph/yard_map/directives/attribute_directive.rb +65 -0
- data/lib/solargraph/yard_map/directives/domain_directive.rb +30 -0
- data/lib/solargraph/yard_map/directives/method_directive.rb +51 -0
- data/lib/solargraph/yard_map/directives/override_directive.rb +30 -0
- data/lib/solargraph/yard_map/directives/parse_directive.rb +53 -0
- data/lib/solargraph/yard_map/directives/visibility_directive.rb +70 -0
- data/lib/solargraph/yard_map/directives.rb +35 -0
- data/lib/solargraph/yard_map/helpers.rb +8 -3
- data/lib/solargraph/yard_map/macro.rb +113 -0
- data/lib/solargraph/yard_map/mapper/to_constant.rb +28 -28
- data/lib/solargraph/yard_map/mapper/to_method.rb +13 -7
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +2 -1
- data/lib/solargraph/yard_map/mapper.rb +31 -8
- data/lib/solargraph/yard_map.rb +19 -18
- data/lib/solargraph/yard_tags.rb +2 -2
- data/lib/solargraph/yardoc.rb +7 -4
- data/lib/solargraph.rb +34 -10
- data/rbs/fills/rubygems/0/dependency.rbs +193 -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 +38 -35
- metadata +64 -42
- 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
- data/rbs/fills/tuple/tuple.rbs +0 -149
|
@@ -28,18 +28,14 @@ module Solargraph
|
|
|
28
28
|
# @param arguments [::Array<Chain>]
|
|
29
29
|
# @param block [Chain, nil]
|
|
30
30
|
def initialize word, location = nil, arguments = [], block = nil
|
|
31
|
-
|
|
31
|
+
super(word)
|
|
32
|
+
|
|
32
33
|
@location = location
|
|
33
34
|
@arguments = arguments
|
|
34
35
|
@block = block
|
|
35
36
|
fix_block_pass
|
|
36
37
|
end
|
|
37
38
|
|
|
38
|
-
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
|
39
|
-
protected def equality_fields
|
|
40
|
-
super + [arguments, block]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
39
|
def with_block?
|
|
44
40
|
!!@block
|
|
45
41
|
end
|
|
@@ -50,24 +46,32 @@ module Solargraph
|
|
|
50
46
|
def resolve api_map, name_pin, locals
|
|
51
47
|
return super_pins(api_map, name_pin) if word == 'super'
|
|
52
48
|
return yield_pins(api_map, name_pin) if word == 'yield'
|
|
53
|
-
found = if head?
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
found = api_map.var_at_location(locals, word, name_pin, location) if head?
|
|
50
|
+
|
|
51
|
+
return inferred_pins([found], api_map, name_pin, locals) unless found.nil?
|
|
52
|
+
binder = name_pin.binder
|
|
53
|
+
# this is a q_call - i.e., foo&.bar - assume result of call
|
|
54
|
+
# will be nil or result as if binder were not nil -
|
|
55
|
+
# chain.rb#maybe_nil will add the nil type later, we just
|
|
56
|
+
# need to worry about the not-nil case
|
|
57
|
+
|
|
58
|
+
# @sg-ignore Need to handle duck-typed method calls on union types
|
|
59
|
+
binder = binder.without_nil if nullable?
|
|
60
|
+
# @sg-ignore Need to handle duck-typed method calls on union types
|
|
61
|
+
pin_groups = binder.each_unique_type.map do |context|
|
|
60
62
|
ns_tag = context.namespace == '' ? '' : context.namespace_type.tag
|
|
61
63
|
stack = api_map.get_method_stack(ns_tag, word, scope: context.scope)
|
|
62
64
|
[stack.first].compact
|
|
63
65
|
end
|
|
66
|
+
pin_groups = [] if !api_map.loose_unions && pin_groups.any?(&:empty?)
|
|
67
|
+
pins = pin_groups.flatten.uniq(&:path)
|
|
64
68
|
return [] if pins.empty?
|
|
65
69
|
inferred_pins(pins, api_map, name_pin, locals)
|
|
66
70
|
end
|
|
67
71
|
|
|
68
72
|
private
|
|
69
73
|
|
|
70
|
-
# @param pins [::Enumerable<Pin::
|
|
74
|
+
# @param pins [::Enumerable<Pin::Base>]
|
|
71
75
|
# @param api_map [ApiMap]
|
|
72
76
|
# @param name_pin [Pin::Base]
|
|
73
77
|
# @param locals [::Array<Solargraph::Pin::LocalVariable, Solargraph::Pin::Parameter>]
|
|
@@ -84,9 +88,13 @@ module Solargraph
|
|
|
84
88
|
# reject it regardless
|
|
85
89
|
|
|
86
90
|
with_block, without_block = overloads.partition(&:block?)
|
|
91
|
+
# @sg-ignore flow sensitive typing should handle is_a? and next
|
|
92
|
+
# @type Array<Pin::Signature>
|
|
87
93
|
sorted_overloads = with_block + without_block
|
|
88
94
|
# @type [Pin::Signature, nil]
|
|
89
95
|
new_signature_pin = nil
|
|
96
|
+
# @sg-ignore flow sensitive typing should handle is_a? and next
|
|
97
|
+
# @param ol [Pin::Signature]
|
|
90
98
|
sorted_overloads.each do |ol|
|
|
91
99
|
next unless ol.arity_matches?(arguments, with_block?)
|
|
92
100
|
match = true
|
|
@@ -99,6 +107,7 @@ module Solargraph
|
|
|
99
107
|
break
|
|
100
108
|
end
|
|
101
109
|
arg_name_pin = Pin::ProxyType.anonymous(name_pin.context,
|
|
110
|
+
closure: name_pin.closure,
|
|
102
111
|
gates: name_pin.gates,
|
|
103
112
|
source: :chain)
|
|
104
113
|
atype = atypes[idx] ||= arg.infer(api_map, arg_name_pin, locals)
|
|
@@ -110,130 +119,78 @@ module Solargraph
|
|
|
110
119
|
if match
|
|
111
120
|
if ol.block && with_block?
|
|
112
121
|
block_atypes = ol.block.parameters.map(&:return_type)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
# @todo Need to add nil check here
|
|
123
|
+
blocktype = if block.links.map(&:class) == [BlockSymbol]
|
|
124
|
+
# like the bar in foo(&:bar)
|
|
125
|
+
block_symbol_call_type(api_map, name_pin.context, block_atypes, locals)
|
|
126
|
+
else
|
|
127
|
+
block_call_type(api_map, name_pin, locals)
|
|
128
|
+
end
|
|
119
129
|
end
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if
|
|
124
|
-
|
|
125
|
-
# method somewhere that marked itself as returning
|
|
126
|
-
# self. Given we didn't invoke this on an object,
|
|
127
|
-
# this must be a method in this same class - so we
|
|
128
|
-
# use our own self type
|
|
129
|
-
self_type = name_pin.context
|
|
130
|
+
new_signature_pin = ol.resolve_generics_from_context_until_complete(ol.generics, atypes, nil, nil,
|
|
131
|
+
blocktype)
|
|
132
|
+
# @todo It shouldn't be necessary to choose either generics or macros
|
|
133
|
+
new_return_type = if new_signature_pin.return_type.defined?
|
|
134
|
+
new_signature_pin.return_type
|
|
130
135
|
else
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
# declaration - we can't just use the type of the
|
|
134
|
-
# method pin, as this might be a subclass of the
|
|
135
|
-
# place where the method is defined
|
|
136
|
-
self_type = name_pin.binder
|
|
136
|
+
named_types = p.parameter_names.zip(arguments.map { |arg| ComplexType.try_parse(simple_convert(arg.node).to_s) }).to_h
|
|
137
|
+
p.typify(api_map).expand(named_types)
|
|
137
138
|
end
|
|
139
|
+
self_type = if head?
|
|
140
|
+
# If we're at the head of the chain, we called a
|
|
141
|
+
# method somewhere that marked itself as returning
|
|
142
|
+
# self. Given we didn't invoke this on an object,
|
|
143
|
+
# this must be a method in this same class - so we
|
|
144
|
+
# use our own self type
|
|
145
|
+
name_pin.context
|
|
146
|
+
else
|
|
147
|
+
# if we're past the head in the chain, whatever the
|
|
148
|
+
# type of the lhs side is what 'self' will be in its
|
|
149
|
+
# declaration - we can't just use the type of the
|
|
150
|
+
# method pin, as this might be a subclass of the
|
|
151
|
+
# place where the method is defined
|
|
152
|
+
name_pin.binder
|
|
153
|
+
end
|
|
138
154
|
# This same logic applies to the YARD work done by
|
|
139
155
|
# 'with_params()'.
|
|
140
156
|
#
|
|
141
157
|
# qualify(), however, happens in the namespace where
|
|
142
158
|
# the docs were written - from the method pin.
|
|
143
|
-
|
|
159
|
+
# @todo Need to add nil check here
|
|
160
|
+
if new_return_type.defined?
|
|
161
|
+
type = with_params(new_return_type.self_to_type(self_type), self_type).qualify(api_map, *p.gates)
|
|
162
|
+
end
|
|
144
163
|
type ||= ComplexType::UNDEFINED
|
|
145
164
|
end
|
|
146
165
|
break if type.defined?
|
|
147
166
|
end
|
|
148
167
|
p = p.with_single_signature(new_signature_pin) unless new_signature_pin.nil?
|
|
149
168
|
next p.proxy(type) if type.defined?
|
|
150
|
-
if !p.macros.empty?
|
|
151
|
-
result = process_macro(p, api_map, name_pin.context, locals)
|
|
152
|
-
next result unless result.return_type.undefined?
|
|
153
|
-
elsif !p.directives.empty?
|
|
154
|
-
result = process_directive(p, api_map, name_pin.context, locals)
|
|
155
|
-
next result unless result.return_type.undefined?
|
|
156
|
-
end
|
|
157
169
|
p
|
|
158
170
|
end
|
|
159
|
-
logger.debug
|
|
160
|
-
|
|
171
|
+
logger.debug do
|
|
172
|
+
"Call#inferred_pins(name_pin.binder=#{name_pin.binder}, word=#{word}, pins=#{pins.map(&:desc)}, name_pin=#{name_pin}) - result=#{result}"
|
|
173
|
+
end
|
|
174
|
+
result.map do |pin|
|
|
161
175
|
if pin.path == 'Class#new' && name_pin.binder.tag != 'Class'
|
|
162
176
|
reduced_context = name_pin.binder.reduce_class_type
|
|
163
177
|
pin.proxy(reduced_context)
|
|
164
178
|
else
|
|
179
|
+
# @sg-ignore Need to add nil check here
|
|
165
180
|
next pin if pin.return_type.undefined?
|
|
181
|
+
# @sg-ignore Need to add nil check here
|
|
166
182
|
selfy = pin.return_type.self_to_type(name_pin.binder)
|
|
183
|
+
# @sg-ignore Need to add nil check here
|
|
167
184
|
selfy == pin.return_type ? pin : pin.proxy(selfy)
|
|
168
185
|
end
|
|
169
186
|
end
|
|
170
187
|
end
|
|
171
188
|
|
|
172
|
-
# @param pin [Pin::Base]
|
|
173
|
-
# @param api_map [ApiMap]
|
|
174
|
-
# @param context [ComplexType]
|
|
175
|
-
# @param locals [::Array<Solargraph::Pin::LocalVariable, Solargraph::Pin::Parameter>]
|
|
176
|
-
# @return [Pin::Base]
|
|
177
|
-
def process_macro pin, api_map, context, locals
|
|
178
|
-
pin.macros.each do |macro|
|
|
179
|
-
# @todo 'Wrong argument type for
|
|
180
|
-
# Solargraph::Source::Chain::Call#inner_process_macro:
|
|
181
|
-
# macro expected YARD::Tags::MacroDirective, received
|
|
182
|
-
# generic<Elem>' is because we lose 'rooted' information
|
|
183
|
-
# in the 'Chain::Array' class internally, leaving
|
|
184
|
-
# ::Array#each shadowed when it shouldn't be.
|
|
185
|
-
result = inner_process_macro(pin, macro, api_map, context, locals)
|
|
186
|
-
return result unless result.return_type.undefined?
|
|
187
|
-
end
|
|
188
|
-
Pin::ProxyType.anonymous(ComplexType::UNDEFINED, source: :chain)
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
# @param pin [Pin::Method]
|
|
192
|
-
# @param api_map [ApiMap]
|
|
193
|
-
# @param context [ComplexType]
|
|
194
|
-
# @param locals [::Array<Solargraph::Pin::LocalVariable, Solargraph::Pin::Parameter>]
|
|
195
|
-
# @return [Pin::ProxyType]
|
|
196
|
-
def process_directive pin, api_map, context, locals
|
|
197
|
-
pin.directives.each do |dir|
|
|
198
|
-
macro = api_map.named_macro(dir.tag.name)
|
|
199
|
-
next if macro.nil?
|
|
200
|
-
result = inner_process_macro(pin, macro, api_map, context, locals)
|
|
201
|
-
return result unless result.return_type.undefined?
|
|
202
|
-
end
|
|
203
|
-
Pin::ProxyType.anonymous ComplexType::UNDEFINED, source: :chain
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
# @param pin [Pin::Base]
|
|
207
|
-
# @param macro [YARD::Tags::MacroDirective]
|
|
208
|
-
# @param api_map [ApiMap]
|
|
209
|
-
# @param context [ComplexType]
|
|
210
|
-
# @param locals [::Array<Pin::LocalVariable, Pin::Parameter>]
|
|
211
|
-
# @return [Pin::ProxyType]
|
|
212
|
-
def inner_process_macro pin, macro, api_map, context, locals
|
|
213
|
-
vals = arguments.map{ |c| Pin::ProxyType.anonymous(c.infer(api_map, pin, locals), source: :chain) }
|
|
214
|
-
txt = macro.tag.text.clone
|
|
215
|
-
if txt.empty? && macro.tag.name
|
|
216
|
-
named = api_map.named_macro(macro.tag.name)
|
|
217
|
-
txt = named.tag.text.clone if named
|
|
218
|
-
end
|
|
219
|
-
i = 1
|
|
220
|
-
vals.each do |v|
|
|
221
|
-
txt.gsub!(/\$#{i}/, v.context.namespace)
|
|
222
|
-
i += 1
|
|
223
|
-
end
|
|
224
|
-
docstring = Solargraph::Source.parse_docstring(txt).to_docstring
|
|
225
|
-
tag = docstring.tag(:return)
|
|
226
|
-
unless tag.nil? || tag.types.nil?
|
|
227
|
-
return Pin::ProxyType.anonymous(ComplexType.try_parse(*tag.types), source: :chain)
|
|
228
|
-
end
|
|
229
|
-
Pin::ProxyType.anonymous(ComplexType::UNDEFINED, source: :chain)
|
|
230
|
-
end
|
|
231
|
-
|
|
232
189
|
# @param docstring [YARD::Docstring]
|
|
233
190
|
# @param context [ComplexType]
|
|
234
191
|
# @return [ComplexType, nil]
|
|
235
192
|
def extra_return_type docstring, context
|
|
236
|
-
if docstring.has_tag?('return_single_parameter')
|
|
193
|
+
if docstring.has_tag?('return_single_parameter') # && context.subtypes.one?
|
|
237
194
|
return context.subtypes.first || ComplexType::UNDEFINED
|
|
238
195
|
elsif docstring.has_tag?('return_value_parameter') && context.value_types.one?
|
|
239
196
|
return context.value_types.first
|
|
@@ -243,9 +200,10 @@ module Solargraph
|
|
|
243
200
|
|
|
244
201
|
# @param name_pin [Pin::Base]
|
|
245
202
|
# @return [Pin::Method, nil]
|
|
246
|
-
def find_method_pin
|
|
203
|
+
def find_method_pin name_pin
|
|
247
204
|
method_pin = name_pin
|
|
248
205
|
until method_pin.is_a?(Pin::Method)
|
|
206
|
+
# @sg-ignore Need to support this in flow sensitive typing
|
|
249
207
|
method_pin = method_pin.closure
|
|
250
208
|
return if method_pin.nil?
|
|
251
209
|
end
|
|
@@ -259,7 +217,7 @@ module Solargraph
|
|
|
259
217
|
method_pin = find_method_pin(name_pin)
|
|
260
218
|
return [] if method_pin.nil?
|
|
261
219
|
pins = api_map.get_method_stack(method_pin.namespace, method_pin.name, scope: method_pin.context.scope)
|
|
262
|
-
pins.reject{|p| p.path == name_pin.path}
|
|
220
|
+
pins.reject { |p| p.path == name_pin.path }
|
|
263
221
|
end
|
|
264
222
|
|
|
265
223
|
# @param api_map [ApiMap]
|
|
@@ -271,13 +229,14 @@ module Solargraph
|
|
|
271
229
|
|
|
272
230
|
# @param signature_pin [Pin::Signature]
|
|
273
231
|
method_pin.signatures.map(&:block).compact.map do |signature_pin|
|
|
232
|
+
# @sg-ignore Need to add nil check here
|
|
274
233
|
return_type = signature_pin.return_type.qualify(api_map, *name_pin.gates)
|
|
275
234
|
signature_pin.proxy(return_type)
|
|
276
235
|
end
|
|
277
236
|
end
|
|
278
237
|
|
|
279
238
|
# @param type [ComplexType]
|
|
280
|
-
# @param context [ComplexType]
|
|
239
|
+
# @param context [ComplexType, ComplexType::UniqueType]
|
|
281
240
|
# @return [ComplexType]
|
|
282
241
|
def with_params type, context
|
|
283
242
|
return type unless type.to_s.include?('$')
|
|
@@ -291,13 +250,14 @@ module Solargraph
|
|
|
291
250
|
end
|
|
292
251
|
|
|
293
252
|
# @param api_map [ApiMap]
|
|
294
|
-
# @param context [ComplexType]
|
|
253
|
+
# @param context [ComplexType, ComplexType::UniqueType]
|
|
295
254
|
# @param block_parameter_types [::Array<ComplexType>]
|
|
296
255
|
# @param locals [::Array<Pin::LocalVariable>]
|
|
297
256
|
# @return [ComplexType, nil]
|
|
298
|
-
def block_symbol_call_type
|
|
257
|
+
def block_symbol_call_type api_map, context, block_parameter_types, locals
|
|
299
258
|
# Ruby's shorthand for sending the passed in method name
|
|
300
259
|
# to the first yield parameter with no arguments
|
|
260
|
+
# @sg-ignore Need to add nil check here
|
|
301
261
|
block_symbol_name = block.links.first.word
|
|
302
262
|
block_symbol_call_path = "#{block_parameter_types.first}##{block_symbol_name}"
|
|
303
263
|
callee = api_map.get_path_pins(block_symbol_call_path).first
|
|
@@ -305,31 +265,43 @@ module Solargraph
|
|
|
305
265
|
# @todo: Figure out why we get unresolved generics at
|
|
306
266
|
# this point and need to assume method return types
|
|
307
267
|
# based on the generic type
|
|
268
|
+
# @sg-ignore Need to add nil check here
|
|
308
269
|
return_type ||= api_map.get_path_pins("#{context.subtypes.first}##{block.links.first.word}").first&.return_type
|
|
309
270
|
return_type || ComplexType::UNDEFINED
|
|
310
271
|
end
|
|
311
272
|
|
|
312
273
|
# @param api_map [ApiMap]
|
|
313
274
|
# @return [Pin::Block, nil]
|
|
314
|
-
def find_block_pin
|
|
275
|
+
def find_block_pin api_map
|
|
276
|
+
# @sg-ignore Need to add nil check here
|
|
315
277
|
node_location = Solargraph::Location.from_node(block.node)
|
|
316
|
-
return if
|
|
278
|
+
return if node_location.nil?
|
|
317
279
|
block_pins = api_map.get_block_pins
|
|
280
|
+
# @sg-ignore Need to add nil check here
|
|
318
281
|
block_pins.find { |pin| pin.location.contain?(node_location) }
|
|
319
282
|
end
|
|
320
283
|
|
|
321
284
|
# @param api_map [ApiMap]
|
|
322
285
|
# @param name_pin [Pin::Base]
|
|
323
|
-
# @param block_parameter_types [::Array<ComplexType>]
|
|
324
286
|
# @param locals [::Array<Pin::LocalVariable>]
|
|
325
287
|
# @return [ComplexType, nil]
|
|
326
|
-
def block_call_type
|
|
288
|
+
def block_call_type api_map, name_pin, locals
|
|
327
289
|
return nil unless with_block?
|
|
328
290
|
|
|
329
|
-
block_context_pin = name_pin
|
|
330
291
|
block_pin = find_block_pin(api_map)
|
|
331
|
-
|
|
332
|
-
block
|
|
292
|
+
# We use the block pin as the closure, as the parameters
|
|
293
|
+
# here will only be defined inside the block itself and we
|
|
294
|
+
# need to be able to see them
|
|
295
|
+
# @sg-ignore Need to add nil check here
|
|
296
|
+
block.infer(api_map, block_pin, locals)
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
protected
|
|
300
|
+
|
|
301
|
+
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
|
302
|
+
def equality_fields
|
|
303
|
+
# @sg-ignore literal arrays in this module turn into ::Solargraph::Source::Chain::Array
|
|
304
|
+
super + [arguments, block]
|
|
333
305
|
end
|
|
334
306
|
end
|
|
335
307
|
end
|
|
@@ -5,7 +5,7 @@ module Solargraph
|
|
|
5
5
|
class Chain
|
|
6
6
|
class ClassVariable < Link
|
|
7
7
|
def resolve api_map, name_pin, locals
|
|
8
|
-
api_map.get_class_variable_pins(name_pin.context.namespace).select{|p| p.name == word}
|
|
8
|
+
api_map.get_class_variable_pins(name_pin.context.namespace).select { |p| p.name == word }
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -6,18 +6,22 @@ module Solargraph
|
|
|
6
6
|
class Constant < Link
|
|
7
7
|
def initialize word
|
|
8
8
|
@word = word
|
|
9
|
+
|
|
10
|
+
super
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
def resolve api_map, name_pin, locals
|
|
12
14
|
return [Pin::ROOT_PIN] if word.empty?
|
|
13
15
|
if word.start_with?('::')
|
|
14
|
-
base = word[2
|
|
16
|
+
base = word[2..]
|
|
15
17
|
gates = ['']
|
|
16
18
|
else
|
|
17
19
|
base = word
|
|
18
20
|
gates = name_pin.gates
|
|
19
21
|
end
|
|
22
|
+
# @sg-ignore Need to add nil check here
|
|
20
23
|
fqns = api_map.resolve(base, gates)
|
|
24
|
+
# @sg-ignore Need to add nil check here
|
|
21
25
|
api_map.get_path_pins(fqns)
|
|
22
26
|
end
|
|
23
27
|
end
|
|
@@ -12,11 +12,6 @@ module Solargraph
|
|
|
12
12
|
@splatted = splatted
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
|
16
|
-
protected def equality_fields
|
|
17
|
-
super + [@splatted]
|
|
18
|
-
end
|
|
19
|
-
|
|
20
15
|
def word
|
|
21
16
|
@word ||= "<#{@type}>"
|
|
22
17
|
end
|
|
@@ -28,6 +23,14 @@ module Solargraph
|
|
|
28
23
|
def splatted?
|
|
29
24
|
@splatted
|
|
30
25
|
end
|
|
26
|
+
|
|
27
|
+
protected
|
|
28
|
+
|
|
29
|
+
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
|
30
|
+
def equality_fields
|
|
31
|
+
# @sg-ignore literal arrays in this module turn into ::Solargraph::Source::Chain::Array
|
|
32
|
+
super + [@splatted]
|
|
33
|
+
end
|
|
31
34
|
end
|
|
32
35
|
end
|
|
33
36
|
end
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
class Source
|
|
5
|
-
class Chain
|
|
6
|
-
# Chain::Head is a link for ambiguous words, e.g.; `String` can refer to
|
|
7
|
-
# either a class (`String`) or a function (`Kernel#String`).
|
|
8
|
-
#
|
|
9
|
-
# @note Chain::Head is only intended to handle `self` and `super`.
|
|
10
|
-
class Head < Link
|
|
11
|
-
def resolve api_map, name_pin, locals
|
|
12
|
-
return [Pin::ProxyType.anonymous(name_pin.binder, source: :chain)] if word == 'self'
|
|
13
|
-
# return super_pins(api_map, name_pin) if word == 'super'
|
|
14
|
-
[]
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
class Source
|
|
5
|
+
class Chain
|
|
6
|
+
# Chain::Head is a link for ambiguous words, e.g.; `String` can refer to
|
|
7
|
+
# either a class (`String`) or a function (`Kernel#String`).
|
|
8
|
+
#
|
|
9
|
+
# @note Chain::Head is only intended to handle `self` and `super`.
|
|
10
|
+
class Head < Link
|
|
11
|
+
def resolve api_map, name_pin, locals
|
|
12
|
+
return [Pin::ProxyType.anonymous(name_pin.binder, source: :chain)] if word == 'self'
|
|
13
|
+
# return super_pins(api_map, name_pin) if word == 'super'
|
|
14
|
+
[]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -4,23 +4,25 @@ module Solargraph
|
|
|
4
4
|
class Source
|
|
5
5
|
class Chain
|
|
6
6
|
class If < Link
|
|
7
|
-
def word
|
|
8
|
-
'<if>'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
7
|
# @param links [::Array<Chain>]
|
|
12
8
|
def initialize links
|
|
13
|
-
|
|
14
|
-
end
|
|
9
|
+
super('<if>')
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
protected def equality_fields
|
|
18
|
-
super + [@links]
|
|
11
|
+
@links = links
|
|
19
12
|
end
|
|
20
13
|
|
|
21
14
|
def resolve api_map, name_pin, locals
|
|
22
15
|
types = @links.map { |link| link.infer(api_map, name_pin, locals) }
|
|
23
|
-
[Solargraph::Pin::ProxyType.anonymous(Solargraph::ComplexType.try_parse(types.map(&:tag).uniq.join(', ')),
|
|
16
|
+
[Solargraph::Pin::ProxyType.anonymous(Solargraph::ComplexType.try_parse(types.map(&:tag).uniq.join(', ')),
|
|
17
|
+
source: :chain)]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
protected
|
|
21
|
+
|
|
22
|
+
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
|
23
|
+
def equality_fields
|
|
24
|
+
# @sg-ignore literal arrays in this module turn into ::Solargraph::Source::Chain::Array
|
|
25
|
+
super + [@links]
|
|
24
26
|
end
|
|
25
27
|
end
|
|
26
28
|
end
|
|
@@ -4,9 +4,32 @@ module Solargraph
|
|
|
4
4
|
class Source
|
|
5
5
|
class Chain
|
|
6
6
|
class InstanceVariable < Link
|
|
7
|
+
# @param word [String]
|
|
8
|
+
# @param node [Parser::AST::Node, nil] The node representing the variable
|
|
9
|
+
# @param location [Location, nil] The location of the variable reference in the source
|
|
10
|
+
def initialize word, node, location
|
|
11
|
+
super(word)
|
|
12
|
+
@node = node
|
|
13
|
+
@location = location
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @sg-ignore Declared return type
|
|
17
|
+
# ::Array<::Solargraph::Pin::Base> does not match inferred
|
|
18
|
+
# type ::Array<::Solargraph::Pin::BaseVariable, ::NilClass>
|
|
19
|
+
# for Solargraph::Source::Chain::InstanceVariable#resolve
|
|
7
20
|
def resolve api_map, name_pin, locals
|
|
8
|
-
api_map.get_instance_variable_pins(name_pin.
|
|
21
|
+
ivars = api_map.get_instance_variable_pins(name_pin.context.namespace, name_pin.context.scope).select do |p|
|
|
22
|
+
p.name == word
|
|
23
|
+
end
|
|
24
|
+
out = api_map.var_at_location(ivars, word, name_pin, location)
|
|
25
|
+
[out].compact
|
|
9
26
|
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
# @todo: Missed nil violation
|
|
31
|
+
# @return [Location]
|
|
32
|
+
attr_reader :location
|
|
10
33
|
end
|
|
11
34
|
end
|
|
12
35
|
end
|
|
@@ -17,17 +17,6 @@ module Solargraph
|
|
|
17
17
|
@word = word
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
# @sg-ignore two problems - Declared return type
|
|
21
|
-
# ::Solargraph::Source::Chain::Array does not match inferred
|
|
22
|
-
# type ::Array(::Class<::Solargraph::Source::Chain::Link>,
|
|
23
|
-
# ::String) for
|
|
24
|
-
# Solargraph::Source::Chain::Link#equality_fields
|
|
25
|
-
# and
|
|
26
|
-
# Not enough arguments to Module#protected
|
|
27
|
-
protected def equality_fields
|
|
28
|
-
[self.class, word]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
20
|
def undefined?
|
|
32
21
|
word == '<undefined>'
|
|
33
22
|
end
|
|
@@ -44,18 +33,12 @@ module Solargraph
|
|
|
44
33
|
[]
|
|
45
34
|
end
|
|
46
35
|
|
|
47
|
-
# debugging description of contents; not for machine use
|
|
48
|
-
# @return [String]
|
|
49
|
-
def desc
|
|
50
|
-
word
|
|
51
|
-
end
|
|
52
|
-
|
|
53
36
|
def to_s
|
|
54
37
|
desc
|
|
55
38
|
end
|
|
56
39
|
|
|
57
40
|
def inspect
|
|
58
|
-
"#<#{self.class} - `#{
|
|
41
|
+
"#<#{self.class} - `#{desc}`>"
|
|
59
42
|
end
|
|
60
43
|
|
|
61
44
|
def head?
|
|
@@ -87,14 +70,21 @@ module Solargraph
|
|
|
87
70
|
word
|
|
88
71
|
end
|
|
89
72
|
|
|
90
|
-
def inspect
|
|
91
|
-
"#<#{self.class} - `#{self.desc}`>"
|
|
92
|
-
end
|
|
93
|
-
|
|
94
73
|
include Logging
|
|
95
74
|
|
|
96
75
|
protected
|
|
97
76
|
|
|
77
|
+
# @sg-ignore two problems - Declared return type
|
|
78
|
+
# ::Solargraph::Source::Chain::Array does not match inferred
|
|
79
|
+
# type ::Array(::Class<::Solargraph::Source::Chain::Link>,
|
|
80
|
+
# ::String) for
|
|
81
|
+
# Solargraph::Source::Chain::Link#equality_fields
|
|
82
|
+
# and
|
|
83
|
+
# Not enough arguments to Module#protected
|
|
84
|
+
def equality_fields
|
|
85
|
+
[self.class, word]
|
|
86
|
+
end
|
|
87
|
+
|
|
98
88
|
# Mark whether this link is the head of a chain
|
|
99
89
|
#
|
|
100
90
|
# @param bool [Boolean]
|
|
@@ -6,31 +6,38 @@ module Solargraph
|
|
|
6
6
|
class Source
|
|
7
7
|
class Chain
|
|
8
8
|
class Literal < Link
|
|
9
|
-
|
|
10
|
-
@word ||= "<#{@type}>"
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
attr_reader :value
|
|
9
|
+
attr_reader :word, :value
|
|
14
10
|
|
|
15
11
|
# @param type [String]
|
|
16
12
|
# @param node [Parser::AST::Node, Object]
|
|
17
13
|
def initialize type, node
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
super("<#{type}>")
|
|
15
|
+
|
|
16
|
+
# @todo We might be able to do some light inference from literals and
|
|
17
|
+
# tuples as long as literal values are intransitive.
|
|
18
|
+
|
|
19
|
+
# if node.is_a?(::Parser::AST::Node)
|
|
20
|
+
# # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check
|
|
21
|
+
# if node.type == :true
|
|
22
|
+
# @value = true
|
|
23
|
+
# # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check
|
|
24
|
+
# elsif node.type == :false
|
|
25
|
+
# @value = false
|
|
26
|
+
# # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check
|
|
27
|
+
# elsif %i[int sym].include?(node.type)
|
|
28
|
+
# # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check
|
|
29
|
+
# @value = node.children.first
|
|
30
|
+
# end
|
|
31
|
+
# end
|
|
27
32
|
@type = type
|
|
28
|
-
@literal_type = ComplexType.try_parse(@value.inspect)
|
|
33
|
+
# @literal_type = ComplexType.try_parse(@value.inspect)
|
|
34
|
+
@literal_type = ComplexType::UNDEFINED
|
|
29
35
|
@complex_type = ComplexType.try_parse(type)
|
|
30
36
|
end
|
|
31
37
|
|
|
32
38
|
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
|
33
39
|
protected def equality_fields
|
|
40
|
+
# @sg-ignore literal arrays in this module turn into ::Solargraph::Source::Chain::Array
|
|
34
41
|
super + [@value, @type, @literal_type, @complex_type]
|
|
35
42
|
end
|
|
36
43
|
|