Class: Steep::Diagnostic::Ruby::DeprecatedReference

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(node:, location:, message:) ⇒ DeprecatedReference

Returns a new instance of DeprecatedReference.



1056
1057
1058
1059
# File 'lib/steep/diagnostic/ruby.rb', line 1056

def initialize(node:, location:, message:)
  super(node: node, location: location)
  @message = message
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



1054
1055
1056
# File 'lib/steep/diagnostic/ruby.rb', line 1054

def message
  @message
end

Instance Method Details

#header_lineObject



1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
# File 'lib/steep/diagnostic/ruby.rb', line 1061

def header_line
  header =
    case node&.type
    when :send, :csend, :block, :numblock
      "The method is deprecated"
    when :const, :casgn
      "The constant is deprecated"
    when :gvar, :gvasgn
      "The global variable is deprecated"
    else
      raise "Unexpected node: #{node}"
    end

  if message
    header = +header
    header.concat(": ", message)
  end

  header
end