Class: Prism::SourceFileNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::SourceFileNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Class Method Summary collapse
-
.type ⇒ :source_file_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#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, filepath: self.filepath) ⇒ SourceFileNode
:call-seq: copy(**fields) -> SourceFileNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#filepath ⇒ String
:call-seq: filepath -> String.
-
#forced_binary_encoding? ⇒ Boolean
:category: Flags internal bytes forced the encoding to binary.
-
#forced_utf8_encoding? ⇒ Boolean
:category: Flags internal bytes forced the encoding to UTF-8.
-
#frozen? ⇒ Boolean
:category: Flags frozen by virtue of a
frozen_string_literal: truecomment or--enable-frozen-string-literal. -
#initialize(source, node_id, location, flags, filepath) ⇒ SourceFileNode
constructor
Initialize a new SourceFileNode node.
-
#inspect ⇒ String
: () -> String.
-
#mutable? ⇒ Boolean
:category: Flags mutable by virtue of a
frozen_string_literal: falsecomment or--disable-frozen-string-literal. -
#type ⇒ :source_file_node
See
Node#type.
Constructor Details
#initialize(source, node_id, location, flags, filepath) ⇒ SourceFileNode
Initialize a new SourceFileNode node.
: (Source source, Integer node_id, Location location, Integer flags, String filepath) -> void
30412 30413 30414 30415 30416 30417 30418 |
# File 'lib/prism/node.rb', line 30412 def initialize(source, node_id, location, flags, filepath) @source = source @node_id = node_id @location = location @flags = flags @filepath = filepath end |
Class Method Details
.type ⇒ :source_file_node
See Node.type.
: () -> :source_file_node
30496 30497 30498 |
# File 'lib/prism/node.rb', line 30496 def self.type :source_file_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
30554 30555 30556 30557 30558 |
# File 'lib/prism/node.rb', line 30554 def ===(other) # :nodoc: other.is_a?(SourceFileNode) && (flags === other.flags) && (filepath === other.filepath) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
30434 30435 30436 |
# File 'lib/prism/node.rb', line 30434 def accept(visitor) visitor.visit_source_file_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
30441 30442 30443 |
# File 'lib/prism/node.rb', line 30441 def child_nodes [] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
30457 30458 30459 |
# File 'lib/prism/node.rb', line 30457 def compact_child_nodes [] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, filepath: self.filepath) ⇒ SourceFileNode
:call-seq:
copy(**fields) -> SourceFileNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?filepath: String) -> SourceFileNode
30467 30468 30469 |
# File 'lib/prism/node.rb', line 30467 def copy(node_id: self.node_id, location: self.location, flags: self.flags, filepath: self.filepath) SourceFileNode.new(source, node_id, location, flags, filepath) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
30474 30475 30476 30477 30478 30479 30480 30481 30482 30483 30484 |
# File 'lib/prism/node.rb', line 30474 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location filepath]).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 :filepath then deconstructed[:filepath] = self.filepath end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
30449 30450 30451 30452 |
# File 'lib/prism/node.rb', line 30449 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? end |
#filepath ⇒ String
:call-seq:
filepath -> String
Represents the file path being parsed. This corresponds directly to the filepath option given to the various Prism.parse* APIs.
: () -> String
30545 30546 30547 |
# File 'lib/prism/node.rb', line 30545 def filepath @filepath end |
#forced_binary_encoding? ⇒ Boolean
:category: Flags internal bytes forced the encoding to binary
: () -> bool
30519 30520 30521 |
# File 'lib/prism/node.rb', line 30519 def forced_binary_encoding? flags.anybits?(StringFlags::FORCED_BINARY_ENCODING) end |
#forced_utf8_encoding? ⇒ Boolean
:category: Flags internal bytes forced the encoding to UTF-8
: () -> bool
30511 30512 30513 |
# File 'lib/prism/node.rb', line 30511 def forced_utf8_encoding? flags.anybits?(StringFlags::FORCED_UTF8_ENCODING) end |
#frozen? ⇒ Boolean
:category: Flags
frozen by virtue of a frozen_string_literal: true comment or --enable-frozen-string-literal
: () -> bool
30527 30528 30529 |
# File 'lib/prism/node.rb', line 30527 def frozen? flags.anybits?(StringFlags::FROZEN) end |
#inspect ⇒ String
: () -> String
30501 30502 30503 |
# File 'lib/prism/node.rb', line 30501 def inspect # :nodoc: InspectVisitor.compose(self) end |
#mutable? ⇒ Boolean
:category: Flags
mutable by virtue of a frozen_string_literal: false comment or --disable-frozen-string-literal
: () -> bool
30535 30536 30537 |
# File 'lib/prism/node.rb', line 30535 def mutable? flags.anybits?(StringFlags::MUTABLE) end |
#type ⇒ :source_file_node
See Node#type.
: () -> :source_file_node
30489 30490 30491 |
# File 'lib/prism/node.rb', line 30489 def type :source_file_node end |