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.
338 339 340 341 342 343 |
# File 'lib/rbs/inline/ast/declarations.rb', line 338 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?
331 332 333 |
# File 'lib/rbs/inline/ast/declarations.rb', line 331 def comments @comments end |
#data_define_node ⇒ Object (readonly)
: Prism::CallNode
335 336 337 |
# File 'lib/rbs/inline/ast/declarations.rb', line 335 def data_define_node @data_define_node end |
#node ⇒ Object (readonly)
: Prism::ConstantWriteNode
329 330 331 |
# File 'lib/rbs/inline/ast/declarations.rb', line 329 def node @node end |
#type_decls ⇒ Object (readonly)
: Hash[Integer, Annotations::TypeAssertion]
333 334 335 |
# File 'lib/rbs/inline/ast/declarations.rb', line 333 def type_decls @type_decls end |
Class Method Details
.data_define?(node) ⇒ Boolean
356 357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/rbs/inline/ast/declarations.rb', line 356 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
351 352 353 |
# File 'lib/rbs/inline/ast/declarations.rb', line 351 def constant_name TypeName.new(name: node.name, namespace: Namespace.empty) end |
#each_attribute_argument(&block) ⇒ Object
371 372 373 374 375 |
# File 'lib/rbs/inline/ast/declarations.rb', line 371 def each_attribute_argument(&block) if args = data_define_node.arguments args.arguments.each(&block) end end |
#start_line ⇒ Object
: Integer
345 346 347 |
# File 'lib/rbs/inline/ast/declarations.rb', line 345 def start_line #: Integer node.location.start_line end |