Class: Steep::Diagnostic::Signature::InconsistentClassModuleAliasError

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

Instance Attribute Summary collapse

Attributes inherited from Base

#location

Instance Method Summary collapse

Methods inherited from Base

#detail_lines, #diagnostic_code, #path

Methods included from Helper

#error_name, #full_message

Constructor Details

#initialize(decl:) ⇒ InconsistentClassModuleAliasError

Returns a new instance of InconsistentClassModuleAliasError.



397
398
399
400
# File 'lib/steep/diagnostic/signature.rb', line 397

def initialize(decl:)
  @decl = decl
  super(location: decl.location&.[](:old_name))
end

Instance Attribute Details

#declObject (readonly)

Returns the value of attribute decl.



395
396
397
# File 'lib/steep/diagnostic/signature.rb', line 395

def decl
  @decl
end

Instance Method Details

#header_lineObject



402
403
404
405
406
407
408
409
410
411
412
413
414
# File 'lib/steep/diagnostic/signature.rb', line 402

def header_line
  expected_kind =
    case decl
    when RBS::AST::Declarations::ModuleAlias
      "module"
    when RBS::AST::Declarations::ClassAlias
      "class"
    else
      raise
    end

  "A #{expected_kind} `#{decl.new_name}` cannot be an alias of `#{decl.old_name}`"
end