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.



428
429
430
431
# File 'lib/steep/diagnostic/signature.rb', line 428

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

Instance Attribute Details

#declObject (readonly)

Returns the value of attribute decl.



426
427
428
# File 'lib/steep/diagnostic/signature.rb', line 426

def decl
  @decl
end

Instance Method Details

#header_lineObject



433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/steep/diagnostic/signature.rb', line 433

def header_line
  expected_kind =
    case decl
    when RBS::AST::Declarations::ModuleAlias
      "module"
    when RBS::AST::Declarations::ClassAlias
      "class"
    when RBS::AST::Ruby::Declarations::ClassModuleAliasDecl
      if decl.annotation.is_a?(RBS::AST::Ruby::Annotations::ClassAliasAnnotation)
        "class"
      else
        "module"
      end
    end

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