class Solargraph::LanguageServer::Host::Diagnoser
An asynchronous diagnosis reporter.
Attributes
@return [Host]
@return [Mutex]
@return [::Array]
Public Class Methods
Source
# File lib/solargraph/language_server/host/diagnoser.rb, line 10 def initialize host @host = host @mutex = Mutex.new @queue = [] @stopped = true end
@param host [Host]
Public Instance Methods
Source
# File lib/solargraph/language_server/host/diagnoser.rb, line 21 def schedule uri mutex.synchronize { queue.push uri } end
Schedule a file to be diagnosed.
@param uri [String] @return [void]
Source
# File lib/solargraph/language_server/host/diagnoser.rb, line 42 def start return unless @stopped @stopped = false Thread.new do until stopped? tick sleep 0.1 end end self end
Start the diagnosis thread.
@return [self, nil]
Source
# File lib/solargraph/language_server/host/diagnoser.rb, line 28 def stop @stopped = true end
Stop the diagnosis thread.
@return [void]
Source
# File lib/solargraph/language_server/host/diagnoser.rb, line 35 def stopped? @stopped end
True is the diagnoser is stopped.
@return [Boolean]
Source
# File lib/solargraph/language_server/host/diagnoser.rb, line 57 def tick return if queue.empty? || host.synchronizing? if !host.options['diagnostics'] mutex.synchronize { queue.clear } return end current = mutex.synchronize { queue.shift } return if queue.include?(current) begin host.diagnose current rescue InvalidOffsetError # @todo This error can occur when the Source is out of sync with # with the ApiMap. It's probably not the best way to handle it, # but it's quick and easy. Logging.logger.warn "Deferring diagnosis due to invalid offset: #{current}" mutex.synchronize { queue.push current } end end
Perform diagnoses.
@return [void]