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

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

Overview

@rbs METHOD-TYPEs annotation in leading comments

^^^^                                            -- prefix_location
                ^                               -- vertical_bar_locations[0]
                                       ^        -- vertical_bar_locations[1]
                                         ^^^    -- dot3_location

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.

Parameters:



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_locationLocation? (readonly)

Returns the value of attribute dot3_location.

Returns:



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

def dot3_location
  @dot3_location
end

#overloadsArray[Overload] (readonly)

Returns the value of attribute overloads.

Returns:



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

def overloads
  @overloads
end

#vertical_bar_locationsArray[Location] (readonly)

Returns the value of attribute vertical_bar_locations.

Returns:



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 {|arg0| ... } ⇒ self

Yields:

Yield Parameters:

Yield Returns:

Returns:

  • (self)


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

Returns:

  • (Object)


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