Class: RBS::AST::Ruby::Annotations::MethodTypesAnnotation

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

Constant Summary collapse

Overload =
AST::Members::MethodDefinition::Overload

Instance Attribute Summary collapse

Attributes inherited from Base

#location, #prefix_location

Instance Method Summary collapse

Methods inherited from Base

#buffer

Constructor Details

#initialize(location:, prefix_location:, overloads:, vertical_bar_locations:, dot3_location:) ⇒ MethodTypesAnnotation

Returns a new instance of MethodTypesAnnotation.



114
115
116
117
118
119
# File 'lib/rbs/ast/ruby/annotations.rb', line 114

def initialize(location:, prefix_location:, overloads:, vertical_bar_locations:, dot3_location:)
  super(location, prefix_location)
  @overloads = overloads
  @vertical_bar_locations = vertical_bar_locations
  @dot3_location = dot3_location
end

Instance Attribute Details

#dot3_locationObject (readonly)

Returns the value of attribute dot3_location.



112
113
114
# File 'lib/rbs/ast/ruby/annotations.rb', line 112

def dot3_location
  @dot3_location
end

#overloadsObject (readonly)

Returns the value of attribute overloads.



112
113
114
# File 'lib/rbs/ast/ruby/annotations.rb', line 112

def overloads
  @overloads
end

#vertical_bar_locationsObject (readonly)

Returns the value of attribute vertical_bar_locations.



112
113
114
# File 'lib/rbs/ast/ruby/annotations.rb', line 112

def vertical_bar_locations
  @vertical_bar_locations
end

Instance Method Details

#map_type_name(&block) ⇒ Object



121
122
123
124
125
126
127
128
129
130
# File 'lib/rbs/ast/ruby/annotations.rb', line 121

def map_type_name(&block)
  ovs = overloads.map do |overload|
    Overload.new(
      method_type: overload.method_type.map_type {|type| type.map_type_name { yield _1 } },
      annotations: overload.annotations
    )
  end

  self.class.new(location:, prefix_location:, overloads: ovs, vertical_bar_locations:, dot3_location:) #: self
end

#type_fingerprintObject



132
133
134
135
136
137
138
# File 'lib/rbs/ast/ruby/annotations.rb', line 132

def type_fingerprint
  [
    "annots/method_types",
    overloads.map { |o| [o.annotations.map(&:to_s), o.method_type.to_s] },
    overloading: dot3_location ? true : false
  ]
end