Class: Steep::Drivers::DiagnosticPrinter::CodeFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- Steep::Drivers::DiagnosticPrinter::CodeFormatter
- Defined in:
- lib/steep/drivers/diagnostic_printer/code_formatter.rb
Instance Attribute Summary
Attributes inherited from BaseFormatter
Instance Method Summary collapse
Methods inherited from BaseFormatter
Constructor Details
This class inherits a constructor from Steep::Drivers::DiagnosticPrinter::BaseFormatter
Instance Method Details
#print(diagnostic, prefix: "", source: true) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/steep/drivers/diagnostic_printer/code_formatter.rb', line 5 def print(diagnostic, prefix: "", source: true) header, *rest = diagnostic[:message].split(/\n/) stdout.puts "#{prefix}#{location(diagnostic)}: [#{(diagnostic[:severity])}] #{Rainbow(header).underline}" unless rest.empty? rest.each do || stdout.puts "#{prefix}│ #{}" end end if diagnostic[:code] stdout.puts "#{prefix}│" unless rest.empty? stdout.puts "#{prefix}│ Diagnostic ID: #{diagnostic[:code]}" end stdout.puts "#{prefix}│" if source print_source_line(diagnostic, prefix: prefix) else stdout.puts "#{prefix}└ (no source code available)" stdout.puts "#{prefix}" end end |