Class: ThemeCheck::LanguageServer::DiagnosticsEngine

Inherits:
Object
  • Object
show all
Includes:
URIHelper
Defined in:
lib/theme_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/theme_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/theme_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
34
# File 'lib/theme_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

  theme = ThemeCheck::Theme.new(storage)
  analyzer = ThemeCheck::Analyzer.new(theme, config.enabled_checks)

  if !only_single_file && (@diagnostics_manager.first_run? || force)
    run_full_theme_check(analyzer)
  else
    run_partial_theme_check(absolute_path_or_paths, theme, analyzer, only_single_file)
  end

  @diagnostics_lock.unlock
end

#clear_diagnostics(relative_paths) ⇒ Object



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

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/theme_check/language_server/diagnostics_engine.rb', line 17

def first_run?
  @diagnostics_manager.first_run?
end