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

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

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.

Parameters:



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

#commentsAnnotationParser::ParsingResult? (readonly)

Leading comment



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

def comments
  @comments
end

#membersArray[Members::t | t] (readonly)

Members included in the declaration

Returns:

  • (Array[Members::t | t])


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

def members
  @members
end

#nodeNODE (readonly)

The node that represents the declaration

Returns:

  • (NODE)


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

def node
  @node
end

Instance Method Details

#start_lineInteger

: Integer

Returns:

  • (Integer)


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

def start_line #: Integer
  node.location.start_line
end

#type_paramsArray[RBS::AST::TypeParam]

Type parameters for the declaration

Returns:

  • (Array[RBS::AST::TypeParam])


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