Module: RBS::Inline::AST::Declarations::DataStructUtil

Included in:
DataAssignDecl, StructAssignDecl
Defined in:
lib/rbs/inline/ast/declarations.rb

Instance Method Summary collapse

Instance Method Details

#class_annotationsObject

: Array



326
327
328
329
330
331
332
333
334
335
336
# File 'lib/rbs/inline/ast/declarations.rb', line 326

def class_annotations #: Array[RBS::AST::Annotation]
  annotations = [] #: Array[RBS::AST::Annotation]

  comments&.each_annotation do |annotation|
    if annotation.is_a?(Annotations::RBSAnnotation)
      annotations.concat annotation.annotations
    end
  end

  annotations
end

#each_attribute(&block) ⇒ Object



311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/rbs/inline/ast/declarations.rb', line 311

def each_attribute(&block)
  if block
    each_attribute_argument do |arg|
      if arg.is_a?(Prism::SymbolNode)
        if name = arg.value
          type = type_decls.fetch(arg.location.start_line, nil)
          yield [name.to_sym, type]
        end
      end
    end
  else
    enum_for :each_attribute
  end
end