Class: RBS::Inline::AST::Members::RBSEmbedded
- Defined in:
- lib/rbs/inline/ast/members.rb
Instance Attribute Summary collapse
-
#annotation ⇒ Object
readonly
: Annotations::Embedded.
-
#comment ⇒ Object
readonly
: AnnotationParser::ParsingResult.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(comment, annotation) ⇒ RBSEmbedded
constructor
A new instance of RBSEmbedded.
-
#members ⇒ Object
Returns the array of ‘RBS::AST` members.
Methods inherited from Base
Constructor Details
#initialize(comment, annotation) ⇒ RBSEmbedded
Returns a new instance of RBSEmbedded.
561 562 563 564 565 566 |
# File 'lib/rbs/inline/ast/members.rb', line 561 def initialize(comment, annotation) #: void @comment = comment @annotation = annotation super(comment.comments[0].location) end |
Instance Attribute Details
#annotation ⇒ Object (readonly)
: Annotations::Embedded
555 556 557 |
# File 'lib/rbs/inline/ast/members.rb', line 555 def annotation @annotation end |
#comment ⇒ Object (readonly)
: AnnotationParser::ParsingResult
557 558 559 |
# File 'lib/rbs/inline/ast/members.rb', line 557 def comment @comment end |
Instance Method Details
#members ⇒ Object
Returns the array of ‘RBS::AST` members
Returns ‘RBS::ParsingError` when the `content` has syntax error.
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
# File 'lib/rbs/inline/ast/members.rb', line 572 def members #: Array[RBS::AST::Members::t | RBS::AST::Declarations::t] | RBS::ParsingError source = <<~RBS module EmbeddedModuleTest #{annotation.content} end RBS _, _, decls = RBS::Parser.parse_signature(source) mod = decls[0] mod.is_a?(RBS::AST::Declarations::Module) or raise mod.members.each do |member| # Clear `@location` of each member so that new lines are inserted between members. # See `RBS::Writer#preserve_empty_line`. member.instance_variable_set(:@location, nil) end rescue RBS::ParsingError => exn exn end |