solargraph 0.55.3 → 0.55.4
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/.github/workflows/typecheck.yml +1 -1
- data/CHANGELOG.md +4 -1
- data/lib/solargraph/api_map/store.rb +6 -3
- data/lib/solargraph/api_map.rb +97 -30
- data/lib/solargraph/complex_type/type_methods.rb +1 -0
- data/lib/solargraph/complex_type/unique_type.rb +3 -2
- data/lib/solargraph/doc_map.rb +3 -3
- data/lib/solargraph/gem_pins.rb +2 -1
- data/lib/solargraph/language_server/host.rb +2 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +1 -0
- data/lib/solargraph/logging.rb +1 -0
- data/lib/solargraph/parser/comment_ripper.rb +1 -0
- data/lib/solargraph/parser/flow_sensitive_typing.rb +2 -1
- data/lib/solargraph/parser/node_processor.rb +3 -1
- data/lib/solargraph/parser/parser_gem/node_methods.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/cvasgn_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +6 -3
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +4 -2
- 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 -3
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +28 -16
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +1 -0
- data/lib/solargraph/parser/region.rb +1 -1
- data/lib/solargraph/pin/base.rb +27 -4
- data/lib/solargraph/pin/callable.rb +5 -3
- data/lib/solargraph/pin/closure.rb +6 -1
- data/lib/solargraph/pin/common.rb +5 -0
- data/lib/solargraph/pin/delegated_method.rb +2 -0
- data/lib/solargraph/pin/documenting.rb +16 -0
- data/lib/solargraph/pin/keyword.rb +7 -2
- data/lib/solargraph/pin/method.rb +14 -9
- data/lib/solargraph/pin/namespace.rb +7 -2
- data/lib/solargraph/pin/parameter.rb +4 -0
- data/lib/solargraph/pin/proxy_type.rb +3 -3
- data/lib/solargraph/pin/reference/override.rb +10 -6
- data/lib/solargraph/pin/reference/require.rb +2 -2
- data/lib/solargraph/pin/signature.rb +4 -0
- data/lib/solargraph/pin/singleton.rb +1 -1
- data/lib/solargraph/pin/symbol.rb +3 -2
- data/lib/solargraph/pin.rb +1 -1
- data/lib/solargraph/rbs_map/conversions.rb +164 -48
- data/lib/solargraph/rbs_map/core_fills.rb +24 -15
- data/lib/solargraph/rbs_map/core_map.rb +3 -2
- data/lib/solargraph/shell.rb +1 -0
- data/lib/solargraph/source/chain/array.rb +7 -4
- 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 +8 -7
- data/lib/solargraph/source/chain/hash.rb +1 -1
- data/lib/solargraph/source/chain/head.rb +1 -1
- data/lib/solargraph/source/chain/if.rb +1 -1
- data/lib/solargraph/source/chain/literal.rb +2 -2
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain.rb +2 -2
- data/lib/solargraph/source_map/mapper.rb +9 -5
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map/mapper/to_constant.rb +4 -2
- data/lib/solargraph/yard_map/mapper/to_method.rb +14 -1
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +4 -2
- data/lib/solargraph/yard_map/mapper.rb +4 -3
- data/lib/solargraph/yard_map/to_method.rb +4 -2
- data/lib/solargraph.rb +19 -0
- data/rbs/fills/tuple.rbs +150 -0
- metadata +3 -2
@@ -9,7 +9,7 @@ module Solargraph
|
|
9
9
|
# @note Chain::Head is only intended to handle `self` and `super`.
|
10
10
|
class Head < Link
|
11
11
|
def resolve api_map, name_pin, locals
|
12
|
-
return [Pin::ProxyType.anonymous(name_pin.binder)] if word == 'self'
|
12
|
+
return [Pin::ProxyType.anonymous(name_pin.binder, source: :chain)] if word == 'self'
|
13
13
|
# return super_pins(api_map, name_pin) if word == 'super'
|
14
14
|
[]
|
15
15
|
end
|
@@ -20,7 +20,7 @@ module Solargraph
|
|
20
20
|
|
21
21
|
def resolve api_map, name_pin, locals
|
22
22
|
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(', ')))]
|
23
|
+
[Solargraph::Pin::ProxyType.anonymous(Solargraph::ComplexType.try_parse(types.map(&:tag).uniq.join(', ')), source: :chain)]
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -36,10 +36,10 @@ module Solargraph
|
|
36
36
|
|
37
37
|
def resolve api_map, name_pin, locals
|
38
38
|
if api_map.super_and_sub?(@complex_type.name, @literal_type.name)
|
39
|
-
[Pin::ProxyType.anonymous(@literal_type)]
|
39
|
+
[Pin::ProxyType.anonymous(@literal_type, source: :chain)]
|
40
40
|
else
|
41
41
|
# we don't support this value as a literal type
|
42
|
-
[Pin::ProxyType.anonymous(@complex_type)]
|
42
|
+
[Pin::ProxyType.anonymous(@complex_type, source: :chain)]
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -15,7 +15,7 @@ module Solargraph
|
|
15
15
|
|
16
16
|
def resolve api_map, name_pin, locals
|
17
17
|
types = @links.map { |link| link.infer(api_map, name_pin, locals) }
|
18
|
-
[Solargraph::Pin::ProxyType.anonymous(Solargraph::ComplexType.new(types.uniq))]
|
18
|
+
[Solargraph::Pin::ProxyType.anonymous(Solargraph::ComplexType.new(types.uniq), source: :chain)]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -122,7 +122,7 @@ module Solargraph
|
|
122
122
|
# evaluation. However, we use the last link's return type
|
123
123
|
# for the binder, as this is chaining off of it, and the
|
124
124
|
# binder is now the lhs of the rhs we are evaluating.
|
125
|
-
working_pin = Pin::ProxyType.anonymous(name_pin.context, binder: type, closure: name_pin)
|
125
|
+
working_pin = Pin::ProxyType.anonymous(name_pin.context, binder: type, closure: name_pin, source: :chain)
|
126
126
|
logger.debug { "Chain#define(links=#{links.map(&:desc)}, name_pin=#{name_pin.inspect}, locals=#{locals}) - after processing #{link.desc}, new working_pin=#{working_pin} with binder #{working_pin.binder}" }
|
127
127
|
end
|
128
128
|
links.last.last_context = working_pin
|
@@ -130,7 +130,7 @@ module Solargraph
|
|
130
130
|
end
|
131
131
|
|
132
132
|
# @param api_map [ApiMap]
|
133
|
-
# @param name_pin [Pin::Base]
|
133
|
+
# @param name_pin [Pin::Base] The pin for the closure in which this code runs
|
134
134
|
# @param locals [::Array<Pin::LocalVariable>]
|
135
135
|
# @return [ComplexType]
|
136
136
|
# @sg-ignore
|
@@ -41,7 +41,7 @@ module Solargraph
|
|
41
41
|
s = Position.new(0, 0)
|
42
42
|
e = Position.from_offset(code, code.length)
|
43
43
|
location = Location.new(filename, Range.new(s, e))
|
44
|
-
[[Pin::Namespace.new(location: location, name: '')], []]
|
44
|
+
[[Pin::Namespace.new(location: location, name: '', source: :source_map)], []]
|
45
45
|
end
|
46
46
|
|
47
47
|
class << self
|
@@ -55,6 +55,7 @@ module Solargraph
|
|
55
55
|
|
56
56
|
# @return [Array<Solargraph::Pin::Base>]
|
57
57
|
def pins
|
58
|
+
# @type [Array<Solargraph::Pin::Base>]
|
58
59
|
@pins ||= []
|
59
60
|
end
|
60
61
|
|
@@ -140,7 +141,8 @@ module Solargraph
|
|
140
141
|
scope: namespace.is_a?(Pin::Singleton) ? :class : :instance,
|
141
142
|
visibility: :public,
|
142
143
|
explicit: false,
|
143
|
-
attribute: true
|
144
|
+
attribute: true,
|
145
|
+
source: :source_map
|
144
146
|
)
|
145
147
|
end
|
146
148
|
if t.nil? || t.include?('w')
|
@@ -151,10 +153,11 @@ module Solargraph
|
|
151
153
|
comments: docstring.all.to_s,
|
152
154
|
scope: namespace.is_a?(Pin::Singleton) ? :class : :instance,
|
153
155
|
visibility: :public,
|
154
|
-
attribute: true
|
156
|
+
attribute: true,
|
157
|
+
source: :source_map
|
155
158
|
)
|
156
159
|
pins.push method_pin
|
157
|
-
method_pin.parameters.push Pin::Parameter.new(name: 'value', decl: :arg, closure: pins.last)
|
160
|
+
method_pin.parameters.push Pin::Parameter.new(name: 'value', decl: :arg, closure: pins.last, source: :source_map)
|
158
161
|
if pins.last.return_type.defined?
|
159
162
|
pins.last.docstring.add_tag YARD::Tags::Tag.new(:param, '', pins.last.return_type.to_s.split(', '), 'value')
|
160
163
|
end
|
@@ -205,7 +208,8 @@ module Solargraph
|
|
205
208
|
namespace = closure_at(source_position) || Pin::ROOT_PIN
|
206
209
|
namespace.domains.concat directive.tag.types unless directive.tag.types.nil?
|
207
210
|
when 'override'
|
208
|
-
pins.push Pin::Reference::Override.new(location, directive.tag.name, docstring.tags
|
211
|
+
pins.push Pin::Reference::Override.new(location, directive.tag.name, docstring.tags,
|
212
|
+
source: :source_map)
|
209
213
|
when 'macro'
|
210
214
|
# @todo Handle macros
|
211
215
|
end
|
data/lib/solargraph/version.rb
CHANGED
@@ -10,14 +10,16 @@ module Solargraph
|
|
10
10
|
def self.make code_object, closure = nil, spec = nil
|
11
11
|
closure ||= Solargraph::Pin::Namespace.new(
|
12
12
|
name: code_object.namespace.to_s,
|
13
|
-
gates: [code_object.namespace.to_s]
|
13
|
+
gates: [code_object.namespace.to_s],
|
14
|
+
source: :yardoc,
|
14
15
|
)
|
15
16
|
Pin::Constant.new(
|
16
17
|
location: object_location(code_object, spec),
|
17
18
|
closure: closure,
|
18
19
|
name: code_object.name.to_s,
|
19
20
|
comments: code_object.docstring ? code_object.docstring.all.to_s : '',
|
20
|
-
visibility: code_object.visibility
|
21
|
+
visibility: code_object.visibility,
|
22
|
+
source: :yardoc
|
21
23
|
)
|
22
24
|
end
|
23
25
|
end
|
@@ -6,6 +6,11 @@ module Solargraph
|
|
6
6
|
module ToMethod
|
7
7
|
extend YardMap::Helpers
|
8
8
|
|
9
|
+
VISIBILITY_OVERRIDE = {
|
10
|
+
# YARD pays attention to 'private' statements prior to class methods but shouldn't
|
11
|
+
["Rails::Engine", :class, "find_root_with_flag"] => :public
|
12
|
+
}
|
13
|
+
|
9
14
|
# @param code_object [YARD::CodeObjects::Base]
|
10
15
|
# @param name [String, nil]
|
11
16
|
# @param scope [Symbol, nil]
|
@@ -25,7 +30,14 @@ module Solargraph
|
|
25
30
|
return_type = ComplexType::SELF if name == 'new'
|
26
31
|
comments = code_object.docstring ? code_object.docstring.all.to_s : ''
|
27
32
|
final_scope = scope || code_object.scope
|
28
|
-
|
33
|
+
override_key = [closure.path, final_scope, name]
|
34
|
+
final_visibility = VISIBILITY_OVERRIDE[override_key]
|
35
|
+
final_visibility ||= VISIBILITY_OVERRIDE[override_key[0..-2]]
|
36
|
+
final_visibility ||= :private if closure.path == 'Kernel' && Kernel.private_instance_methods(false).include?(name)
|
37
|
+
final_visibility ||= visibility
|
38
|
+
final_visibility ||= :private if code_object.module_function? && final_scope == :instance
|
39
|
+
final_visibility ||= :public if code_object.module_function? && final_scope == :class
|
40
|
+
final_visibility ||= code_object.visibility
|
29
41
|
if code_object.is_alias?
|
30
42
|
origin_code_object = code_object.namespace.aliases[code_object]
|
31
43
|
pin = Pin::MethodAlias.new(
|
@@ -57,6 +69,7 @@ module Solargraph
|
|
57
69
|
source: :yardoc,
|
58
70
|
)
|
59
71
|
pin.parameters.concat get_parameters(code_object, location, comments, pin)
|
72
|
+
pin.parameters.freeze
|
60
73
|
end
|
61
74
|
logger.debug { "ToMethod.make: Just created method pin: #{pin.inspect}" }
|
62
75
|
pin
|
@@ -11,7 +11,8 @@ module Solargraph
|
|
11
11
|
closure ||= Solargraph::Pin::Namespace.new(
|
12
12
|
name: code_object.namespace.to_s,
|
13
13
|
closure: Pin::ROOT_PIN,
|
14
|
-
gates: [code_object.namespace.to_s]
|
14
|
+
gates: [code_object.namespace.to_s],
|
15
|
+
source: :yardoc,
|
15
16
|
)
|
16
17
|
Pin::Namespace.new(
|
17
18
|
location: object_location(code_object, spec),
|
@@ -19,7 +20,8 @@ module Solargraph
|
|
19
20
|
comments: code_object.docstring ? code_object.docstring.all.to_s : '',
|
20
21
|
type: code_object.is_a?(YARD::CodeObjects::ClassObject) ? :class : :module,
|
21
22
|
visibility: code_object.visibility,
|
22
|
-
closure: closure
|
23
|
+
closure: closure,
|
24
|
+
source: :yardoc,
|
23
25
|
)
|
24
26
|
end
|
25
27
|
end
|
@@ -47,15 +47,16 @@ module Solargraph
|
|
47
47
|
else
|
48
48
|
code_object.superclass.to_s
|
49
49
|
end
|
50
|
-
result.push Solargraph::Pin::Reference::Superclass.new(name: superclass, closure: nspin)
|
50
|
+
result.push Solargraph::Pin::Reference::Superclass.new(name: superclass, closure: nspin, source: :yard_map)
|
51
51
|
end
|
52
52
|
code_object.class_mixins.each do |m|
|
53
|
-
result.push Solargraph::Pin::Reference::Extend.new(closure: nspin, name: m.path)
|
53
|
+
result.push Solargraph::Pin::Reference::Extend.new(closure: nspin, name: m.path, source: :yard_map)
|
54
54
|
end
|
55
55
|
code_object.instance_mixins.each do |m|
|
56
56
|
result.push Solargraph::Pin::Reference::Include.new(
|
57
57
|
closure: nspin, # @todo Fix this
|
58
|
-
name: m.path
|
58
|
+
name: m.path,
|
59
|
+
source: :yard_map
|
59
60
|
)
|
60
61
|
end
|
61
62
|
elsif code_object.is_a?(YARD::CodeObjects::MethodObject)
|
@@ -23,7 +23,8 @@ module Solargraph
|
|
23
23
|
name: arg_name(a),
|
24
24
|
presence: nil,
|
25
25
|
decl: arg_type(a),
|
26
|
-
asgn_code: a[1]
|
26
|
+
asgn_code: a[1],
|
27
|
+
source: :yard_map
|
27
28
|
)
|
28
29
|
end
|
29
30
|
end
|
@@ -78,7 +79,8 @@ module Solargraph
|
|
78
79
|
scope: scope || code_object.scope,
|
79
80
|
visibility: visibility || code_object.visibility,
|
80
81
|
parameters: InnerMethods.get_parameters(code_object, location, comments),
|
81
|
-
explicit: code_object.is_explicit
|
82
|
+
explicit: code_object.is_explicit?,
|
83
|
+
source: :yard_map
|
82
84
|
)
|
83
85
|
end
|
84
86
|
end
|
data/lib/solargraph.rb
CHANGED
@@ -53,6 +53,25 @@ module Solargraph
|
|
53
53
|
dir = File.dirname(__FILE__)
|
54
54
|
VIEWS_PATH = File.join(dir, 'solargraph', 'views')
|
55
55
|
|
56
|
+
# @param type [Symbol] Type of assert. Not used yet, but may be
|
57
|
+
# used in the future to allow configurable asserts mixes for
|
58
|
+
# different situations.
|
59
|
+
def self.asserts_on?(type)
|
60
|
+
@asserts_on ||= if ENV['SOLARGRAPH_ASSERTS'].nil? || ENV['SOLARGRAPH_ASSERTS'].empty?
|
61
|
+
false
|
62
|
+
elsif ENV['SOLARGRAPH_ASSERTS'] == 'on'
|
63
|
+
true
|
64
|
+
else
|
65
|
+
logger.warn "Unrecognized SOLARGRAPH_ASSERTS value: #{ENV['SOLARGRAPH_ASSERTS']}"
|
66
|
+
false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.assert_or_log(type, msg = nil, &block)
|
71
|
+
raise (msg || block.call) if asserts_on?(type) && ![:combine_with_visibility].include?(type)
|
72
|
+
logger.info msg, &block
|
73
|
+
end
|
74
|
+
|
56
75
|
# A convenience method for Solargraph::Logging.logger.
|
57
76
|
#
|
58
77
|
# @return [Logger]
|
data/rbs/fills/tuple.rbs
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
# <-- liberally borrowed from
|
2
|
+
# https://github.com/ruby/rbs/blob/master/core/array.rbs, which
|
3
|
+
# was generated from
|
4
|
+
# https://github.com/ruby/ruby/blob/master/array.c
|
5
|
+
# -->
|
6
|
+
module Solargraph
|
7
|
+
module Fills
|
8
|
+
class Tuple[unchecked out A,
|
9
|
+
unchecked out B = A,
|
10
|
+
unchecked out C = A | B,
|
11
|
+
unchecked out D = A | B | C,
|
12
|
+
unchecked out E = A | B | C | D,
|
13
|
+
unchecked out F = A | B | C | D | E,
|
14
|
+
unchecked out G = A | B | C | D | E | F,
|
15
|
+
unchecked out H = A | B | C | D | E | F | G,
|
16
|
+
unchecked out I = A | B | C | D | E | F | G | H,
|
17
|
+
unchecked out J = A | B | C | D | E | F | G | H | I] < Array[A | B | C | D | E | F | G | H | I | J]
|
18
|
+
# <!--
|
19
|
+
# rdoc-file=array.c
|
20
|
+
# - self[index] -> object or nil
|
21
|
+
# -->
|
22
|
+
# Returns elements from `self`; does not modify `self`.
|
23
|
+
#
|
24
|
+
# In brief:
|
25
|
+
#
|
26
|
+
# a = [:foo, 'bar', 2]
|
27
|
+
#
|
28
|
+
# # Single argument index: returns one element.
|
29
|
+
# a[0] # => :foo # Zero-based index.
|
30
|
+
#
|
31
|
+
# When a single integer argument `index` is given, returns the element at offset
|
32
|
+
# `index`:
|
33
|
+
#
|
34
|
+
# a = [:foo, 'bar', 2]
|
35
|
+
# a[0] # => :foo
|
36
|
+
# a[2] # => 2
|
37
|
+
# a # => [:foo, "bar", 2]
|
38
|
+
def []: (0 index) -> A
|
39
|
+
| (1 index) -> B
|
40
|
+
| (2 index) -> C
|
41
|
+
| (3 index) -> D
|
42
|
+
| (4 index) -> E
|
43
|
+
| (5 index) -> F
|
44
|
+
| (6 index) -> G
|
45
|
+
| (7 index) -> H
|
46
|
+
| (8 index) -> I
|
47
|
+
| (9 index) -> J
|
48
|
+
| (0 index) -> K
|
49
|
+
| (int index) -> nil
|
50
|
+
|
51
|
+
# <!--
|
52
|
+
# rdoc-file=array.c
|
53
|
+
# - at(index) -> object or nil
|
54
|
+
# -->
|
55
|
+
# Returns the element of `self` specified by the given `index` or `nil` if there
|
56
|
+
# is no such element; `index` must be an [integer-convertible
|
57
|
+
# object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
|
58
|
+
#
|
59
|
+
# For non-negative `index`, returns the element of `self` at offset `index`:
|
60
|
+
#
|
61
|
+
# a = [:foo, 'bar', 2]
|
62
|
+
# a.at(0) # => :foo
|
63
|
+
# a.at(2) # => 2
|
64
|
+
# a.at(2.0) # => 2
|
65
|
+
#
|
66
|
+
# Related: Array#[]; see also [Methods for
|
67
|
+
# Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
68
|
+
#
|
69
|
+
def at: (0 index) -> A
|
70
|
+
| (1 index) -> B
|
71
|
+
| (2 index) -> C
|
72
|
+
| (3 index) -> D
|
73
|
+
| (4 index) -> E
|
74
|
+
| (5 index) -> F
|
75
|
+
| (6 index) -> G
|
76
|
+
| (7 index) -> H
|
77
|
+
| (8 index) -> I
|
78
|
+
| (9 index) -> J
|
79
|
+
| (int index) -> nil
|
80
|
+
|
81
|
+
# <!--
|
82
|
+
# rdoc-file=array.c
|
83
|
+
# - fetch(index) -> element
|
84
|
+
# - fetch(index, default_value) -> element or default_value
|
85
|
+
# - fetch(index) {|index| ... } -> element or block_return_value
|
86
|
+
# -->
|
87
|
+
# Returns the element of `self` at offset `index` if `index` is in range;
|
88
|
+
# `index` must be an [integer-convertible
|
89
|
+
# object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
|
90
|
+
#
|
91
|
+
# With the single argument `index` and no block, returns the element at offset
|
92
|
+
# `index`:
|
93
|
+
#
|
94
|
+
# a = [:foo, 'bar', 2]
|
95
|
+
# a.fetch(1) # => "bar"
|
96
|
+
# a.fetch(1.1) # => "bar"
|
97
|
+
#
|
98
|
+
# With arguments `index` and `default_value` (which may be any object) and no
|
99
|
+
# block, returns `default_value` if `index` is out-of-range:
|
100
|
+
#
|
101
|
+
# a = [:foo, 'bar', 2]
|
102
|
+
# a.fetch(1, nil) # => "bar"
|
103
|
+
# a.fetch(3, :foo) # => :foo
|
104
|
+
#
|
105
|
+
# With argument `index` and a block, returns the element at offset `index` if
|
106
|
+
# index is in range (and the block is not called); otherwise calls the block
|
107
|
+
# with index and returns its return value:
|
108
|
+
#
|
109
|
+
# a = [:foo, 'bar', 2]
|
110
|
+
# a.fetch(1) {|index| raise 'Cannot happen' } # => "bar"
|
111
|
+
# a.fetch(50) {|index| "Value for #{index}" } # => "Value for 50"
|
112
|
+
#
|
113
|
+
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
114
|
+
#
|
115
|
+
def fetch: (0 index) -> A
|
116
|
+
| (1 index) -> B
|
117
|
+
| (2 index) -> C
|
118
|
+
| (3 index) -> D
|
119
|
+
| (4 index) -> E
|
120
|
+
| (5 index) -> F
|
121
|
+
| (6 index) -> G
|
122
|
+
| (7 index) -> H
|
123
|
+
| (8 index) -> I
|
124
|
+
| (9 index) -> J
|
125
|
+
| (int index) -> void
|
126
|
+
| [T] (0 index, T default) -> (A | T)
|
127
|
+
| [T] (1 index, T default) -> (B | T)
|
128
|
+
| [T] (2 index, T default) -> (C | T)
|
129
|
+
| [T] (3 index, T default) -> (D | T)
|
130
|
+
| [T] (4 index, T default) -> (E | T)
|
131
|
+
| [T] (5 index, T default) -> (F | T)
|
132
|
+
| [T] (6 index, T default) -> (G | T)
|
133
|
+
| [T] (7 index, T default) -> (H | T)
|
134
|
+
| [T] (8 index, T default) -> (I | T)
|
135
|
+
| [T] (9 index, T default) -> (J | T)
|
136
|
+
| [T] (int index, T default) -> (A | B | C | D | E | F |G | H | I | J | T)
|
137
|
+
| [T] (0 index) { (int index) -> T } -> (A | T)
|
138
|
+
| [T] (1 index) { (int index) -> T } -> (B | T)
|
139
|
+
| [T] (2 index) { (int index) -> T } -> (C | T)
|
140
|
+
| [T] (3 index) { (int index) -> T } -> (D | T)
|
141
|
+
| [T] (4 index) { (int index) -> T } -> (E | T)
|
142
|
+
| [T] (5 index) { (int index) -> T } -> (F | T)
|
143
|
+
| [T] (6 index) { (int index) -> T } -> (G | T)
|
144
|
+
| [T] (7 index) { (int index) -> T } -> (H | T)
|
145
|
+
| [T] (8 index) { (int index) -> T } -> (I | T)
|
146
|
+
| [T] (9 index) { (int index) -> T } -> (J | T)
|
147
|
+
| [T] (int index) { (int index) -> T } -> (A | B | C | D | E | F |G | H | I | J | T)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.55.
|
4
|
+
version: 0.55.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-06-
|
11
|
+
date: 2025-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -631,6 +631,7 @@ files:
|
|
631
631
|
- lib/solargraph/yard_map/to_method.rb
|
632
632
|
- lib/solargraph/yard_tags.rb
|
633
633
|
- lib/solargraph/yardoc.rb
|
634
|
+
- rbs/fills/tuple.rbs
|
634
635
|
- solargraph.gemspec
|
635
636
|
homepage: https://solargraph.org
|
636
637
|
licenses:
|