Class: Steep::Diagnostic::Ruby::NoMethod

Inherits:
Base 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(node:, type:, method:) ⇒ NoMethod

Returns a new instance of NoMethod.



241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/steep/diagnostic/ruby.rb', line 241

def initialize(node:, type:, method:)
  loc = case node.type
        when :send
          loc = _ = nil
          loc ||= node.loc.operator if node.loc.respond_to?(:operator) # steep:ignore NoMethod
          loc ||= node.loc.selector if node.loc.respond_to?(:selector) # steep:ignore NoMethod
          loc
        when :block
          node.children[0].loc.selector
        end
  super(node: node, location: loc || node.loc.expression)
  @type = type
  @method = method
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



239
240
241
# File 'lib/steep/diagnostic/ruby.rb', line 239

def method
  @method
end

#typeObject (readonly)

Returns the value of attribute type.



238
239
240
# File 'lib/steep/diagnostic/ruby.rb', line 238

def type
  @type
end

Instance Method Details

#header_lineObject



256
257
258
# File 'lib/steep/diagnostic/ruby.rb', line 256

def header_line
  "Type `#{type}` does not have method `#{method}`"
end