Class: RBS::Inline::AST::Annotations::ModuleSelf
- Defined in:
- lib/rbs/inline/ast/annotations.rb
Overview
‘# @rbs module-self [MODULE_SELF]`
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
: String?.
-
#self_types ⇒ Object
readonly
: Array.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(tree, source) ⇒ ModuleSelf
constructor
A new instance of ModuleSelf.
Constructor Details
#initialize(tree, source) ⇒ ModuleSelf
Returns a new instance of ModuleSelf.
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
# File 'lib/rbs/inline/ast/annotations.rb', line 518 def initialize(tree, source) @tree = tree @source = source @self_types = [] module_self = tree.nth_tree!(1) self_trees = module_self.non_trivia_trees self_trees.shift while true type = self_trees.shift case type when Types::ClassInstance, Types::Interface @self_types << RBS::AST::Declarations::Module::Self.new( name: type.name, args: type.args, location: nil ) end break if self_trees.empty? next_tree = self_trees.first if next_tree.is_a?(Array) && next_tree[0] == :kCOMMA self_trees.shift else break end end if comment = self_trees.first @comment = comment.to_s end end |
Instance Attribute Details
#comment ⇒ Object (readonly)
: String?
515 516 517 |
# File 'lib/rbs/inline/ast/annotations.rb', line 515 def comment @comment end |
#self_types ⇒ Object (readonly)
: Array
513 514 515 |
# File 'lib/rbs/inline/ast/annotations.rb', line 513 def self_types @self_types end |