solargraph 0.56.2 → 0.58.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/.github/workflows/linting.yml +127 -0
- data/.github/workflows/plugins.yml +183 -7
- data/.github/workflows/rspec.yml +55 -5
- data/.github/workflows/typecheck.yml +6 -3
- data/.gitignore +5 -0
- data/.overcommit.yml +72 -0
- data/.rspec +1 -0
- data/.rubocop.yml +66 -0
- data/.rubocop_todo.yml +1279 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +69 -0
- data/README.md +8 -4
- data/Rakefile +125 -13
- data/bin/solargraph +8 -5
- data/lib/solargraph/api_map/cache.rb +3 -2
- data/lib/solargraph/api_map/constants.rb +279 -0
- data/lib/solargraph/api_map/index.rb +49 -31
- data/lib/solargraph/api_map/source_to_yard.rb +13 -4
- data/lib/solargraph/api_map/store.rb +144 -26
- data/lib/solargraph/api_map.rb +217 -245
- data/lib/solargraph/bench.rb +1 -0
- data/lib/solargraph/complex_type/type_methods.rb +6 -0
- data/lib/solargraph/complex_type/unique_type.rb +19 -12
- data/lib/solargraph/complex_type.rb +24 -3
- data/lib/solargraph/convention/active_support_concern.rb +111 -0
- data/lib/solargraph/convention/base.rb +17 -0
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +1 -0
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +4 -2
- data/lib/solargraph/convention/data_definition.rb +2 -1
- data/lib/solargraph/convention/gemspec.rb +1 -1
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +1 -0
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +3 -1
- data/lib/solargraph/convention/struct_definition.rb +36 -13
- data/lib/solargraph/convention.rb +31 -2
- data/lib/solargraph/diagnostics/rubocop.rb +6 -1
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +5 -3
- data/lib/solargraph/doc_map.rb +44 -13
- data/lib/solargraph/environ.rb +9 -2
- data/lib/solargraph/equality.rb +1 -0
- data/lib/solargraph/gem_pins.rb +21 -11
- data/lib/solargraph/language_server/host/dispatch.rb +2 -0
- data/lib/solargraph/language_server/host/message_worker.rb +3 -0
- data/lib/solargraph/language_server/host.rb +12 -5
- data/lib/solargraph/language_server/message/base.rb +2 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/definition.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/formatting.rb +19 -2
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +1 -0
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +2 -0
- data/lib/solargraph/language_server/progress.rb +8 -0
- data/lib/solargraph/language_server/request.rb +4 -1
- data/lib/solargraph/library.rb +11 -18
- data/lib/solargraph/location.rb +3 -0
- data/lib/solargraph/logging.rb +11 -2
- data/lib/solargraph/page.rb +3 -0
- data/lib/solargraph/parser/comment_ripper.rb +8 -1
- data/lib/solargraph/parser/flow_sensitive_typing.rb +33 -5
- data/lib/solargraph/parser/node_processor/base.rb +1 -1
- data/lib/solargraph/parser/node_processor.rb +6 -2
- data/lib/solargraph/parser/parser_gem/class_methods.rb +3 -13
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +3 -1
- data/lib/solargraph/parser/parser_gem/node_methods.rb +5 -16
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +3 -2
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +2 -0
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +3 -0
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +64 -8
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +12 -3
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +36 -16
- data/lib/solargraph/parser/region.rb +3 -0
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/pin/base.rb +77 -14
- data/lib/solargraph/pin/base_variable.rb +6 -5
- data/lib/solargraph/pin/block.rb +3 -2
- data/lib/solargraph/pin/callable.rb +14 -1
- data/lib/solargraph/pin/closure.rb +5 -7
- data/lib/solargraph/pin/common.rb +6 -2
- data/lib/solargraph/pin/constant.rb +2 -0
- data/lib/solargraph/pin/local_variable.rb +1 -2
- data/lib/solargraph/pin/method.rb +28 -9
- data/lib/solargraph/pin/method_alias.rb +3 -0
- data/lib/solargraph/pin/parameter.rb +24 -10
- data/lib/solargraph/pin/proxy_type.rb +5 -1
- data/lib/solargraph/pin/reference/override.rb +15 -1
- data/lib/solargraph/pin/reference/superclass.rb +5 -0
- data/lib/solargraph/pin/reference.rb +17 -0
- data/lib/solargraph/pin/search.rb +6 -1
- data/lib/solargraph/pin/signature.rb +2 -0
- data/lib/solargraph/pin/symbol.rb +5 -0
- data/lib/solargraph/pin_cache.rb +64 -4
- data/lib/solargraph/position.rb +3 -0
- data/lib/solargraph/range.rb +5 -0
- data/lib/solargraph/rbs_map/conversions.rb +29 -6
- data/lib/solargraph/rbs_map/core_fills.rb +18 -0
- data/lib/solargraph/rbs_map/core_map.rb +14 -7
- data/lib/solargraph/rbs_map.rb +14 -1
- data/lib/solargraph/shell.rb +85 -1
- data/lib/solargraph/source/chain/call.rb +7 -3
- data/lib/solargraph/source/chain/constant.rb +3 -66
- data/lib/solargraph/source/chain/if.rb +1 -1
- data/lib/solargraph/source/chain/link.rb +11 -2
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain.rb +11 -2
- data/lib/solargraph/source/change.rb +2 -2
- data/lib/solargraph/source/cursor.rb +2 -3
- data/lib/solargraph/source/source_chainer.rb +1 -1
- data/lib/solargraph/source.rb +6 -3
- data/lib/solargraph/source_map/clip.rb +18 -26
- data/lib/solargraph/source_map/data.rb +4 -0
- data/lib/solargraph/source_map/mapper.rb +2 -2
- data/lib/solargraph/source_map.rb +28 -16
- data/lib/solargraph/type_checker/param_def.rb +2 -0
- data/lib/solargraph/type_checker/rules.rb +30 -8
- data/lib/solargraph/type_checker.rb +301 -186
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +21 -5
- data/lib/solargraph/workspace/require_paths.rb +97 -0
- data/lib/solargraph/workspace.rb +30 -67
- data/lib/solargraph/yard_map/mapper/to_method.rb +4 -3
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +1 -0
- data/lib/solargraph/yard_map/to_method.rb +2 -1
- data/lib/solargraph/yardoc.rb +39 -3
- data/lib/solargraph.rb +2 -0
- data/rbs/fills/bundler/0/bundler.rbs +4271 -0
- data/rbs/fills/open3/0/open3.rbs +172 -0
- data/rbs/fills/rubygems/0/basic_specification.rbs +326 -0
- data/rbs/fills/rubygems/0/errors.rbs +364 -0
- data/rbs/fills/rubygems/0/spec_fetcher.rbs +107 -0
- data/rbs/fills/rubygems/0/specification.rbs +1753 -0
- data/rbs/fills/{tuple.rbs → tuple/tuple.rbs} +2 -3
- data/rbs_collection.yaml +4 -4
- data/sig/shims/ast/0/node.rbs +5 -0
- data/sig/shims/ast/2.4/.rbs_meta.yaml +9 -0
- data/sig/shims/ast/2.4/ast.rbs +73 -0
- data/sig/shims/parser/3.2.0.1/builders/default.rbs +195 -0
- data/sig/shims/parser/3.2.0.1/manifest.yaml +7 -0
- data/sig/shims/parser/3.2.0.1/parser.rbs +201 -0
- data/sig/shims/parser/3.2.0.1/polyfill.rbs +4 -0
- data/sig/shims/thor/1.2.0.1/.rbs_meta.yaml +9 -0
- data/sig/shims/thor/1.2.0.1/manifest.yaml +7 -0
- data/sig/shims/thor/1.2.0.1/thor.rbs +17 -0
- data/solargraph.gemspec +26 -5
- metadata +181 -13
- data/lib/.rubocop.yml +0 -22
- data/lib/solargraph/parser/node_methods.rb +0 -97
|
@@ -17,12 +17,13 @@ module Solargraph
|
|
|
17
17
|
|
|
18
18
|
# @param visibility [::Symbol] :public, :protected, or :private
|
|
19
19
|
# @param explicit [Boolean]
|
|
20
|
-
# @param block [Pin::Signature, nil,
|
|
20
|
+
# @param block [Pin::Signature, nil, :undefined]
|
|
21
21
|
# @param node [Parser::AST::Node, nil]
|
|
22
22
|
# @param attribute [Boolean]
|
|
23
23
|
# @param signatures [::Array<Signature>, nil]
|
|
24
24
|
# @param anon_splat [Boolean]
|
|
25
|
-
def initialize visibility: :public, explicit: true, block: :undefined, node: nil, attribute: false, signatures: nil, anon_splat: false,
|
|
25
|
+
def initialize visibility: :public, explicit: true, block: :undefined, node: nil, attribute: false, signatures: nil, anon_splat: false,
|
|
26
|
+
**splat
|
|
26
27
|
super(**splat)
|
|
27
28
|
@visibility = visibility
|
|
28
29
|
@explicit = explicit
|
|
@@ -33,14 +34,18 @@ module Solargraph
|
|
|
33
34
|
@anon_splat = anon_splat
|
|
34
35
|
end
|
|
35
36
|
|
|
37
|
+
# @param signature_pins [Array<Pin::Signature>]
|
|
36
38
|
# @return [Array<Pin::Signature>]
|
|
37
39
|
def combine_all_signature_pins(*signature_pins)
|
|
40
|
+
# @type [Hash{Array => Array<Pin::Signature>}]
|
|
38
41
|
by_arity = {}
|
|
39
42
|
signature_pins.each do |signature_pin|
|
|
40
43
|
by_arity[signature_pin.arity] ||= []
|
|
41
44
|
by_arity[signature_pin.arity] << signature_pin
|
|
42
45
|
end
|
|
43
46
|
by_arity.transform_values! do |same_arity_pins|
|
|
47
|
+
# @param memo [Pin::Signature, nil]
|
|
48
|
+
# @param signature [Pin::Signature]
|
|
44
49
|
same_arity_pins.reduce(nil) do |memo, signature|
|
|
45
50
|
next signature if memo.nil?
|
|
46
51
|
memo.combine_with(signature)
|
|
@@ -50,7 +55,7 @@ module Solargraph
|
|
|
50
55
|
end
|
|
51
56
|
|
|
52
57
|
# @param other [Pin::Method]
|
|
53
|
-
# @return [Symbol]
|
|
58
|
+
# @return [::Symbol]
|
|
54
59
|
def combine_visibility(other)
|
|
55
60
|
if dodgy_visibility_source? && !other.dodgy_visibility_source?
|
|
56
61
|
other.visibility
|
|
@@ -76,6 +81,9 @@ module Solargraph
|
|
|
76
81
|
end
|
|
77
82
|
|
|
78
83
|
def combine_with(other, attrs = {})
|
|
84
|
+
priority_choice = choose_priority(other)
|
|
85
|
+
return priority_choice unless priority_choice.nil?
|
|
86
|
+
|
|
79
87
|
sigs = combine_signatures(other)
|
|
80
88
|
parameters = if sigs.length > 0
|
|
81
89
|
[].freeze
|
|
@@ -84,6 +92,7 @@ module Solargraph
|
|
|
84
92
|
end
|
|
85
93
|
new_attrs = {
|
|
86
94
|
visibility: combine_visibility(other),
|
|
95
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1050
|
|
87
96
|
explicit: explicit? || other.explicit?,
|
|
88
97
|
block: combine_blocks(other),
|
|
89
98
|
node: choose_node(other, :node),
|
|
@@ -294,14 +303,13 @@ module Solargraph
|
|
|
294
303
|
type = see_reference(api_map) || typify_from_super(api_map)
|
|
295
304
|
logger.debug { "Method#typify(self=#{self}) - type=#{type&.rooted_tags.inspect}" }
|
|
296
305
|
unless type.nil?
|
|
297
|
-
qualified = type.qualify(api_map,
|
|
306
|
+
qualified = type.qualify(api_map, *closure.gates)
|
|
298
307
|
logger.debug { "Method#typify(self=#{self}) => #{qualified.rooted_tags.inspect}" }
|
|
299
308
|
return qualified
|
|
300
309
|
end
|
|
301
310
|
super
|
|
302
311
|
end
|
|
303
312
|
|
|
304
|
-
# @sg-ignore
|
|
305
313
|
def documentation
|
|
306
314
|
if @documentation.nil?
|
|
307
315
|
method_docs ||= super || ''
|
|
@@ -373,11 +381,14 @@ module Solargraph
|
|
|
373
381
|
@attribute
|
|
374
382
|
end
|
|
375
383
|
|
|
376
|
-
# @parm other [
|
|
384
|
+
# @parm other [self]
|
|
377
385
|
def nearly? other
|
|
378
386
|
super &&
|
|
387
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1050
|
|
379
388
|
parameters == other.parameters &&
|
|
389
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1050
|
|
380
390
|
scope == other.scope &&
|
|
391
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1050
|
|
381
392
|
visibility == other.visibility
|
|
382
393
|
end
|
|
383
394
|
|
|
@@ -389,9 +400,12 @@ module Solargraph
|
|
|
389
400
|
def overloads
|
|
390
401
|
# Ignore overload tags with nil parameters. If it's not an array, the
|
|
391
402
|
# tag's source is likely malformed.
|
|
403
|
+
|
|
404
|
+
# @param tag [YARD::Tags::OverloadTag]
|
|
392
405
|
@overloads ||= docstring.tags(:overload).select(&:parameters).map do |tag|
|
|
393
406
|
Pin::Signature.new(
|
|
394
407
|
generics: generics,
|
|
408
|
+
# @param src [Array(String, String)]
|
|
395
409
|
parameters: tag.parameters.map do |src|
|
|
396
410
|
name, decl = parse_overload_param(src.first)
|
|
397
411
|
Pin::Parameter.new(
|
|
@@ -425,7 +439,7 @@ module Solargraph
|
|
|
425
439
|
@resolved_ref_tag = true
|
|
426
440
|
return self unless docstring.ref_tags.any?
|
|
427
441
|
docstring.ref_tags.each do |tag|
|
|
428
|
-
ref = if tag.owner.to_s.start_with?(/[
|
|
442
|
+
ref = if tag.owner.to_s.start_with?(/[#.]/)
|
|
429
443
|
api_map.get_methods(namespace)
|
|
430
444
|
.select { |pin| pin.path.end_with?(tag.owner.to_s) }
|
|
431
445
|
.first
|
|
@@ -504,6 +518,7 @@ module Solargraph
|
|
|
504
518
|
#
|
|
505
519
|
# @return [ComplexType]
|
|
506
520
|
def param_type_from_name(tag, name)
|
|
521
|
+
# @param t [YARD::Tags::Tag]
|
|
507
522
|
param = tag.tags(:param).select { |t| t.name == name }.first
|
|
508
523
|
return ComplexType::UNDEFINED unless param
|
|
509
524
|
ComplexType.try_parse(*param.types)
|
|
@@ -519,8 +534,12 @@ module Solargraph
|
|
|
519
534
|
# @param api_map [ApiMap]
|
|
520
535
|
# @return [ComplexType, nil]
|
|
521
536
|
def see_reference api_map
|
|
537
|
+
# This should actually be an intersection type
|
|
538
|
+
# @param ref [YARD::Tags::Tag, Solargraph::Yard::Tags::RefTag]
|
|
522
539
|
docstring.ref_tags.each do |ref|
|
|
540
|
+
# @sg-ignore ref should actually be an intersection type
|
|
523
541
|
next unless ref.tag_name == 'return' && ref.owner
|
|
542
|
+
# @sg-ignore ref should actually be an intersection type
|
|
524
543
|
result = resolve_reference(ref.owner.to_s, api_map)
|
|
525
544
|
return result unless result.nil?
|
|
526
545
|
end
|
|
@@ -549,11 +568,11 @@ module Solargraph
|
|
|
549
568
|
# @param api_map [ApiMap]
|
|
550
569
|
# @return [ComplexType, nil]
|
|
551
570
|
def resolve_reference ref, api_map
|
|
552
|
-
parts = ref.split(/[
|
|
571
|
+
parts = ref.split(/[.#]/)
|
|
553
572
|
if parts.first.empty? || parts.one?
|
|
554
573
|
path = "#{namespace}#{ref}"
|
|
555
574
|
else
|
|
556
|
-
fqns = api_map.qualify(parts.first,
|
|
575
|
+
fqns = api_map.qualify(parts.first, *gates)
|
|
557
576
|
return ComplexType::UNDEFINED if fqns.nil?
|
|
558
577
|
path = fqns + ref[parts.first.length] + parts.last
|
|
559
578
|
end
|
|
@@ -13,6 +13,9 @@ module Solargraph
|
|
|
13
13
|
# @return [String]
|
|
14
14
|
attr_reader :original
|
|
15
15
|
|
|
16
|
+
# @param scope [::Symbol]
|
|
17
|
+
# @param original [String, nil] The name of the original method
|
|
18
|
+
# @param splat [Hash] Additional options supported by superclasses
|
|
16
19
|
def initialize scope: :instance, original: nil, **splat
|
|
17
20
|
super(**splat)
|
|
18
21
|
@scope = scope
|
|
@@ -105,15 +105,13 @@ module Solargraph
|
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
# @return [String]
|
|
109
|
-
|
|
108
|
+
# @return [String] the full name of the parameter, including any
|
|
109
|
+
# declarative symbols such as `*` or `:` indicating type of
|
|
110
|
+
# parameter. This is used in method signatures.
|
|
111
|
+
def full_name
|
|
110
112
|
case decl
|
|
111
|
-
when :
|
|
112
|
-
"#{name} = #{asgn_code || '?'}"
|
|
113
|
-
when :kwarg
|
|
113
|
+
when :kwarg, :kwoptarg
|
|
114
114
|
"#{name}:"
|
|
115
|
-
when :kwoptarg
|
|
116
|
-
"#{name}: #{asgn_code || '?'}"
|
|
117
115
|
when :restarg
|
|
118
116
|
"*#{name}"
|
|
119
117
|
when :kwrestarg
|
|
@@ -125,6 +123,18 @@ module Solargraph
|
|
|
125
123
|
end
|
|
126
124
|
end
|
|
127
125
|
|
|
126
|
+
# @return [String]
|
|
127
|
+
def full
|
|
128
|
+
full_name + case decl
|
|
129
|
+
when :optarg
|
|
130
|
+
" = #{asgn_code || '?'}"
|
|
131
|
+
when :kwoptarg
|
|
132
|
+
" #{asgn_code || '?'}"
|
|
133
|
+
else
|
|
134
|
+
''
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
128
138
|
# @return [ComplexType]
|
|
129
139
|
def return_type
|
|
130
140
|
if @return_type.nil?
|
|
@@ -156,7 +166,7 @@ module Solargraph
|
|
|
156
166
|
|
|
157
167
|
# @param api_map [ApiMap]
|
|
158
168
|
def typify api_map
|
|
159
|
-
return return_type.qualify(api_map, closure.
|
|
169
|
+
return return_type.qualify(api_map, *closure.gates) unless return_type.undefined?
|
|
160
170
|
closure.is_a?(Pin::Block) ? typify_block_param(api_map) : typify_method_param(api_map)
|
|
161
171
|
end
|
|
162
172
|
|
|
@@ -212,7 +222,7 @@ module Solargraph
|
|
|
212
222
|
if found.nil? and !index.nil?
|
|
213
223
|
found = params[index] if params[index] && (params[index].name.nil? || params[index].name.empty?)
|
|
214
224
|
end
|
|
215
|
-
return ComplexType.try_parse(*found.types).qualify(api_map, meth.
|
|
225
|
+
return ComplexType.try_parse(*found.types).qualify(api_map, *meth.closure.gates) unless found.nil? || found.types.nil?
|
|
216
226
|
end
|
|
217
227
|
ComplexType::UNDEFINED
|
|
218
228
|
end
|
|
@@ -222,8 +232,12 @@ module Solargraph
|
|
|
222
232
|
# @param skip [::Array]
|
|
223
233
|
# @return [::Array<YARD::Tags::Tag>]
|
|
224
234
|
def see_reference heredoc, api_map, skip = []
|
|
235
|
+
# This should actually be an intersection type
|
|
236
|
+
# @param ref [YARD::Tags::Tag, Solargraph::Yard::Tags::RefTag]
|
|
225
237
|
heredoc.ref_tags.each do |ref|
|
|
238
|
+
# @sg-ignore ref should actually be an intersection type
|
|
226
239
|
next unless ref.tag_name == 'param' && ref.owner
|
|
240
|
+
# @sg-ignore ref should actually be an intersection type
|
|
227
241
|
result = resolve_reference(ref.owner.to_s, api_map, skip)
|
|
228
242
|
return result unless result.nil?
|
|
229
243
|
end
|
|
@@ -237,7 +251,7 @@ module Solargraph
|
|
|
237
251
|
def resolve_reference ref, api_map, skip
|
|
238
252
|
return nil if skip.include?(ref)
|
|
239
253
|
skip.push ref
|
|
240
|
-
parts = ref.split(/[
|
|
254
|
+
parts = ref.split(/[.#]/)
|
|
241
255
|
if parts.first.empty?
|
|
242
256
|
path = "#{namespace}#{ref}"
|
|
243
257
|
else
|
|
@@ -4,8 +4,12 @@ module Solargraph
|
|
|
4
4
|
module Pin
|
|
5
5
|
class ProxyType < Base
|
|
6
6
|
# @param return_type [ComplexType]
|
|
7
|
-
|
|
7
|
+
# @param gates [Array<String>, nil] Namespaces to try while resolving non-rooted types
|
|
8
|
+
# @param binder [ComplexType, ComplexType::UniqueType, nil]
|
|
9
|
+
# @param gates [Array<String>, nil]
|
|
10
|
+
def initialize return_type: ComplexType::UNDEFINED, binder: nil, gates: nil, **splat
|
|
8
11
|
super(**splat)
|
|
12
|
+
@gates = gates
|
|
9
13
|
@return_type = return_type
|
|
10
14
|
@binder = binder if binder
|
|
11
15
|
end
|
|
@@ -14,16 +14,30 @@ module Solargraph
|
|
|
14
14
|
nil
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# @param location [Location, nil]
|
|
18
|
+
# @param name [String]
|
|
19
|
+
# @param tags [::Array<YARD::Tags::Tag>]
|
|
20
|
+
# @param delete [::Array<Symbol>]
|
|
21
|
+
# @param splat [Hash]
|
|
17
22
|
def initialize location, name, tags, delete = [], **splat
|
|
18
23
|
super(location: location, name: name, **splat)
|
|
19
24
|
@tags = tags
|
|
20
25
|
@delete = delete
|
|
21
26
|
end
|
|
22
27
|
|
|
28
|
+
# @param name [String]
|
|
29
|
+
# @param tags [::Array<String>]
|
|
30
|
+
# @param delete [::Array<Symbol>]
|
|
31
|
+
# @param splat [Hash]
|
|
32
|
+
# @return [Solargraph::Pin::Reference::Override]
|
|
23
33
|
def self.method_return name, *tags, delete: [], **splat
|
|
24
|
-
new(nil, name, [YARD::Tags::Tag.new('return',
|
|
34
|
+
new(nil, name, [YARD::Tags::Tag.new('return', '', tags)], delete, **splat)
|
|
25
35
|
end
|
|
26
36
|
|
|
37
|
+
# @param name [String]
|
|
38
|
+
# @param comment [String]
|
|
39
|
+
# @param splat [Hash]
|
|
40
|
+
# @return [Solargraph::Pin::Reference::Override]
|
|
27
41
|
def self.from_comment name, comment, **splat
|
|
28
42
|
new(nil, name, Solargraph::Source.parse_docstring(comment).to_docstring.tags, **splat)
|
|
29
43
|
end
|
|
@@ -17,6 +17,23 @@ module Solargraph
|
|
|
17
17
|
super(**splat)
|
|
18
18
|
@generic_values = generic_values
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
# @return [ComplexType]
|
|
22
|
+
def type
|
|
23
|
+
@type ||= ComplexType.try_parse(
|
|
24
|
+
name +
|
|
25
|
+
if generic_values&.length&.> 0
|
|
26
|
+
"<#{generic_values.join(', ')}>"
|
|
27
|
+
else
|
|
28
|
+
''
|
|
29
|
+
end
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @return [Array<String>]
|
|
34
|
+
def reference_gates
|
|
35
|
+
closure.gates
|
|
36
|
+
end
|
|
20
37
|
end
|
|
21
38
|
end
|
|
22
39
|
end
|
|
@@ -12,6 +12,8 @@ module Solargraph
|
|
|
12
12
|
# @return [Pin::Base]
|
|
13
13
|
attr_reader :pin
|
|
14
14
|
|
|
15
|
+
# @param match [Float] The match score for the pin
|
|
16
|
+
# @param pin [Pin::Base]
|
|
15
17
|
def initialize match, pin
|
|
16
18
|
@match = match
|
|
17
19
|
@pin = pin
|
|
@@ -40,6 +42,9 @@ module Solargraph
|
|
|
40
42
|
Result.new(match, pin) if match > 0.7
|
|
41
43
|
end
|
|
42
44
|
.compact
|
|
45
|
+
# @param a [self]
|
|
46
|
+
# @param b [self]
|
|
47
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1050
|
|
43
48
|
.sort { |a, b| b.match <=> a.match }
|
|
44
49
|
.map(&:pin)
|
|
45
50
|
end
|
|
@@ -48,7 +53,7 @@ module Solargraph
|
|
|
48
53
|
# @param str2 [String]
|
|
49
54
|
# @return [Float]
|
|
50
55
|
def fuzzy_string_match str1, str2
|
|
51
|
-
return
|
|
56
|
+
return 1.0 + (str2.length.to_f / str1.length.to_f) if str1.downcase.include?(str2.downcase)
|
|
52
57
|
JaroWinkler.similarity(str1, str2, ignore_case: true)
|
|
53
58
|
end
|
|
54
59
|
end
|
|
@@ -39,6 +39,8 @@ module Solargraph
|
|
|
39
39
|
end
|
|
40
40
|
return ComplexType::UNDEFINED if closure.nil?
|
|
41
41
|
return ComplexType::UNDEFINED unless closure.is_a?(Pin::Method)
|
|
42
|
+
# @sg-ignore need is_a? support
|
|
43
|
+
# @type [Array<Pin::Method>]
|
|
42
44
|
method_stack = closure.rest_of_stack api_map
|
|
43
45
|
logger.debug { "Signature#typify(self=#{self}) - method_stack: #{method_stack}" }
|
|
44
46
|
method_stack.each do |pin|
|
|
@@ -20,6 +20,10 @@ module Solargraph
|
|
|
20
20
|
''
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
def closure
|
|
24
|
+
@closure ||= Pin::ROOT_PIN
|
|
25
|
+
end
|
|
26
|
+
|
|
23
27
|
def completion_item_kind
|
|
24
28
|
Solargraph::LanguageServer::CompletionItemKinds::KEYWORD
|
|
25
29
|
end
|
|
@@ -36,6 +40,7 @@ module Solargraph
|
|
|
36
40
|
[]
|
|
37
41
|
end
|
|
38
42
|
|
|
43
|
+
# @return [::Symbol]
|
|
39
44
|
def visibility
|
|
40
45
|
:public
|
|
41
46
|
end
|
data/lib/solargraph/pin_cache.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require 'yard-activesupport-concern'
|
|
1
2
|
require 'fileutils'
|
|
2
3
|
require 'rbs'
|
|
3
4
|
|
|
@@ -26,98 +27,156 @@ module Solargraph
|
|
|
26
27
|
File.join(base_dir, "ruby-#{RUBY_VERSION}", "rbs-#{RBS::VERSION}", "solargraph-#{Solargraph::VERSION}")
|
|
27
28
|
end
|
|
28
29
|
|
|
30
|
+
# @param gemspec [Gem::Specification]
|
|
31
|
+
# @return [String]
|
|
29
32
|
def yardoc_path gemspec
|
|
30
|
-
File.join(base_dir,
|
|
33
|
+
File.join(base_dir,
|
|
34
|
+
"yard-#{YARD::VERSION}",
|
|
35
|
+
"yard-activesupport-concern-#{YARD::ActiveSupport::Concern::VERSION}",
|
|
36
|
+
"#{gemspec.name}-#{gemspec.version}.yardoc")
|
|
31
37
|
end
|
|
32
38
|
|
|
39
|
+
# @return [String]
|
|
33
40
|
def stdlib_path
|
|
34
41
|
File.join(work_dir, 'stdlib')
|
|
35
42
|
end
|
|
36
43
|
|
|
44
|
+
# @param require [String]
|
|
45
|
+
# @return [String]
|
|
37
46
|
def stdlib_require_path require
|
|
38
47
|
File.join(stdlib_path, "#{require}.ser")
|
|
39
48
|
end
|
|
40
49
|
|
|
50
|
+
# @param require [String]
|
|
51
|
+
# @return [Array<Pin::Base>, nil]
|
|
41
52
|
def deserialize_stdlib_require require
|
|
42
53
|
load(stdlib_require_path(require))
|
|
43
54
|
end
|
|
44
55
|
|
|
56
|
+
# @param require [String]
|
|
57
|
+
# @param pins [Array<Pin::Base>]
|
|
58
|
+
# @return [void]
|
|
45
59
|
def serialize_stdlib_require require, pins
|
|
46
60
|
save(stdlib_require_path(require), pins)
|
|
47
61
|
end
|
|
48
62
|
|
|
63
|
+
# @return [String]
|
|
49
64
|
def core_path
|
|
50
65
|
File.join(work_dir, 'core.ser')
|
|
51
66
|
end
|
|
52
67
|
|
|
68
|
+
# @return [Array<Pin::Base>, nil]
|
|
53
69
|
def deserialize_core
|
|
54
70
|
load(core_path)
|
|
55
71
|
end
|
|
56
72
|
|
|
73
|
+
# @param pins [Array<Pin::Base>]
|
|
74
|
+
# @return [void]
|
|
57
75
|
def serialize_core pins
|
|
58
76
|
save(core_path, pins)
|
|
59
77
|
end
|
|
60
78
|
|
|
79
|
+
# @param gemspec [Gem::Specification]
|
|
80
|
+
# @return [String]
|
|
61
81
|
def yard_gem_path gemspec
|
|
62
82
|
File.join(work_dir, 'yard', "#{gemspec.name}-#{gemspec.version}.ser")
|
|
63
83
|
end
|
|
64
84
|
|
|
85
|
+
# @param gemspec [Gem::Specification]
|
|
86
|
+
# @return [Array<Pin::Base>, nil]
|
|
65
87
|
def deserialize_yard_gem(gemspec)
|
|
66
88
|
load(yard_gem_path(gemspec))
|
|
67
89
|
end
|
|
68
90
|
|
|
91
|
+
# @param gemspec [Gem::Specification]
|
|
92
|
+
# @param pins [Array<Pin::Base>]
|
|
93
|
+
# @return [void]
|
|
69
94
|
def serialize_yard_gem(gemspec, pins)
|
|
70
95
|
save(yard_gem_path(gemspec), pins)
|
|
71
96
|
end
|
|
72
97
|
|
|
98
|
+
# @param gemspec [Gem::Specification]
|
|
99
|
+
# @return [Boolean]
|
|
73
100
|
def has_yard?(gemspec)
|
|
74
101
|
exist?(yard_gem_path(gemspec))
|
|
75
102
|
end
|
|
76
103
|
|
|
104
|
+
# @param gemspec [Gem::Specification]
|
|
105
|
+
# @param hash [String, nil]
|
|
106
|
+
# @return [String]
|
|
77
107
|
def rbs_collection_path(gemspec, hash)
|
|
78
108
|
File.join(work_dir, 'rbs', "#{gemspec.name}-#{gemspec.version}-#{hash || 0}.ser")
|
|
79
109
|
end
|
|
80
110
|
|
|
111
|
+
# @param gemspec [Gem::Specification]
|
|
112
|
+
# @return [String]
|
|
81
113
|
def rbs_collection_path_prefix(gemspec)
|
|
82
114
|
File.join(work_dir, 'rbs', "#{gemspec.name}-#{gemspec.version}-")
|
|
83
115
|
end
|
|
84
116
|
|
|
117
|
+
# @param gemspec [Gem::Specification]
|
|
118
|
+
# @param hash [String, nil]
|
|
119
|
+
# @return [Array<Pin::Base>, nil]
|
|
85
120
|
def deserialize_rbs_collection_gem(gemspec, hash)
|
|
86
121
|
load(rbs_collection_path(gemspec, hash))
|
|
87
122
|
end
|
|
88
123
|
|
|
124
|
+
# @param gemspec [Gem::Specification]
|
|
125
|
+
# @param hash [String, nil]
|
|
126
|
+
# @param pins [Array<Pin::Base>]n
|
|
127
|
+
# @return [void]
|
|
89
128
|
def serialize_rbs_collection_gem(gemspec, hash, pins)
|
|
90
129
|
save(rbs_collection_path(gemspec, hash), pins)
|
|
91
130
|
end
|
|
92
131
|
|
|
132
|
+
# @param gemspec [Gem::Specification]
|
|
133
|
+
# @param hash [String, nil]
|
|
134
|
+
# @return [String]
|
|
93
135
|
def combined_path(gemspec, hash)
|
|
94
136
|
File.join(work_dir, 'combined', "#{gemspec.name}-#{gemspec.version}-#{hash || 0}.ser")
|
|
95
137
|
end
|
|
96
138
|
|
|
139
|
+
# @param gemspec [Gem::Specification]
|
|
140
|
+
# @return [String]
|
|
97
141
|
def combined_path_prefix(gemspec)
|
|
98
142
|
File.join(work_dir, 'combined', "#{gemspec.name}-#{gemspec.version}-")
|
|
99
143
|
end
|
|
100
144
|
|
|
145
|
+
# @param gemspec [Gem::Specification]
|
|
146
|
+
# @param hash [String, nil]
|
|
147
|
+
# @param pins [Array<Pin::Base>]
|
|
148
|
+
# @return [void]
|
|
101
149
|
def serialize_combined_gem(gemspec, hash, pins)
|
|
102
150
|
save(combined_path(gemspec, hash), pins)
|
|
103
151
|
end
|
|
104
152
|
|
|
153
|
+
# @param gemspec [Gem::Specification]
|
|
154
|
+
# @param hash [String, nil]
|
|
155
|
+
# @return [Array<Pin::Base>, nil]
|
|
105
156
|
def deserialize_combined_gem gemspec, hash
|
|
106
157
|
load(combined_path(gemspec, hash))
|
|
107
158
|
end
|
|
108
159
|
|
|
160
|
+
# @param gemspec [Gem::Specification]
|
|
161
|
+
# @param hash [String, nil]
|
|
162
|
+
# @return [Boolean]
|
|
109
163
|
def has_rbs_collection?(gemspec, hash)
|
|
110
164
|
exist?(rbs_collection_path(gemspec, hash))
|
|
111
165
|
end
|
|
112
166
|
|
|
167
|
+
# @return [void]
|
|
113
168
|
def uncache_core
|
|
114
169
|
uncache(core_path)
|
|
115
170
|
end
|
|
116
171
|
|
|
172
|
+
# @return [void]
|
|
117
173
|
def uncache_stdlib
|
|
118
174
|
uncache(stdlib_path)
|
|
119
175
|
end
|
|
120
176
|
|
|
177
|
+
# @param gemspec [Gem::Specification]
|
|
178
|
+
# @param out [IO, nil]
|
|
179
|
+
# @return [void]
|
|
121
180
|
def uncache_gem(gemspec, out: nil)
|
|
122
181
|
uncache(yardoc_path(gemspec), out: out)
|
|
123
182
|
uncache_by_prefix(rbs_collection_path_prefix(gemspec), out: out)
|
|
@@ -143,11 +202,12 @@ module Solargraph
|
|
|
143
202
|
nil
|
|
144
203
|
end
|
|
145
204
|
|
|
205
|
+
# @param path [String]
|
|
146
206
|
def exist? *path
|
|
147
|
-
File.file? join(*path)
|
|
207
|
+
File.file? File.join(*path)
|
|
148
208
|
end
|
|
149
209
|
|
|
150
|
-
# @param
|
|
210
|
+
# @param file [String]
|
|
151
211
|
# @param pins [Array<Pin::Base>]
|
|
152
212
|
# @return [void]
|
|
153
213
|
def save file, pins
|
|
@@ -158,8 +218,8 @@ module Solargraph
|
|
|
158
218
|
logger.debug { "Cache#save: Saved #{pins.length} pins to #{file}" }
|
|
159
219
|
end
|
|
160
220
|
|
|
161
|
-
# @return [void]
|
|
162
221
|
# @param path_segments [Array<String>]
|
|
222
|
+
# @return [void]
|
|
163
223
|
def uncache *path_segments, out: nil
|
|
164
224
|
path = File.join(*path_segments)
|
|
165
225
|
if File.exist?(path)
|
data/lib/solargraph/position.rb
CHANGED
|
@@ -26,6 +26,7 @@ module Solargraph
|
|
|
26
26
|
[line, character]
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
# @param other [Position]
|
|
29
30
|
def <=>(other)
|
|
30
31
|
return nil unless other.is_a?(Position)
|
|
31
32
|
if line == other.line
|
|
@@ -57,6 +58,7 @@ module Solargraph
|
|
|
57
58
|
# @return [Integer]
|
|
58
59
|
def self.to_offset text, position
|
|
59
60
|
return 0 if text.empty?
|
|
61
|
+
# @sg-ignore Unresolved call to + on Integer
|
|
60
62
|
text.lines[0...position.line].sum(&:length) + position.character
|
|
61
63
|
end
|
|
62
64
|
|
|
@@ -110,6 +112,7 @@ module Solargraph
|
|
|
110
112
|
|
|
111
113
|
def == other
|
|
112
114
|
return false unless other.is_a?(Position)
|
|
115
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
113
116
|
line == other.line and character == other.character
|
|
114
117
|
end
|
|
115
118
|
end
|
data/lib/solargraph/range.rb
CHANGED
|
@@ -24,11 +24,15 @@ module Solargraph
|
|
|
24
24
|
[start, ending]
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
# @param other [BasicObject]
|
|
27
28
|
def <=>(other)
|
|
28
29
|
return nil unless other.is_a?(Range)
|
|
30
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
29
31
|
if start == other.start
|
|
32
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
30
33
|
ending <=> other.ending
|
|
31
34
|
else
|
|
35
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
32
36
|
start <=> other.start
|
|
33
37
|
end
|
|
34
38
|
end
|
|
@@ -97,6 +101,7 @@ module Solargraph
|
|
|
97
101
|
|
|
98
102
|
def == other
|
|
99
103
|
return false unless other.is_a?(Range)
|
|
104
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
100
105
|
start == other.start && ending == other.ending
|
|
101
106
|
end
|
|
102
107
|
|