Module: RBS::DetailedMessageable

Included in:
ParsingError
Defined in:
lib/rbs/errors.rb

Instance Method Summary collapse

Instance Method Details

#detailed_message(highlight: false) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rbs/errors.rb', line 24

def detailed_message(highlight: false, **)
  indent = " " * location.start_column
  marker = "^" * (location.end_column - location.start_column)

  io = StringIO.new
  io.puts super
  io.puts
  io.print "\e[1m" if highlight
  io.puts "  #{location.buffer.lines[location.end_line - 1]}"
  io.puts "  #{indent}#{marker}"
  io.print "\e[m" if highlight
  io.string
end