Class: RBS::AST::Ruby::Declarations::ClassDecl

Inherits:
Base
  • Object
show all
Defined in:
lib/rbs/ast/ruby/declarations.rb

Defined Under Namespace

Classes: SuperClass

Instance Attribute Summary collapse

Attributes inherited from Base

#buffer

Instance Method Summary collapse

Methods included from Helpers::LocationHelper

#rbs_location

Methods included from Helpers::ConstantHelper

constant_as_type_name

Constructor Details

#initialize(buffer, name, node, super_class) ⇒ ClassDecl

Returns a new instance of ClassDecl.



74
75
76
77
78
79
80
# File 'lib/rbs/ast/ruby/declarations.rb', line 74

def initialize(buffer, name, node, super_class)
  super(buffer)
  @class_name = name
  @node = node
  @members = []
  @super_class = super_class
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.



66
67
68
# File 'lib/rbs/ast/ruby/declarations.rb', line 66

def class_name
  @class_name
end

#membersObject (readonly)

Returns the value of attribute members.



68
69
70
# File 'lib/rbs/ast/ruby/declarations.rb', line 68

def members
  @members
end

#nodeObject (readonly)

Returns the value of attribute node.



70
71
72
# File 'lib/rbs/ast/ruby/declarations.rb', line 70

def node
  @node
end

#super_classObject (readonly)

Returns the value of attribute super_class.



72
73
74
# File 'lib/rbs/ast/ruby/declarations.rb', line 72

def super_class
  @super_class
end

Instance Method Details

#each_decl(&block) ⇒ Object



82
83
84
85
86
87
88
89
90
# File 'lib/rbs/ast/ruby/declarations.rb', line 82

def each_decl(&block)
  return enum_for(:each_decl) unless block

  @members.each do |member|
    if member.is_a?(Base)
      yield member
    end
  end
end

#locationObject



94
95
96
# File 'lib/rbs/ast/ruby/declarations.rb', line 94

def location
  rbs_location(node.location)
end

#name_locationObject



98
99
100
# File 'lib/rbs/ast/ruby/declarations.rb', line 98

def name_location
  rbs_location(node.constant_path.location)
end

#type_fingerprintObject



102
103
104
105
106
107
108
109
110
111
# File 'lib/rbs/ast/ruby/declarations.rb', line 102

def type_fingerprint
  result = [] #: Array[untyped]

  result << "decls/class"
  result << class_name.to_s
  result << super_class&.type_fingerprint
  result << members.map { _1.type_fingerprint }

  result
end

#type_paramsObject



92
# File 'lib/rbs/ast/ruby/declarations.rb', line 92

def type_params = []