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.
353 354 355 356 357 358 |
# File 'lib/rbs/inline/ast/declarations.rb', line 353 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?
346 347 348 |
# File 'lib/rbs/inline/ast/declarations.rb', line 346 def comments @comments end |
#data_define_node ⇒ Object (readonly)
: Prism::CallNode
350 351 352 |
# File 'lib/rbs/inline/ast/declarations.rb', line 350 def data_define_node @data_define_node end |
#node ⇒ Object (readonly)
: Prism::ConstantWriteNode
344 345 346 |
# File 'lib/rbs/inline/ast/declarations.rb', line 344 def node @node end |
#type_decls ⇒ Object (readonly)
: Hash[Integer, Annotations::TypeAssertion]
348 349 350 |
# File 'lib/rbs/inline/ast/declarations.rb', line 348 def type_decls @type_decls end |
Class Method Details
.data_define?(node) ⇒ Boolean
371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/rbs/inline/ast/declarations.rb', line 371 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
366 367 368 |
# File 'lib/rbs/inline/ast/declarations.rb', line 366 def constant_name TypeName.new(name: node.name, namespace: Namespace.empty) end |
#each_attribute_argument(&block) ⇒ Object
386 387 388 389 390 |
# File 'lib/rbs/inline/ast/declarations.rb', line 386 def each_attribute_argument(&block) if args = data_define_node.arguments args.arguments.each(&block) end end |
#start_line ⇒ Object
: Integer
360 361 362 |
# File 'lib/rbs/inline/ast/declarations.rb', line 360 def start_line #: Integer node.location.start_line end |