Class: Steep::Diagnostic::Ruby::UndeclaredMethodDefinition

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

Instance Attribute Summary collapse

Attributes inherited from Base

#location, #node

Instance Method Summary collapse

Methods inherited from Base

#detail_lines, #diagnostic_code

Methods included from Helper

#error_name, #full_message

Constructor Details

#initialize(method_name:, type_name:, node:) ⇒ UndeclaredMethodDefinition

Returns a new instance of UndeclaredMethodDefinition.



1020
1021
1022
1023
1024
# File 'lib/steep/diagnostic/ruby.rb', line 1020

def initialize(method_name:, type_name:, node:)
  @method_name = method_name
  @type_name = type_name
  super(node: node, location: (_ = node.loc).name)
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



1018
1019
1020
# File 'lib/steep/diagnostic/ruby.rb', line 1018

def method_name
  @method_name
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



1018
1019
1020
# File 'lib/steep/diagnostic/ruby.rb', line 1018

def type_name
  @type_name
end

Instance Method Details

#header_lineObject



1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
# File 'lib/steep/diagnostic/ruby.rb', line 1026

def header_line
  name =
      case node.type
      when :def
        "#{type_name}##{method_name}"
      when :defs
        "#{type_name}.#{method_name}"
      else
        raise
      end
  "Method `#{name}` is not declared in RBS"
end