Class: PlatformosCheck::LanguageServer::DiagnosticsEngine

Inherits:
Object
  • Object
show all
Includes:
URIHelper
Defined in:
lib/platformos_check/language_server/diagnostics_engine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from URIHelper

#file_path, #file_uri

Constructor Details

#initialize(storage, bridge, diagnostics_manager = DiagnosticsManager.new) ⇒ DiagnosticsEngine

Returns a new instance of DiagnosticsEngine.



10
11
12
13
14
15
# File 'lib/platformos_check/language_server/diagnostics_engine.rb', line 10

def initialize(storage, bridge, diagnostics_manager = DiagnosticsManager.new)
  @diagnostics_lock = Mutex.new
  @diagnostics_manager = diagnostics_manager
  @storage = storage
  @bridge = bridge
end

Instance Attribute Details

#storageObject (readonly)

Returns the value of attribute storage.



8
9
10
# File 'lib/platformos_check/language_server/diagnostics_engine.rb', line 8

def storage
  @storage
end

Instance Method Details

#analyze_and_send_offenses(absolute_path_or_paths, config, force: false, only_single_file: false) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/platformos_check/language_server/diagnostics_engine.rb', line 21

def analyze_and_send_offenses(absolute_path_or_paths, config, force: false, only_single_file: false)
  return unless @diagnostics_lock.try_lock

  analyzer = PlatformosCheck::Analyzer.new(storage.platformos_app, config.enabled_checks)

  if !only_single_file && (@diagnostics_manager.first_run? || force)
    run_full_platformos_check(analyzer)
  else
    run_partial_platformos_check(absolute_path_or_paths, storage.platformos_app, analyzer, only_single_file)
  end

  @diagnostics_lock.unlock
end

#clear_diagnostics(relative_paths) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/platformos_check/language_server/diagnostics_engine.rb', line 35

def clear_diagnostics(relative_paths)
  return unless @diagnostics_lock.try_lock

  as_array(relative_paths).each do |relative_path|
    send_clearing_diagnostics(relative_path)
  end

  @diagnostics_lock.unlock
end

#first_run?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/platformos_check/language_server/diagnostics_engine.rb', line 17

def first_run?
  @diagnostics_manager.first_run?
end