19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/theme_check/language_server/diagnostics_engine.rb', line 19
def analyze_and_send_offenses(absolute_path, config)
return unless @diagnostics_lock.try_lock
@token += 1
@bridge.send_create_work_done_progress_request(@token)
storage = ThemeCheck::FileSystemStorage.new(
config.root,
ignored_patterns: config.ignored_patterns
)
theme = ThemeCheck::Theme.new(storage)
analyzer = ThemeCheck::Analyzer.new(theme, config.enabled_checks)
if @diagnostics_tracker.first_run?
@bridge.send_work_done_progress_begin(@token, "Full theme check")
@bridge.log("Checking #{config.root}")
offenses = nil
time = Benchmark.measure do
offenses = analyzer.analyze_theme do |path, i, total|
@bridge.send_work_done_progress_report(@token, "#{i}/#{total} #{path}", (i.to_f / total * 100.0).to_i)
end
end
end_message = "Found #{offenses.size} offenses in #{format("%0.2f", time.real)}s"
@bridge.send_work_done_progress_end(@token, end_message)
send_diagnostics(offenses)
else
relative_path = Pathname.new(storage.relative_path(absolute_path))
file = theme[relative_path]
if file
@bridge.send_work_done_progress_begin(@token, "Partial theme check")
offenses = nil
time = Benchmark.measure do
offenses = analyzer.analyze_files([file]) do |path, i, total|
@bridge.send_work_done_progress_report(@token, "#{i}/#{total} #{path}", (i.to_f / total * 100.0).to_i)
end
end
end_message = "Found #{offenses.size} new offenses in #{format("%0.2f", time.real)}s"
@bridge.send_work_done_progress_end(@token, end_message)
@bridge.log(end_message)
send_diagnostics(offenses, [absolute_path])
end
end
@diagnostics_lock.unlock
end
|