class Solargraph::LanguageServer::Host::Diagnoser
An asynchronous diagnosis reporter.
def initialize host
-
host
(Host
) --
def initialize host @host = host @mutex = Mutex.new @queue = [] @stopped = true end
def schedule uri
-
(void)
-
Parameters:
-
uri
(String
) --
def schedule uri mutex.synchronize { queue.push uri } end
def start
-
(self, nil)
-
def start return unless @stopped @stopped = false Thread.new do until stopped? tick sleep 0.1 end end self end
def stop
-
(void)
-
def stop @stopped = true end
def stopped?
-
(Boolean)
-
def stopped? @stopped end
def tick
-
(void)
-
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