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.
564 565 566 567 568 569 |
# File 'lib/rbs/inline/ast/members.rb', line 564 def initialize(comment, annotation) #: void @comment = comment @annotation = annotation super(comment.comments[0].location) end |
Instance Attribute Details
#annotation ⇒ Object (readonly)
: Annotations::Embedded
558 559 560 |
# File 'lib/rbs/inline/ast/members.rb', line 558 def annotation @annotation end |
#comment ⇒ Object (readonly)
: AnnotationParser::ParsingResult
560 561 562 |
# File 'lib/rbs/inline/ast/members.rb', line 560 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.
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
# File 'lib/rbs/inline/ast/members.rb', line 575 def members #: Array[RBS::AST::Members::t | RBS::AST::Declarations::t] | RBS::ParsingError source = " module EmbeddedModuleTest\n \#{annotation.content}\n end\n RBS\n\n _, _, decls = RBS::Parser.parse_signature(source)\n\n mod = decls[0]\n mod.is_a?(RBS::AST::Declarations::Module) or raise\n\n mod.members.each do |member|\n # Clear `@location` of each member so that new lines are inserted between members.\n # See `RBS::Writer#preserve_empty_line`.\n member.instance_variable_set(:@location, nil)\n end\n\nrescue RBS::ParsingError => exn\n exn\nend\n" |