Class: Steep::Diagnostic::Ruby::UnresolvedOverloading

Inherits:
Base
  • Object
show all
Defined in:
lib/steep/diagnostic/ruby.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#location

Instance Method Summary collapse

Methods inherited from Base

#diagnostic_code

Methods included from Helper

#error_name, #full_message

Constructor Details

#initialize(node:, receiver_type:, method_name:, method_types:) ⇒ UnresolvedOverloading

Returns a new instance of UnresolvedOverloading.



193
194
195
196
197
198
# File 'lib/steep/diagnostic/ruby.rb', line 193

def initialize(node:, receiver_type:, method_name:, method_types:)
  super node: node
  @receiver_type = receiver_type
  @method_name = method_name
  @method_types = method_types
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



190
191
192
# File 'lib/steep/diagnostic/ruby.rb', line 190

def method_name
  @method_name
end

#method_typesObject (readonly)

Returns the value of attribute method_types.



191
192
193
# File 'lib/steep/diagnostic/ruby.rb', line 191

def method_types
  @method_types
end

#nodeObject (readonly)

Returns the value of attribute node.



188
189
190
# File 'lib/steep/diagnostic/ruby.rb', line 188

def node
  @node
end

#receiver_typeObject (readonly)

Returns the value of attribute receiver_type.



189
190
191
# File 'lib/steep/diagnostic/ruby.rb', line 189

def receiver_type
  @receiver_type
end

Instance Method Details

#detail_linesObject



204
205
206
207
208
209
210
211
212
213
214
# File 'lib/steep/diagnostic/ruby.rb', line 204

def detail_lines
  StringIO.new.tap do |io|
    io.puts "Method types:"
    first_type, *rest_types = method_types
    defn = "  def #{method_name}"
    io.puts "#{defn}: #{first_type}"
    rest_types.each do |method_type|
      io.puts "#{" " * defn.size}| #{method_type}"
    end
  end.string.chomp
end

#header_lineObject



200
201
202
# File 'lib/steep/diagnostic/ruby.rb', line 200

def header_line
  "Cannot find compatible overloading of method `#{method_name}` of type `#{receiver_type}`"
end