Class: RBS::Inline::AST::Annotations::ModuleDecl
- Includes:
- Utils
- Defined in:
- lib/rbs/inline/ast/annotations.rb
Overview
‘@rbs module Foo`
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
: TypeName?.
-
#self_types ⇒ Object
readonly
: Array.
-
#type_params ⇒ Object
readonly
: Array.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(tree, comments) ⇒ ModuleDecl
constructor
A new instance of ModuleDecl.
Methods included from Utils
#translate_super_class, #translate_type_name, #translate_type_param
Constructor Details
#initialize(tree, comments) ⇒ ModuleDecl
Returns a new instance of ModuleDecl.
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 |
# File 'lib/rbs/inline/ast/annotations.rb', line 680 def initialize(tree, comments) @tree = tree @source = comments decl_tree = tree.nth_tree!(1) if type_name = translate_type_name(decl_tree.nth_tree!(1)) if type_name.class? @name = type_name end end @type_params = [] if type_params = decl_tree.nth_tree(2) params = type_params.non_trivia_trees params.shift params.pop params.each_slice(2) do |param, _comma| raise unless param.is_a?(Tree) if type_param = translate_type_param(param) @type_params << type_param end end end @self_types = [] if selfs_tree = decl_tree.nth_tree(3) self_trees = selfs_tree.non_trivia_trees self_trees.shift self_trees.each_slice(2) do |type, _comma| case type when Types::ClassInstance, Types::Interface @self_types << RBS::AST::Declarations::Module::Self.new( name: type.name, args: type.args, location: type.location ) end end end end |
Instance Attribute Details
#name ⇒ Object (readonly)
: TypeName?
671 672 673 |
# File 'lib/rbs/inline/ast/annotations.rb', line 671 def name @name end |
#self_types ⇒ Object (readonly)
: Array
675 676 677 |
# File 'lib/rbs/inline/ast/annotations.rb', line 675 def self_types @self_types end |
#type_params ⇒ Object (readonly)
: Array
673 674 675 |
# File 'lib/rbs/inline/ast/annotations.rb', line 673 def type_params @type_params end |