Class: RBS::Inline::AST::Declarations::ModuleOrClass

Inherits:
Base
  • Object
show all
Defined in:
lib/rbs/inline/ast/declarations.rb

Direct Known Subclasses

ClassDecl, ModuleDecl, SingletonClassDecl

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, comments) ⇒ ModuleOrClass

Returns a new instance of ModuleOrClass.



69
70
71
72
73
# File 'lib/rbs/inline/ast/declarations.rb', line 69

def initialize(node, comments) #: void
  @node = node
  @comments = comments
  @members = []
end

Instance Attribute Details

#commentsObject (readonly)

Leading comment



62
63
64
# File 'lib/rbs/inline/ast/declarations.rb', line 62

def comments
  @comments
end

#membersObject (readonly)

Members included in the declaration



65
66
67
# File 'lib/rbs/inline/ast/declarations.rb', line 65

def members
  @members
end

#nodeObject (readonly)

The node that represents the declaration



59
60
61
# File 'lib/rbs/inline/ast/declarations.rb', line 59

def node
  @node
end

Instance Method Details

#start_lineObject

: Integer



88
89
90
# File 'lib/rbs/inline/ast/declarations.rb', line 88

def start_line #: Integer
  node.location.start_line
end

#type_paramsObject

Type parameters for the declaration



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rbs/inline/ast/declarations.rb', line 76

def type_params #: Array[RBS::AST::TypeParam]
  if comments = comments()
    comments.each_annotation.filter_map do |annotation|
      if annotation.is_a?(Annotations::Generic)
        annotation.type_param
      end
    end
  else
    []
  end
end