solargraph 0.54.1 → 0.54.3
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 +17 -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 +48 -120
- data/lib/solargraph/api_map.rb +76 -20
- data/lib/solargraph/complex_type/type_methods.rb +7 -0
- data/lib/solargraph/complex_type/unique_type.rb +21 -1
- data/lib/solargraph/complex_type.rb +13 -12
- 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 +23 -6
- 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/formatting.rb +4 -0
- data/lib/solargraph/library.rb +3 -2
- data/lib/solargraph/location.rb +7 -0
- data/lib/solargraph/parser/node_methods.rb +1 -1
- data/lib/solargraph/parser/node_processor.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +3 -3
- data/lib/solargraph/parser/parser_gem/node_methods.rb +2 -2
- data/lib/solargraph/pin/base.rb +28 -18
- data/lib/solargraph/pin/base_variable.rb +3 -2
- data/lib/solargraph/pin/block.rb +1 -3
- data/lib/solargraph/pin/callable.rb +3 -3
- data/lib/solargraph/pin/method.rb +6 -0
- data/lib/solargraph/pin/namespace.rb +1 -1
- data/lib/solargraph/pin/parameter.rb +2 -1
- data/lib/solargraph/position.rb +7 -0
- data/lib/solargraph/range.rb +7 -0
- data/lib/solargraph/rbs_map/conversions.rb +8 -2
- data/lib/solargraph/rbs_map.rb +1 -0
- data/lib/solargraph/shell.rb +2 -0
- data/lib/solargraph/source/chain/array.rb +1 -1
- data/lib/solargraph/source/chain/call.rb +15 -8
- 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 +17 -5
- data/lib/solargraph/source/chain/literal.rb +5 -0
- data/lib/solargraph/source/chain.rb +33 -19
- data/lib/solargraph/source/cursor.rb +2 -1
- data/lib/solargraph/source.rb +2 -1
- data/lib/solargraph/source_map/clip.rb +1 -1
- data/lib/solargraph/type_checker.rb +8 -8
- data/lib/solargraph/version.rb +1 -1
- 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.rb +1 -0
- data/solargraph.gemspec +5 -5
- metadata +26 -24
@@ -31,6 +31,10 @@ module Solargraph
|
|
31
31
|
@anon_splat = anon_splat
|
32
32
|
end
|
33
33
|
|
34
|
+
def == other
|
35
|
+
super && other.node == node
|
36
|
+
end
|
37
|
+
|
34
38
|
def transform_types(&transform)
|
35
39
|
# @todo 'super' alone should work here I think, but doesn't typecheck at level typed
|
36
40
|
m = super(&transform)
|
@@ -262,6 +266,7 @@ module Solargraph
|
|
262
266
|
@attribute
|
263
267
|
end
|
264
268
|
|
269
|
+
# @parm other [Method]
|
265
270
|
def nearly? other
|
266
271
|
super &&
|
267
272
|
parameters == other.parameters &&
|
@@ -273,6 +278,7 @@ module Solargraph
|
|
273
278
|
attribute? ? infer_from_iv(api_map) : infer_from_return_nodes(api_map)
|
274
279
|
end
|
275
280
|
|
281
|
+
# @param pin [Pin::Method]
|
276
282
|
def try_merge! pin
|
277
283
|
return false unless super
|
278
284
|
@node = pin.node
|
@@ -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]
|
@@ -121,6 +121,7 @@ module Solargraph
|
|
121
121
|
tag.text
|
122
122
|
end
|
123
123
|
|
124
|
+
# @param pin [Pin::Parameter]
|
124
125
|
def try_merge! pin
|
125
126
|
return false unless super && closure == pin.closure
|
126
127
|
true
|
data/lib/solargraph/position.rb
CHANGED
@@ -4,6 +4,8 @@ module Solargraph
|
|
4
4
|
# The zero-based line and column numbers of a position in a string.
|
5
5
|
#
|
6
6
|
class Position
|
7
|
+
include Equality
|
8
|
+
|
7
9
|
# @return [Integer]
|
8
10
|
attr_reader :line
|
9
11
|
|
@@ -19,6 +21,11 @@ module Solargraph
|
|
19
21
|
@character = character
|
20
22
|
end
|
21
23
|
|
24
|
+
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
25
|
+
protected def equality_fields
|
26
|
+
[line, character]
|
27
|
+
end
|
28
|
+
|
22
29
|
# Get a hash of the position. This representation is suitable for use in
|
23
30
|
# the language server protocol.
|
24
31
|
#
|
data/lib/solargraph/range.rb
CHANGED
@@ -4,6 +4,8 @@ module Solargraph
|
|
4
4
|
# A pair of Positions that compose a section of text in code.
|
5
5
|
#
|
6
6
|
class Range
|
7
|
+
include Equality
|
8
|
+
|
7
9
|
# @return [Position]
|
8
10
|
attr_reader :start
|
9
11
|
|
@@ -17,6 +19,11 @@ module Solargraph
|
|
17
19
|
@ending = ending
|
18
20
|
end
|
19
21
|
|
22
|
+
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
23
|
+
protected def equality_fields
|
24
|
+
[start, ending]
|
25
|
+
end
|
26
|
+
|
20
27
|
# Get a hash of the range. This representation is suitable for use in
|
21
28
|
# the language server protocol.
|
22
29
|
#
|
@@ -80,9 +80,12 @@ module Solargraph
|
|
80
80
|
# @param closure [Pin::Namespace]
|
81
81
|
# @return [void]
|
82
82
|
def convert_self_type_to_pins decl, closure
|
83
|
+
type = build_type(decl.name, decl.args)
|
84
|
+
generic_values = type.all_params.map(&:to_s)
|
83
85
|
include_pin = Solargraph::Pin::Reference::Include.new(
|
84
86
|
name: decl.name.relative!.to_s,
|
85
87
|
type_location: location_decl_to_pin_location(decl.location),
|
88
|
+
generic_values: generic_values,
|
86
89
|
closure: closure
|
87
90
|
)
|
88
91
|
pins.push include_pin
|
@@ -318,7 +321,7 @@ module Solargraph
|
|
318
321
|
# @return [void]
|
319
322
|
def method_def_to_sigs decl, pin
|
320
323
|
decl.overloads.map do |overload|
|
321
|
-
generics = overload.method_type.type_params.map(&:to_s)
|
324
|
+
generics = overload.method_type.type_params.map(&:name).map(&:to_s)
|
322
325
|
signature_parameters, signature_return_type = parts_of_function(overload.method_type, pin)
|
323
326
|
block = if overload.method_type.block
|
324
327
|
block_parameters, block_return_type = parts_of_function(overload.method_type.block, pin)
|
@@ -628,9 +631,12 @@ module Solargraph
|
|
628
631
|
def add_mixins decl, namespace
|
629
632
|
decl.each_mixin do |mixin|
|
630
633
|
klass = mixin.is_a?(RBS::AST::Members::Include) ? Pin::Reference::Include : Pin::Reference::Extend
|
634
|
+
type = build_type(mixin.name, mixin.args)
|
635
|
+
generic_values = type.all_params.map(&:to_s)
|
631
636
|
pins.push klass.new(
|
632
637
|
name: mixin.name.relative!.to_s,
|
633
|
-
|
638
|
+
type_location: location_decl_to_pin_location(mixin.location),
|
639
|
+
generic_values: generic_values,
|
634
640
|
closure: namespace
|
635
641
|
)
|
636
642
|
end
|
data/lib/solargraph/rbs_map.rb
CHANGED
data/lib/solargraph/shell.rb
CHANGED
@@ -111,6 +111,7 @@ module Solargraph
|
|
111
111
|
also be specified to clear cached system documentation.
|
112
112
|
Documentation will be regenerated as needed.
|
113
113
|
)
|
114
|
+
# @param gems [Array<String>]
|
114
115
|
# @return [void]
|
115
116
|
def uncache *gems
|
116
117
|
raise ArgumentError, 'No gems specified.' if gems.empty?
|
@@ -133,6 +134,7 @@ module Solargraph
|
|
133
134
|
|
134
135
|
desc 'gems [GEM[=VERSION]]', 'Cache documentation for installed gems'
|
135
136
|
option :rebuild, type: :boolean, desc: 'Rebuild existing documentation', default: false
|
137
|
+
# @param names [Array<String>]
|
136
138
|
# @return [void]
|
137
139
|
def gems *names
|
138
140
|
if names.empty?
|
@@ -14,7 +14,7 @@ module Solargraph
|
|
14
14
|
|
15
15
|
# @param api_map [ApiMap]
|
16
16
|
# @param name_pin [Pin::Base]
|
17
|
-
# @param locals [
|
17
|
+
# @param locals [::Array<Pin::Parameter, Pin::LocalVariable>]
|
18
18
|
def resolve api_map, name_pin, locals
|
19
19
|
child_types = @children.map do |child|
|
20
20
|
child.infer(api_map, name_pin, locals)
|
@@ -25,6 +25,11 @@ module Solargraph
|
|
25
25
|
fix_block_pass
|
26
26
|
end
|
27
27
|
|
28
|
+
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
29
|
+
protected def equality_fields
|
30
|
+
super + [arguments, block]
|
31
|
+
end
|
32
|
+
|
28
33
|
def with_block?
|
29
34
|
!!@block
|
30
35
|
end
|
@@ -42,8 +47,8 @@ module Solargraph
|
|
42
47
|
end
|
43
48
|
return inferred_pins(found, api_map, name_pin, locals) unless found.empty?
|
44
49
|
pins = name_pin.binder.each_unique_type.flat_map do |context|
|
45
|
-
|
46
|
-
api_map.get_method_stack(
|
50
|
+
ns = context.namespace == '' ? '' : context.namespace_type.tag
|
51
|
+
api_map.get_method_stack(ns, word, scope: context.scope)
|
47
52
|
end
|
48
53
|
return [] if pins.empty?
|
49
54
|
inferred_pins(pins, api_map, name_pin, locals)
|
@@ -54,7 +59,7 @@ module Solargraph
|
|
54
59
|
# @param pins [::Enumerable<Pin::Method>]
|
55
60
|
# @param api_map [ApiMap]
|
56
61
|
# @param name_pin [Pin::Base]
|
57
|
-
# @param locals [::Array<Pin::LocalVariable>]
|
62
|
+
# @param locals [::Array<Solargraph::Pin::LocalVariable, Solargraph::Pin::Parameter>]
|
58
63
|
# @return [::Array<Pin::Base>]
|
59
64
|
def inferred_pins pins, api_map, name_pin, locals
|
60
65
|
result = pins.map do |p|
|
@@ -81,10 +86,12 @@ module Solargraph
|
|
81
86
|
break
|
82
87
|
end
|
83
88
|
atype = atypes[idx] ||= arg.infer(api_map, Pin::ProxyType.anonymous(name_pin.context), locals)
|
84
|
-
|
89
|
+
# make sure we get types from up the method
|
90
|
+
# inheritance chain if we don't have them on this pin
|
91
|
+
ptype = param.typify api_map
|
85
92
|
# @todo Weak type comparison
|
86
93
|
# unless atype.tag == param.return_type.tag || api_map.super_and_sub?(param.return_type.tag, atype.tag)
|
87
|
-
unless
|
94
|
+
unless ptype.undefined? || atype.name == ptype.name || ptype.any? { |current_ptype| api_map.super_and_sub?(current_ptype.name, atype.name) } || ptype.generic? || param.restarg?
|
88
95
|
match = false
|
89
96
|
break
|
90
97
|
end
|
@@ -132,7 +139,7 @@ module Solargraph
|
|
132
139
|
# @param pin [Pin::Base]
|
133
140
|
# @param api_map [ApiMap]
|
134
141
|
# @param context [ComplexType]
|
135
|
-
# @param locals [
|
142
|
+
# @param locals [::Array<Solargraph::Pin::LocalVariable, Solargraph::Pin::Parameter>]
|
136
143
|
# @return [Pin::Base]
|
137
144
|
def process_macro pin, api_map, context, locals
|
138
145
|
pin.macros.each do |macro|
|
@@ -151,7 +158,7 @@ module Solargraph
|
|
151
158
|
# @param pin [Pin::Method]
|
152
159
|
# @param api_map [ApiMap]
|
153
160
|
# @param context [ComplexType]
|
154
|
-
# @param locals [
|
161
|
+
# @param locals [::Array<Solargraph::Pin::LocalVariable, Solargraph::Pin::Parameter>]
|
155
162
|
# @return [Pin::ProxyType]
|
156
163
|
def process_directive pin, api_map, context, locals
|
157
164
|
pin.directives.each do |dir|
|
@@ -167,7 +174,7 @@ module Solargraph
|
|
167
174
|
# @param macro [YARD::Tags::MacroDirective]
|
168
175
|
# @param api_map [ApiMap]
|
169
176
|
# @param context [ComplexType]
|
170
|
-
# @param locals [
|
177
|
+
# @param locals [::Array<Pin::LocalVariable, Pin::Parameter>]
|
171
178
|
# @return [Pin::ProxyType]
|
172
179
|
def inner_process_macro pin, macro, api_map, context, locals
|
173
180
|
vals = arguments.map{ |c| Pin::ProxyType.anonymous(c.infer(api_map, pin, locals)) }
|
@@ -13,6 +13,11 @@ module Solargraph
|
|
13
13
|
@links = links
|
14
14
|
end
|
15
15
|
|
16
|
+
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
17
|
+
protected def equality_fields
|
18
|
+
super + [@links]
|
19
|
+
end
|
20
|
+
|
16
21
|
def resolve api_map, name_pin, locals
|
17
22
|
types = @links.map { |link| link.infer(api_map, name_pin, locals) }
|
18
23
|
[Solargraph::Pin::ProxyType.anonymous(Solargraph::ComplexType.try_parse(types.map(&:tag).uniq.join(', ')))]
|
@@ -4,6 +4,8 @@ module Solargraph
|
|
4
4
|
class Source
|
5
5
|
class Chain
|
6
6
|
class Link
|
7
|
+
include Equality
|
8
|
+
|
7
9
|
# @return [String]
|
8
10
|
attr_reader :word
|
9
11
|
|
@@ -15,6 +17,11 @@ module Solargraph
|
|
15
17
|
@word = word
|
16
18
|
end
|
17
19
|
|
20
|
+
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
21
|
+
protected def equality_fields
|
22
|
+
[self.class, word]
|
23
|
+
end
|
24
|
+
|
18
25
|
def undefined?
|
19
26
|
word == '<undefined>'
|
20
27
|
end
|
@@ -31,18 +38,23 @@ module Solargraph
|
|
31
38
|
[]
|
32
39
|
end
|
33
40
|
|
41
|
+
# debugging description of contents; not for machine use
|
42
|
+
def desc
|
43
|
+
word
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
desc
|
48
|
+
end
|
49
|
+
|
34
50
|
def inspect
|
35
|
-
"
|
51
|
+
"#<#{self.class} - `#{self.desc}`>"
|
36
52
|
end
|
37
53
|
|
38
54
|
def head?
|
39
55
|
@head ||= false
|
40
56
|
end
|
41
57
|
|
42
|
-
def == other
|
43
|
-
self.class == other.class and word == other.word
|
44
|
-
end
|
45
|
-
|
46
58
|
# Make a copy of this link marked as the head of a chain
|
47
59
|
#
|
48
60
|
# @return [self]
|
@@ -14,6 +14,11 @@ module Solargraph
|
|
14
14
|
@complex_type = ComplexType.try_parse(type)
|
15
15
|
end
|
16
16
|
|
17
|
+
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
18
|
+
protected def equality_fields
|
19
|
+
super + [@value, @type, @literal_type, @complex_type]
|
20
|
+
end
|
21
|
+
|
17
22
|
def resolve api_map, name_pin, locals
|
18
23
|
[Pin::ProxyType.anonymous(@complex_type)]
|
19
24
|
end
|
@@ -14,10 +14,8 @@ module Solargraph
|
|
14
14
|
# expression.
|
15
15
|
#
|
16
16
|
class Chain
|
17
|
-
|
18
|
-
|
19
|
-
# values.
|
20
|
-
#
|
17
|
+
include Equality
|
18
|
+
|
21
19
|
autoload :Link, 'solargraph/source/chain/link'
|
22
20
|
autoload :Call, 'solargraph/source/chain/call'
|
23
21
|
autoload :QCall, 'solargraph/source/chain/q_call'
|
@@ -49,6 +47,11 @@ module Solargraph
|
|
49
47
|
|
50
48
|
attr_reader :node
|
51
49
|
|
50
|
+
# @sg-ignore Fix "Not enough arguments to Module#protected"
|
51
|
+
protected def equality_fields
|
52
|
+
[links, node]
|
53
|
+
end
|
54
|
+
|
52
55
|
# @param node [Parser::AST::Node, nil]
|
53
56
|
# @param links [::Array<Chain::Link>]
|
54
57
|
# @param splat [Boolean]
|
@@ -107,26 +110,27 @@ module Solargraph
|
|
107
110
|
end
|
108
111
|
|
109
112
|
# @param api_map [ApiMap]
|
110
|
-
# @param name_pin [Pin::Base]
|
111
|
-
# @param locals [::
|
113
|
+
# @param name_pin [Pin::Base]
|
114
|
+
# @param locals [::Array<Pin::LocalVariable>]
|
112
115
|
# @return [ComplexType]
|
113
116
|
# @sg-ignore
|
114
117
|
def infer api_map, name_pin, locals
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
@@inference_cache = {}
|
118
|
+
cache_key = [node, node&.location, links, name_pin&.return_type, locals]
|
119
|
+
if @@inference_invalidation_key == api_map.hash
|
120
|
+
cached = @@inference_cache[cache_key]
|
121
|
+
return cached if cached
|
122
|
+
else
|
121
123
|
@@inference_invalidation_key = api_map.hash
|
124
|
+
@@inference_cache = {}
|
122
125
|
end
|
123
|
-
|
124
|
-
|
126
|
+
out = infer_uncached api_map, name_pin, locals
|
127
|
+
logger.debug { "Chain#infer() - caching result - cache_key_hash=#{cache_key.hash}, links.map(&:hash)=#{links.map(&:hash)}, links=#{links}, cache_key.map(&:hash) = #{cache_key.map(&:hash)}, cache_key=#{cache_key}" }
|
128
|
+
@@inference_cache[cache_key] = out
|
125
129
|
end
|
126
130
|
|
127
131
|
# @param api_map [ApiMap]
|
128
132
|
# @param name_pin [Pin::Base]
|
129
|
-
# @param locals [::
|
133
|
+
# @param locals [::Array<Pin::LocalVariable>]
|
130
134
|
# @return [ComplexType]
|
131
135
|
def infer_uncached api_map, name_pin, locals
|
132
136
|
pins = define(api_map, name_pin, locals)
|
@@ -160,6 +164,16 @@ module Solargraph
|
|
160
164
|
links.any?(&:nullable?)
|
161
165
|
end
|
162
166
|
|
167
|
+
include Logging
|
168
|
+
|
169
|
+
def desc
|
170
|
+
links.map(&:desc).to_s
|
171
|
+
end
|
172
|
+
|
173
|
+
def to_s
|
174
|
+
desc
|
175
|
+
end
|
176
|
+
|
163
177
|
private
|
164
178
|
|
165
179
|
# @param pins [::Array<Pin::Base>]
|
@@ -174,9 +188,9 @@ module Solargraph
|
|
174
188
|
# @param pin [Pin::Base]
|
175
189
|
pins.each do |pin|
|
176
190
|
# Avoid infinite recursion
|
177
|
-
next if @@inference_stack.include?(pin
|
191
|
+
next if @@inference_stack.include?(pin)
|
178
192
|
|
179
|
-
@@inference_stack.push pin
|
193
|
+
@@inference_stack.push pin
|
180
194
|
type = pin.typify(api_map)
|
181
195
|
@@inference_stack.pop
|
182
196
|
if type.defined?
|
@@ -200,9 +214,9 @@ module Solargraph
|
|
200
214
|
# @param pin [Pin::Base]
|
201
215
|
pins.each do |pin|
|
202
216
|
# Avoid infinite recursion
|
203
|
-
next if @@inference_stack.include?(pin
|
217
|
+
next if @@inference_stack.include?(pin)
|
204
218
|
|
205
|
-
@@inference_stack.push pin
|
219
|
+
@@inference_stack.push pin
|
206
220
|
type = pin.probe(api_map)
|
207
221
|
@@inference_stack.pop
|
208
222
|
if type.defined?
|
@@ -35,6 +35,7 @@ module Solargraph
|
|
35
35
|
# The part of the word before the current position. Given the text
|
36
36
|
# `foo.bar`, the start_of_word at position(0, 6) is `ba`.
|
37
37
|
#
|
38
|
+
# @sg-ignore Improve resolution of String#match below
|
38
39
|
# @return [String]
|
39
40
|
def start_of_word
|
40
41
|
@start_of_word ||= begin
|
@@ -111,7 +112,7 @@ module Solargraph
|
|
111
112
|
#
|
112
113
|
# @return [Boolean]
|
113
114
|
def assign?
|
114
|
-
[
|
115
|
+
%i[lvasgn ivasgn gvasgn cvasgn].include? chain&.node&.type
|
115
116
|
end
|
116
117
|
|
117
118
|
# Get a cursor pointing to the method that receives the current statement
|
data/lib/solargraph/source.rb
CHANGED
@@ -307,7 +307,7 @@ module Solargraph
|
|
307
307
|
|
308
308
|
# A hash of line numbers and their associated comments.
|
309
309
|
#
|
310
|
-
# @return [Hash{Integer => Array<String
|
310
|
+
# @return [Hash{Integer => Array<String>, nil}]
|
311
311
|
def stringified_comments
|
312
312
|
@stringified_comments ||= {}
|
313
313
|
end
|
@@ -375,6 +375,7 @@ module Solargraph
|
|
375
375
|
|
376
376
|
protected
|
377
377
|
|
378
|
+
# @return [Array<Change>]
|
378
379
|
def changes
|
379
380
|
@changes ||= []
|
380
381
|
end
|
@@ -29,6 +29,7 @@ module Solargraph
|
|
29
29
|
# @todo Smarter directory resolution
|
30
30
|
@api_map = api_map || Solargraph::ApiMap.load(File.dirname(filename))
|
31
31
|
@rules = Rules.new(level)
|
32
|
+
# @type [Array<Range>]
|
32
33
|
@marked_ranges = []
|
33
34
|
end
|
34
35
|
|
@@ -413,7 +414,7 @@ module Solargraph
|
|
413
414
|
# @param locals [Array<Pin::LocalVariable>]
|
414
415
|
# @param location [Location]
|
415
416
|
# @param pin [Pin::Method]
|
416
|
-
# @param params [Hash{String =>
|
417
|
+
# @param params [Hash{String => Hash{Symbol => String, Solargraph::ComplexType}}]
|
417
418
|
# @param idx [Integer]
|
418
419
|
#
|
419
420
|
# @return [Array<Problem>]
|
@@ -467,10 +468,11 @@ module Solargraph
|
|
467
468
|
end
|
468
469
|
|
469
470
|
# @param pin [Pin::Method]
|
470
|
-
# @return [Hash{String => Hash{Symbol =>
|
471
|
+
# @return [Hash{String => Hash{Symbol => String, ComplexType}}]
|
471
472
|
def param_hash(pin)
|
472
473
|
tags = pin.docstring.tags(:param)
|
473
474
|
return {} if tags.empty?
|
475
|
+
# @type [Hash{String => Hash{Symbol => String, ComplexType}}]
|
474
476
|
result = {}
|
475
477
|
tags.each do |tag|
|
476
478
|
next if tag.types.nil? || tag.types.empty?
|
@@ -483,11 +485,9 @@ module Solargraph
|
|
483
485
|
end
|
484
486
|
|
485
487
|
# @param pins [Array<Pin::Method>]
|
486
|
-
# @return [Hash{String => Hash{Symbol =>
|
488
|
+
# @return [Hash{String => Hash{Symbol => String, ComplexType}}]
|
487
489
|
def first_param_hash(pins)
|
488
490
|
pins.each do |pin|
|
489
|
-
# @todo this assignment from parametric use of Hash should not lose its generic
|
490
|
-
# @type [Hash{String => Hash{Symbol => BasicObject}}]
|
491
491
|
result = param_hash(pin)
|
492
492
|
return result unless result.empty?
|
493
493
|
end
|
@@ -512,7 +512,7 @@ module Solargraph
|
|
512
512
|
!internal? pin
|
513
513
|
end
|
514
514
|
|
515
|
-
# @param pin [Pin::
|
515
|
+
# @param pin [Pin::BaseVariable]
|
516
516
|
def declared_externally? pin
|
517
517
|
return true if pin.assignment.nil?
|
518
518
|
chain = Solargraph::Parser.chain(pin.assignment, filename)
|
@@ -562,7 +562,7 @@ module Solargraph
|
|
562
562
|
return [] unless pin.explicit?
|
563
563
|
return [] if parameters.empty? && arguments.empty?
|
564
564
|
return [] if pin.anon_splat?
|
565
|
-
unchecked = arguments.
|
565
|
+
unchecked = arguments.dup # creates copy of and unthaws array
|
566
566
|
add_params = 0
|
567
567
|
if unchecked.empty? && parameters.any? { |param| param.decl == :kwarg }
|
568
568
|
return [Problem.new(location, "Missing keyword arguments to #{pin.path}")]
|
@@ -638,7 +638,7 @@ module Solargraph
|
|
638
638
|
(pin.closure && pin.closure.docstring.has_tag?('abstract'))
|
639
639
|
end
|
640
640
|
|
641
|
-
# @param pin [Pin::
|
641
|
+
# @param pin [Pin::Method]
|
642
642
|
# @return [Array<Source::Chain>]
|
643
643
|
def fake_args_for(pin)
|
644
644
|
args = []
|
data/lib/solargraph/version.rb
CHANGED
@@ -15,7 +15,7 @@ module Solargraph
|
|
15
15
|
attr_reader :directory
|
16
16
|
|
17
17
|
# @todo To make this strongly typed we'll need a record syntax
|
18
|
-
# @return [Hash{String =>
|
18
|
+
# @return [Hash{String => Array, Hash, Integer, nil}]
|
19
19
|
attr_reader :raw_data
|
20
20
|
|
21
21
|
# @param directory [String]
|
@@ -90,6 +90,7 @@ module Solargraph
|
|
90
90
|
|
91
91
|
# A hash of options supported by the formatter
|
92
92
|
#
|
93
|
+
# @sg-ignore pending https://github.com/castwide/solargraph/pull/905
|
93
94
|
# @return [Hash]
|
94
95
|
def formatter
|
95
96
|
raw_data['formatter']
|
@@ -104,6 +105,7 @@ module Solargraph
|
|
104
105
|
|
105
106
|
# The maximum number of files to parse from the workspace.
|
106
107
|
#
|
108
|
+
# @sg-ignore pending https://github.com/castwide/solargraph/pull/905
|
107
109
|
# @return [Integer]
|
108
110
|
def max_files
|
109
111
|
raw_data['max_files']
|
@@ -123,7 +125,7 @@ module Solargraph
|
|
123
125
|
File.join(@directory, '.solargraph.yml')
|
124
126
|
end
|
125
127
|
|
126
|
-
# @return [Hash{String => Array
|
128
|
+
# @return [Hash{String => Array<undefined>, Hash{String => undefined}, Integer}]
|
127
129
|
def config_data
|
128
130
|
workspace_config = read_config(workspace_config_path)
|
129
131
|
global_config = read_config(global_config_path)
|
@@ -226,7 +228,9 @@ module Solargraph
|
|
226
228
|
|
227
229
|
# @return [Array<String>]
|
228
230
|
def excluded_directories
|
229
|
-
@
|
231
|
+
# @type [Array<String>]
|
232
|
+
excluded = @raw_data['exclude']
|
233
|
+
excluded
|
230
234
|
.select { |g| glob_is_directory?(g) }
|
231
235
|
.map { |g| File.absolute_path(glob_to_directory(g), directory) }
|
232
236
|
end
|
data/lib/solargraph/workspace.rb
CHANGED
@@ -45,7 +45,7 @@ module Solargraph
|
|
45
45
|
# or add it to the sources if the workspace is configured to include it.
|
46
46
|
# The source is ignored if the configuration excludes it.
|
47
47
|
#
|
48
|
-
# @param
|
48
|
+
# @param sources [Array<Solargraph::Source>]
|
49
49
|
# @return [Boolean] True if the source was added to the workspace
|
50
50
|
def merge *sources
|
51
51
|
unless directory == '*' || sources.all? { |source| source_hash.key?(source.filename) }
|
data/lib/solargraph.rb
CHANGED
@@ -42,6 +42,7 @@ module Solargraph
|
|
42
42
|
autoload :Logging, 'solargraph/logging'
|
43
43
|
autoload :TypeChecker, 'solargraph/type_checker'
|
44
44
|
autoload :Environ, 'solargraph/environ'
|
45
|
+
autoload :Equality, 'solargraph/equality'
|
45
46
|
autoload :Convention, 'solargraph/convention'
|
46
47
|
autoload :Parser, 'solargraph/parser'
|
47
48
|
autoload :RbsMap, 'solargraph/rbs_map'
|