17
18
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
63
|
# File 'lib/theme_check/language_server/diagnostics_tracker.rb', line 17
def build_diagnostics(offenses, analyzed_files: nil)
reported_files = Set.new
new_single_file_offenses = {}
analyzed_files = analyzed_files.map { |path| Pathname.new(path) } if analyzed_files
offenses.group_by(&:template).each do |template, template_offenses|
next unless template
reported_offenses = template_offenses
previous_offenses = @single_files_offenses[template.path]
if analyzed_files.nil? || analyzed_files.include?(template.path)
reported_single_file_offenses = reported_offenses.select(&:single_file?)
if reported_single_file_offenses.any?
new_single_file_offenses[template.path] = reported_single_file_offenses
end
elsif previous_offenses
reported_offenses |= previous_offenses
end
yield template.path, reported_offenses
reported_files << template.path
end
@single_files_offenses.each do |path, _|
next if reported_files.include?(path)
if analyzed_files.nil? || analyzed_files.include?(path)
yield path, []
new_single_file_offenses[path] = nil
end
reported_files << path
end
(@previously_reported_files - reported_files).each do |path|
yield path, []
end
@previously_reported_files = reported_files
@single_files_offenses.merge!(new_single_file_offenses)
@first_run = false
end
|