Class: RBS::AST::Ruby::Annotations::ModuleSelfAnnotation

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

Overview

@rbs module-self: NAME[ARGS] -- comment annotation in leading comments

^^^^                                                -- prefix_location
     ^^^^^^^^^^^                                    -- keyword_location
                ^                                   -- colon_location
                       ^                            -- open_bracket_location
                              ^                     -- args_comma_locations[0]
                                       ^            -- close_bracket_location
                                         ^^^^^^^^^^ -- comment_location

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:, keyword_location:, colon_location:, name:, args:, open_bracket_location:, close_bracket_location:, args_comma_locations:, comment_location:) ⇒ ModuleSelfAnnotation

Returns a new instance of ModuleSelfAnnotation.



359
360
361
362
363
364
365
366
367
368
369
# File 'lib/rbs/ast/ruby/annotations.rb', line 359

def initialize(location:, prefix_location:, keyword_location:, colon_location:, name:, args:, open_bracket_location:, close_bracket_location:, args_comma_locations:, comment_location:)
  super(location, prefix_location)
  @keyword_location = keyword_location
  @colon_location = colon_location
  @name = name
  @args = args
  @open_bracket_location = open_bracket_location
  @close_bracket_location = close_bracket_location
  @args_comma_locations = args_comma_locations
  @comment_location = comment_location
end

Instance Attribute Details

#argsArray[Types::t] (readonly)

Returns the value of attribute args.

Returns:

  • (Array[Types::t])


357
358
359
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

def args
  @args
end

#args_comma_locationsArray[Location] (readonly)

Returns the value of attribute args_comma_locations.

Returns:



357
358
359
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

def args_comma_locations
  @args_comma_locations
end

#close_bracket_locationLocation? (readonly)

Returns the value of attribute close_bracket_location.

Returns:



357
358
359
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

def close_bracket_location
  @close_bracket_location
end

#colon_locationLocation (readonly)

Returns the value of attribute colon_location.

Returns:



357
358
359
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

def colon_location
  @colon_location
end

#comment_locationLocation? (readonly)

Returns the value of attribute comment_location.

Returns:



357
358
359
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

def comment_location
  @comment_location
end

#keyword_locationLocation (readonly)

Returns the value of attribute keyword_location.

Returns:



357
358
359
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

def keyword_location
  @keyword_location
end

#nameTypeName (readonly)

Returns the value of attribute name.

Returns:



357
358
359
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

def name
  @name
end

#open_bracket_locationLocation? (readonly)

Returns the value of attribute open_bracket_location.

Returns:



357
358
359
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

def open_bracket_location
  @open_bracket_location
end

Instance Method Details

#map_type_name {|arg0| ... } ⇒ self

Yields:

Yield Parameters:

Yield Returns:

Returns:

  • (self)


371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/rbs/ast/ruby/annotations.rb', line 371

def map_type_name
  mapped_args = args.map { |type| type.map_type_name { yield _1 } }

  self.class.new(
    location:,
    prefix_location:,
    keyword_location:,
    colon_location:,
    name: yield(name),
    args: mapped_args,
    open_bracket_location:,
    close_bracket_location:,
    args_comma_locations:,
    comment_location:
  ) #: self
end

#type_fingerprintObject

Returns:

  • (Object)


388
389
390
391
392
393
394
395
# File 'lib/rbs/ast/ruby/annotations.rb', line 388

def type_fingerprint
  [
    "annots/module_self",
    name.to_s,
    args.map(&:to_s),
    comment_location&.source
  ]
end