solargraph 0.54.0 → 0.54.5
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/CHANGELOG.md +45 -0
- data/lib/solargraph/api_map/cache.rb +10 -1
- data/lib/solargraph/api_map/index.rb +167 -0
- data/lib/solargraph/api_map/store.rb +72 -121
- data/lib/solargraph/api_map.rb +94 -36
- data/lib/solargraph/bench.rb +17 -1
- data/lib/solargraph/complex_type/type_methods.rb +17 -11
- data/lib/solargraph/complex_type/unique_type.rb +93 -10
- data/lib/solargraph/complex_type.rb +68 -18
- data/lib/solargraph/convention.rb +1 -0
- data/lib/solargraph/doc_map.rb +1 -0
- data/lib/solargraph/equality.rb +33 -0
- data/lib/solargraph/language_server/host/message_worker.rb +48 -5
- data/lib/solargraph/language_server/host.rb +12 -11
- data/lib/solargraph/language_server/message/base.rb +19 -12
- data/lib/solargraph/language_server/message/initialize.rb +3 -1
- data/lib/solargraph/language_server/message/text_document/completion.rb +0 -3
- data/lib/solargraph/language_server/message/text_document/definition.rb +3 -3
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +3 -3
- data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -0
- data/lib/solargraph/language_server/message/text_document/hover.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +3 -3
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +2 -2
- data/lib/solargraph/language_server/progress.rb +19 -2
- data/lib/solargraph/library.rb +31 -41
- data/lib/solargraph/location.rb +21 -1
- data/lib/solargraph/parser/node_methods.rb +1 -1
- data/lib/solargraph/parser/node_processor.rb +1 -0
- data/lib/solargraph/parser/parser_gem/class_methods.rb +2 -6
- data/lib/solargraph/parser/parser_gem/node_methods.rb +3 -3
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +23 -19
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +8 -2
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +1 -1
- data/lib/solargraph/parser.rb +2 -5
- data/lib/solargraph/pin/base.rb +41 -17
- data/lib/solargraph/pin/base_variable.rb +4 -3
- data/lib/solargraph/pin/block.rb +6 -26
- data/lib/solargraph/pin/callable.rb +147 -0
- data/lib/solargraph/pin/closure.rb +8 -3
- data/lib/solargraph/pin/common.rb +2 -6
- data/lib/solargraph/pin/conversions.rb +3 -2
- data/lib/solargraph/pin/instance_variable.rb +2 -2
- data/lib/solargraph/pin/method.rb +57 -31
- data/lib/solargraph/pin/namespace.rb +5 -5
- data/lib/solargraph/pin/parameter.rb +11 -12
- data/lib/solargraph/pin/proxy_type.rb +1 -1
- data/lib/solargraph/pin/signature.rb +3 -129
- data/lib/solargraph/pin.rb +4 -1
- data/lib/solargraph/position.rb +7 -0
- data/lib/solargraph/range.rb +9 -4
- data/lib/solargraph/rbs_map/conversions.rb +77 -38
- data/lib/solargraph/rbs_map/core_fills.rb +6 -6
- data/lib/solargraph/rbs_map.rb +1 -0
- data/lib/solargraph/shell.rb +19 -2
- data/lib/solargraph/source/chain/array.rb +7 -6
- data/lib/solargraph/source/chain/block_symbol.rb +1 -1
- data/lib/solargraph/source/chain/block_variable.rb +1 -1
- data/lib/solargraph/source/chain/call.rb +90 -55
- data/lib/solargraph/source/chain/hash.rb +5 -0
- data/lib/solargraph/source/chain/if.rb +5 -0
- data/lib/solargraph/source/chain/link.rb +26 -5
- data/lib/solargraph/source/chain/literal.rb +5 -0
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain.rb +68 -30
- data/lib/solargraph/source/cursor.rb +3 -2
- data/lib/solargraph/source.rb +104 -86
- data/lib/solargraph/source_map/clip.rb +5 -5
- data/lib/solargraph/source_map/data.rb +30 -0
- data/lib/solargraph/source_map.rb +28 -16
- data/lib/solargraph/type_checker/rules.rb +6 -1
- data/lib/solargraph/type_checker.rb +15 -15
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/environment.erb +3 -5
- data/lib/solargraph/workspace/config.rb +7 -3
- data/lib/solargraph/workspace.rb +1 -1
- data/lib/solargraph/yard_map/mapper/to_constant.rb +1 -0
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +1 -0
- data/lib/solargraph/yard_map/mapper.rb +1 -0
- data/lib/solargraph/yardoc.rb +1 -1
- data/lib/solargraph.rb +1 -0
- data/solargraph.gemspec +5 -5
- metadata +29 -25
@@ -0,0 +1,147 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Pin
|
5
|
+
class Callable < Closure
|
6
|
+
# @return [Signature]
|
7
|
+
attr_reader :block
|
8
|
+
|
9
|
+
attr_reader :parameters
|
10
|
+
|
11
|
+
# @return [ComplexType, nil]
|
12
|
+
attr_reader :return_type
|
13
|
+
|
14
|
+
# @param block [Signature, nil]
|
15
|
+
# @param return_type [ComplexType, nil]
|
16
|
+
# @param parameters [::Array<Pin::Parameter>]
|
17
|
+
def initialize block: nil, return_type: nil, parameters: [], **splat
|
18
|
+
super(**splat)
|
19
|
+
@block = block
|
20
|
+
@return_type = return_type
|
21
|
+
@parameters = parameters
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [::Array<String>]
|
25
|
+
def parameter_names
|
26
|
+
@parameter_names ||= parameters.map(&:name)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @param generics_to_resolve [Enumerable<String>]
|
30
|
+
# @param arg_types [Array<ComplexType>, nil]
|
31
|
+
# @param return_type_context [ComplexType, nil]
|
32
|
+
# @param yield_arg_types [Array<ComplexType>, nil]
|
33
|
+
# @param yield_return_type_context [ComplexType, nil]
|
34
|
+
# @param context [ComplexType, nil]
|
35
|
+
# @param resolved_generic_values [Hash{String => ComplexType}]
|
36
|
+
# @return [self]
|
37
|
+
def resolve_generics_from_context(generics_to_resolve,
|
38
|
+
arg_types = nil,
|
39
|
+
return_type_context = nil,
|
40
|
+
yield_arg_types = nil,
|
41
|
+
yield_return_type_context = nil,
|
42
|
+
resolved_generic_values: {})
|
43
|
+
callable = super(generics_to_resolve, return_type_context, resolved_generic_values: resolved_generic_values)
|
44
|
+
callable.parameters = callable.parameters.each_with_index.map do |param, i|
|
45
|
+
if arg_types.nil?
|
46
|
+
param.dup
|
47
|
+
else
|
48
|
+
param.resolve_generics_from_context(generics_to_resolve,
|
49
|
+
arg_types[i],
|
50
|
+
resolved_generic_values: resolved_generic_values)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
callable.block = block.resolve_generics_from_context(generics_to_resolve,
|
54
|
+
yield_arg_types,
|
55
|
+
yield_return_type_context,
|
56
|
+
resolved_generic_values: resolved_generic_values) if callable.block?
|
57
|
+
callable
|
58
|
+
end
|
59
|
+
|
60
|
+
# @param generics_to_resolve [::Array<String>]
|
61
|
+
# @param arg_types [Array<ComplexType>, nil]
|
62
|
+
# @param return_type_context [ComplexType, nil]
|
63
|
+
# @param yield_arg_types [Array<ComplexType>, nil]
|
64
|
+
# @param yield_return_type_context [ComplexType, nil]
|
65
|
+
# @param context [ComplexType, nil]
|
66
|
+
# @param resolved_generic_values [Hash{String => ComplexType}]
|
67
|
+
# @return [self]
|
68
|
+
def resolve_generics_from_context_until_complete(generics_to_resolve,
|
69
|
+
arg_types = nil,
|
70
|
+
return_type_context = nil,
|
71
|
+
yield_arg_types = nil,
|
72
|
+
yield_return_type_context = nil,
|
73
|
+
resolved_generic_values: {})
|
74
|
+
# See
|
75
|
+
# https://github.com/soutaro/steep/tree/master/lib/steep/type_inference
|
76
|
+
# and
|
77
|
+
# https://github.com/sorbet/sorbet/blob/master/infer/inference.cc
|
78
|
+
# for other implementations
|
79
|
+
|
80
|
+
return self if generics_to_resolve.empty?
|
81
|
+
|
82
|
+
last_resolved_generic_values = resolved_generic_values.dup
|
83
|
+
new_pin = resolve_generics_from_context(generics_to_resolve,
|
84
|
+
arg_types,
|
85
|
+
return_type_context,
|
86
|
+
yield_arg_types,
|
87
|
+
yield_return_type_context,
|
88
|
+
resolved_generic_values: resolved_generic_values)
|
89
|
+
if last_resolved_generic_values == resolved_generic_values
|
90
|
+
# erase anything unresolved
|
91
|
+
return new_pin.erase_generics(self.generics)
|
92
|
+
end
|
93
|
+
new_pin.resolve_generics_from_context_until_complete(generics_to_resolve,
|
94
|
+
arg_types,
|
95
|
+
return_type_context,
|
96
|
+
yield_arg_types,
|
97
|
+
yield_return_type_context,
|
98
|
+
resolved_generic_values: resolved_generic_values)
|
99
|
+
end
|
100
|
+
|
101
|
+
# @return [Array<String>]
|
102
|
+
# @yieldparam [ComplexType]
|
103
|
+
# @yieldreturn [ComplexType]
|
104
|
+
# @return [self]
|
105
|
+
def transform_types(&transform)
|
106
|
+
# @todo 'super' alone should work here I think, but doesn't typecheck at level typed
|
107
|
+
callable = super(&transform)
|
108
|
+
callable.block = block.transform_types(&transform) if block?
|
109
|
+
callable.parameters = parameters.map do |param|
|
110
|
+
param.transform_types(&transform)
|
111
|
+
end
|
112
|
+
callable
|
113
|
+
end
|
114
|
+
|
115
|
+
# @param arguments [::Array<Chain>]
|
116
|
+
# @param with_block [Boolean]
|
117
|
+
# @return [Boolean]
|
118
|
+
def arity_matches? arguments, with_block
|
119
|
+
argcount = arguments.length
|
120
|
+
parcount = mandatory_positional_param_count
|
121
|
+
parcount -= 1 if !parameters.empty? && parameters.last.block?
|
122
|
+
return false if block? && !with_block
|
123
|
+
return false if argcount < parcount && !(argcount == parcount - 1 && parameters.last.restarg?)
|
124
|
+
true
|
125
|
+
end
|
126
|
+
|
127
|
+
def mandatory_positional_param_count
|
128
|
+
parameters.count(&:arg?)
|
129
|
+
end
|
130
|
+
|
131
|
+
# @return [String]
|
132
|
+
def to_rbs
|
133
|
+
rbs_generics + '(' + parameters.map { |param| param.to_rbs }.join(', ') + ') ' + (block.nil? ? '' : '{ ' + block.to_rbs + ' } ') + '-> ' + return_type.to_rbs
|
134
|
+
end
|
135
|
+
|
136
|
+
def block?
|
137
|
+
!!@block
|
138
|
+
end
|
139
|
+
|
140
|
+
protected
|
141
|
+
|
142
|
+
attr_writer :block
|
143
|
+
|
144
|
+
attr_writer :parameters
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -18,7 +18,7 @@ module Solargraph
|
|
18
18
|
@context ||= begin
|
19
19
|
result = super
|
20
20
|
if scope == :instance
|
21
|
-
|
21
|
+
result.reduce_class_type
|
22
22
|
else
|
23
23
|
result
|
24
24
|
end
|
@@ -42,10 +42,15 @@ module Solargraph
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# @return [String]
|
45
|
-
def
|
45
|
+
def to_rbs
|
46
|
+
rbs_generics + return_type.to_rbs
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [String]
|
50
|
+
def rbs_generics
|
46
51
|
return '' if generics.empty?
|
47
52
|
|
48
|
-
generics.join(', ') + ' '
|
53
|
+
'[' + generics.map { |gen| gen.to_s }.join(', ') + '] '
|
49
54
|
end
|
50
55
|
end
|
51
56
|
end
|
@@ -19,7 +19,7 @@ module Solargraph
|
|
19
19
|
@return_type ||= ComplexType::UNDEFINED
|
20
20
|
end
|
21
21
|
|
22
|
-
# @return [ComplexType
|
22
|
+
# @return [ComplexType]
|
23
23
|
def context
|
24
24
|
# Get the static context from the nearest namespace
|
25
25
|
@context ||= find_context
|
@@ -59,11 +59,7 @@ module Solargraph
|
|
59
59
|
if here.is_a?(Pin::Namespace)
|
60
60
|
return here.return_type
|
61
61
|
elsif here.is_a?(Pin::Method)
|
62
|
-
|
63
|
-
return ComplexType.try_parse(here.context.tag)
|
64
|
-
else
|
65
|
-
return here.context
|
66
|
-
end
|
62
|
+
return here.context
|
67
63
|
end
|
68
64
|
here = here.closure
|
69
65
|
end
|
@@ -87,7 +87,7 @@ module Solargraph
|
|
87
87
|
|
88
88
|
# @return [String, nil]
|
89
89
|
def text_documentation
|
90
|
-
this_path = path || return_type.tag
|
90
|
+
this_path = path || name || return_type.tag
|
91
91
|
return nil if this_path == 'undefined'
|
92
92
|
escape_brackets this_path
|
93
93
|
end
|
@@ -105,9 +105,10 @@ module Solargraph
|
|
105
105
|
|
106
106
|
# @return [String, nil]
|
107
107
|
def generate_link
|
108
|
-
this_path = path || return_type.tag
|
108
|
+
this_path = path || name || return_type.tag
|
109
109
|
return nil if this_path == 'undefined'
|
110
110
|
return nil if this_path.nil? || this_path == 'undefined'
|
111
|
+
return this_path if path.nil?
|
111
112
|
"[#{escape_brackets(this_path).gsub('_', '\\\\_')}](solargraph:/document?query=#{CGI.escape(this_path)})"
|
112
113
|
end
|
113
114
|
|
@@ -18,9 +18,9 @@ module Solargraph
|
|
18
18
|
@context ||= begin
|
19
19
|
result = super
|
20
20
|
if scope == :class
|
21
|
-
ComplexType.parse("Class<#{result.
|
21
|
+
ComplexType.parse("::Class<#{result.rooted_namespace}>")
|
22
22
|
else
|
23
|
-
|
23
|
+
result.reduce_class_type
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -4,12 +4,9 @@ module Solargraph
|
|
4
4
|
module Pin
|
5
5
|
# The base class for method and attribute pins.
|
6
6
|
#
|
7
|
-
class Method <
|
7
|
+
class Method < Callable
|
8
8
|
include Solargraph::Parser::NodeMethods
|
9
9
|
|
10
|
-
# @return [::Array<Pin::Parameter>]
|
11
|
-
attr_reader :parameters
|
12
|
-
|
13
10
|
# @return [::Symbol] :public, :private, or :protected
|
14
11
|
attr_reader :visibility
|
15
12
|
|
@@ -18,24 +15,24 @@ module Solargraph
|
|
18
15
|
|
19
16
|
# @param visibility [::Symbol] :public, :protected, or :private
|
20
17
|
# @param explicit [Boolean]
|
21
|
-
# @param parameters [::Array<Pin::Parameter>]
|
22
18
|
# @param block [Pin::Signature, nil, ::Symbol]
|
23
|
-
# @param node [Parser::AST::Node,
|
19
|
+
# @param node [Parser::AST::Node, nil]
|
24
20
|
# @param attribute [Boolean]
|
25
21
|
# @param signatures [::Array<Signature>, nil]
|
26
22
|
# @param anon_splat [Boolean]
|
27
|
-
|
28
|
-
def initialize visibility: :public, explicit: true, parameters: [], block: :undefined, node: nil, attribute: false, signatures: nil, anon_splat: false, return_type: nil, **splat
|
23
|
+
def initialize visibility: :public, explicit: true, block: :undefined, node: nil, attribute: false, signatures: nil, anon_splat: false, **splat
|
29
24
|
super(**splat)
|
30
25
|
@visibility = visibility
|
31
26
|
@explicit = explicit
|
32
|
-
@parameters = parameters
|
33
27
|
@block = block
|
34
28
|
@node = node
|
35
29
|
@attribute = attribute
|
36
30
|
@signatures = signatures
|
37
31
|
@anon_splat = anon_splat
|
38
|
-
|
32
|
+
end
|
33
|
+
|
34
|
+
def == other
|
35
|
+
super && other.node == node
|
39
36
|
end
|
40
37
|
|
41
38
|
def transform_types(&transform)
|
@@ -44,15 +41,16 @@ module Solargraph
|
|
44
41
|
m.signatures = m.signatures.map do |sig|
|
45
42
|
sig.transform_types(&transform)
|
46
43
|
end
|
47
|
-
m.parameters = m.parameters.map do |param|
|
48
|
-
param.transform_types(&transform)
|
49
|
-
end
|
50
44
|
m.block = block&.transform_types(&transform)
|
51
45
|
m.signature_help = nil
|
52
46
|
m.documentation = nil
|
53
47
|
m
|
54
48
|
end
|
55
49
|
|
50
|
+
def all_rooted?
|
51
|
+
super && parameters.all?(&:all_rooted?) && (!block || block&.all_rooted?) && signatures.all?(&:all_rooted?)
|
52
|
+
end
|
53
|
+
|
56
54
|
# @param signature [Pin::Signature]
|
57
55
|
# @return [Pin::Method]
|
58
56
|
def with_single_signature(signature)
|
@@ -71,15 +69,14 @@ module Solargraph
|
|
71
69
|
m
|
72
70
|
end
|
73
71
|
|
72
|
+
def block?
|
73
|
+
!block.nil?
|
74
|
+
end
|
75
|
+
|
74
76
|
# @return [Pin::Signature, nil]
|
75
77
|
def block
|
76
78
|
return @block unless @block == :undefined
|
77
|
-
@block = signatures.first
|
78
|
-
end
|
79
|
-
|
80
|
-
# @return [::Array<String>]
|
81
|
-
def parameter_names
|
82
|
-
@parameter_names ||= parameters.map(&:name)
|
79
|
+
@block = signatures.first&.block
|
83
80
|
end
|
84
81
|
|
85
82
|
def completion_item_kind
|
@@ -123,9 +120,9 @@ module Solargraph
|
|
123
120
|
)
|
124
121
|
end
|
125
122
|
yield_return_type = ComplexType.try_parse(*yieldreturn_tags.flat_map(&:types))
|
126
|
-
block = Signature.new(generics, yield_parameters, yield_return_type)
|
123
|
+
block = Signature.new(generics: generics, parameters: yield_parameters, return_type: yield_return_type)
|
127
124
|
end
|
128
|
-
Signature.new(generics, parameters, return_type, block)
|
125
|
+
Signature.new(generics: generics, parameters: parameters, return_type: return_type, block: block)
|
129
126
|
end
|
130
127
|
|
131
128
|
# @return [::Array<Signature>]
|
@@ -269,10 +266,11 @@ module Solargraph
|
|
269
266
|
@attribute
|
270
267
|
end
|
271
268
|
|
269
|
+
# @parm other [Method]
|
272
270
|
def nearly? other
|
273
|
-
|
274
|
-
|
275
|
-
scope == other.scope
|
271
|
+
super &&
|
272
|
+
parameters == other.parameters &&
|
273
|
+
scope == other.scope &&
|
276
274
|
visibility == other.visibility
|
277
275
|
end
|
278
276
|
|
@@ -280,9 +278,11 @@ module Solargraph
|
|
280
278
|
attribute? ? infer_from_iv(api_map) : infer_from_return_nodes(api_map)
|
281
279
|
end
|
282
280
|
|
281
|
+
# @param pin [Pin::Method]
|
283
282
|
def try_merge! pin
|
284
283
|
return false unless super
|
285
284
|
@node = pin.node
|
285
|
+
@resolved_ref_tag = false
|
286
286
|
true
|
287
287
|
end
|
288
288
|
|
@@ -292,8 +292,8 @@ module Solargraph
|
|
292
292
|
# tag's source is likely malformed.
|
293
293
|
@overloads ||= docstring.tags(:overload).select(&:parameters).map do |tag|
|
294
294
|
Pin::Signature.new(
|
295
|
-
generics,
|
296
|
-
tag.parameters.map do |src|
|
295
|
+
generics: generics,
|
296
|
+
parameters: tag.parameters.map do |src|
|
297
297
|
name, decl = parse_overload_param(src.first)
|
298
298
|
Pin::Parameter.new(
|
299
299
|
location: location,
|
@@ -305,7 +305,7 @@ module Solargraph
|
|
305
305
|
return_type: param_type_from_name(tag, src.first)
|
306
306
|
)
|
307
307
|
end,
|
308
|
-
ComplexType.try_parse(*tag.docstring.tags(:return).flat_map(&:types))
|
308
|
+
return_type: ComplexType.try_parse(*tag.docstring.tags(:return).flat_map(&:types))
|
309
309
|
)
|
310
310
|
end
|
311
311
|
@overloads
|
@@ -315,12 +315,33 @@ module Solargraph
|
|
315
315
|
@anon_splat
|
316
316
|
end
|
317
317
|
|
318
|
+
# @param [ApiMap]
|
319
|
+
# @return [self]
|
320
|
+
def resolve_ref_tag api_map
|
321
|
+
return self if @resolved_ref_tag
|
322
|
+
|
323
|
+
@resolved_ref_tag = true
|
324
|
+
return self unless docstring.ref_tags.any?
|
325
|
+
docstring.ref_tags.each do |tag|
|
326
|
+
ref = if tag.owner.to_s.start_with?(/[#\.]/)
|
327
|
+
api_map.get_methods(namespace)
|
328
|
+
.select { |pin| pin.path.end_with?(tag.owner.to_s) }
|
329
|
+
.first
|
330
|
+
else
|
331
|
+
# @todo Resolve relative namespaces
|
332
|
+
api_map.get_path_pins(tag.owner.to_s).first
|
333
|
+
end
|
334
|
+
next unless ref
|
335
|
+
|
336
|
+
docstring.add_tag(*ref.docstring.tags(:param))
|
337
|
+
end
|
338
|
+
self
|
339
|
+
end
|
340
|
+
|
318
341
|
protected
|
319
342
|
|
320
343
|
attr_writer :block
|
321
344
|
|
322
|
-
attr_writer :parameters
|
323
|
-
|
324
345
|
attr_writer :signatures
|
325
346
|
|
326
347
|
attr_writer :signature_help
|
@@ -452,7 +473,7 @@ module Solargraph
|
|
452
473
|
end
|
453
474
|
result.push ComplexType::NIL if has_nil
|
454
475
|
return ComplexType::UNDEFINED if result.empty?
|
455
|
-
ComplexType.
|
476
|
+
ComplexType.new(result.uniq)
|
456
477
|
end
|
457
478
|
|
458
479
|
# @param [ApiMap] api_map
|
@@ -467,7 +488,7 @@ module Solargraph
|
|
467
488
|
types.push type if type.defined?
|
468
489
|
end
|
469
490
|
return ComplexType::UNDEFINED if types.empty?
|
470
|
-
ComplexType.
|
491
|
+
ComplexType.new(types.uniq)
|
471
492
|
end
|
472
493
|
|
473
494
|
# When YARD parses an overload tag, it includes rest modifiers in the parameters names.
|
@@ -475,6 +496,7 @@ module Solargraph
|
|
475
496
|
# @param name [String]
|
476
497
|
# @return [::Array(String, ::Symbol)]
|
477
498
|
def parse_overload_param(name)
|
499
|
+
# @todo this needs to handle mandatory vs not args, kwargs, blocks, etc
|
478
500
|
if name.start_with?('**')
|
479
501
|
[name[2..-1], :kwrestarg]
|
480
502
|
elsif name.start_with?('*')
|
@@ -496,6 +518,10 @@ module Solargraph
|
|
496
518
|
.join("\n")
|
497
519
|
.concat("```\n")
|
498
520
|
end
|
521
|
+
|
522
|
+
protected
|
523
|
+
|
524
|
+
attr_writer :signatures
|
499
525
|
end
|
500
526
|
end
|
501
527
|
end
|
@@ -41,14 +41,14 @@ module Solargraph
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def to_rbs
|
44
|
-
"#{@type.to_s} #{
|
44
|
+
"#{@type.to_s} #{return_type.all_params.first.to_rbs}#{rbs_generics}".strip
|
45
45
|
end
|
46
46
|
|
47
47
|
def desc
|
48
|
-
if name.nil?
|
48
|
+
if name.nil? || name.empty?
|
49
49
|
'(top-level)'
|
50
50
|
else
|
51
|
-
|
51
|
+
return_type.rooted_tags
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -57,7 +57,7 @@ module Solargraph
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def full_context
|
60
|
-
@full_context ||= ComplexType.try_parse("
|
60
|
+
@full_context ||= ComplexType.try_parse("::#{type.to_s.capitalize}<#{path}>")
|
61
61
|
end
|
62
62
|
|
63
63
|
def binder
|
@@ -83,7 +83,7 @@ module Solargraph
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def return_type
|
86
|
-
@return_type ||= ComplexType.try_parse( (type == :class ? 'Class' : 'Module') + "
|
86
|
+
@return_type ||= ComplexType.try_parse( (type == :class ? '::Class' : '::Module') + "<::#{path}>")
|
87
87
|
end
|
88
88
|
|
89
89
|
# @return [Array<String>]
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Solargraph
|
4
4
|
module Pin
|
5
5
|
class Parameter < LocalVariable
|
6
|
-
# @return [Symbol]
|
6
|
+
# @return [::Symbol]
|
7
7
|
attr_reader :decl
|
8
8
|
|
9
9
|
# @return [String]
|
@@ -27,6 +27,10 @@ module Solargraph
|
|
27
27
|
decl == :kwrestarg || (assignment && [:HASH, :hash].include?(assignment.type))
|
28
28
|
end
|
29
29
|
|
30
|
+
def arg?
|
31
|
+
decl == :arg
|
32
|
+
end
|
33
|
+
|
30
34
|
def restarg?
|
31
35
|
decl == :restarg
|
32
36
|
end
|
@@ -84,11 +88,11 @@ module Solargraph
|
|
84
88
|
@return_type = ComplexType.try_parse(*found.types) unless found.nil? or found.types.nil?
|
85
89
|
if @return_type.undefined?
|
86
90
|
if decl == :restarg
|
87
|
-
@return_type = ComplexType.try_parse('Array')
|
91
|
+
@return_type = ComplexType.try_parse('::Array')
|
88
92
|
elsif decl == :kwrestarg
|
89
|
-
@return_type = ComplexType.try_parse('Hash')
|
93
|
+
@return_type = ComplexType.try_parse('::Hash')
|
90
94
|
elsif decl == :blockarg
|
91
|
-
@return_type = ComplexType.try_parse('Proc')
|
95
|
+
@return_type = ComplexType.try_parse('::Proc')
|
92
96
|
end
|
93
97
|
end
|
94
98
|
end
|
@@ -117,6 +121,7 @@ module Solargraph
|
|
117
121
|
tag.text
|
118
122
|
end
|
119
123
|
|
124
|
+
# @param pin [Pin::Parameter]
|
120
125
|
def try_merge! pin
|
121
126
|
return false unless super && closure == pin.closure
|
122
127
|
true
|
@@ -126,17 +131,11 @@ module Solargraph
|
|
126
131
|
|
127
132
|
# @return [YARD::Tags::Tag, nil]
|
128
133
|
def param_tag
|
129
|
-
found = nil
|
130
134
|
params = closure.docstring.tags(:param)
|
131
135
|
params.each do |p|
|
132
|
-
|
133
|
-
found = p
|
134
|
-
break
|
135
|
-
end
|
136
|
-
if found.nil? and !index.nil?
|
137
|
-
found = params[index] if params[index] && (params[index].name.nil? || params[index].name.empty?)
|
136
|
+
return p if p.name == name
|
138
137
|
end
|
139
|
-
|
138
|
+
params[index] if index && params[index] && (params[index].name.nil? || params[index].name.empty?)
|
140
139
|
end
|
141
140
|
|
142
141
|
# @param api_map [ApiMap]
|
@@ -18,7 +18,7 @@ module Solargraph
|
|
18
18
|
def self.anonymous return_type
|
19
19
|
parts = return_type.namespace.split('::')
|
20
20
|
namespace = parts[0..-2].join('::').to_s
|
21
|
-
name = parts.last.to_s
|
21
|
+
# name = parts.last.to_s
|
22
22
|
# ProxyType.new(nil, namespace, name, return_type)
|
23
23
|
ProxyType.new(
|
24
24
|
closure: Solargraph::Pin::Namespace.new(name: namespace), return_type: return_type
|