Class: RBS::Inline::AST::Declarations::BlockDecl

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, comments) ⇒ BlockDecl

Returns a new instance of BlockDecl.



255
256
257
258
259
# File 'lib/rbs/inline/ast/declarations.rb', line 255

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

Instance Attribute Details

#commentsObject (readonly)

: AnnotationParser::ParsingResult?



249
250
251
# File 'lib/rbs/inline/ast/declarations.rb', line 249

def comments
  @comments
end

#membersObject (readonly)

Members included in the declaration



252
253
254
# File 'lib/rbs/inline/ast/declarations.rb', line 252

def members
  @members
end

#nodeObject (readonly)

: Prism::BlockNode



247
248
249
# File 'lib/rbs/inline/ast/declarations.rb', line 247

def node
  @node
end

Instance Method Details

#module_class_annotationObject

: Annotations::ModuleDecl | Annotations::ClassDecl | nil



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/rbs/inline/ast/declarations.rb', line 265

def module_class_annotation #: Annotations::ModuleDecl | Annotations::ClassDecl | nil
  if comments
    comments.each_annotation.each do |annotation|
      if annotation.is_a?(Annotations::ModuleDecl)
        return annotation
      end

      if annotation.is_a?(Annotations::ClassDecl)
        return annotation
      end
    end

    nil
  end
end

#start_lineObject

: Integer



261
262
263
# File 'lib/rbs/inline/ast/declarations.rb', line 261

def start_line #: Integer
  node.location.start_line
end