Module: Steep::Diagnostic::Signature

Defined in:
lib/steep/diagnostic/signature.rb

Defined Under Namespace

Classes: Base, ClassInstanceVariableDuplicationError, ClassVariableDuplicationError, CyclicClassAliasDefinitionError, DeprecatedTypeName, DuplicatedDeclaration, DuplicatedMethodDefinition, GenericParameterMismatch, InconsistentClassModuleAliasError, InheritModuleError, InlineDiagnostic, InstanceVariableDuplicationError, InstanceVariableTypeError, InvalidMethodOverload, InvalidTypeApplication, InvalidVarianceAnnotation, MixinClassError, ModuleSelfTypeError, NonregularTypeAlias, RecursiveAlias, RecursiveAncestor, RecursiveTypeAlias, SuperclassMismatch, SyntaxError, TypeParamDefaultReferenceError, UnexpectedError, UnknownMethodAlias, UnknownTypeName, UnsatisfiableGenericsDefaultType, UnsatisfiableTypeApplication, VariableDuplicationError

Class Method Summary collapse

Class Method Details

.from_rbs_error(error, factory:) ⇒ Object



531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/steep/diagnostic/signature.rb', line 531

def self.from_rbs_error(error, factory:)
  case error
  when RBS::ParsingError
    Diagnostic::Signature::SyntaxError.new(error, location: error.location)
  when RBS::DuplicatedDeclarationError
    Diagnostic::Signature::DuplicatedDeclaration.new(
      type_name: error.name,
      location: error.decls.fetch(0).location
    )
  when RBS::GenericParameterMismatchError
    Diagnostic::Signature::GenericParameterMismatch.new(
      name: error.name,
      location: error.decl.location
    )
  when RBS::InvalidTypeApplicationError
    Diagnostic::Signature::InvalidTypeApplication.new(
      name: error.type_name,
      args: error.args.map {|ty| factory.type(ty) },
      params: error.params,
      location: error.location
    )
  when RBS::NoTypeFoundError,
    RBS::NoSuperclassFoundError,
    RBS::NoMixinFoundError,
    RBS::NoSelfTypeFoundError
    Diagnostic::Signature::UnknownTypeName.new(
      name: error.type_name,
      location: error.location
    )
  when RBS::InvalidOverloadMethodError
    Diagnostic::Signature::InvalidMethodOverload.new(
      class_name: error.type_name,
      method_name: error.method_name,
      location: error.members.fetch(0).location
    )
  when RBS::DuplicatedMethodDefinitionError
    Diagnostic::Signature::DuplicatedMethodDefinition.new(
      class_name: error.type_name,
      method_name: error.method_name,
      location: error.location
    )
  when RBS::DuplicatedInterfaceMethodDefinitionError
    Diagnostic::Signature::DuplicatedMethodDefinition.new(
      class_name: error.type_name,
      method_name: error.method_name,
      location: error.member.location
    )
  when RBS::UnknownMethodAliasError
    Diagnostic::Signature::UnknownMethodAlias.new(
      class_name: error.type_name,
      method_name: error.original_name,
      location: error.location
    )
  when RBS::RecursiveAliasDefinitionError
    Diagnostic::Signature::RecursiveAlias.new(
      class_name: error.type.name,
      names: error.defs.map(&:name),
      location: error.defs.fetch(0).original&.location
    )
  when RBS::RecursiveAncestorError
    Diagnostic::Signature::RecursiveAncestor.new(
      ancestors: error.ancestors,
      location: error.location
    )
  when RBS::SuperclassMismatchError
    Diagnostic::Signature::SuperclassMismatch.new(
      name: error.name,
      location: error.entry.primary_decl.location
    )
  when RBS::InvalidVarianceAnnotationError
    Diagnostic::Signature::InvalidVarianceAnnotation.new(
      name: error.type_name,
      param: error.param,
      location: error.location
    )
  when RBS::MixinClassError
    Diagnostic::Signature::MixinClassError.new(
      location: error.location,
      type_name: error.type_name,
      member: error.member,
    )
  when RBS::RecursiveTypeAliasError
    Diagnostic::Signature::RecursiveTypeAlias.new(
      alias_names: error.alias_names,
      location: error.location
    )
  when RBS::NonregularTypeAliasError
    Diagnostic::Signature::NonregularTypeAlias.new(
      type_name: error.diagnostic.type_name,
      nonregular_type: factory.type(error.diagnostic.nonregular_type),
      location: error.location
    )
  when RBS::InheritModuleError
    Diagnostic::Signature::InheritModuleError.new(error.super_decl)
  when RBS::InconsistentClassModuleAliasError
    Diagnostic::Signature::InconsistentClassModuleAliasError.new(decl: error.alias_entry.decl)
  when RBS::CyclicClassAliasDefinitionError
    Diagnostic::Signature::CyclicClassAliasDefinitionError.new(decl: error.alias_entry.decl)
  when RBS::TypeParamDefaultReferenceError
    Diagnostic::Signature::TypeParamDefaultReferenceError.new(error.type_param, location: error.location)
  when RBS::InstanceVariableDuplicationError
    Diagnostic::Signature::InstanceVariableDuplicationError.new(type_name: error.type_name, variable_name: error.variable_name, location: error.location)
  when RBS::ClassInstanceVariableDuplicationError
    Diagnostic::Signature::ClassInstanceVariableDuplicationError.new(type_name: error.type_name, variable_name: error.variable_name, location: error.location)
  else
    raise error
  end
end