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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, comments) ⇒ BlockDecl

Returns a new instance of BlockDecl.

Parameters:



345
346
347
348
349
# File 'lib/rbs/inline/ast/declarations.rb', line 345

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

Instance Attribute Details

#commentsAnnotationParser::ParsingResult? (readonly)

: AnnotationParser::ParsingResult?



339
340
341
# File 'lib/rbs/inline/ast/declarations.rb', line 339

def comments
  @comments
end

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

Members included in the declaration

Returns:

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


342
343
344
# File 'lib/rbs/inline/ast/declarations.rb', line 342

def members
  @members
end

#nodePrism::BlockNode (readonly)

: Prism::BlockNode

Returns:

  • (Prism::BlockNode)


337
338
339
# File 'lib/rbs/inline/ast/declarations.rb', line 337

def node
  @node
end

Instance Method Details

#module_class_annotationAnnotations::ModuleDecl, ...

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



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/rbs/inline/ast/declarations.rb', line 355

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_lineInteger

: Integer

Returns:

  • (Integer)


351
352
353
# File 'lib/rbs/inline/ast/declarations.rb', line 351

def start_line #: Integer
  node.location.start_line
end