solargraph 0.59.0.dev.2 → 0.59.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 +3 -1
- data/.github/workflows/plugins.yml +8 -2
- data/.github/workflows/rspec.yml +6 -40
- data/.github/workflows/typecheck.yml +2 -1
- data/.rubocop.yml +6 -1
- data/.rubocop_todo.yml +3 -0
- data/CHANGELOG.md +15 -0
- data/lib/solargraph/api_map/constants.rb +0 -1
- data/lib/solargraph/api_map/index.rb +6 -0
- data/lib/solargraph/api_map/store.rb +6 -0
- data/lib/solargraph/api_map.rb +20 -4
- data/lib/solargraph/complex_type/type_methods.rb +2 -1
- data/lib/solargraph/complex_type/unique_type.rb +2 -4
- data/lib/solargraph/complex_type.rb +1 -1
- data/lib/solargraph/doc_map.rb +370 -131
- data/lib/solargraph/gem_pins.rb +16 -17
- data/lib/solargraph/library.rb +44 -66
- data/lib/solargraph/logging.rb +0 -2
- data/lib/solargraph/parser/flow_sensitive_typing.rb +0 -2
- data/lib/solargraph/parser/parser_gem/class_methods.rb +0 -2
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +0 -1
- data/lib/solargraph/pin/base.rb +0 -2
- data/lib/solargraph/pin/method.rb +3 -0
- data/lib/solargraph/pin/reference/type_alias.rb +16 -0
- data/lib/solargraph/pin/reference.rb +1 -0
- data/lib/solargraph/pin_cache.rb +66 -480
- data/lib/solargraph/position.rb +7 -4
- data/lib/solargraph/rbs_map/conversions.rb +18 -18
- data/lib/solargraph/rbs_map.rb +2 -3
- data/lib/solargraph/shell.rb +163 -15
- data/lib/solargraph/source/chain.rb +3 -1
- data/lib/solargraph/source_map/mapper.rb +0 -2
- data/lib/solargraph/type_checker.rb +1 -2
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +1 -1
- data/lib/solargraph/workspace/gemspecs.rb +2 -2
- data/lib/solargraph/workspace.rb +32 -129
- data/lib/solargraph/yard_map.rb +17 -18
- data/lib/solargraph/yardoc.rb +26 -33
- data/lib/solargraph.rb +2 -0
- data/solargraph.gemspec +2 -2
- metadata +6 -11
|
@@ -37,11 +37,6 @@ module Solargraph
|
|
|
37
37
|
|
|
38
38
|
private
|
|
39
39
|
|
|
40
|
-
# @return [Hash{String => RBS::AST::Declarations::TypeAlias}]
|
|
41
|
-
def type_aliases
|
|
42
|
-
@type_aliases ||= {}
|
|
43
|
-
end
|
|
44
|
-
|
|
45
40
|
# @param loader [RBS::EnvironmentLoader]
|
|
46
41
|
#
|
|
47
42
|
# @return [void]
|
|
@@ -81,8 +76,13 @@ module Solargraph
|
|
|
81
76
|
# @sg-ignore flow sensitive typing should support case/when
|
|
82
77
|
"Ignoring closure #{closure.inspect} on alias type name #{decl.name}")
|
|
83
78
|
end
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
pins.push(
|
|
80
|
+
# @sg-ignore Wrong argument type for Solargraph::Pin::Reference::TypeAlias.new: return_type expected Solargraph::ComplexType, received Solargraph::ComplexType::UniqueType, Solargraph::ComplexType
|
|
81
|
+
Solargraph::Pin::Reference::TypeAlias.new(
|
|
82
|
+
# @sg-ignore Unresolved calls to name, type, type_location; return_type type mismatch
|
|
83
|
+
name: ComplexType.try_parse(decl.name.to_s).to_s, return_type: other_type_to_type(decl.type).force_rooted, closure: closure, source: :rbs, type_location: location_decl_to_pin_location(decl.location)
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
86
|
when RBS::AST::Declarations::Module
|
|
87
87
|
# @sg-ignore flow sensitive typing should support case/when
|
|
88
88
|
unless closure.name == '' || decl.name.absolute?
|
|
@@ -474,6 +474,8 @@ module Solargraph
|
|
|
474
474
|
# @param scope [Symbol] :instance or :class
|
|
475
475
|
# @param name [String] The name of the method
|
|
476
476
|
# @return [Symbol]
|
|
477
|
+
# @sg-ignore Declared return type ::Symbol does not match inferred type
|
|
478
|
+
# ::Symbol, :public, :private, nil for Solargraph::RbsMap::Conversions#calculate_method_visibility
|
|
477
479
|
def calculate_method_visibility decl, context, closure, scope, name
|
|
478
480
|
override_key = [closure.path, scope, name]
|
|
479
481
|
visibility = VISIBILITY_OVERRIDE[override_key]
|
|
@@ -552,6 +554,8 @@ module Solargraph
|
|
|
552
554
|
def method_def_to_sigs decl, pin
|
|
553
555
|
# @param overload [RBS::AST::Members::MethodDefinition::Overload]
|
|
554
556
|
decl.overloads.map do |overload|
|
|
557
|
+
# @sg-ignore Wrong argument type for Solargraph::RbsMap::Conversions#location_decl_to_pin_location:
|
|
558
|
+
# location expected RBS::Location, nil, received RBS::Location<:type, :type_params>, RBS::AST::Members::Attribute::loc, nil
|
|
555
559
|
type_location = location_decl_to_pin_location(overload.method_type.location)
|
|
556
560
|
generics = type_parameter_names(overload.method_type)
|
|
557
561
|
signature_parameters, signature_return_type = parts_of_function(overload.method_type, pin)
|
|
@@ -598,7 +602,7 @@ module Solargraph
|
|
|
598
602
|
parameters = []
|
|
599
603
|
arg_num = -1
|
|
600
604
|
type.type.required_positionals.each do |param|
|
|
601
|
-
# @sg-ignore
|
|
605
|
+
# @sg-ignore Unresolved call to name
|
|
602
606
|
name = param.name ? param.name.to_s : "arg_#{arg_num += 1}"
|
|
603
607
|
parameters.push Solargraph::Pin::Parameter.new(decl: :arg, name: name, closure: pin,
|
|
604
608
|
# @sg-ignore RBS generic type understanding issue
|
|
@@ -606,7 +610,7 @@ module Solargraph
|
|
|
606
610
|
source: :rbs, type_location: type_location)
|
|
607
611
|
end
|
|
608
612
|
type.type.optional_positionals.each do |param|
|
|
609
|
-
# @sg-ignore
|
|
613
|
+
# @sg-ignore Unresolved call to name
|
|
610
614
|
name = param.name ? param.name.to_s : "arg_#{arg_num += 1}"
|
|
611
615
|
parameters.push Solargraph::Pin::Parameter.new(decl: :optarg, name: name, closure: pin,
|
|
612
616
|
# @sg-ignore RBS generic type understanding issue
|
|
@@ -626,13 +630,13 @@ module Solargraph
|
|
|
626
630
|
return_type: rest_positional_type)
|
|
627
631
|
end
|
|
628
632
|
type.type.trailing_positionals.each do |param|
|
|
629
|
-
# @sg-ignore
|
|
633
|
+
# @sg-ignore Unresolved call to name
|
|
630
634
|
name = param.name ? param.name.to_s : "arg_#{arg_num += 1}"
|
|
631
635
|
parameters.push Solargraph::Pin::Parameter.new(decl: :arg, name: name, closure: pin, source: :rbs,
|
|
632
636
|
type_location: type_location)
|
|
633
637
|
end
|
|
634
638
|
type.type.required_keywords.each do |orig, param|
|
|
635
|
-
# @sg-ignore
|
|
639
|
+
# @sg-ignore Unresolved call to to_s
|
|
636
640
|
name = orig ? orig.to_s : "arg_#{arg_num += 1}"
|
|
637
641
|
parameters.push Solargraph::Pin::Parameter.new(decl: :kwarg, name: name, closure: pin,
|
|
638
642
|
# @sg-ignore RBS generic type understanding issue
|
|
@@ -640,7 +644,7 @@ module Solargraph
|
|
|
640
644
|
source: :rbs, type_location: type_location)
|
|
641
645
|
end
|
|
642
646
|
type.type.optional_keywords.each do |orig, param|
|
|
643
|
-
# @sg-ignore
|
|
647
|
+
# @sg-ignore Unresolved call to to_s
|
|
644
648
|
name = orig ? orig.to_s : "arg_#{arg_num += 1}"
|
|
645
649
|
parameters.push Solargraph::Pin::Parameter.new(decl: :kwoptarg, name: name, closure: pin,
|
|
646
650
|
# @sg-ignore RBS generic type understanding issue
|
|
@@ -840,11 +844,7 @@ module Solargraph
|
|
|
840
844
|
# @param type [RBS::MethodType, RBS::Types::Block]
|
|
841
845
|
# @return [ComplexType, ComplexType::UniqueType]
|
|
842
846
|
def method_type_to_type type
|
|
843
|
-
|
|
844
|
-
other_type_to_type(type_aliases[type.type.return_type.to_s].type)
|
|
845
|
-
else
|
|
846
|
-
other_type_to_type type.type.return_type
|
|
847
|
-
end
|
|
847
|
+
other_type_to_type type.type.return_type
|
|
848
848
|
end
|
|
849
849
|
|
|
850
850
|
# @param type [RBS::Types::Bases::Base,Object] RBS type object.
|
|
@@ -932,7 +932,7 @@ module Solargraph
|
|
|
932
932
|
# @param namespace [Pin::Namespace, nil]
|
|
933
933
|
# @return [void]
|
|
934
934
|
def add_mixins decl, namespace
|
|
935
|
-
# @param mixin [RBS::AST::Members::Include, RBS::AST::Members::
|
|
935
|
+
# @param mixin [RBS::AST::Members::Include, RBS::AST::Members::Extend, RBS::AST::Members::Prepend]
|
|
936
936
|
decl.each_mixin do |mixin|
|
|
937
937
|
# @todo are we handling prepend correctly?
|
|
938
938
|
klass = mixin.is_a?(RBS::AST::Members::Include) ? Pin::Reference::Include : Pin::Reference::Extend
|
data/lib/solargraph/rbs_map.rb
CHANGED
|
@@ -74,7 +74,7 @@ module Solargraph
|
|
|
74
74
|
# @type gem_config [nil, Hash{String => Hash{String => String}}]
|
|
75
75
|
gem_config = nil
|
|
76
76
|
if rbs_collection_config_path
|
|
77
|
-
# @sg-ignore
|
|
77
|
+
# @sg-ignore rbs_collection_config_path is not nil here
|
|
78
78
|
lockfile_path = RBS::Collection::Config.to_lockfile_path(Pathname.new(rbs_collection_config_path))
|
|
79
79
|
if lockfile_path.exist?
|
|
80
80
|
collection_config = RBS::Collection::Config.from_path lockfile_path
|
|
@@ -95,8 +95,7 @@ module Solargraph
|
|
|
95
95
|
when 'stdlib'
|
|
96
96
|
CACHE_KEY_STDLIB
|
|
97
97
|
else
|
|
98
|
-
|
|
99
|
-
Digest::SHA1.hexdigest(data)
|
|
98
|
+
Digest::SHA1.hexdigest(data || '')
|
|
100
99
|
end
|
|
101
100
|
end
|
|
102
101
|
end
|
data/lib/solargraph/shell.rb
CHANGED
|
@@ -39,7 +39,7 @@ module Solargraph
|
|
|
39
39
|
end
|
|
40
40
|
# @sg-ignore Wrong argument type for Backport.prepare_tcp_server: adapter expected Backport::Adapter, received Module<Solargraph::LanguageServer::Transport::Adapter>
|
|
41
41
|
Backport.prepare_tcp_server host: options[:host], port: port, adapter: Solargraph::LanguageServer::Transport::Adapter
|
|
42
|
-
|
|
42
|
+
$stderr.puts "Solargraph is listening PORT=#{port} PID=#{Process.pid}"
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
|
|
@@ -56,7 +56,7 @@ module Solargraph
|
|
|
56
56
|
end
|
|
57
57
|
# @sg-ignore Wrong argument type for Backport.prepare_stdio_server: adapter expected Backport::Adapter, received Module<Solargraph::LanguageServer::Transport::Adapter>
|
|
58
58
|
Backport.prepare_stdio_server adapter: Solargraph::LanguageServer::Transport::Adapter
|
|
59
|
-
|
|
59
|
+
$stderr.puts "Solargraph is listening on stdio PID=#{Process.pid}"
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -105,8 +105,22 @@ module Solargraph
|
|
|
105
105
|
# @param gem [String]
|
|
106
106
|
# @param version [String, nil]
|
|
107
107
|
def cache gem, version = nil
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
gemspec = Gem::Specification.find_by_name(gem, version)
|
|
109
|
+
|
|
110
|
+
if options[:rebuild] || !PinCache.has_yard?(gemspec)
|
|
111
|
+
pins = GemPins.build_yard_pins(['yard-activesupport-concern'], gemspec)
|
|
112
|
+
PinCache.serialize_yard_gem(gemspec, pins)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
workspace = Solargraph::Workspace.new(Dir.pwd)
|
|
116
|
+
rbs_map = RbsMap.from_gemspec(gemspec, workspace.rbs_collection_path, workspace.rbs_collection_config_path)
|
|
117
|
+
if options[:rebuild] || !PinCache.has_rbs_collection?(gemspec, rbs_map.cache_key)
|
|
118
|
+
# cache pins even if result is zero, so we don't retry building pins
|
|
119
|
+
pins = rbs_map.pins || []
|
|
120
|
+
PinCache.serialize_rbs_collection_gem(gemspec, rbs_map.cache_key, pins)
|
|
121
|
+
end
|
|
122
|
+
rescue Gem::MissingSpecError
|
|
123
|
+
warn "Gem '#{gem}' not found"
|
|
110
124
|
end
|
|
111
125
|
|
|
112
126
|
desc 'uncache GEM [...GEM]', 'Delete specific cached gem documentation'
|
|
@@ -119,24 +133,19 @@ module Solargraph
|
|
|
119
133
|
# @return [void]
|
|
120
134
|
def uncache *gems
|
|
121
135
|
raise ArgumentError, 'No gems specified.' if gems.empty?
|
|
122
|
-
workspace = Solargraph::Workspace.new(Dir.pwd)
|
|
123
|
-
|
|
124
136
|
gems.each do |gem|
|
|
125
137
|
if gem == 'core'
|
|
126
|
-
PinCache.uncache_core
|
|
138
|
+
PinCache.uncache_core
|
|
127
139
|
next
|
|
128
140
|
end
|
|
129
141
|
|
|
130
142
|
if gem == 'stdlib'
|
|
131
|
-
PinCache.uncache_stdlib
|
|
143
|
+
PinCache.uncache_stdlib
|
|
132
144
|
next
|
|
133
145
|
end
|
|
134
146
|
|
|
135
|
-
spec =
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
# @sg-ignore flow sensitive typing needs to handle 'raise if'
|
|
139
|
-
workspace.uncache_gem(spec, out: $stdout)
|
|
147
|
+
spec = Gem::Specification.find_by_name(gem)
|
|
148
|
+
PinCache.uncache_gem(spec, out: $stdout)
|
|
140
149
|
end
|
|
141
150
|
end
|
|
142
151
|
|
|
@@ -172,11 +181,13 @@ module Solargraph
|
|
|
172
181
|
workspace = Solargraph::Workspace.new('.')
|
|
173
182
|
|
|
174
183
|
if names.empty?
|
|
175
|
-
|
|
184
|
+
Gem::Specification.to_a.each { |spec| do_cache spec, rebuild: options[:rebuild] }
|
|
185
|
+
$stderr.puts "Documentation cached for all #{Gem::Specification.count} gems."
|
|
176
186
|
else
|
|
177
187
|
warn("Caching these gems: #{names}")
|
|
178
188
|
names.each do |name|
|
|
179
189
|
if name == 'core'
|
|
190
|
+
# @sg-ignore cache_core and core? are dynamically defined
|
|
180
191
|
PinCache.cache_core(out: $stdout) if !PinCache.core? || options[:rebuild]
|
|
181
192
|
next
|
|
182
193
|
end
|
|
@@ -185,7 +196,18 @@ module Solargraph
|
|
|
185
196
|
if gemspec.nil?
|
|
186
197
|
warn "Gem '#{name}' not found"
|
|
187
198
|
else
|
|
188
|
-
|
|
199
|
+
if options[:rebuild] || !PinCache.has_yard?(gemspec)
|
|
200
|
+
pins = GemPins.build_yard_pins(['yard-activesupport-concern'], gemspec)
|
|
201
|
+
PinCache.serialize_yard_gem(gemspec, pins)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
workspace = Solargraph::Workspace.new(Dir.pwd)
|
|
205
|
+
rbs_map = RbsMap.from_gemspec(gemspec, workspace.rbs_collection_path, workspace.rbs_collection_config_path)
|
|
206
|
+
if options[:rebuild] || !PinCache.has_rbs_collection?(gemspec, rbs_map.cache_key)
|
|
207
|
+
# cache pins even if result is zero, so we don't retry building pins
|
|
208
|
+
pins = rbs_map.pins || []
|
|
209
|
+
PinCache.serialize_rbs_collection_gem(gemspec, rbs_map.cache_key, pins)
|
|
210
|
+
end
|
|
189
211
|
end
|
|
190
212
|
rescue Gem::MissingSpecError
|
|
191
213
|
warn "Gem '#{name}' not found"
|
|
@@ -364,6 +386,110 @@ module Solargraph
|
|
|
364
386
|
end
|
|
365
387
|
end
|
|
366
388
|
|
|
389
|
+
desc 'profile [FILE]', 'Profile go-to-definition performance using vernier'
|
|
390
|
+
option :directory, type: :string, aliases: :d, desc: 'The workspace directory', default: '.'
|
|
391
|
+
option :output_dir, type: :string, aliases: :o, desc: 'The output directory for profiles', default: './tmp/profiles'
|
|
392
|
+
option :line, type: :numeric, aliases: :l, desc: 'Line number (0-based)', default: 4
|
|
393
|
+
option :column, type: :numeric, aliases: :c, desc: 'Column number', default: 10
|
|
394
|
+
option :memory, type: :boolean, aliases: :m, desc: 'Include memory usage counter', default: true
|
|
395
|
+
# @param file [String, nil]
|
|
396
|
+
# @return [void]
|
|
397
|
+
def profile file = nil
|
|
398
|
+
begin
|
|
399
|
+
require 'vernier'
|
|
400
|
+
rescue LoadError
|
|
401
|
+
$stderr.puts 'vernier gem not found. Please install this dependency:'
|
|
402
|
+
$stderr.puts
|
|
403
|
+
$stderr.puts " gem 'vernier', '>1.0', '<2'"
|
|
404
|
+
|
|
405
|
+
return
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
hooks = []
|
|
409
|
+
hooks << :memory_usage if options[:memory]
|
|
410
|
+
|
|
411
|
+
directory = File.realpath(options[:directory])
|
|
412
|
+
FileUtils.mkdir_p(options[:output_dir])
|
|
413
|
+
|
|
414
|
+
host = Solargraph::LanguageServer::Host.new
|
|
415
|
+
host.client_capabilities.merge!({ 'window' => { 'workDoneProgress' => true } })
|
|
416
|
+
# @param method [String] The message method
|
|
417
|
+
# @param params [Hash] The method parameters
|
|
418
|
+
# @return [void]
|
|
419
|
+
def host.send_notification method, params
|
|
420
|
+
puts "Notification: #{method} - #{params}"
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
puts 'Parsing and mapping source files...'
|
|
424
|
+
prepare_start = Time.now
|
|
425
|
+
Vernier.profile(out: "#{options[:output_dir]}/parse_benchmark.json.gz", hooks: hooks) do
|
|
426
|
+
puts 'Mapping libraries'
|
|
427
|
+
host.prepare(directory)
|
|
428
|
+
sleep 0.2 until host.libraries.all?(&:mapped?)
|
|
429
|
+
end
|
|
430
|
+
prepare_time = Time.now - prepare_start
|
|
431
|
+
|
|
432
|
+
puts 'Building the catalog...'
|
|
433
|
+
catalog_start = Time.now
|
|
434
|
+
Vernier.profile(out: "#{options[:output_dir]}/catalog_benchmark.json.gz", hooks: hooks) do
|
|
435
|
+
host.catalog
|
|
436
|
+
end
|
|
437
|
+
catalog_time = Time.now - catalog_start
|
|
438
|
+
|
|
439
|
+
# Determine test file
|
|
440
|
+
if file
|
|
441
|
+
test_file = File.join(directory, file)
|
|
442
|
+
else
|
|
443
|
+
test_file = File.join(directory, 'lib', 'other.rb')
|
|
444
|
+
unless File.exist?(test_file)
|
|
445
|
+
# Fallback to any Ruby file in the workspace
|
|
446
|
+
workspace = Solargraph::Workspace.new(directory)
|
|
447
|
+
test_file = workspace.filenames.find { |f| f.end_with?('.rb') }
|
|
448
|
+
unless test_file
|
|
449
|
+
warn 'No Ruby files found in workspace'
|
|
450
|
+
return
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
file_uri = Solargraph::LanguageServer::UriHelpers.file_to_uri(File.absolute_path(test_file))
|
|
456
|
+
|
|
457
|
+
puts "Profiling go-to-definition for #{test_file}"
|
|
458
|
+
puts "Position: line #{options[:line]}, column #{options[:column]}"
|
|
459
|
+
|
|
460
|
+
definition_start = Time.now
|
|
461
|
+
Vernier.profile(out: "#{options[:output_dir]}/definition_benchmark.json.gz", hooks: hooks) do
|
|
462
|
+
message = Solargraph::LanguageServer::Message::TextDocument::Definition.new(
|
|
463
|
+
host, {
|
|
464
|
+
'params' => {
|
|
465
|
+
'textDocument' => { 'uri' => file_uri },
|
|
466
|
+
'position' => { 'line' => options[:line], 'character' => options[:column] }
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
)
|
|
470
|
+
puts 'Processing go-to-definition request...'
|
|
471
|
+
result = message.process
|
|
472
|
+
|
|
473
|
+
puts "Result: #{result.inspect}"
|
|
474
|
+
end
|
|
475
|
+
definition_time = Time.now - definition_start
|
|
476
|
+
|
|
477
|
+
puts "\n=== Timing Results ==="
|
|
478
|
+
puts "Parsing & mapping: #{(prepare_time * 1000).round(2)}ms"
|
|
479
|
+
puts "Catalog building: #{(catalog_time * 1000).round(2)}ms"
|
|
480
|
+
puts "Go-to-definition: #{(definition_time * 1000).round(2)}ms"
|
|
481
|
+
total_time = prepare_time + catalog_time + definition_time
|
|
482
|
+
puts "Total time: #{(total_time * 1000).round(2)}ms"
|
|
483
|
+
|
|
484
|
+
puts "\nProfiles saved to:"
|
|
485
|
+
puts " - #{File.expand_path('parse_benchmark.json.gz', options[:output_dir])}"
|
|
486
|
+
puts " - #{File.expand_path('catalog_benchmark.json.gz', options[:output_dir])}"
|
|
487
|
+
puts " - #{File.expand_path('definition_benchmark.json.gz', options[:output_dir])}"
|
|
488
|
+
|
|
489
|
+
puts "\nUpload the JSON files to https://vernier.prof/ to view the profiles."
|
|
490
|
+
puts 'Or use https://rubygems.org/gems/profile-viewer to view them locally.'
|
|
491
|
+
end
|
|
492
|
+
|
|
367
493
|
private
|
|
368
494
|
|
|
369
495
|
# @param pin [Solargraph::Pin::Base]
|
|
@@ -403,5 +529,27 @@ module Solargraph
|
|
|
403
529
|
puts pin.inspect
|
|
404
530
|
end
|
|
405
531
|
end
|
|
532
|
+
|
|
533
|
+
# @param gemspec [Gem::Specification, nil]
|
|
534
|
+
# @param rebuild [Boolean]
|
|
535
|
+
# @return [void]
|
|
536
|
+
def do_cache gemspec, rebuild: false
|
|
537
|
+
if gemspec.nil?
|
|
538
|
+
warn "Gem '#{gemspec&.name}' not found"
|
|
539
|
+
else
|
|
540
|
+
if rebuild || !PinCache.has_yard?(gemspec)
|
|
541
|
+
pins = GemPins.build_yard_pins(['yard-activesupport-concern'], gemspec)
|
|
542
|
+
PinCache.serialize_yard_gem(gemspec, pins)
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
workspace = Solargraph::Workspace.new(Dir.pwd)
|
|
546
|
+
rbs_map = RbsMap.from_gemspec(gemspec, workspace.rbs_collection_path, workspace.rbs_collection_config_path)
|
|
547
|
+
if rebuild || !PinCache.has_rbs_collection?(gemspec, rbs_map.cache_key)
|
|
548
|
+
# cache pins even if result is zero, so we don't retry building pins
|
|
549
|
+
pins = rbs_map.pins || []
|
|
550
|
+
PinCache.serialize_rbs_collection_gem(gemspec, rbs_map.cache_key, pins)
|
|
551
|
+
end
|
|
552
|
+
end
|
|
553
|
+
end
|
|
406
554
|
end
|
|
407
555
|
end
|
|
@@ -170,7 +170,9 @@ module Solargraph
|
|
|
170
170
|
type = infer_from_definitions(pins, links.last.last_context, api_map, locals)
|
|
171
171
|
out = maybe_nil(type)
|
|
172
172
|
logger.debug do
|
|
173
|
-
"Chain#infer_uncached(links=#{links.map(&:desc)}, locals=#{locals.map(&:desc)},
|
|
173
|
+
"Chain#infer_uncached(links=#{links.map(&:desc)}, locals=#{locals.map(&:desc)}, " \
|
|
174
|
+
"name_pin=#{name_pin}, name_pin.closure=#{name_pin&.closure&.inspect}, " \
|
|
175
|
+
"name_pin.binder=#{name_pin&.binder}) => #{out.rooted_tags.inspect}"
|
|
174
176
|
end
|
|
175
177
|
out
|
|
176
178
|
end
|
|
@@ -174,7 +174,6 @@ module Solargraph
|
|
|
174
174
|
when 'visibility'
|
|
175
175
|
|
|
176
176
|
kind = directive.tag.text&.to_sym
|
|
177
|
-
# @sg-ignore Need to look at Tuple#include? handling
|
|
178
177
|
return unless %i[private protected public].include?(kind)
|
|
179
178
|
|
|
180
179
|
name = directive.tag.name
|
|
@@ -225,7 +224,6 @@ module Solargraph
|
|
|
225
224
|
# @sg-ignore flow sensitive typing should be able to handle redefinition
|
|
226
225
|
namespace.domains.concat directive.tag.types unless directive.tag.types.nil?
|
|
227
226
|
when 'override'
|
|
228
|
-
# @sg-ignore Need to add nil check here
|
|
229
227
|
pins.push Pin::Reference::Override.new(location, directive.tag.name, docstring.tags,
|
|
230
228
|
source: :source_map)
|
|
231
229
|
when 'macro'
|
|
@@ -351,7 +351,6 @@ module Solargraph
|
|
|
351
351
|
all_closest = all_found.map { |pin| pin.typify(api_map) }
|
|
352
352
|
closest = ComplexType.new(all_closest.flat_map(&:items).uniq)
|
|
353
353
|
# @todo remove the internal_or_core? check at a higher-than-strict level
|
|
354
|
-
# @sg-ignore Need to add nil check here
|
|
355
354
|
if (!found || found.is_a?(Pin::BaseVariable) || (closest.defined? && internal_or_core?(found))) && !(closest.generic? || ignored_pins.include?(found))
|
|
356
355
|
if closest.defined?
|
|
357
356
|
result.push Problem.new(location, "Unresolved call to #{missing.links.last.word} on #{closest}")
|
|
@@ -479,7 +478,7 @@ module Solargraph
|
|
|
479
478
|
ptype = params.key?(par.name) ? params[par.name][:qualified] : ComplexType::UNDEFINED
|
|
480
479
|
ptype = ptype.self_to_type(par.context)
|
|
481
480
|
if ptype.nil?
|
|
482
|
-
|
|
481
|
+
# @todo Some level (strong, I guess) should require the param here
|
|
483
482
|
else
|
|
484
483
|
argtype = argchain.infer(api_map, closure_pin, locals)
|
|
485
484
|
argtype = argtype.self_to_type(closure_pin.context)
|
data/lib/solargraph/version.rb
CHANGED
|
@@ -168,7 +168,7 @@ module Solargraph
|
|
|
168
168
|
# @return [Hash{String => Array, Hash, Integer}]
|
|
169
169
|
def default_config
|
|
170
170
|
{
|
|
171
|
-
'include' => ['Rakefile', 'Gemfile', '*.gemspec', '
|
|
171
|
+
'include' => ['Rakefile', 'Gemfile', '*.gemspec', './**/*.rb'],
|
|
172
172
|
'exclude' => ['spec/**/*', 'test/**/*', 'vendor/**/*', '.bundle/**/*'],
|
|
173
173
|
'require' => [],
|
|
174
174
|
'domains' => [],
|
|
@@ -190,7 +190,7 @@ module Solargraph
|
|
|
190
190
|
end
|
|
191
191
|
# @sg-ignore Unresolved constant Gem::StubSpecification
|
|
192
192
|
when Gem::StubSpecification
|
|
193
|
-
# @sg-ignore
|
|
193
|
+
# @sg-ignore Unresolved call to to_spec on Gem::Specification, Bundler::LazySpecification, Bundler::StubSpecification
|
|
194
194
|
specish.to_spec
|
|
195
195
|
else
|
|
196
196
|
raise "Unexpected type while resolving gem: #{specish.class}"
|
|
@@ -313,7 +313,7 @@ module Solargraph
|
|
|
313
313
|
end
|
|
314
314
|
end
|
|
315
315
|
|
|
316
|
-
# @sg-ignore
|
|
316
|
+
# @sg-ignore return type could not be inferred
|
|
317
317
|
# @return [Array<Gem::Specification>]
|
|
318
318
|
def all_gemspecs_from_external_bundle
|
|
319
319
|
@all_gemspecs_from_external_bundle ||=
|