solargraph 0.57.0 → 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 +4 -2
- data/.github/workflows/plugins.yml +61 -27
- data/.github/workflows/rspec.yml +19 -4
- data/.github/workflows/typecheck.yml +2 -2
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +90 -1438
- data/CHANGELOG.md +27 -0
- data/Rakefile +1 -1
- data/bin/solargraph +8 -5
- data/lib/solargraph/api_map/constants.rb +107 -46
- data/lib/solargraph/api_map/index.rb +32 -8
- data/lib/solargraph/api_map/source_to_yard.rb +5 -2
- data/lib/solargraph/api_map/store.rb +22 -12
- data/lib/solargraph/api_map.rb +27 -33
- data/lib/solargraph/complex_type/type_methods.rb +5 -0
- data/lib/solargraph/complex_type/unique_type.rb +12 -5
- data/lib/solargraph/complex_type.rb +19 -2
- data/lib/solargraph/convention/active_support_concern.rb +1 -1
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +1 -1
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +4 -2
- data/lib/solargraph/doc_map.rb +9 -6
- data/lib/solargraph/environ.rb +1 -1
- data/lib/solargraph/equality.rb +1 -0
- data/lib/solargraph/gem_pins.rb +4 -0
- data/lib/solargraph/language_server/host.rb +10 -4
- data/lib/solargraph/language_server/message/text_document/definition.rb +2 -2
- data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -1
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +1 -1
- data/lib/solargraph/language_server/progress.rb +1 -1
- data/lib/solargraph/language_server/request.rb +3 -1
- data/lib/solargraph/library.rb +3 -3
- data/lib/solargraph/location.rb +1 -0
- data/lib/solargraph/page.rb +0 -1
- data/lib/solargraph/parser/flow_sensitive_typing.rb +1 -1
- data/lib/solargraph/parser/parser_gem/class_methods.rb +2 -12
- data/lib/solargraph/parser/parser_gem/node_methods.rb +1 -14
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +1 -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 +4 -5
- data/lib/solargraph/pin/base.rb +29 -8
- data/lib/solargraph/pin/base_variable.rb +5 -3
- data/lib/solargraph/pin/block.rb +3 -2
- data/lib/solargraph/pin/callable.rb +6 -2
- data/lib/solargraph/pin/closure.rb +3 -7
- data/lib/solargraph/pin/delegated_method.rb +0 -1
- data/lib/solargraph/pin/local_variable.rb +0 -4
- data/lib/solargraph/pin/method.rb +20 -4
- data/lib/solargraph/pin/parameter.rb +6 -2
- data/lib/solargraph/pin/proxy_type.rb +4 -1
- data/lib/solargraph/pin/reference.rb +2 -11
- data/lib/solargraph/pin/search.rb +3 -0
- data/lib/solargraph/pin_cache.rb +5 -5
- data/lib/solargraph/position.rb +1 -0
- data/lib/solargraph/range.rb +4 -0
- data/lib/solargraph/rbs_map/conversions.rb +22 -1
- data/lib/solargraph/rbs_map/core_fills.rb +18 -0
- data/lib/solargraph/rbs_map/core_map.rb +11 -7
- data/lib/solargraph/rbs_map.rb +2 -2
- data/lib/solargraph/shell.rb +82 -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 +1 -1
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain.rb +2 -0
- data/lib/solargraph/source.rb +1 -1
- data/lib/solargraph/source_map/clip.rb +17 -25
- data/lib/solargraph/source_map/mapper.rb +0 -2
- data/lib/solargraph/source_map.rb +8 -3
- data/lib/solargraph/type_checker/rules.rb +23 -9
- data/lib/solargraph/type_checker.rb +133 -71
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +21 -3
- data/lib/solargraph/workspace/require_paths.rb +0 -1
- data/lib/solargraph/workspace.rb +14 -19
- data/lib/solargraph/yard_map/mapper/to_method.rb +2 -1
- 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 +27 -4
- 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_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/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/solargraph.gemspec +15 -4
- metadata +66 -12
- data/lib/solargraph/parser/node_methods.rb +0 -97
- /data/rbs/fills/{tuple.rbs → tuple/tuple.rbs} +0 -0
data/lib/solargraph/api_map.rb
CHANGED
|
@@ -39,6 +39,7 @@ module Solargraph
|
|
|
39
39
|
# @param other [Object]
|
|
40
40
|
def eql?(other)
|
|
41
41
|
self.class == other.class &&
|
|
42
|
+
# @sg-ignore Flow sensitive typing needs to handle self.class == other.class
|
|
42
43
|
equality_fields == other.equality_fields
|
|
43
44
|
end
|
|
44
45
|
|
|
@@ -179,6 +180,7 @@ module Solargraph
|
|
|
179
180
|
# Create an ApiMap with a workspace in the specified directory.
|
|
180
181
|
#
|
|
181
182
|
# @param directory [String]
|
|
183
|
+
#
|
|
182
184
|
# @return [ApiMap]
|
|
183
185
|
def self.load directory
|
|
184
186
|
api_map = new
|
|
@@ -214,6 +216,7 @@ module Solargraph
|
|
|
214
216
|
#
|
|
215
217
|
# @param directory [String]
|
|
216
218
|
# @param out [IO] The output stream for messages
|
|
219
|
+
#
|
|
217
220
|
# @return [ApiMap]
|
|
218
221
|
def self.load_with_cache directory, out
|
|
219
222
|
api_map = load(directory)
|
|
@@ -238,13 +241,6 @@ module Solargraph
|
|
|
238
241
|
store.pins_by_class(Pin::Keyword)
|
|
239
242
|
end
|
|
240
243
|
|
|
241
|
-
# An array of namespace names defined in the ApiMap.
|
|
242
|
-
#
|
|
243
|
-
# @return [Set<String>]
|
|
244
|
-
def namespaces
|
|
245
|
-
store.namespaces
|
|
246
|
-
end
|
|
247
|
-
|
|
248
244
|
# True if the namespace exists.
|
|
249
245
|
#
|
|
250
246
|
# @param name [String] The namespace to match
|
|
@@ -259,7 +255,7 @@ module Solargraph
|
|
|
259
255
|
#
|
|
260
256
|
# @param namespace [String] The namespace
|
|
261
257
|
# @param contexts [Array<String>] The contexts
|
|
262
|
-
# @return [Array<Solargraph::Pin::
|
|
258
|
+
# @return [Array<Solargraph::Pin::Constant, Solargraph::Pin::Namespace>]
|
|
263
259
|
def get_constants namespace, *contexts
|
|
264
260
|
namespace ||= ''
|
|
265
261
|
gates = contexts.clone
|
|
@@ -289,12 +285,21 @@ module Solargraph
|
|
|
289
285
|
# @param tag [String, nil] The namespace to
|
|
290
286
|
# match, complete with generic parameters set to appropriate
|
|
291
287
|
# values if available
|
|
292
|
-
# @param
|
|
288
|
+
# @param gates [Array<String>] The fully qualified context in which
|
|
293
289
|
# the tag was referenced; start from here to resolve the name.
|
|
294
290
|
# Should not be prefixed with '::'.
|
|
295
291
|
# @return [String, nil] fully qualified tag
|
|
296
|
-
def qualify tag,
|
|
297
|
-
store.constants.qualify(tag,
|
|
292
|
+
def qualify tag, *gates
|
|
293
|
+
store.constants.qualify(tag, *gates)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
# @see Store::Constants#resolve
|
|
297
|
+
#
|
|
298
|
+
# @param name [String]
|
|
299
|
+
# @param gates [Array<String, Array<String>>]
|
|
300
|
+
# @return [String, nil]
|
|
301
|
+
def resolve name, *gates
|
|
302
|
+
store.constants.resolve(name, *gates)
|
|
298
303
|
end
|
|
299
304
|
|
|
300
305
|
# Get a fully qualified namespace from a reference pin.
|
|
@@ -306,13 +311,13 @@ module Solargraph
|
|
|
306
311
|
end
|
|
307
312
|
|
|
308
313
|
# @param fqns [String]
|
|
309
|
-
# @return [Array<
|
|
314
|
+
# @return [Array<Pin::Reference::Extend>]
|
|
310
315
|
def get_extends(fqns)
|
|
311
316
|
store.get_extends(fqns)
|
|
312
317
|
end
|
|
313
318
|
|
|
314
319
|
# @param fqns [String]
|
|
315
|
-
# @return [Array<
|
|
320
|
+
# @return [Array<Pin::Reference::Include>]
|
|
316
321
|
def get_includes(fqns)
|
|
317
322
|
store.get_includes(fqns)
|
|
318
323
|
end
|
|
@@ -499,7 +504,8 @@ module Solargraph
|
|
|
499
504
|
# @param name [String] Method name to look up
|
|
500
505
|
# @param scope [Symbol] :instance or :class
|
|
501
506
|
# @param visibility [Array<Symbol>] :public, :protected, and/or :private
|
|
502
|
-
# @param preserve_generics [Boolean]
|
|
507
|
+
# @param preserve_generics [Boolean] True to preserve any
|
|
508
|
+
# unresolved generic parameters, false to erase them
|
|
503
509
|
# @return [Array<Solargraph::Pin::Method>]
|
|
504
510
|
def get_method_stack rooted_tag, name, scope: :instance, visibility: [:private, :protected, :public], preserve_generics: false
|
|
505
511
|
rooted_type = ComplexType.parse(rooted_tag)
|
|
@@ -525,7 +531,7 @@ module Solargraph
|
|
|
525
531
|
# @deprecated Use #get_path_pins instead.
|
|
526
532
|
#
|
|
527
533
|
# @param path [String] The path to find
|
|
528
|
-
# @return [
|
|
534
|
+
# @return [Array<Solargraph::Pin::Base>]
|
|
529
535
|
def get_path_suggestions path
|
|
530
536
|
return [] if path.nil?
|
|
531
537
|
resolve_method_aliases store.get_path_pins(path)
|
|
@@ -534,7 +540,7 @@ module Solargraph
|
|
|
534
540
|
# Get an array of pins that match the specified path.
|
|
535
541
|
#
|
|
536
542
|
# @param path [String]
|
|
537
|
-
# @return [
|
|
543
|
+
# @return [Array<Pin::Base>]
|
|
538
544
|
def get_path_pins path
|
|
539
545
|
get_path_suggestions(path)
|
|
540
546
|
end
|
|
@@ -653,7 +659,7 @@ module Solargraph
|
|
|
653
659
|
#
|
|
654
660
|
# @return [Boolean]
|
|
655
661
|
def type_include?(host_ns, module_ns)
|
|
656
|
-
store.get_includes(host_ns).map { |inc_tag| inc_tag.
|
|
662
|
+
store.get_includes(host_ns).map { |inc_tag| inc_tag.type.name }.include?(module_ns)
|
|
657
663
|
end
|
|
658
664
|
|
|
659
665
|
# @param pins [Enumerable<Pin::Base>]
|
|
@@ -728,7 +734,6 @@ module Solargraph
|
|
|
728
734
|
# @param skip [Set<String>]
|
|
729
735
|
# @param no_core [Boolean] Skip core classes if true
|
|
730
736
|
# @return [Array<Pin::Base>]
|
|
731
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
|
732
737
|
def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false
|
|
733
738
|
rooted_type = ComplexType.parse(rooted_tag).force_rooted
|
|
734
739
|
fqns = rooted_type.namespace
|
|
@@ -763,17 +768,8 @@ module Solargraph
|
|
|
763
768
|
|
|
764
769
|
if scope == :instance
|
|
765
770
|
store.get_includes(fqns).reverse.each do |ref|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
result.concat inner_get_methods(const.path, scope, visibility, deep, skip, true)
|
|
769
|
-
elsif const.is_a?(Pin::Constant)
|
|
770
|
-
type = const.infer(self)
|
|
771
|
-
result.concat inner_get_methods(type.namespace, scope, visibility, deep, skip, true) if type.defined?
|
|
772
|
-
else
|
|
773
|
-
referenced_tag = ref.parametrized_tag
|
|
774
|
-
next unless referenced_tag.defined?
|
|
775
|
-
result.concat inner_get_methods_from_reference(referenced_tag.to_s, namespace_pin, rooted_type, scope, visibility, deep, skip, true)
|
|
776
|
-
end
|
|
771
|
+
in_tag = dereference(ref)
|
|
772
|
+
result.concat inner_get_methods_from_reference(in_tag, namespace_pin, rooted_type, scope, visibility, deep, skip, true)
|
|
777
773
|
end
|
|
778
774
|
rooted_sc_tag = qualify_superclass(rooted_tag)
|
|
779
775
|
unless rooted_sc_tag.nil?
|
|
@@ -782,7 +778,7 @@ module Solargraph
|
|
|
782
778
|
else
|
|
783
779
|
logger.info { "ApiMap#inner_get_methods(#{fqns}, #{scope}, #{visibility}, #{deep}, #{skip}) - looking for get_extends() from #{fqns}" }
|
|
784
780
|
store.get_extends(fqns).reverse.each do |em|
|
|
785
|
-
fqem =
|
|
781
|
+
fqem = dereference(em)
|
|
786
782
|
result.concat inner_get_methods(fqem, :instance, visibility, deep, skip, true) unless fqem.nil?
|
|
787
783
|
end
|
|
788
784
|
rooted_sc_tag = qualify_superclass(rooted_tag)
|
|
@@ -802,7 +798,6 @@ module Solargraph
|
|
|
802
798
|
end
|
|
803
799
|
result
|
|
804
800
|
end
|
|
805
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
|
806
801
|
|
|
807
802
|
# @return [Hash]
|
|
808
803
|
def path_macros
|
|
@@ -851,12 +846,11 @@ module Solargraph
|
|
|
851
846
|
# @param alias_pin [Pin::MethodAlias]
|
|
852
847
|
# @return [Pin::Method, nil]
|
|
853
848
|
def resolve_method_alias(alias_pin)
|
|
854
|
-
ancestors = store.get_ancestors(alias_pin.full_context.tag)
|
|
849
|
+
ancestors = store.get_ancestors(alias_pin.full_context.reduce_class_type.tag)
|
|
855
850
|
original = nil
|
|
856
851
|
|
|
857
852
|
# Search each ancestor for the original method
|
|
858
853
|
ancestors.each do |ancestor_fqns|
|
|
859
|
-
ancestor_fqns = ComplexType.try_parse(ancestor_fqns).force_rooted.namespace
|
|
860
854
|
next if ancestor_fqns.nil?
|
|
861
855
|
ancestor_method_path = "#{ancestor_fqns}#{alias_pin.scope == :instance ? '#' : '.'}#{alias_pin.original}"
|
|
862
856
|
|
|
@@ -43,6 +43,10 @@ module Solargraph
|
|
|
43
43
|
@rooted_tag ||= rooted_name + rooted_substring
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
def interface?
|
|
47
|
+
name.start_with?('_')
|
|
48
|
+
end
|
|
49
|
+
|
|
46
50
|
# @return [Boolean]
|
|
47
51
|
def duck_type?
|
|
48
52
|
@duck_type ||= name.start_with?('#')
|
|
@@ -190,6 +194,7 @@ module Solargraph
|
|
|
190
194
|
# @param other [Object]
|
|
191
195
|
def == other
|
|
192
196
|
return false unless self.class == other.class
|
|
197
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
193
198
|
tag == other.tag
|
|
194
199
|
end
|
|
195
200
|
|
|
@@ -138,11 +138,17 @@ module Solargraph
|
|
|
138
138
|
|
|
139
139
|
def eql?(other)
|
|
140
140
|
self.class == other.class &&
|
|
141
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
141
142
|
@name == other.name &&
|
|
143
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
142
144
|
@key_types == other.key_types &&
|
|
145
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
143
146
|
@subtypes == other.subtypes &&
|
|
147
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
144
148
|
@rooted == other.rooted? &&
|
|
149
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
145
150
|
@all_params == other.all_params &&
|
|
151
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
146
152
|
@parameters_type == other.parameters_type
|
|
147
153
|
end
|
|
148
154
|
|
|
@@ -280,7 +286,7 @@ module Solargraph
|
|
|
280
286
|
end
|
|
281
287
|
|
|
282
288
|
# @param generics_to_resolve [Enumerable<String>]
|
|
283
|
-
# @param context_type [UniqueType]
|
|
289
|
+
# @param context_type [UniqueType, nil]
|
|
284
290
|
# @param resolved_generic_values [Hash{String => ComplexType}]
|
|
285
291
|
# @yieldreturn [Array<ComplexType>]
|
|
286
292
|
# @return [Array<ComplexType>]
|
|
@@ -409,12 +415,12 @@ module Solargraph
|
|
|
409
415
|
# @param api_map [ApiMap] The ApiMap that performs qualification
|
|
410
416
|
# @param context [String] The namespace from which to resolve names
|
|
411
417
|
# @return [self, ComplexType, UniqueType] The generated ComplexType
|
|
412
|
-
def qualify api_map,
|
|
418
|
+
def qualify api_map, *gates
|
|
413
419
|
transform do |t|
|
|
414
420
|
next t if t.name == GENERIC_TAG_NAME
|
|
415
|
-
next t if t.duck_type? || t.void? || t.undefined?
|
|
416
|
-
|
|
417
|
-
fqns = api_map.qualify(t.
|
|
421
|
+
next t if t.duck_type? || t.void? || t.undefined? || t.literal?
|
|
422
|
+
open = t.rooted? ? [''] : gates
|
|
423
|
+
fqns = api_map.qualify(t.non_literal_name, *open)
|
|
418
424
|
if fqns.nil?
|
|
419
425
|
next UniqueType::BOOLEAN if t.tag == 'Boolean'
|
|
420
426
|
next UniqueType::UNDEFINED
|
|
@@ -446,6 +452,7 @@ module Solargraph
|
|
|
446
452
|
!can_root_name? || @rooted
|
|
447
453
|
end
|
|
448
454
|
|
|
455
|
+
# @param name_to_check [String]
|
|
449
456
|
def can_root_name?(name_to_check = name)
|
|
450
457
|
self.class.can_root_name?(name_to_check)
|
|
451
458
|
end
|
|
@@ -33,12 +33,12 @@ module Solargraph
|
|
|
33
33
|
# @param api_map [ApiMap]
|
|
34
34
|
# @param context [String]
|
|
35
35
|
# @return [ComplexType]
|
|
36
|
-
def qualify api_map,
|
|
36
|
+
def qualify api_map, *gates
|
|
37
37
|
red = reduce_object
|
|
38
38
|
types = red.items.map do |t|
|
|
39
39
|
next t if ['nil', 'void', 'undefined'].include?(t.name)
|
|
40
40
|
next t if ['::Boolean'].include?(t.rooted_name)
|
|
41
|
-
t.qualify api_map,
|
|
41
|
+
t.qualify api_map, *gates
|
|
42
42
|
end
|
|
43
43
|
ComplexType.new(types).reduce_object
|
|
44
44
|
end
|
|
@@ -105,6 +105,21 @@ module Solargraph
|
|
|
105
105
|
any? { |ut| ut.can_assign?(api_map, atype) }
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
+
# @param new_name [String, nil]
|
|
109
|
+
# @param make_rooted [Boolean, nil]
|
|
110
|
+
# @param new_key_types [Array<ComplexType>, nil]
|
|
111
|
+
# @param rooted [Boolean, nil]
|
|
112
|
+
# @param new_subtypes [Array<ComplexType>, nil]
|
|
113
|
+
# @return [self]
|
|
114
|
+
def recreate(new_name: nil, make_rooted: nil, new_key_types: nil, new_subtypes: nil)
|
|
115
|
+
ComplexType.new(map do |ut|
|
|
116
|
+
ut.recreate(new_name: new_name,
|
|
117
|
+
make_rooted: make_rooted,
|
|
118
|
+
new_key_types: new_key_types,
|
|
119
|
+
new_subtypes: new_subtypes)
|
|
120
|
+
end)
|
|
121
|
+
end
|
|
122
|
+
|
|
108
123
|
# @return [Integer]
|
|
109
124
|
def length
|
|
110
125
|
@items.length
|
|
@@ -246,6 +261,7 @@ module Solargraph
|
|
|
246
261
|
def reduce_class_type
|
|
247
262
|
new_items = items.flat_map do |type|
|
|
248
263
|
next type unless ['Module', 'Class'].include?(type.name)
|
|
264
|
+
next type if type.all_params.empty?
|
|
249
265
|
|
|
250
266
|
type.all_params
|
|
251
267
|
end
|
|
@@ -323,6 +339,7 @@ module Solargraph
|
|
|
323
339
|
paren_stack = 0
|
|
324
340
|
base = String.new
|
|
325
341
|
subtype_string = String.new
|
|
342
|
+
# @param char [String]
|
|
326
343
|
type_string&.each_char do |char|
|
|
327
344
|
if char == '='
|
|
328
345
|
#raise ComplexTypeError, "Invalid = in type #{type_string}" unless curly_stack > 0
|
|
@@ -80,7 +80,7 @@ module Solargraph
|
|
|
80
80
|
"ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \
|
|
81
81
|
"Handling class include include_tag=#{include_tag}"
|
|
82
82
|
end
|
|
83
|
-
module_extends = api_map.get_extends(rooted_include_tag).map(&:
|
|
83
|
+
module_extends = api_map.get_extends(rooted_include_tag).map(&:type).map(&:to_s)
|
|
84
84
|
logger.debug do
|
|
85
85
|
"ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \
|
|
86
86
|
"found module extends of #{rooted_include_tag}: #{module_extends}"
|
|
@@ -19,11 +19,12 @@ module Solargraph
|
|
|
19
19
|
gem_path = Gem::Specification.find_by_name('rubocop', version).full_gem_path
|
|
20
20
|
gem_lib_path = File.join(gem_path, 'lib')
|
|
21
21
|
$LOAD_PATH.unshift(gem_lib_path) unless $LOAD_PATH.include?(gem_lib_path)
|
|
22
|
-
# @sg-ignore
|
|
23
22
|
rescue Gem::MissingSpecVersionError => e
|
|
23
|
+
# @type [Array<Gem::Specification>]
|
|
24
|
+
specs = e.specs
|
|
24
25
|
raise InvalidRubocopVersionError,
|
|
25
26
|
"could not find '#{e.name}' (#{e.requirement}) - "\
|
|
26
|
-
"did find: [#{
|
|
27
|
+
"did find: [#{specs.map { |s| s.version.version }.join(', ')}]"
|
|
27
28
|
end
|
|
28
29
|
require 'rubocop'
|
|
29
30
|
end
|
|
@@ -37,6 +38,7 @@ module Solargraph
|
|
|
37
38
|
args = ['-f', 'j', '--force-exclusion', filename]
|
|
38
39
|
base_options = RuboCop::Options.new
|
|
39
40
|
options, paths = base_options.parse(args)
|
|
41
|
+
# @sg-ignore
|
|
40
42
|
options[:stdin] = code
|
|
41
43
|
[options, paths]
|
|
42
44
|
end
|
data/lib/solargraph/doc_map.rb
CHANGED
|
@@ -128,7 +128,7 @@ module Solargraph
|
|
|
128
128
|
@unresolved_requires ||= required_gems_map.select { |_, gemspecs| gemspecs.nil? }.keys
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
-
# @return [Hash{Array(String, String) => Array<
|
|
131
|
+
# @return [Hash{Array(String, String) => Array<Pin::Base>}] Indexed by gemspec name and version
|
|
132
132
|
def self.all_yard_gems_in_memory
|
|
133
133
|
@yard_gems_in_memory ||= {}
|
|
134
134
|
end
|
|
@@ -177,10 +177,10 @@ module Solargraph
|
|
|
177
177
|
@uncached_yard_gemspecs = []
|
|
178
178
|
@uncached_rbs_collection_gemspecs = []
|
|
179
179
|
with_gemspecs, without_gemspecs = required_gems_map.partition { |_, v| v }
|
|
180
|
-
# @sg-ignore
|
|
180
|
+
# @sg-ignore Need support for RBS duck interfaces like _ToHash
|
|
181
181
|
# @type [Array<String>]
|
|
182
182
|
paths = Hash[without_gemspecs].keys
|
|
183
|
-
# @sg-ignore
|
|
183
|
+
# @sg-ignore Need support for RBS duck interfaces like _ToHash
|
|
184
184
|
# @type [Array<Gem::Specification>]
|
|
185
185
|
gemspecs = Hash[with_gemspecs].values.flatten.compact + dependencies.to_a
|
|
186
186
|
|
|
@@ -212,7 +212,7 @@ module Solargraph
|
|
|
212
212
|
end
|
|
213
213
|
|
|
214
214
|
# @param gemspec [Gem::Specification]
|
|
215
|
-
# @return [Array<Pin::Base
|
|
215
|
+
# @return [Array<Pin::Base>, nil]
|
|
216
216
|
def deserialize_yard_pin_cache gemspec
|
|
217
217
|
if yard_pins_in_memory.key?([gemspec.name, gemspec.version])
|
|
218
218
|
return yard_pins_in_memory[[gemspec.name, gemspec.version]]
|
|
@@ -359,13 +359,16 @@ module Solargraph
|
|
|
359
359
|
# @return [Array<Gem::Specification>]
|
|
360
360
|
def fetch_dependencies gemspec
|
|
361
361
|
# @param spec [Gem::Dependency]
|
|
362
|
+
# @param deps [Set<Gem::Specification>]
|
|
362
363
|
only_runtime_dependencies(gemspec).each_with_object(Set.new) do |spec, deps|
|
|
363
364
|
Solargraph.logger.info "Adding #{spec.name} dependency for #{gemspec.name}"
|
|
364
365
|
dep = Gem.loaded_specs[spec.name]
|
|
365
366
|
# @todo is next line necessary?
|
|
367
|
+
# @sg-ignore Unresolved call to requirement on Gem::Dependency
|
|
366
368
|
dep ||= Gem::Specification.find_by_name(spec.name, spec.requirement)
|
|
367
369
|
deps.merge fetch_dependencies(dep) if deps.add?(dep)
|
|
368
370
|
rescue Gem::MissingSpecError
|
|
371
|
+
# @sg-ignore Unresolved call to requirement on Gem::Dependency
|
|
369
372
|
Solargraph.logger.warn "Gem dependency #{spec.name} #{spec.requirement} for #{gemspec.name} not found in RubyGems."
|
|
370
373
|
end.to_a
|
|
371
374
|
end
|
|
@@ -381,7 +384,7 @@ module Solargraph
|
|
|
381
384
|
self.class.inspect
|
|
382
385
|
end
|
|
383
386
|
|
|
384
|
-
# @return [Array<Gem::Specification
|
|
387
|
+
# @return [Array<Gem::Specification>, nil]
|
|
385
388
|
def gemspecs_required_from_bundler
|
|
386
389
|
# @todo Handle projects with custom Bundler/Gemfile setups
|
|
387
390
|
return unless workspace.gemfile?
|
|
@@ -404,7 +407,7 @@ module Solargraph
|
|
|
404
407
|
end
|
|
405
408
|
end
|
|
406
409
|
|
|
407
|
-
# @return [Array<Gem::Specification
|
|
410
|
+
# @return [Array<Gem::Specification>, nil]
|
|
408
411
|
def gemspecs_required_from_external_bundle
|
|
409
412
|
logger.info 'Fetching gemspecs required from external bundle'
|
|
410
413
|
return [] unless workspace&.directory
|
data/lib/solargraph/environ.rb
CHANGED
|
@@ -22,7 +22,7 @@ module Solargraph
|
|
|
22
22
|
# @param requires [Array<String>]
|
|
23
23
|
# @param domains [Array<String>]
|
|
24
24
|
# @param pins [Array<Pin::Base>]
|
|
25
|
-
# @param yard_plugins[Array<String>]
|
|
25
|
+
# @param yard_plugins [Array<String>]
|
|
26
26
|
def initialize requires: [], domains: [], pins: [], yard_plugins: []
|
|
27
27
|
@requires = requires
|
|
28
28
|
@domains = domains
|
data/lib/solargraph/equality.rb
CHANGED
data/lib/solargraph/gem_pins.rb
CHANGED
|
@@ -27,6 +27,8 @@ module Solargraph
|
|
|
27
27
|
def self.combine_method_pins(*pins)
|
|
28
28
|
# @type [Pin::Method, nil]
|
|
29
29
|
combined_pin = nil
|
|
30
|
+
# @param memo [Pin::Method, nil]
|
|
31
|
+
# @param pin [Pin::Method]
|
|
30
32
|
out = pins.reduce(combined_pin) do |memo, pin|
|
|
31
33
|
next pin if memo.nil?
|
|
32
34
|
if memo == pin && memo.source != :combined
|
|
@@ -46,6 +48,7 @@ module Solargraph
|
|
|
46
48
|
# @return [Array<Pin::Base>]
|
|
47
49
|
def self.build_yard_pins(yard_plugins, gemspec)
|
|
48
50
|
Yardoc.cache(yard_plugins, gemspec) unless Yardoc.cached?(gemspec)
|
|
51
|
+
return [] unless Yardoc.cached?(gemspec)
|
|
49
52
|
yardoc = Yardoc.load!(gemspec)
|
|
50
53
|
YardMap::Mapper.new(yardoc, gemspec).map
|
|
51
54
|
end
|
|
@@ -63,6 +66,7 @@ module Solargraph
|
|
|
63
66
|
next yard_pin unless rbs_pin && yard_pin.class == Pin::Method
|
|
64
67
|
|
|
65
68
|
unless rbs_pin
|
|
69
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
66
70
|
logger.debug { "GemPins.combine: No rbs pin for #{yard_pin.path} - using YARD's '#{yard_pin.inspect} (return_type=#{yard_pin.return_type}; signatures=#{yard_pin.signatures})" }
|
|
67
71
|
next yard_pin
|
|
68
72
|
end
|
|
@@ -94,7 +94,8 @@ module Solargraph
|
|
|
94
94
|
# processed, caller is responsible for sending the response.
|
|
95
95
|
#
|
|
96
96
|
# @param request [Hash{String => unspecified}] The contents of the message.
|
|
97
|
-
#
|
|
97
|
+
#
|
|
98
|
+
# @return [Solargraph::LanguageServer::Message::Base, Solargraph::LanguageServer::Request, nil] The message handler.
|
|
98
99
|
def receive request
|
|
99
100
|
if request['method']
|
|
100
101
|
logger.info "Host received ##{request['id']} #{request['method']}"
|
|
@@ -503,6 +504,7 @@ module Solargraph
|
|
|
503
504
|
name: 'new',
|
|
504
505
|
scope: :class,
|
|
505
506
|
location: pin.location,
|
|
507
|
+
# @sg-ignore Unresolved call to parameters on Solargraph::Pin::Base
|
|
506
508
|
parameters: pin.parameters,
|
|
507
509
|
return_type: ComplexType.try_parse(params['data']['path']),
|
|
508
510
|
comments: pin.comments,
|
|
@@ -534,7 +536,7 @@ module Solargraph
|
|
|
534
536
|
# @param uri [String]
|
|
535
537
|
# @param line [Integer]
|
|
536
538
|
# @param column [Integer]
|
|
537
|
-
# @return [Solargraph::SourceMap::Completion]
|
|
539
|
+
# @return [Solargraph::SourceMap::Completion, nil]
|
|
538
540
|
def completions_at uri, line, column
|
|
539
541
|
library = library_for(uri)
|
|
540
542
|
library.completions_at uri_to_file(uri), line, column
|
|
@@ -548,7 +550,7 @@ module Solargraph
|
|
|
548
550
|
# @param uri [String]
|
|
549
551
|
# @param line [Integer]
|
|
550
552
|
# @param column [Integer]
|
|
551
|
-
# @return [Array<Solargraph::Pin::Base
|
|
553
|
+
# @return [Array<Solargraph::Pin::Base>, nil]
|
|
552
554
|
def definitions_at uri, line, column
|
|
553
555
|
library = library_for(uri)
|
|
554
556
|
library.definitions_at(uri_to_file(uri), line, column)
|
|
@@ -557,7 +559,7 @@ module Solargraph
|
|
|
557
559
|
# @param uri [String]
|
|
558
560
|
# @param line [Integer]
|
|
559
561
|
# @param column [Integer]
|
|
560
|
-
# @return [Array<Solargraph::Pin::Base
|
|
562
|
+
# @return [Array<Solargraph::Pin::Base>, nil]
|
|
561
563
|
def type_definitions_at uri, line, column
|
|
562
564
|
library = library_for(uri)
|
|
563
565
|
library.type_definitions_at(uri_to_file(uri), line, column)
|
|
@@ -581,6 +583,10 @@ module Solargraph
|
|
|
581
583
|
def references_from uri, line, column, strip: true, only: false
|
|
582
584
|
library = library_for(uri)
|
|
583
585
|
library.references_from(uri_to_file(uri), line, column, strip: strip, only: only)
|
|
586
|
+
rescue FileNotFoundError, InvalidOffsetError => e
|
|
587
|
+
Solargraph.logger.warn "[#{e.class}] #{e.message}"
|
|
588
|
+
Solargraph.logger.debug e.backtrace
|
|
589
|
+
[]
|
|
584
590
|
end
|
|
585
591
|
|
|
586
592
|
# @param query [String]
|
|
@@ -10,7 +10,7 @@ module Solargraph::LanguageServer::Message::TextDocument
|
|
|
10
10
|
|
|
11
11
|
private
|
|
12
12
|
|
|
13
|
-
# @return [Array<Hash
|
|
13
|
+
# @return [Array<Hash>, nil]
|
|
14
14
|
def code_location
|
|
15
15
|
suggestions = host.definitions_at(params['textDocument']['uri'], @line, @column)
|
|
16
16
|
return nil if suggestions.empty?
|
|
@@ -22,7 +22,7 @@ module Solargraph::LanguageServer::Message::TextDocument
|
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# @return [Array<Hash
|
|
25
|
+
# @return [Array<Hash>, nil]
|
|
26
26
|
def require_location
|
|
27
27
|
# @todo Terrible hack
|
|
28
28
|
lib = host.library_for(params['textDocument']['uri'])
|
|
@@ -18,6 +18,7 @@ module Solargraph
|
|
|
18
18
|
|
|
19
19
|
require_rubocop(config['version'])
|
|
20
20
|
options, paths = ::RuboCop::Options.new.parse(args)
|
|
21
|
+
# @sg-ignore Unresolved call to []=
|
|
21
22
|
options[:stdin] = original
|
|
22
23
|
|
|
23
24
|
# Ensure only one instance of RuboCop::Runner is running at
|
|
@@ -28,6 +29,7 @@ module Solargraph
|
|
|
28
29
|
::RuboCop::Runner.new(options, ::RuboCop::ConfigStore.new).run(paths)
|
|
29
30
|
end
|
|
30
31
|
end
|
|
32
|
+
# @sg-ignore Unresolved call to []=
|
|
31
33
|
result = options[:stdin]
|
|
32
34
|
|
|
33
35
|
log_corrections(corrections)
|
|
@@ -96,8 +98,9 @@ module Solargraph
|
|
|
96
98
|
end
|
|
97
99
|
|
|
98
100
|
# @param value [Array, String]
|
|
99
|
-
# @return [String]
|
|
101
|
+
# @return [String, nil]
|
|
100
102
|
def cop_list(value)
|
|
103
|
+
# @type [String]
|
|
101
104
|
value = value.join(',') if value.respond_to?(:join)
|
|
102
105
|
return nil if value == '' || !value.is_a?(String)
|
|
103
106
|
value
|
|
@@ -10,7 +10,7 @@ module Solargraph::LanguageServer::Message::TextDocument
|
|
|
10
10
|
|
|
11
11
|
private
|
|
12
12
|
|
|
13
|
-
# @return [Array<Hash
|
|
13
|
+
# @return [Array<Hash>, nil]
|
|
14
14
|
def code_location
|
|
15
15
|
suggestions = host.type_definitions_at(params['textDocument']['uri'], @line, @column)
|
|
16
16
|
return nil if suggestions.empty?
|
data/lib/solargraph/library.rb
CHANGED
|
@@ -259,11 +259,11 @@ module Solargraph
|
|
|
259
259
|
referenced&.path == pin.path
|
|
260
260
|
end
|
|
261
261
|
if pin.path == 'Class#new'
|
|
262
|
-
caller = cursor.chain.base.infer(api_map, clip.send(:
|
|
262
|
+
caller = cursor.chain.base.infer(api_map, clip.send(:closure), clip.locals).first
|
|
263
263
|
if caller.defined?
|
|
264
264
|
found.select! do |loc|
|
|
265
265
|
clip = api_map.clip_at(loc.filename, loc.range.start)
|
|
266
|
-
other = clip.send(:cursor).chain.base.infer(api_map, clip.send(:
|
|
266
|
+
other = clip.send(:cursor).chain.base.infer(api_map, clip.send(:closure), clip.locals).first
|
|
267
267
|
caller == other
|
|
268
268
|
end
|
|
269
269
|
else
|
|
@@ -522,7 +522,7 @@ module Solargraph
|
|
|
522
522
|
@external_requires = nil
|
|
523
523
|
end
|
|
524
524
|
|
|
525
|
-
# @return [Mutex]
|
|
525
|
+
# @return [Thread::Mutex]
|
|
526
526
|
def mutex
|
|
527
527
|
@mutex ||= Mutex.new
|
|
528
528
|
end
|
data/lib/solargraph/location.rb
CHANGED
data/lib/solargraph/page.rb
CHANGED
|
@@ -171,7 +171,7 @@ module Solargraph
|
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
# @param isa_node [Parser::AST::Node]
|
|
174
|
-
# @return [Array(String, String)]
|
|
174
|
+
# @return [Array(String, String), nil]
|
|
175
175
|
def parse_isa(isa_node)
|
|
176
176
|
return unless isa_node&.type == :send && isa_node.children[1] == :is_a?
|
|
177
177
|
# Check if conditional node follows this pattern:
|