Class: Solargraph::LanguageServer::Host::Diagnoser
- Inherits:
-
Object
- Object
- Solargraph::LanguageServer::Host::Diagnoser
- Defined in:
- lib/solargraph/language_server/host/diagnoser.rb
Instance Method Summary collapse
-
#initialize(host) ⇒ Diagnoser
constructor
A new instance of Diagnoser.
-
#schedule(uri) ⇒ void
Schedule a file to be diagnosed.
-
#start ⇒ self
Start the diagnosis thread.
-
#stop ⇒ void
Stop the diagnosis thread.
-
#stopped? ⇒ Boolean
True is the diagnoser is stopped.
Constructor Details
#initialize(host) ⇒ Diagnoser
Returns a new instance of Diagnoser.
5 6 7 8 9 10 |
# File 'lib/solargraph/language_server/host/diagnoser.rb', line 5 def initialize host @host = host @mutex = Mutex.new @queue = [] @stopped = true end |
Instance Method Details
#schedule(uri) ⇒ void
This method returns an undefined value.
Schedule a file to be diagnosed.
16 17 18 |
# File 'lib/solargraph/language_server/host/diagnoser.rb', line 16 def schedule uri mutex.synchronize { queue.push uri } end |
#start ⇒ self
Start the diagnosis thread.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/solargraph/language_server/host/diagnoser.rb', line 37 def start return unless @stopped @stopped = false Thread.new do until stopped? sleep 0.1 next if queue.empty? || host.synchronizing? if !host.['diagnostics'] mutex.synchronize { queue.clear } next end current = nil mutex.synchronize { current = queue.shift } next if queue.include?(current) host.diagnose current sleep 0.5 end end self end |
#stop ⇒ void
This method returns an undefined value.
Stop the diagnosis thread.
23 24 25 |
# File 'lib/solargraph/language_server/host/diagnoser.rb', line 23 def stop @stopped = true end |
#stopped? ⇒ Boolean
True is the diagnoser is stopped.
30 31 32 |
# File 'lib/solargraph/language_server/host/diagnoser.rb', line 30 def stopped? @stopped end |