Class: RBS::Inline::AST::Declarations::DataAssignDecl
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
: AnnotationParser::ParsingResult?.
-
#data_define_node ⇒ Object
readonly
: Prism::CallNode.
-
#node ⇒ Object
readonly
: Prism::ConstantWriteNode.
-
#type_decls ⇒ Object
readonly
: Hash[Integer, Annotations::TypeAssertion].
Class Method Summary collapse
Instance Method Summary collapse
- #constant_name ⇒ Object
- #each_attribute_argument(&block) ⇒ Object
-
#initialize(node, data_define_node, comments, type_decls) ⇒ DataAssignDecl
constructor
A new instance of DataAssignDecl.
-
#start_line ⇒ Object
: Integer.
Methods included from ConstantUtil
Methods included from DataStructUtil
#class_annotations, #each_attribute
Constructor Details
#initialize(node, data_define_node, comments, type_decls) ⇒ DataAssignDecl
Returns a new instance of DataAssignDecl.
428 429 430 431 432 433 |
# File 'lib/rbs/inline/ast/declarations.rb', line 428 def initialize(node, data_define_node, comments, type_decls) @node = node @comments = comments @type_decls = type_decls @data_define_node = data_define_node end |
Instance Attribute Details
#comments ⇒ Object (readonly)
: AnnotationParser::ParsingResult?
421 422 423 |
# File 'lib/rbs/inline/ast/declarations.rb', line 421 def comments @comments end |
#data_define_node ⇒ Object (readonly)
: Prism::CallNode
425 426 427 |
# File 'lib/rbs/inline/ast/declarations.rb', line 425 def data_define_node @data_define_node end |
#node ⇒ Object (readonly)
: Prism::ConstantWriteNode
419 420 421 |
# File 'lib/rbs/inline/ast/declarations.rb', line 419 def node @node end |
#type_decls ⇒ Object (readonly)
: Hash[Integer, Annotations::TypeAssertion]
423 424 425 |
# File 'lib/rbs/inline/ast/declarations.rb', line 423 def type_decls @type_decls end |
Class Method Details
.data_define?(node) ⇒ Boolean
446 447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/rbs/inline/ast/declarations.rb', line 446 def self.data_define?(node) value = value_node(node) if value.is_a?(Prism::CallNode) if value.receiver.is_a?(Prism::ConstantReadNode) if value.receiver.full_name.delete_prefix("::") == "Data" if value.name == :define return value end end end end end |
Instance Method Details
#constant_name ⇒ Object
441 442 443 |
# File 'lib/rbs/inline/ast/declarations.rb', line 441 def constant_name TypeName.new(name: node.name, namespace: Namespace.empty) end |
#each_attribute_argument(&block) ⇒ Object
461 462 463 464 465 |
# File 'lib/rbs/inline/ast/declarations.rb', line 461 def each_attribute_argument(&block) if args = data_define_node.arguments args.arguments.each(&block) end end |
#start_line ⇒ Object
: Integer
435 436 437 |
# File 'lib/rbs/inline/ast/declarations.rb', line 435 def start_line #: Integer node.location.start_line end |