Skip to content

Commit 93e2988

Browse files
authored
Show cache progress in shell commands (#874)
* Show cache progress in shell commands * Typecheck error
1 parent c701781 commit 93e2988

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/solargraph/api_map.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,19 @@ def self.load directory
156156
# Create an ApiMap with a workspace in the specified directory and cache
157157
# any missing gems.
158158
#
159+
#
160+
# @todo IO::NULL is incorrectly inferred to be a String.
161+
# @sg-ignore
162+
#
159163
# @param directory [String]
164+
# @param out [IO] The output stream for messages
160165
# @return [ApiMap]
161-
def self.load_with_cache directory
166+
def self.load_with_cache directory, out = IO::NULL
162167
api_map = load(directory)
163168
return api_map if api_map.uncached_gemspecs.empty?
164169

165170
api_map.uncached_gemspecs.each do |gemspec|
166-
Solargraph.logger.info "Caching #{gemspec.name} #{gemspec.version}..."
171+
out.puts "Caching gem #{gemspec.name} #{gemspec.version}"
167172
pins = GemPins.build(gemspec)
168173
Solargraph::Cache.save('gems', "#{gemspec.name}-#{gemspec.version}.ser", pins)
169174
end
@@ -598,7 +603,7 @@ def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false
598603
# namespaces; resolving the generics in the method pins is this
599604
# class' responsibility
600605
raw_methods = store.get_methods(fqns, scope: scope, visibility: visibility).sort{ |a, b| a.name <=> b.name }
601-
namespace_pin = store.get_path_pins(fqns).select{|p| p.is_a?(Pin::Namespace)}.first
606+
namespace_pin = store.get_path_pins(fqns).select { |p| p.is_a?(Pin::Namespace) }.first
602607
methods = if rooted_tag != fqns
603608
methods = raw_methods.map do |method_pin|
604609
method_pin.resolve_generics(namespace_pin, rooted_type)

lib/solargraph/shell.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def reporters
150150
# @return [void]
151151
def typecheck *files
152152
directory = File.realpath(options[:directory])
153-
api_map = Solargraph::ApiMap.load_with_cache(directory)
153+
api_map = Solargraph::ApiMap.load_with_cache(directory, $stdout)
154154
probcount = 0
155155
if files.empty?
156156
files = api_map.source_maps.map(&:filename)
@@ -191,7 +191,7 @@ def scan
191191
directory = File.realpath(options[:directory])
192192
api_map = nil
193193
time = Benchmark.measure {
194-
api_map = Solargraph::ApiMap.load_with_cache(directory)
194+
api_map = Solargraph::ApiMap.load_with_cache(directory, $stdout)
195195
api_map.pins.each do |pin|
196196
begin
197197
puts pin_description(pin) if options[:verbose]

0 commit comments

Comments
 (0)