Class: Prism::ForwardingSuperNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ForwardingSuperNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Represents the use of the super keyword without parentheses or arguments, but which might have a block.
super
^^^^^
super { 123 }
^^^^^^^^^^^^^
Explore code sample
If it has any other arguments, it would be a SuperNode instead.
Class Method Summary collapse
-
.type ⇒ :forwarding_super_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#block ⇒ BlockNode?
:call-seq: block -> BlockNode | nil.
-
#child_nodes ⇒ Array[node?]
(also: #deconstruct)
See Node.child_nodes.
-
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, block: self.block) ⇒ ForwardingSuperNode
:call-seq: copy(**fields) -> ForwardingSuperNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#initialize(source, node_id, location, flags, keyword_loc, block) ⇒ ForwardingSuperNode
constructor
Initialize a new ForwardingSuperNode node.
-
#inspect ⇒ String
: () -> String.
-
#keyword ⇒ String
:call-seq: keyword -> String.
-
#keyword_loc ⇒ Location
:category: Locations :call-seq: keyword_loc -> Location.
-
#save_keyword_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the keyword_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ :forwarding_super_node
See
Node#type.
Constructor Details
#initialize(source, node_id, location, flags, keyword_loc, block) ⇒ ForwardingSuperNode
Initialize a new ForwardingSuperNode node.
: (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, BlockNode? block) -> void
13770 13771 13772 13773 13774 13775 13776 13777 |
# File 'lib/prism/node.rb', line 13770 def initialize(source, node_id, location, flags, keyword_loc, block) @source = source @node_id = node_id @location = location @flags = flags @keyword_loc = keyword_loc @block = block end |
Class Method Details
.type ⇒ :forwarding_super_node
See Node.type.
: () -> :forwarding_super_node
13860 13861 13862 |
# File 'lib/prism/node.rb', line 13860 def self.type :forwarding_super_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
13922 13923 13924 13925 13926 |
# File 'lib/prism/node.rb', line 13922 def ===(other) # :nodoc: other.is_a?(ForwardingSuperNode) && (keyword_loc.nil? == other.keyword_loc.nil?) && (block === other.block) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
13793 13794 13795 |
# File 'lib/prism/node.rb', line 13793 def accept(visitor) visitor.visit_forwarding_super_node(self) end |
#block ⇒ BlockNode?
:call-seq:
block -> BlockNode | nil
All other arguments are forwarded as normal, except the original block is replaced with the new block.
: () -> BlockNode?
13903 13904 13905 |
# File 'lib/prism/node.rb', line 13903 def block @block end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
13800 13801 13802 |
# File 'lib/prism/node.rb', line 13800 def child_nodes [block] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
13817 13818 13819 13820 13821 |
# File 'lib/prism/node.rb', line 13817 def compact_child_nodes compact = [] #: Array[Prism::node] if (block = self.block); compact << block; end compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, block: self.block) ⇒ ForwardingSuperNode
:call-seq:
copy(**fields) -> ForwardingSuperNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?block: BlockNode?) -> ForwardingSuperNode
13829 13830 13831 |
# File 'lib/prism/node.rb', line 13829 def copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, block: self.block) ForwardingSuperNode.new(source, node_id, location, flags, keyword_loc, block) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 |
# File 'lib/prism/node.rb', line 13836 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location keyword_loc block keyword]).each_with_object( {} #: Hash[Symbol, untyped] ) do |key, deconstructed| case key when :node_id then deconstructed[:node_id] = self.node_id when :location then deconstructed[:location] = self.location when :keyword_loc then deconstructed[:keyword_loc] = self.keyword_loc when :block then deconstructed[:block] = self.block when :keyword then deconstructed[:keyword] = self.keyword end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
13808 13809 13810 13811 13812 |
# File 'lib/prism/node.rb', line 13808 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? if (block = self.block); yield block; end end |
#inspect ⇒ String
: () -> String
13865 13866 13867 |
# File 'lib/prism/node.rb', line 13865 def inspect # :nodoc: InspectVisitor.compose(self) end |
#keyword ⇒ String
:call-seq:
keyword -> String
Slice the location of keyword_loc from the source.
: () -> String
13915 13916 13917 |
# File 'lib/prism/node.rb', line 13915 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Location
:category: Locations :call-seq:
keyword_loc -> Location
super ^^^^^
super { 123 } ^^^^^
: () -> Location
13882 13883 13884 13885 13886 |
# File 'lib/prism/node.rb', line 13882 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_keyword_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the keyword_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
13893 13894 13895 |
# File 'lib/prism/node.rb', line 13893 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end |
#type ⇒ :forwarding_super_node
See Node#type.
: () -> :forwarding_super_node
13853 13854 13855 |
# File 'lib/prism/node.rb', line 13853 def type :forwarding_super_node end |