Module: Steep::Diagnostic::Ruby::ResultPrinter

Instance Method Summary collapse

Instance Method Details

#detail_linesObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/steep/diagnostic/ruby.rb', line 48

def detail_lines
  lines = StringIO.new.tap do |io|
    failure_path = result.failure_path || []
    failure_path.reverse_each.map do |result|
      relation_message(result.relation)
    end.compact.each.with_index(1) do |message, index|
      io.puts "#{"  " * (index)}#{message}"
    end
  end.string.chomp

  unless lines.empty?
    lines
  end
end

#relation_message(relation) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/steep/diagnostic/ruby.rb', line 29

def relation_message(relation)
  case
  when relation.type?
    relation.to_s
  when relation.method?
    if relation.super_type.is_a?(Interface::MethodType) && relation.sub_type.is_a?(Interface::MethodType)
      relation.to_s
    end
  when relation.interface?
    nil
  when relation.block?
    "(Blocks are incompatible)"
  when relation.function?
    nil
  when relation.params?
    "(Params are incompatible)"
  end
end