diff --git a/.gitattributes b/.gitattributes index 21fd53cb14..6b1cb4d76a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,6 +7,7 @@ test/prism/fixtures/seattlerb/**/*.txt linguist-vendored test/prism/fixtures/unparser/**/*.txt linguist-vendored test/prism/fixtures/whitequark/**/*.txt linguist-vendored test/prism/snapshots/**/*.txt linguist-generated +sig/generated/**/*.rbs linguist-generated # All .rb files should have LF line ending, even on Windows, regardless of the git config core.autocrlf value. # All .txt should have their line endings as committed in the repository (there are some intentional CR in there), diff --git a/.gitignore b/.gitignore index 6706482b64..942a8c9fe9 100644 --- a/.gitignore +++ b/.gitignore @@ -59,12 +59,6 @@ out.svg /src/serialize.c /src/token_type.c /src/**/*.o -/sig/prism.rbs -/sig/prism/dsl.rbs -/sig/prism/mutation_compiler.rbs -/sig/prism/node.rbs -/sig/prism/visitor.rbs -/sig/prism/_private/dot_visitor.rbs /rbi/prism/dsl.rbi /rbi/prism/node.rbi /rbi/prism/visitor.rbi diff --git a/Steepfile b/Steepfile index 433e53cd29..e6e1a8efb5 100644 --- a/Steepfile +++ b/Steepfile @@ -1,21 +1,18 @@ # frozen_string_literal: true target :lib do + check "lib" signature "sig" - library "cgi" # in lib/prism/dot_visitor.rb (Prism::DotVisitor) - - check "lib" + library "cgi" + library "pp" - # TODO: Type-checking these files is still WIP - ignore "lib/prism/desugar_compiler.rb" - ignore "lib/prism/lex_compat.rb" - ignore "lib/prism/serialize.rb" - ignore "lib/prism/ffi.rb" + # Ignored because it requires other libraries. ignore "lib/prism/translation" - ignore "lib/prism/polyfill/append_as_bytes.rb" - ignore "lib/prism/polyfill/byteindex.rb" - ignore "lib/prism/polyfill/scan_byte.rb" - ignore "lib/prism/polyfill/unpack1.rb" + # Ignored because they are only for older Rubies. + ignore "lib/prism/polyfill" + + # Ignored because we do not want to overlap with the C extension. + ignore "lib/prism/ffi.rb" end diff --git a/gemfiles/typecheck/Gemfile b/gemfiles/typecheck/Gemfile index 7d552d2404..06f44effab 100644 --- a/gemfiles/typecheck/Gemfile +++ b/gemfiles/typecheck/Gemfile @@ -6,8 +6,10 @@ gem "minitest" gem "parser" gem "rake-compiler" gem "rake" +gem "rbs-inline" gem "ruby_parser" gem "sorbet", "<= 0.6.12666" # until tapioca is bumped gem "steep", ">= 1.7.0.dev.1" gem "tapioca" gem "test-unit" +gem "tsort" # until rbs is bumped diff --git a/gemfiles/typecheck/Gemfile.lock b/gemfiles/typecheck/Gemfile.lock index d880e049a5..e8e5157c6a 100644 --- a/gemfiles/typecheck/Gemfile.lock +++ b/gemfiles/typecheck/Gemfile.lock @@ -23,8 +23,7 @@ GEM csv (3.3.5) drb (2.2.3) erubi (1.13.1) - ffi (1.17.3-arm64-darwin) - ffi (1.17.3-x86_64-linux-gnu) + ffi (1.17.3) fileutils (1.8.0) i18n (1.14.7) concurrent-ruby (~> 1.0) @@ -57,12 +56,15 @@ GEM rbs (>= 3.4.4) rbs (3.10.2) logger + rbs-inline (0.13.0) + prism (>= 0.29) + rbs (>= 3.8.0) rexml (3.4.4) ruby_parser (3.22.0) racc (~> 1.5) sexp_processor (~> 4.16) securerandom (0.4.1) - sexp_processor (4.17.4) + sexp_processor (4.17.5) sorbet (0.6.12666) sorbet-static (= 0.6.12666) sorbet-runtime (0.6.12666) @@ -111,11 +113,12 @@ GEM test-unit (3.7.7) power_assert thor (1.4.0) + tsort (0.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (3.2.0) unicode-emoji (~> 4.1) - unicode-emoji (4.1.0) + unicode-emoji (4.2.0) uri (1.1.1) yard (0.9.37) yard-sorbet (0.9.0) @@ -131,11 +134,13 @@ DEPENDENCIES parser rake rake-compiler + rbs-inline ruby_parser sorbet (<= 0.6.12666) steep (>= 1.7.0.dev.1) tapioca test-unit + tsort BUNDLED WITH 2.5.16 diff --git a/lib/prism.rb b/lib/prism.rb index 5b3ce8752c..079026cf89 100644 --- a/lib/prism.rb +++ b/lib/prism.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled # The Prism Ruby parser. # @@ -37,6 +39,8 @@ module Prism # Raised when requested to parse as the currently running Ruby version but Prism has no support for it. class CurrentVersionError < ArgumentError # Initialize a new exception for the given ruby version string. + #-- + #: (String version) -> void def initialize(version) message = +"invalid version: Requested to parse as `version: 'current'`; " segments = @@ -61,6 +65,8 @@ def initialize(version) # resembles the return value of Ripper.lex. # # For supported options, see Prism.parse. + #-- + #: (String source, **untyped options) -> LexCompat::Result def self.lex_compat(source, **options) LexCompat.new(source, **options).result # steep:ignore end @@ -69,9 +75,37 @@ def self.lex_compat(source, **options) # load(source, serialized, freeze) -> ParseResult # # Load the serialized AST using the source as a reference into a tree. + #-- + #: (String source, String serialized, ?bool freeze) -> ParseResult def self.load(source, serialized, freeze = false) Serialize.load_parse(source, serialized, freeze) end + + # @rbs! + # VERSION: String + # BACKEND: :CEXT | :FFI + # + # interface _Stream + # def gets: (?Integer integer) -> (String | nil) + # end + # + # def self.parse: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult + # def self.profile: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> void + # def self.lex: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> LexResult + # def self.parse_lex: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseLexResult + # def self.dump: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> String + # def self.parse_comments: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> Array[Comment] + # def self.parse_success?: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool + # def self.parse_failure?: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool + # def self.parse_stream: (_Stream stream, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult + # def self.parse_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult + # def self.profile_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> void + # def self.lex_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> LexResult + # def self.parse_lex_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseLexResult + # def self.dump_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> String + # def self.parse_file_comments: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> Array[Comment] + # def self.parse_file_success?: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool + # def self.parse_file_failure?: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool end require_relative "prism/polyfill/byteindex" diff --git a/lib/prism/desugar_compiler.rb b/lib/prism/desugar_compiler.rb index 7d4201c1c4..c64d03f64a 100644 --- a/lib/prism/desugar_compiler.rb +++ b/lib/prism/desugar_compiler.rb @@ -1,12 +1,18 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled module Prism class DesugarAndWriteNode # :nodoc: include DSL - attr_reader :node, :default_source, :read_class, :write_class, :arguments + attr_reader :node #: ClassVariableAndWriteNode | ConstantAndWriteNode | GlobalVariableAndWriteNode | InstanceVariableAndWriteNode | LocalVariableAndWriteNode + attr_reader :default_source #: Source + attr_reader :read_class, :write_class #: Symbol + attr_reader :arguments #: Hash[Symbol, untyped] + #: ((ClassVariableAndWriteNode | ConstantAndWriteNode | GlobalVariableAndWriteNode | InstanceVariableAndWriteNode | LocalVariableAndWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void def initialize(node, default_source, read_class, write_class, **arguments) @node = node @default_source = default_source @@ -16,6 +22,8 @@ def initialize(node, default_source, read_class, write_class, **arguments) end # Desugar `x &&= y` to `x && x = y` + #-- + #: () -> node def compile and_node( location: node.location, @@ -36,8 +44,12 @@ def compile class DesugarOrWriteDefinedNode # :nodoc: include DSL - attr_reader :node, :default_source, :read_class, :write_class, :arguments + attr_reader :node #: ClassVariableOrWriteNode | ConstantOrWriteNode | GlobalVariableOrWriteNode + attr_reader :default_source #: Source + attr_reader :read_class, :write_class #: Symbol + attr_reader :arguments #: Hash[Symbol, untyped] + #: ((ClassVariableOrWriteNode | ConstantOrWriteNode | GlobalVariableOrWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void def initialize(node, default_source, read_class, write_class, **arguments) @node = node @default_source = default_source @@ -47,6 +59,8 @@ def initialize(node, default_source, read_class, write_class, **arguments) end # Desugar `x ||= y` to `defined?(x) ? x : x = y` + #-- + #: () -> node def compile if_node( location: node.location, @@ -87,8 +101,12 @@ def compile class DesugarOperatorWriteNode # :nodoc: include DSL - attr_reader :node, :default_source, :read_class, :write_class, :arguments + attr_reader :node #: ClassVariableOperatorWriteNode | ConstantOperatorWriteNode | GlobalVariableOperatorWriteNode | InstanceVariableOperatorWriteNode | LocalVariableOperatorWriteNode + attr_reader :default_source #: Source + attr_reader :read_class, :write_class #: Symbol + attr_reader :arguments #: Hash[Symbol, untyped] + #: ((ClassVariableOperatorWriteNode | ConstantOperatorWriteNode | GlobalVariableOperatorWriteNode | InstanceVariableOperatorWriteNode | LocalVariableOperatorWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void def initialize(node, default_source, read_class, write_class, **arguments) @node = node @default_source = default_source @@ -98,6 +116,8 @@ def initialize(node, default_source, read_class, write_class, **arguments) end # Desugar `x += y` to `x = x + y` + #-- + #: () -> node def compile binary_operator_loc = node.binary_operator_loc.chop @@ -131,8 +151,12 @@ def compile class DesugarOrWriteNode # :nodoc: include DSL - attr_reader :node, :default_source, :read_class, :write_class, :arguments + attr_reader :node #: InstanceVariableOrWriteNode | LocalVariableOrWriteNode + attr_reader :default_source #: Source + attr_reader :read_class, :write_class #: Symbol + attr_reader :arguments #: Hash[Symbol, untyped] + #: ((InstanceVariableOrWriteNode | LocalVariableOrWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void def initialize(node, default_source, read_class, write_class, **arguments) @node = node @default_source = default_source @@ -142,6 +166,8 @@ def initialize(node, default_source, read_class, write_class, **arguments) end # Desugar `x ||= y` to `x || x = y` + #-- + #: () -> node def compile or_node( location: node.location, @@ -162,90 +188,105 @@ def compile private_constant :DesugarAndWriteNode, :DesugarOrWriteNode, :DesugarOrWriteDefinedNode, :DesugarOperatorWriteNode class ClassVariableAndWriteNode + #: () -> node def desugar # :nodoc: DesugarAndWriteNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile end end class ClassVariableOrWriteNode + #: () -> node def desugar # :nodoc: DesugarOrWriteDefinedNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile end end class ClassVariableOperatorWriteNode + #: () -> node def desugar # :nodoc: DesugarOperatorWriteNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile end end class ConstantAndWriteNode + #: () -> node def desugar # :nodoc: DesugarAndWriteNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile end end class ConstantOrWriteNode + #: () -> node def desugar # :nodoc: DesugarOrWriteDefinedNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile end end class ConstantOperatorWriteNode + #: () -> node def desugar # :nodoc: DesugarOperatorWriteNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile end end class GlobalVariableAndWriteNode + #: () -> node def desugar # :nodoc: DesugarAndWriteNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile end end class GlobalVariableOrWriteNode + #: () -> node def desugar # :nodoc: DesugarOrWriteDefinedNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile end end class GlobalVariableOperatorWriteNode + #: () -> node def desugar # :nodoc: DesugarOperatorWriteNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile end end class InstanceVariableAndWriteNode + #: () -> node def desugar # :nodoc: DesugarAndWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile end end class InstanceVariableOrWriteNode + #: () -> node def desugar # :nodoc: DesugarOrWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile end end class InstanceVariableOperatorWriteNode + #: () -> node def desugar # :nodoc: DesugarOperatorWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile end end class LocalVariableAndWriteNode + #: () -> node def desugar # :nodoc: DesugarAndWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile end end class LocalVariableOrWriteNode + #: () -> node def desugar # :nodoc: DesugarOrWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile end end class LocalVariableOperatorWriteNode + #: () -> node def desugar # :nodoc: DesugarOperatorWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile end @@ -259,6 +300,8 @@ class DesugarCompiler < MutationCompiler # becomes # # `@@foo && @@foo = bar` + #-- + #: (ClassVariableAndWriteNode node) -> node def visit_class_variable_and_write_node(node) node.desugar end @@ -268,6 +311,8 @@ def visit_class_variable_and_write_node(node) # becomes # # `defined?(@@foo) ? @@foo : @@foo = bar` + #-- + #: (ClassVariableOrWriteNode node) -> node def visit_class_variable_or_write_node(node) node.desugar end @@ -277,6 +322,8 @@ def visit_class_variable_or_write_node(node) # becomes # # `@@foo = @@foo + bar` + #-- + #: (ClassVariableOperatorWriteNode node) -> node def visit_class_variable_operator_write_node(node) node.desugar end @@ -286,6 +333,8 @@ def visit_class_variable_operator_write_node(node) # becomes # # `Foo && Foo = bar` + #-- + #: (ConstantAndWriteNode node) -> node def visit_constant_and_write_node(node) node.desugar end @@ -295,6 +344,8 @@ def visit_constant_and_write_node(node) # becomes # # `defined?(Foo) ? Foo : Foo = bar` + #-- + #: (ConstantOrWriteNode node) -> node def visit_constant_or_write_node(node) node.desugar end @@ -304,6 +355,8 @@ def visit_constant_or_write_node(node) # becomes # # `Foo = Foo + bar` + #-- + #: (ConstantOperatorWriteNode node) -> node def visit_constant_operator_write_node(node) node.desugar end @@ -313,6 +366,8 @@ def visit_constant_operator_write_node(node) # becomes # # `$foo && $foo = bar` + #-- + #: (GlobalVariableAndWriteNode node) -> node def visit_global_variable_and_write_node(node) node.desugar end @@ -322,6 +377,8 @@ def visit_global_variable_and_write_node(node) # becomes # # `defined?($foo) ? $foo : $foo = bar` + #-- + #: (GlobalVariableOrWriteNode node) -> node def visit_global_variable_or_write_node(node) node.desugar end @@ -331,6 +388,8 @@ def visit_global_variable_or_write_node(node) # becomes # # `$foo = $foo + bar` + #-- + #: (GlobalVariableOperatorWriteNode node) -> node def visit_global_variable_operator_write_node(node) node.desugar end @@ -340,6 +399,8 @@ def visit_global_variable_operator_write_node(node) # becomes # # `@foo && @foo = bar` + #-- + #: (InstanceVariableAndWriteNode node) -> node def visit_instance_variable_and_write_node(node) node.desugar end @@ -349,6 +410,8 @@ def visit_instance_variable_and_write_node(node) # becomes # # `@foo || @foo = bar` + #-- + #: (InstanceVariableOrWriteNode node) -> node def visit_instance_variable_or_write_node(node) node.desugar end @@ -358,6 +421,8 @@ def visit_instance_variable_or_write_node(node) # becomes # # `@foo = @foo + bar` + #-- + #: (InstanceVariableOperatorWriteNode node) -> node def visit_instance_variable_operator_write_node(node) node.desugar end @@ -367,6 +432,8 @@ def visit_instance_variable_operator_write_node(node) # becomes # # `foo && foo = bar` + #-- + #: (LocalVariableAndWriteNode node) -> node def visit_local_variable_and_write_node(node) node.desugar end @@ -376,6 +443,8 @@ def visit_local_variable_and_write_node(node) # becomes # # `foo || foo = bar` + #-- + #: (LocalVariableOrWriteNode node) -> node def visit_local_variable_or_write_node(node) node.desugar end @@ -385,6 +454,8 @@ def visit_local_variable_or_write_node(node) # becomes # # `foo = foo + bar` + #-- + #: (LocalVariableOperatorWriteNode node) -> node def visit_local_variable_operator_write_node(node) node.desugar end diff --git a/lib/prism/lex_compat.rb b/lib/prism/lex_compat.rb index 3d5cbfcddc..7f3f30b88d 100644 --- a/lib/prism/lex_compat.rb +++ b/lib/prism/lex_compat.rb @@ -1,25 +1,48 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled module Prism + # @rbs! + # module Translation + # class Ripper + # EXPR_BEG: Integer + # + # class Lexer < Ripper + # class State + # def self.[]: (Integer value) -> State + # end + # end + # end + # end + # This class is responsible for lexing the source using prism and then # converting those tokens to be compatible with Ripper. In the vast majority # of cases, this is a one-to-one mapping of the token type. Everything else # generally lines up. However, there are a few cases that require special # handling. class LexCompat # :nodoc: + # @rbs! + # # A token produced by the Ripper lexer that Prism is replicating. + # type lex_compat_token = [[Integer, Integer], Symbol, String, untyped] + # A result class specialized for holding tokens produced by the lexer. class Result < Prism::Result # The list of tokens that were produced by the lexer. - attr_reader :value + attr_reader :value #: Array[lex_compat_token] # Create a new lex compat result object with the given values. + #-- + #: (Array[lex_compat_token] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void def initialize(value, comments, magic_comments, data_loc, errors, warnings, source) @value = value super(comments, magic_comments, data_loc, errors, warnings, source) end # Implement the hash pattern matching interface for Result. + #-- + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: super.merge!(value: value) end @@ -205,16 +228,19 @@ module Heredoc # :nodoc: # order back into the token stream and set the state of the last token to # the state that the heredoc was opened in. class PlainHeredoc # :nodoc: - attr_reader :tokens + attr_reader :tokens #: Array[lex_compat_token] + #: () -> void def initialize @tokens = [] end + #: (lex_compat_token token) -> void def <<(token) tokens << token end + #: () -> Array[lex_compat_token] def to_a tokens end @@ -224,21 +250,25 @@ def to_a # that need to be split on "\\\n" to mimic Ripper's behavior. We also need # to keep track of the state that the heredoc was opened in. class DashHeredoc # :nodoc: - attr_reader :split, :tokens + attr_reader :split #: bool + attr_reader :tokens #: Array[lex_compat_token] + #: (bool split) -> void def initialize(split) @split = split @tokens = [] end + #: (lex_compat_token token) -> void def <<(token) tokens << token end + #: () -> Array[lex_compat_token] def to_a embexpr_balance = 0 - tokens.each_with_object([]) do |token, results| #$ Array[Token] + tokens.each_with_object([]) do |token, results| #$ Array[lex_compat_token] case token[1] when :on_embexpr_beg embexpr_balance += 1 @@ -285,8 +315,13 @@ def to_a class DedentingHeredoc # :nodoc: TAB_WIDTH = 8 - attr_reader :tokens, :dedent_next, :dedent, :embexpr_balance + attr_reader :tokens #: Array[lex_compat_token] + attr_reader :dedent_next #: bool + attr_reader :dedent #: Integer? + attr_reader :embexpr_balance #: Integer + # @rbs @ended_on_newline: bool + #: () -> void def initialize @tokens = [] @dedent_next = true @@ -298,6 +333,8 @@ def initialize # As tokens are coming in, we track the minimum amount of common leading # whitespace on plain string content tokens. This allows us to later # remove that amount of whitespace from the beginning of each line. + # + #: (lex_compat_token token) -> void def <<(token) case token[1] when :on_embexpr_beg, :on_heredoc_beg @@ -310,7 +347,7 @@ def <<(token) line = token[2] if dedent_next && !(line.strip.empty? && line.end_with?("\n")) - leading = line[/\A(\s*)\n?/, 1] + leading = line[/\A(\s*)\n?/, 1] #: String next_dedent = 0 leading.each_char do |char| @@ -335,11 +372,12 @@ def <<(token) tokens << token end + #: () -> Array[lex_compat_token] def to_a # If every line in the heredoc is blank, we still need to split up the # string content token into multiple tokens. if dedent.nil? - results = [] #: Array[Token] + results = [] #: Array[lex_compat_token] embexpr_balance = 0 tokens.each do |token| @@ -374,7 +412,7 @@ def to_a # If the minimum common whitespace is 0, then we need to concatenate # string nodes together that are immediately adjacent. if dedent == 0 - results = [] #: Array[Token] + results = [] #: Array[lex_compat_token] embexpr_balance = 0 index = 0 @@ -407,7 +445,7 @@ def to_a # insert on_ignored_sp tokens for the amount of dedent that we need to # perform. We also need to remove the dedent from the beginning of # each line of plain string content tokens. - results = [] #: Array[Token] + results = [] #: Array[lex_compat_token] dedent_next = true embexpr_balance = 0 @@ -446,7 +484,8 @@ def to_a # line or this line doesn't start with whitespace, then we # should concatenate the rest of the string to match ripper. if dedent == 0 && (!dedent_next || !line.start_with?(/\s/)) - line = splits[index..].join + unjoined = splits[index..] #: Array[String] + line = unjoined.join index = splits.length end @@ -511,6 +550,8 @@ def to_a # Here we will split between the two types of heredocs and return the # object that will store their tokens. + #-- + #: (lex_compat_token opening) -> (PlainHeredoc | DashHeredoc | DedentingHeredoc) def self.build(opening) case opening[2][2] when "~" @@ -530,31 +571,38 @@ def self.build(opening) BOM_FLUSHED = RUBY_VERSION >= "3.3.0" private_constant :BOM_FLUSHED - attr_reader :options + attr_reader :options #: Hash[Symbol, untyped] + # @rbs @source: String - def initialize(code, **options) - @code = code + #: (String source, **untyped options) -> void + def initialize(source, **options) + @source = source @options = options end + #: () -> Result def result - tokens = [] #: Array[LexCompat::Token] + tokens = [] #: Array[lex_compat_token] state = :default heredoc_stack = [[]] #: Array[Array[Heredoc::PlainHeredoc | Heredoc::DashHeredoc | Heredoc::DedentingHeredoc]] - result = Prism.lex(@code, **options) + result = Prism.lex(@source, **options) source = result.source result_value = result.value - previous_state = nil #: State? + previous_state = nil #: Translation::Ripper::Lexer::State? last_heredoc_end = nil #: Integer? - eof_token = nil + eof_token = nil #: Token? bom = source.slice(0, 3) == "\xEF\xBB\xBF" - result_value.each_with_index do |(token, lex_state), index| - lineno = token.location.start_line - column = token.location.start_column + result_value.each_with_index do |(prism_token, prism_state), index| + lineno = prism_token.location.start_line + column = prism_token.location.start_column + + event = RIPPER.fetch(prism_token.type) + value = prism_token.value + lex_state = Translation::Ripper::Lexer::State[prism_state] # If there's a UTF-8 byte-order mark as the start of the file, then for # certain tokens ripper sets the first token back by 3 bytes. It also @@ -566,43 +614,38 @@ def result if index == 0 && column == 0 && !BOM_FLUSHED flushed = - case token.type + case prism_token.type when :BACK_REFERENCE, :INSTANCE_VARIABLE, :CLASS_VARIABLE, :GLOBAL_VARIABLE, :NUMBERED_REFERENCE, :PERCENT_LOWER_I, :PERCENT_LOWER_X, :PERCENT_LOWER_W, :PERCENT_UPPER_I, :PERCENT_UPPER_W, :STRING_BEGIN true when :REGEXP_BEGIN, :SYMBOL_BEGIN - token.value.start_with?("%") + value.start_with?("%") else false end unless flushed column -= 3 - value = token.value value.prepend(String.new("\xEF\xBB\xBF", encoding: value.encoding)) end end end - event = RIPPER.fetch(token.type) - value = token.value - lex_state = Translation::Ripper::Lexer::State[lex_state] - - token = + lex_compat_token = case event when :on___end__ # Ripper doesn't include the rest of the token in the event, so we need to # trim it down to just the content on the first line. - value = value[0..value.index("\n")] + value = value[0..value.index("\n")] #: String [[lineno, column], event, value, lex_state] when :on_comment [[lineno, column], event, value, lex_state] when :on_heredoc_end # Heredoc end tokens can be emitted in an odd order, so we don't # want to bother comparing the state on them. - last_heredoc_end = token.location.end_offset + last_heredoc_end = prism_token.location.end_offset [[lineno, column], event, value, lex_state] when :on_embexpr_end [[lineno, column], event, value, lex_state] @@ -615,7 +658,7 @@ def result end tokens << [[lineno, column], event, line, lex_state] end - tokens.pop + tokens.pop #: lex_compat_token when :on_regexp_end # On regex end, Ripper scans and then sets end state, so the ripper # lexed output is begin, when it should be end. prism sets lex state @@ -647,7 +690,7 @@ def result [[lineno, column], event, value, lex_state] when :on_eof - eof_token = token + eof_token = prism_token previous_token = result_value[index - 1][0] # If we're at the end of the file and the previous token was a @@ -662,7 +705,7 @@ def result # Use the greater offset of the two to determine the start of # the trailing whitespace. start_offset = [previous_token.location.end_offset, last_heredoc_end].compact.max - end_offset = token.location.start_offset + end_offset = prism_token.location.start_offset if start_offset < end_offset if bom @@ -677,7 +720,7 @@ def result [[lineno, column], event, value, lex_state] else [[lineno, column], event, value, lex_state] - end + end #: lex_compat_token previous_state = lex_state @@ -694,19 +737,19 @@ def result when :default # The default state is when there are no heredocs at all. In this # state we can append the token to the list of tokens and move on. - tokens << token + tokens << lex_compat_token # If we get the declaration of a heredoc, then we open a new heredoc # and move into the heredoc_opened state. if event == :on_heredoc_beg state = :heredoc_opened - heredoc_stack.last << Heredoc.build(token) + heredoc_stack.last << Heredoc.build(lex_compat_token) end when :heredoc_opened # The heredoc_opened state is when we've seen the declaration of a # heredoc and are now lexing the body of the heredoc. In this state we # push tokens onto the most recently created heredoc. - heredoc_stack.last.last << token + heredoc_stack.last.last << lex_compat_token case event when :on_heredoc_beg @@ -714,7 +757,7 @@ def result # heredoc, this means we have nested heredocs. In this case we'll # push a new heredoc onto the stack and stay in the heredoc_opened # state since we're now lexing the body of the new heredoc. - heredoc_stack << [Heredoc.build(token)] + heredoc_stack << [Heredoc.build(lex_compat_token)] when :on_heredoc_end # If we receive the end of a heredoc, then we're done lexing the # body of the heredoc. In this case we now have a completed heredoc @@ -723,10 +766,10 @@ def result state = :heredoc_closed end when :heredoc_closed - if %i[on_nl on_ignored_nl on_comment].include?(event) || (event == :on_tstring_content && value.end_with?("\n")) + if %i[on_nl on_ignored_nl on_comment].include?(event) || ((event == :on_tstring_content) && value.end_with?("\n")) if heredoc_stack.size > 1 - flushing = heredoc_stack.pop - heredoc_stack.last.last << token + flushing = heredoc_stack.pop #: Array[Heredoc::PlainHeredoc | Heredoc::DashHeredoc | Heredoc::DedentingHeredoc] + heredoc_stack.last.last << lex_compat_token flushing.each do |heredoc| heredoc.to_a.each do |flushed_token| @@ -738,12 +781,12 @@ def result next end elsif event == :on_heredoc_beg - tokens << token + tokens << lex_compat_token state = :heredoc_opened - heredoc_stack.last << Heredoc.build(token) + heredoc_stack.last << Heredoc.build(lex_compat_token) next elsif heredoc_stack.size > 1 - heredoc_stack[-2].last << token + heredoc_stack[-2].last << lex_compat_token next end @@ -754,13 +797,15 @@ def result heredoc_stack.last.clear state = :default - tokens << token + tokens << lex_compat_token end end # Drop the EOF token from the list. The EOF token may not be # present if the source was syntax invalid - tokens = tokens[0...-1] if tokens.dig(-1, 1) == :on_eof + if tokens.dig(-1, 1) == :on_eof + tokens = tokens[0...-1] #: Array[lex_compat_token] + end # We sort by location because Ripper.lex sorts. tokens.sort_by! do |token| @@ -775,8 +820,9 @@ def result private + #: (Array[lex_compat_token] tokens, Source source, Location? data_loc, bool bom, Token? eof_token) -> Array[lex_compat_token] def post_process_tokens(tokens, source, data_loc, bom, eof_token) - new_tokens = [] + new_tokens = [] #: Array[lex_compat_token] prev_token_state = Translation::Ripper::Lexer::State[Translation::Ripper::EXPR_BEG] prev_token_end = bom ? 3 : 0 @@ -806,8 +852,8 @@ def post_process_tokens(tokens, source, data_loc, bom, eof_token) next_whitespace_index = continuation_index + 1 next_whitespace_index += 1 if sp_value.byteslice(next_whitespace_index) == "\r" next_whitespace_index += 1 - first_whitespace = sp_value[0...continuation_index] - continuation = sp_value[continuation_index...next_whitespace_index] + first_whitespace = sp_value[0...continuation_index] #: String + continuation = sp_value[continuation_index...next_whitespace_index] #: String second_whitespace = sp_value[next_whitespace_index..] || "" new_tokens << [[sp_line, sp_column], :on_sp, first_whitespace, prev_token_state] unless first_whitespace.empty? diff --git a/lib/prism/node_ext.rb b/lib/prism/node_ext.rb index a05123d1bb..61f36e09be 100644 --- a/lib/prism/node_ext.rb +++ b/lib/prism/node_ext.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled #-- # Here we are reopening the prism module to provide methods on nodes that aren't @@ -7,6 +9,7 @@ #++ module Prism class Node + #: (*String replacements) -> void def deprecated(*replacements) # :nodoc: location = caller_locations(1, 1) location = location[0].label if location @@ -23,7 +26,9 @@ def deprecated(*replacements) # :nodoc: module RegularExpressionOptions # :nodoc: # Returns a numeric value that represents the flags that were used to create # the regular expression. - def options + #-- + #: (Integer flags) -> Integer + def self.options(flags) o = 0 o |= Regexp::IGNORECASE if flags.anybits?(RegularExpressionFlags::IGNORE_CASE) o |= Regexp::EXTENDED if flags.anybits?(RegularExpressionFlags::EXTENDED) @@ -35,43 +40,87 @@ def options end class InterpolatedMatchLastLineNode < Node - include RegularExpressionOptions + # Returns a numeric value that represents the flags that were used to create + # the regular expression. + #-- + #: () -> Integer + def options + RegularExpressionOptions.options(flags) + end end class InterpolatedRegularExpressionNode < Node - include RegularExpressionOptions + # Returns a numeric value that represents the flags that were used to create + # the regular expression. + #-- + #: () -> Integer + def options + RegularExpressionOptions.options(flags) + end end class MatchLastLineNode < Node - include RegularExpressionOptions + # Returns a numeric value that represents the flags that were used to create + # the regular expression. + #-- + #: () -> Integer + def options + RegularExpressionOptions.options(flags) + end end class RegularExpressionNode < Node - include RegularExpressionOptions + # Returns a numeric value that represents the flags that were used to create + # the regular expression. + #-- + #: () -> Integer + def options + RegularExpressionOptions.options(flags) + end end private_constant :RegularExpressionOptions module HeredocQuery # :nodoc: # Returns true if this node was represented as a heredoc in the source code. - def heredoc? + #-- + #: (String? opening) -> bool? + def self.heredoc?(opening) + # @type self: InterpolatedStringNode | InterpolatedXStringNode | StringNode | XStringNode opening&.start_with?("<<") end end class InterpolatedStringNode < Node - include HeredocQuery + # Returns true if this node was represented as a heredoc in the source code. + #-- + #: () -> bool? + def heredoc? + HeredocQuery.heredoc?(opening) + end end class InterpolatedXStringNode < Node - include HeredocQuery + # Returns true if this node was represented as a heredoc in the source code. + #-- + #: () -> bool? + def heredoc? + HeredocQuery.heredoc?(opening) + end end class StringNode < Node - include HeredocQuery + # Returns true if this node was represented as a heredoc in the source code. + #-- + #: () -> bool? + def heredoc? + HeredocQuery.heredoc?(opening) + end # Occasionally it's helpful to treat a string as if it were interpolated so # that there's a consistent interface for working with strings. + #-- + #: () -> InterpolatedStringNode def to_interpolated InterpolatedStringNode.new( source, @@ -86,10 +135,17 @@ def to_interpolated end class XStringNode < Node - include HeredocQuery + # Returns true if this node was represented as a heredoc in the source code. + #-- + #: () -> bool? + def heredoc? + HeredocQuery.heredoc?(opening) + end # Occasionally it's helpful to treat a string as if it were interpolated so # that there's a consistent interface for working with strings. + #-- + #: () -> InterpolatedXStringNode def to_interpolated InterpolatedXStringNode.new( source, @@ -107,6 +163,8 @@ def to_interpolated class ImaginaryNode < Node # Returns the value of the node as a Ruby Complex. + #-- + #: () -> Complex def value Complex(0, numeric.value) end @@ -114,12 +172,16 @@ def value class RationalNode < Node # Returns the value of the node as a Ruby Rational. + #-- + #: () -> Rational def value Rational(numerator, denominator) end # Returns the value of the node as an IntegerNode or a FloatNode. This # method is deprecated in favor of #value or #numerator/#denominator. + #-- + #: () -> (IntegerNode | FloatNode) def numeric deprecated("value", "numerator", "denominator") @@ -134,11 +196,15 @@ def numeric class ConstantReadNode < Node # Returns the list of parts for the full name of this constant. # For example: [:Foo] + #-- + #: () -> Array[Symbol] def full_name_parts [name] end # Returns the full name of this constant. For example: "Foo" + #-- + #: () -> String def full_name name.to_s end @@ -147,11 +213,15 @@ def full_name class ConstantWriteNode < Node # Returns the list of parts for the full name of this constant. # For example: [:Foo] + #-- + #: () -> Array[Symbol] def full_name_parts [name] end # Returns the full name of this constant. For example: "Foo" + #-- + #: () -> String def full_name name.to_s end @@ -173,6 +243,8 @@ class MissingNodesInConstantPathError < StandardError; end # Returns the list of parts for the full name of this constant path. # For example: [:Foo, :Bar] + #-- + #: () -> Array[Symbol] def full_name_parts parts = [] #: Array[Symbol] current = self #: node? @@ -195,6 +267,8 @@ def full_name_parts end # Returns the full name of this constant path. For example: "Foo::Bar" + #-- + #: () -> String def full_name full_name_parts.join("::") end @@ -202,10 +276,12 @@ def full_name # Previously, we had a child node on this class that contained either a # constant read or a missing node. To not cause a breaking change, we # continue to supply that API. + #-- + #: () -> (ConstantReadNode | MissingNode) def child deprecated("name", "name_loc") - if name + if (name = self.name) ConstantReadNode.new(source, -1, name_loc, 0, name) else MissingNode.new(source, -1, location, 0) @@ -216,9 +292,11 @@ def child class ConstantPathTargetNode < Node # Returns the list of parts for the full name of this constant path. # For example: [:Foo, :Bar] + #-- + #: () -> Array[Symbol] def full_name_parts parts = - case parent + case (parent = self.parent) when ConstantPathNode, ConstantReadNode parent.full_name_parts when nil @@ -228,7 +306,7 @@ def full_name_parts raise ConstantPathNode::DynamicPartsInConstantPathError, "Constant target path contains dynamic parts. Cannot compute full name" end - if name.nil? + if (name = self.name).nil? raise ConstantPathNode::MissingNodesInConstantPathError, "Constant target path contains missing nodes. Cannot compute full name" end @@ -236,6 +314,8 @@ def full_name_parts end # Returns the full name of this constant path. For example: "Foo::Bar" + #-- + #: () -> String def full_name full_name_parts.join("::") end @@ -243,10 +323,12 @@ def full_name # Previously, we had a child node on this class that contained either a # constant read or a missing node. To not cause a breaking change, we # continue to supply that API. + #-- + #: () -> (ConstantReadNode | MissingNode) def child deprecated("name", "name_loc") - if name + if (name = self.name) ConstantReadNode.new(source, -1, name_loc, 0, name) else MissingNode.new(source, -1, location, 0) @@ -257,11 +339,15 @@ def child class ConstantTargetNode < Node # Returns the list of parts for the full name of this constant. # For example: [:Foo] + #-- + #: () -> Array[Symbol] def full_name_parts [name] end # Returns the full name of this constant. For example: "Foo" + #-- + #: () -> String def full_name name.to_s end @@ -269,6 +355,8 @@ def full_name class ParametersNode < Node # Mirrors the Method#parameters method. + #-- + #: () -> Array[[Symbol, Symbol] | [Symbol]] def signature names = [] #: Array[[Symbol, Symbol] | [Symbol]] @@ -278,7 +366,7 @@ def signature optionals.each { |param| names << [:opt, param.name] } - if rest && rest.is_a?(RestParameterNode) + if (rest = self.rest).is_a?(RestParameterNode) names << [:rest, rest.name || :*] end @@ -309,7 +397,7 @@ def signature keyopt.each { |param| names << [:key, param.name] } - case keyword_rest + case (keyword_rest = self.keyword_rest) when ForwardingParameterNode names.concat([[:rest, :*], [:keyrest, :**], [:block, :&]]) when KeywordRestParameterNode @@ -318,7 +406,7 @@ def signature names << [:nokey] end - case block + case (block = self.block) when BlockParameterNode names << [:block, block.name || :&] when NoBlockParameterNode @@ -339,6 +427,8 @@ class CallNode < Node # can be any amount of space between the message and the = sign. However, # sometimes you want the location of the full message including the inner # space and the = sign. This method provides that. + #-- + #: () -> Location? def full_message_loc attribute_write? ? message_loc&.adjoin("=") : message_loc end @@ -347,6 +437,8 @@ def full_message_loc class CallOperatorWriteNode < Node # Returns the binary operator used to modify the receiver. This method is # deprecated in favor of #binary_operator. + #-- + #: () -> Symbol def operator deprecated("binary_operator") binary_operator @@ -354,6 +446,8 @@ def operator # Returns the location of the binary operator used to modify the receiver. # This method is deprecated in favor of #binary_operator_loc. + #-- + #: () -> Location def operator_loc deprecated("binary_operator_loc") binary_operator_loc @@ -363,6 +457,8 @@ def operator_loc class ClassVariableOperatorWriteNode < Node # Returns the binary operator used to modify the receiver. This method is # deprecated in favor of #binary_operator. + #-- + #: () -> Symbol def operator deprecated("binary_operator") binary_operator @@ -370,6 +466,8 @@ def operator # Returns the location of the binary operator used to modify the receiver. # This method is deprecated in favor of #binary_operator_loc. + #-- + #: () -> Location def operator_loc deprecated("binary_operator_loc") binary_operator_loc @@ -379,6 +477,8 @@ def operator_loc class ConstantOperatorWriteNode < Node # Returns the binary operator used to modify the receiver. This method is # deprecated in favor of #binary_operator. + #-- + #: () -> Symbol def operator deprecated("binary_operator") binary_operator @@ -386,6 +486,8 @@ def operator # Returns the location of the binary operator used to modify the receiver. # This method is deprecated in favor of #binary_operator_loc. + #-- + #: () -> Location def operator_loc deprecated("binary_operator_loc") binary_operator_loc @@ -395,6 +497,8 @@ def operator_loc class ConstantPathOperatorWriteNode < Node # Returns the binary operator used to modify the receiver. This method is # deprecated in favor of #binary_operator. + #-- + #: () -> Symbol def operator deprecated("binary_operator") binary_operator @@ -402,6 +506,8 @@ def operator # Returns the location of the binary operator used to modify the receiver. # This method is deprecated in favor of #binary_operator_loc. + #-- + #: () -> Location def operator_loc deprecated("binary_operator_loc") binary_operator_loc @@ -411,6 +517,8 @@ def operator_loc class GlobalVariableOperatorWriteNode < Node # Returns the binary operator used to modify the receiver. This method is # deprecated in favor of #binary_operator. + #-- + #: () -> Symbol def operator deprecated("binary_operator") binary_operator @@ -418,6 +526,8 @@ def operator # Returns the location of the binary operator used to modify the receiver. # This method is deprecated in favor of #binary_operator_loc. + #-- + #: () -> Location def operator_loc deprecated("binary_operator_loc") binary_operator_loc @@ -427,6 +537,8 @@ def operator_loc class IndexOperatorWriteNode < Node # Returns the binary operator used to modify the receiver. This method is # deprecated in favor of #binary_operator. + #-- + #: () -> Symbol def operator deprecated("binary_operator") binary_operator @@ -434,6 +546,8 @@ def operator # Returns the location of the binary operator used to modify the receiver. # This method is deprecated in favor of #binary_operator_loc. + #-- + #: () -> Location def operator_loc deprecated("binary_operator_loc") binary_operator_loc @@ -443,6 +557,8 @@ def operator_loc class InstanceVariableOperatorWriteNode < Node # Returns the binary operator used to modify the receiver. This method is # deprecated in favor of #binary_operator. + #-- + #: () -> Symbol def operator deprecated("binary_operator") binary_operator @@ -450,6 +566,8 @@ def operator # Returns the location of the binary operator used to modify the receiver. # This method is deprecated in favor of #binary_operator_loc. + #-- + #: () -> Location def operator_loc deprecated("binary_operator_loc") binary_operator_loc @@ -459,6 +577,8 @@ def operator_loc class LocalVariableOperatorWriteNode < Node # Returns the binary operator used to modify the receiver. This method is # deprecated in favor of #binary_operator. + #-- + #: () -> Symbol def operator deprecated("binary_operator") binary_operator @@ -466,6 +586,8 @@ def operator # Returns the location of the binary operator used to modify the receiver. # This method is deprecated in favor of #binary_operator_loc. + #-- + #: () -> Location def operator_loc deprecated("binary_operator_loc") binary_operator_loc @@ -475,6 +597,8 @@ def operator_loc class CaseMatchNode < Node # Returns the else clause of the case match node. This method is deprecated # in favor of #else_clause. + #-- + #: () -> ElseNode? def consequent deprecated("else_clause") else_clause @@ -484,6 +608,8 @@ def consequent class CaseNode < Node # Returns the else clause of the case node. This method is deprecated in # favor of #else_clause. + #-- + #: () -> ElseNode? def consequent deprecated("else_clause") else_clause @@ -493,6 +619,8 @@ def consequent class IfNode < Node # Returns the subsequent if/elsif/else clause of the if node. This method is # deprecated in favor of #subsequent. + #-- + #: () -> (IfNode | ElseNode)? def consequent deprecated("subsequent") subsequent @@ -502,6 +630,8 @@ def consequent class RescueNode < Node # Returns the subsequent rescue clause of the rescue node. This method is # deprecated in favor of #subsequent. + #-- + #: () -> RescueNode? def consequent deprecated("subsequent") subsequent @@ -511,6 +641,8 @@ def consequent class UnlessNode < Node # Returns the else clause of the unless node. This method is deprecated in # favor of #else_clause. + #-- + #: () -> ElseNode? def consequent deprecated("else_clause") else_clause diff --git a/lib/prism/parse_result.rb b/lib/prism/parse_result.rb index 07529c4295..9825d559af 100644 --- a/lib/prism/parse_result.rb +++ b/lib/prism/parse_result.rb @@ -1,7 +1,16 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled module Prism + # @rbs! + # # An internal interface for a cache that can be used to compute code + # # units from byte offsets. + # interface _CodeUnitsCache + # def []: (Integer byte_offset) -> Integer + # end + # This represents a source of Ruby code that has been parsed. It is used in # conjunction with locations to allow them to resolve line numbers and source # ranges. @@ -10,6 +19,8 @@ class Source # be used instead of `new` and it will return either a `Source` or a # specialized and more performant `ASCIISource` if no multibyte characters # are present in the source code. + #-- + #: (String source, ?Integer start_line, ?Array[Integer] offsets) -> Source def self.for(source, start_line = 1, offsets = []) if source.ascii_only? ASCIISource.new(source, start_line, offsets) @@ -34,15 +45,17 @@ def self.for(source, start_line = 1, offsets = []) end # The source code that this source object represents. - attr_reader :source + attr_reader :source #: String # The line number where this source starts. - attr_reader :start_line + attr_reader :start_line #: Integer # The list of newline byte offsets in the source code. - attr_reader :offsets + attr_reader :offsets #: Array[Integer] # Create a new source object with the given source code. + #-- + #: (String source, ?Integer start_line, ?Array[Integer] offsets) -> void def initialize(source, start_line = 1, offsets = []) @source = source @start_line = start_line # set after parsing is done @@ -50,33 +63,45 @@ def initialize(source, start_line = 1, offsets = []) end # Replace the value of start_line with the given value. + #-- + #: (Integer start_line) -> void def replace_start_line(start_line) @start_line = start_line end # Replace the value of offsets with the given value. + #-- + #: (Array[Integer] offsets) -> void def replace_offsets(offsets) @offsets.replace(offsets) end # Returns the encoding of the source code, which is set by parameters to the # parser or by the encoding magic comment. + #-- + #: () -> Encoding def encoding source.encoding end # Returns the lines of the source code as an array of strings. + #-- + #: () -> Array[String] def lines source.lines end # Perform a byteslice on the source code using the given byte offset and # byte length. + #-- + #: (Integer byte_offset, Integer length) -> String def slice(byte_offset, length) source.byteslice(byte_offset, length) or raise end # Converts the line number and column in bytes to a byte offset. + #-- + #: (Integer line, Integer column) -> Integer def byte_offset(line, column) normal = line - @start_line raise IndexError if normal < 0 @@ -87,33 +112,45 @@ def byte_offset(line, column) # Binary search through the offsets to find the line number for the given # byte offset. + #-- + #: (Integer byte_offset) -> Integer def line(byte_offset) start_line + find_line(byte_offset) end # Return the byte offset of the start of the line corresponding to the given # byte offset. + #-- + #: (Integer byte_offset) -> Integer def line_start(byte_offset) offsets[find_line(byte_offset)] end # Returns the byte offset of the end of the line corresponding to the given # byte offset. + #-- + #: (Integer byte_offset) -> Integer def line_end(byte_offset) offsets[find_line(byte_offset) + 1] || source.bytesize end # Return the column in bytes for the given byte offset. + #-- + #: (Integer byte_offset) -> Integer def column(byte_offset) byte_offset - line_start(byte_offset) end # Return the character offset for the given byte offset. + #-- + #: (Integer byte_offset) -> Integer def character_offset(byte_offset) (source.byteslice(0, byte_offset) or raise).length end # Return the column in characters for the given byte offset. + #-- + #: (Integer byte_offset) -> Integer def character_column(byte_offset) character_offset(byte_offset) - character_offset(line_start(byte_offset)) end @@ -130,6 +167,8 @@ def character_column(byte_offset) # possible that the given byte offset will not occur on a character # boundary. Second, it's possible that the source code will contain a # character that has no equivalent in the given encoding. + #-- + #: (Integer byte_offset, Encoding encoding) -> Integer def code_units_offset(byte_offset, encoding) byteslice = (source.byteslice(0, byte_offset) or raise).encode(encoding, invalid: :replace, undef: :replace) @@ -142,17 +181,23 @@ def code_units_offset(byte_offset, encoding) # Generate a cache that targets a specific encoding for calculating code # unit offsets. + #-- + #: (Encoding encoding) -> CodeUnitsCache def code_units_cache(encoding) CodeUnitsCache.new(source, encoding) end # Returns the column in code units for the given encoding for the # given byte offset. + #-- + #: (Integer byte_offset, Encoding encoding) -> Integer def code_units_column(byte_offset, encoding) code_units_offset(byte_offset, encoding) - code_units_offset(line_start(byte_offset), encoding) end # Freeze this object and the objects it contains. + #-- + #: () -> void def deep_freeze source.freeze offsets.freeze @@ -163,6 +208,8 @@ def deep_freeze # Binary search through the offsets to find the line number for the given # byte offset. + #-- + #: (Integer byte_offset) -> Integer def find_line(byte_offset) # :nodoc: index = offsets.bsearch_index { |offset| offset > byte_offset } || offsets.length index - 1 @@ -185,30 +232,47 @@ def find_line(byte_offset) # :nodoc: # class CodeUnitsCache class UTF16Counter # :nodoc: + # @rbs @source: String + # @rbs @encoding: Encoding + + #: (String source, Encoding encoding) -> void def initialize(source, encoding) @source = source @encoding = encoding end + #: (Integer byte_offset, Integer byte_length) -> Integer def count(byte_offset, byte_length) - @source.byteslice(byte_offset, byte_length).encode(@encoding, invalid: :replace, undef: :replace).bytesize / 2 + (@source.byteslice(byte_offset, byte_length) or raise).encode(@encoding, invalid: :replace, undef: :replace).bytesize / 2 end end class LengthCounter # :nodoc: + # @rbs @source: String + # @rbs @encoding: Encoding + + #: (String source, Encoding encoding) -> void def initialize(source, encoding) @source = source @encoding = encoding end + #: (Integer byte_offset, Integer byte_length) -> Integer def count(byte_offset, byte_length) - @source.byteslice(byte_offset, byte_length).encode(@encoding, invalid: :replace, undef: :replace).length + (@source.byteslice(byte_offset, byte_length) or raise).encode(@encoding, invalid: :replace, undef: :replace).length end end private_constant :UTF16Counter, :LengthCounter + # @rbs @source: String + # @rbs @counter: UTF16Counter | LengthCounter + # @rbs @cache: Hash[Integer, Integer] + # @rbs @offsets: Array[Integer] + # Initialize a new cache with the given source and encoding. + #-- + #: (String source, Encoding encoding) -> void def initialize(source, encoding) @source = source @counter = @@ -223,6 +287,8 @@ def initialize(source, encoding) end # Retrieve the code units offset from the given byte offset. + #-- + #: (Integer byte_offset) -> Integer def [](byte_offset) @cache[byte_offset] ||= if (index = @offsets.bsearch_index { |offset| offset > byte_offset }).nil? @@ -249,11 +315,15 @@ def [](byte_offset) # at that point we will treat everything as single-byte characters. class ASCIISource < Source # Return the character offset for the given byte offset. + #-- + #: (Integer byte_offset) -> Integer def character_offset(byte_offset) byte_offset end # Return the column in characters for the given byte offset. + #-- + #: (Integer byte_offset) -> Integer def character_column(byte_offset) byte_offset - line_start(byte_offset) end @@ -264,6 +334,8 @@ def character_column(byte_offset) # This method is tested with UTF-8, UTF-16, and UTF-32. If there is the # concept of code units that differs from the number of characters in other # encodings, it is not captured here. + #-- + #: (Integer byte_offset, Encoding encoding) -> Integer def code_units_offset(byte_offset, encoding) byte_offset end @@ -271,6 +343,8 @@ def code_units_offset(byte_offset, encoding) # Returns a cache that is the identity function in order to maintain the # same interface. We can do this because code units are always equivalent to # byte offsets for ASCII-only sources. + #-- + #: (Encoding encoding) -> _CodeUnitsCache def code_units_cache(encoding) ->(byte_offset) { byte_offset } end @@ -278,6 +352,8 @@ def code_units_cache(encoding) # Specialized version of `code_units_column` that does not depend on # `code_units_offset`, which is a more expensive operation. This is # essentially the same as `Prism::Source#column`. + #-- + #: (Integer byte_offset, Encoding encoding) -> Integer def code_units_column(byte_offset, encoding) byte_offset - line_start(byte_offset) end @@ -287,18 +363,23 @@ def code_units_column(byte_offset, encoding) class Location # A Source object that is used to determine more information from the given # offset and length. - attr_reader :source + attr_reader :source #: Source protected :source # The byte offset from the beginning of the source where this location # starts. - attr_reader :start_offset + attr_reader :start_offset #: Integer # The length of this location in bytes. - attr_reader :length + attr_reader :length #: Integer + + # @rbs @leading_comments: Array[Comment]? + # @rbs @trailing_comments: Array[Comment]? # Create a new location object with the given source, start byte offset, and # byte length. + #-- + #: (Source source, Integer start_offset, Integer length) -> void def initialize(source, start_offset, length) @source = source @start_offset = start_offset @@ -313,53 +394,73 @@ def initialize(source, start_offset, length) # These are the comments that are associated with this location that exist # before the start of this location. + #-- + #: () -> Array[Comment] def leading_comments @leading_comments ||= [] end # Attach a comment to the leading comments of this location. + #-- + #: (Comment comment) -> void def leading_comment(comment) leading_comments << comment end # These are the comments that are associated with this location that exist # after the end of this location. + #-- + #: () -> Array[Comment] def trailing_comments @trailing_comments ||= [] end # Attach a comment to the trailing comments of this location. + #-- + #: (Comment comment) -> void def trailing_comment(comment) trailing_comments << comment end # Returns all comments that are associated with this location (both leading # and trailing comments). + #-- + #: () -> Array[Comment] def comments - [*@leading_comments, *@trailing_comments] + [*@leading_comments, *@trailing_comments] #: Array[Comment] end # Create a new location object with the given options. + #-- + #: (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location def copy(source: self.source, start_offset: self.start_offset, length: self.length) Location.new(source, start_offset, length) end # Returns a new location that is the result of chopping off the last byte. + #-- + #: () -> Location def chop copy(length: length == 0 ? length : length - 1) end # Returns a string representation of this location. + #-- + #: () -> String def inspect # :nodoc: "#" end # Returns all of the lines of the source code associated with this location. + #-- + #: () -> Array[String] def source_lines source.lines end # The source code that this location represents. + #-- + #: () -> String def slice source.slice(start_offset, length) end @@ -367,6 +468,8 @@ def slice # The source code that this location represents starting from the beginning # of the line that this location starts on to the end of the line that this # location ends on. + #-- + #: () -> String def slice_lines line_start = source.line_start(start_offset) line_end = source.line_end(end_offset) @@ -375,118 +478,160 @@ def slice_lines # The character offset from the beginning of the source where this location # starts. + #-- + #: () -> Integer def start_character_offset source.character_offset(start_offset) end # The offset from the start of the file in code units of the given encoding. + #-- + #: (Encoding encoding) -> Integer def start_code_units_offset(encoding = Encoding::UTF_16LE) source.code_units_offset(start_offset, encoding) end # The start offset from the start of the file in code units using the given # cache to fetch or calculate the value. + #-- + #: (_CodeUnitsCache cache) -> Integer def cached_start_code_units_offset(cache) cache[start_offset] end # The byte offset from the beginning of the source where this location ends. + #-- + #: () -> Integer def end_offset start_offset + length end # The character offset from the beginning of the source where this location # ends. + #-- + #: () -> Integer def end_character_offset source.character_offset(end_offset) end # The offset from the start of the file in code units of the given encoding. + #-- + #: (Encoding encoding) -> Integer def end_code_units_offset(encoding = Encoding::UTF_16LE) source.code_units_offset(end_offset, encoding) end # The end offset from the start of the file in code units using the given # cache to fetch or calculate the value. + #-- + #: (_CodeUnitsCache cache) -> Integer def cached_end_code_units_offset(cache) cache[end_offset] end # The line number where this location starts. + #-- + #: () -> Integer def start_line source.line(start_offset) end # The content of the line where this location starts before this location. + #-- + #: () -> String def start_line_slice offset = source.line_start(start_offset) source.slice(offset, start_offset - offset) end # The line number where this location ends. + #-- + #: () -> Integer def end_line source.line(end_offset) end # The column in bytes where this location starts from the start of # the line. + #-- + #: () -> Integer def start_column source.column(start_offset) end # The column in characters where this location ends from the start of # the line. + #-- + #: () -> Integer def start_character_column source.character_column(start_offset) end # The column in code units of the given encoding where this location # starts from the start of the line. + #-- + #: (?Encoding encoding) -> Integer def start_code_units_column(encoding = Encoding::UTF_16LE) source.code_units_column(start_offset, encoding) end # The start column in code units using the given cache to fetch or calculate # the value. + #-- + #: (_CodeUnitsCache cache) -> Integer def cached_start_code_units_column(cache) cache[start_offset] - cache[source.line_start(start_offset)] end # The column in bytes where this location ends from the start of the # line. + #-- + #: () -> Integer def end_column source.column(end_offset) end # The column in characters where this location ends from the start of # the line. + #-- + #: () -> Integer def end_character_column source.character_column(end_offset) end # The column in code units of the given encoding where this location # ends from the start of the line. + #-- + #: (?Encoding encoding) -> Integer def end_code_units_column(encoding = Encoding::UTF_16LE) source.code_units_column(end_offset, encoding) end # The end column in code units using the given cache to fetch or calculate # the value. + #-- + #: (_CodeUnitsCache cache) -> Integer def cached_end_code_units_column(cache) cache[end_offset] - cache[source.line_start(end_offset)] end # Implement the hash pattern matching interface for Location. + #-- + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: { start_offset: start_offset, end_offset: end_offset } end # Implement the pretty print interface for Location. + #-- + #: (PP q) -> void def pretty_print(q) # :nodoc: q.text("(#{start_line},#{start_column})-(#{end_line},#{end_column})") end # Returns true if the given other location is equal to this location. + #-- + #: (untyped other) -> bool def ==(other) Location === other && other.start_offset == start_offset && @@ -496,6 +641,8 @@ def ==(other) # Returns a new location that stretches from this location to the given # other location. Raises an error if this location is not before the other # location or if they don't share the same source. + #-- + #: (Location other) -> Location def join(other) raise "Incompatible sources" if source != other.source raise "Incompatible locations" if start_offset > other.start_offset @@ -506,6 +653,8 @@ def join(other) # Join this location with the first occurrence of the string in the source # that occurs after this location on the same line, and return the new # location. This will raise an error if the string does not exist. + #-- + #: (String string) -> Location def adjoin(string) line_suffix = source.slice(end_offset, source.line_end(end_offset) - end_offset) @@ -520,22 +669,37 @@ def adjoin(string) # base class for all comment types. class Comment # The Location of this comment in the source. - attr_reader :location + attr_reader :location #: Location # Create a new comment object with the given location. + #-- + #: (Location location) -> void def initialize(location) @location = location end # Implement the hash pattern matching interface for Comment. + #-- + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: { location: location } end # Returns the content of the comment by slicing it from the source code. + #-- + #: () -> String def slice location.slice end + + # Returns true if this comment happens on the same line as other code and + # false if the comment is by itself. This can only be true for inline + # comments and should be false for block comments. + #-- + #: () -> bool + def trailing? + raise NotImplementedError, "trailing? is not implemented for #{self.class}" + end end # InlineComment objects are the most common. They correspond to comments in @@ -543,11 +707,15 @@ def slice class InlineComment < Comment # Returns true if this comment happens on the same line as other code and # false if the comment is by itself. + #-- + #: () -> bool def trailing? !location.start_line_slice.strip.empty? end # Returns a string representation of this comment. + #-- + #: () -> String def inspect # :nodoc: "#" end @@ -557,11 +725,15 @@ def inspect # :nodoc: # and =end. class EmbDocComment < Comment # Returns false. This can only be true for inline comments. + #-- + #: () -> bool def trailing? false end # Returns a string representation of this comment. + #-- + #: () -> String def inspect # :nodoc: "#" end @@ -570,33 +742,43 @@ def inspect # :nodoc: # This represents a magic comment that was encountered during parsing. class MagicComment # A Location object representing the location of the key in the source. - attr_reader :key_loc + attr_reader :key_loc #: Location # A Location object representing the location of the value in the source. - attr_reader :value_loc + attr_reader :value_loc #: Location # Create a new magic comment object with the given key and value locations. + #-- + #: (Location key_loc, Location value_loc) -> void def initialize(key_loc, value_loc) @key_loc = key_loc @value_loc = value_loc end # Returns the key of the magic comment by slicing it from the source code. + #-- + #: () -> String def key key_loc.slice end # Returns the value of the magic comment by slicing it from the source code. + #-- + #: () -> String def value value_loc.slice end # Implement the hash pattern matching interface for MagicComment. + #-- + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: { key_loc: key_loc, value_loc: value_loc } end # Returns a string representation of this magic comment. + #-- + #: () -> String def inspect # :nodoc: "#" end @@ -606,18 +788,20 @@ def inspect # :nodoc: class ParseError # The type of error. This is an _internal_ symbol that is used for # communicating with translation layers. It is not meant to be public API. - attr_reader :type + attr_reader :type #: Symbol # The message associated with this error. - attr_reader :message + attr_reader :message #: String # A Location object representing the location of this error in the source. - attr_reader :location + attr_reader :location #: Location # The level of this error. - attr_reader :level + attr_reader :level #: Symbol # Create a new error object with the given message and location. + #-- + #: (Symbol type, String message, Location location, Symbol level) -> void def initialize(type, message, location, level) @type = type @message = message @@ -626,11 +810,15 @@ def initialize(type, message, location, level) end # Implement the hash pattern matching interface for ParseError. + #-- + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: { type: type, message: message, location: location, level: level } end # Returns a string representation of this error. + #-- + #: () -> String def inspect # :nodoc: "#" end @@ -640,18 +828,20 @@ def inspect # :nodoc: class ParseWarning # The type of warning. This is an _internal_ symbol that is used for # communicating with translation layers. It is not meant to be public API. - attr_reader :type + attr_reader :type #: Symbol # The message associated with this warning. - attr_reader :message + attr_reader :message #: String # A Location object representing the location of this warning in the source. - attr_reader :location + attr_reader :location #: Location # The level of this warning. - attr_reader :level + attr_reader :level #: Symbol # Create a new warning object with the given message and location. + #-- + #: (Symbol type, String message, Location location, Symbol level) -> void def initialize(type, message, location, level) @type = type @message = message @@ -660,11 +850,15 @@ def initialize(type, message, location, level) end # Implement the hash pattern matching interface for ParseWarning. + #-- + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: { type: type, message: message, location: location, level: level } end # Returns a string representation of this warning. + #-- + #: () -> String def inspect # :nodoc: "#" end @@ -675,26 +869,28 @@ def inspect # :nodoc: # and any errors that were encountered. class Result # The list of comments that were encountered during parsing. - attr_reader :comments + attr_reader :comments #: Array[Comment] # The list of magic comments that were encountered during parsing. - attr_reader :magic_comments + attr_reader :magic_comments #: Array[MagicComment] # An optional location that represents the location of the __END__ marker # and the rest of the content of the file. This content is loaded into the # DATA constant when the file being parsed is the main file being executed. - attr_reader :data_loc + attr_reader :data_loc #: Location? # The list of errors that were generated during parsing. - attr_reader :errors + attr_reader :errors #: Array[ParseError] # The list of warnings that were generated during parsing. - attr_reader :warnings + attr_reader :warnings #: Array[ParseWarning] # A Source instance that represents the source code that was parsed. - attr_reader :source + attr_reader :source #: Source # Create a new result object with the given values. + #-- + #: (Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void def initialize(comments, magic_comments, data_loc, errors, warnings, source) @comments = comments @magic_comments = magic_comments @@ -705,28 +901,38 @@ def initialize(comments, magic_comments, data_loc, errors, warnings, source) end # Implement the hash pattern matching interface for Result. + #-- + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: { comments: comments, magic_comments: magic_comments, data_loc: data_loc, errors: errors, warnings: warnings } end # Returns the encoding of the source code that was parsed. + #-- + #: () -> Encoding def encoding source.encoding end # Returns true if there were no errors during parsing and false if there # were. + #-- + #: () -> bool def success? errors.empty? end # Returns true if there were errors during parsing and false if there were # not. + #-- + #: () -> bool def failure? !success? end # Create a code units cache for the given encoding. + #-- + #: (Encoding encoding) -> _CodeUnitsCache def code_units_cache(encoding) source.code_units_cache(encoding) end @@ -743,32 +949,42 @@ class ParseResult < Result private_constant :Newlines # The syntax tree that was parsed from the source code. - attr_reader :value + attr_reader :value #: ProgramNode # Create a new parse result object with the given values. + #-- + #: (ProgramNode value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void def initialize(value, comments, magic_comments, data_loc, errors, warnings, source) @value = value super(comments, magic_comments, data_loc, errors, warnings, source) end # Implement the hash pattern matching interface for ParseResult. + #-- + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: super.merge!(value: value) end # Attach the list of comments to their respective locations in the tree. + #-- + #: () -> void def attach_comments! Comments.new(self).attach! # steep:ignore end # Walk the tree and mark nodes that are on a new line, loosely emulating # the behavior of CRuby's `:line` tracepoint event. + #-- + #: () -> void def mark_newlines! value.accept(Newlines.new(source.offsets.size)) # steep:ignore end # Returns a string representation of the syntax tree with the errors # displayed inline. + #-- + #: () -> String def errors_format Errors.new(self).format end @@ -777,15 +993,19 @@ def errors_format # This is a result specific to the `lex` and `lex_file` methods. class LexResult < Result # The list of tokens that were parsed from the source code. - attr_reader :value + attr_reader :value #: Array[[Token, Integer]] # Create a new lex result object with the given values. + #-- + #: (Array[[Token, Integer]] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void def initialize(value, comments, magic_comments, data_loc, errors, warnings, source) @value = value super(comments, magic_comments, data_loc, errors, warnings, source) end # Implement the hash pattern matching interface for LexResult. + #-- + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: super.merge!(value: value) end @@ -795,15 +1015,19 @@ def deconstruct_keys(keys) # :nodoc: class ParseLexResult < Result # A tuple of the syntax tree and the list of tokens that were parsed from # the source code. - attr_reader :value + attr_reader :value #: [ProgramNode, Array[[Token, Integer]]] # Create a new parse lex result object with the given values. + #-- + #: ([ProgramNode, Array[[Token, Integer]]] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void def initialize(value, comments, magic_comments, data_loc, errors, warnings, source) @value = value super(comments, magic_comments, data_loc, errors, warnings, source) end # Implement the hash pattern matching interface for ParseLexResult. + #-- + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: super.merge!(value: value) end @@ -812,16 +1036,20 @@ def deconstruct_keys(keys) # :nodoc: # This represents a token from the Ruby source. class Token # The Source object that represents the source this token came from. - attr_reader :source + attr_reader :source #: Source private :source # The type of token that this token is. - attr_reader :type + attr_reader :type #: Symbol # A byteslice of the source that this token represents. - attr_reader :value + attr_reader :value #: String + + # @rbs @location: Location | Integer # Create a new token object with the given type, value, and location. + #-- + #: (Source source, Symbol type, String value, Location | Integer location) -> void def initialize(source, type, value, location) @source = source @type = type @@ -830,11 +1058,15 @@ def initialize(source, type, value, location) end # Implement the hash pattern matching interface for Token. + #-- + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: { type: type, value: value, location: location } end # A Location object representing the location of this token in the source. + #-- + #: () -> Location def location location = @location return location if location.is_a?(Location) @@ -842,6 +1074,8 @@ def location end # Implement the pretty print interface for Token. + #-- + #: (PP q) -> void def pretty_print(q) # :nodoc: q.group do q.text(type.to_s) @@ -857,6 +1091,8 @@ def pretty_print(q) # :nodoc: end # Returns true if the given other token is equal to this token. + #-- + #: (untyped other) -> bool def ==(other) Token === other && other.type == type && @@ -864,12 +1100,16 @@ def ==(other) end # Returns a string representation of this token. + #-- + #: () -> String def inspect # :nodoc: location super end # Freeze this object and the objects it contains. + #-- + #: () -> void def deep_freeze value.freeze location.freeze @@ -884,14 +1124,16 @@ def deep_freeze class Scope # The list of local variables that are defined in this scope. This should be # defined as an array of symbols. - attr_reader :locals + attr_reader :locals #: Array[Symbol] # The list of local variables that are forwarded to the next scope. This # should by defined as an array of symbols containing the specific values of # :*, :**, :&, or :"...". - attr_reader :forwarding + attr_reader :forwarding #: Array[Symbol] # Create a new scope object with the given locals and forwarding. + #-- + #: (Array[Symbol] locals, Array[Symbol] forwarding) -> void def initialize(locals, forwarding) @locals = locals @forwarding = forwarding @@ -901,6 +1143,8 @@ def initialize(locals, forwarding) # Create a new scope with the given locals and forwarding options that is # suitable for passing into one of the Prism.* methods that accepts the # `scopes` option. + #-- + #: (?locals: Array[Symbol], ?forwarding: Array[Symbol]) -> Scope def self.scope(locals: [], forwarding: []) Scope.new(locals, forwarding) end diff --git a/lib/prism/parse_result/comments.rb b/lib/prism/parse_result/comments.rb index 3e93316aff..df80792d39 100644 --- a/lib/prism/parse_result/comments.rb +++ b/lib/prism/parse_result/comments.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled module Prism class ParseResult < Result @@ -18,32 +20,49 @@ class ParseResult < Result # the comment. Otherwise it will favor attaching to the nearest location # that is after the comment. class Comments + # @rbs! + # # An internal interface for a target that comments can be attached + # # to. This is either going to be a NodeTarget or a CommentTarget. + # interface _CommentTarget + # def start_offset: () -> Integer + # def end_offset: () -> Integer + # def encloses?: (Comment) -> bool + # def leading_comment: (Comment) -> void + # def trailing_comment: (Comment) -> void + # end + # A target for attaching comments that is based on a specific node's # location. class NodeTarget # :nodoc: - attr_reader :node + attr_reader :node #: node + #: (node node) -> void def initialize(node) @node = node end + #: () -> Integer def start_offset node.start_offset end + #: () -> Integer def end_offset node.end_offset end + #: (Comment comment) -> bool def encloses?(comment) start_offset <= comment.location.start_offset && comment.location.end_offset <= end_offset end + #: (Comment comment) -> void def leading_comment(comment) node.location.leading_comment(comment) end + #: (Comment comment) -> void def trailing_comment(comment) node.location.trailing_comment(comment) end @@ -52,44 +71,54 @@ def trailing_comment(comment) # A target for attaching comments that is based on a location field on a # node. For example, the `end` token of a ClassNode. class LocationTarget # :nodoc: - attr_reader :location + attr_reader :location #: Location + #: (Location location) -> void def initialize(location) @location = location end + #: () -> Integer def start_offset location.start_offset end + #: () -> Integer def end_offset location.end_offset end + #: (Comment comment) -> bool def encloses?(comment) false end + #: (Comment comment) -> void def leading_comment(comment) location.leading_comment(comment) end + #: (Comment comment) -> void def trailing_comment(comment) location.trailing_comment(comment) end end # The parse result that we are attaching comments to. - attr_reader :parse_result + attr_reader :parse_result #: ParseResult # Create a new Comments object that will attach comments to the given # parse result. + #-- + #: (ParseResult parse_result) -> void def initialize(parse_result) @parse_result = parse_result end # Attach the comments to their respective locations in the tree by # mutating the parse result. + #-- + #: () -> void def attach! parse_result.comments.each do |comment| preceding, enclosing, following = nearest_targets(parse_result.value, comment) @@ -117,11 +146,13 @@ def attach! # Responsible for finding the nearest targets to the given comment within # the context of the given encapsulating node. + #-- + #: (node node, Comment comment) -> [_CommentTarget?, _CommentTarget?, _CommentTarget?] def nearest_targets(node, comment) comment_start = comment.location.start_offset comment_end = comment.location.end_offset - targets = [] #: Array[_Target] + targets = [] #: Array[_CommentTarget] node.comment_targets.map do |value| case value when StatementsNode @@ -134,8 +165,8 @@ def nearest_targets(node, comment) end targets.sort_by!(&:start_offset) - preceding = nil #: _Target? - following = nil #: _Target? + preceding = nil #: _CommentTarget? + following = nil #: _CommentTarget? left = 0 right = targets.length diff --git a/lib/prism/parse_result/errors.rb b/lib/prism/parse_result/errors.rb index 26c376b3ce..388309d23d 100644 --- a/lib/prism/parse_result/errors.rb +++ b/lib/prism/parse_result/errors.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled require "stringio" @@ -9,14 +11,18 @@ class ParseResult < Result # can be used to format the errors in a human-readable way. class Errors # The parse result that contains the errors. - attr_reader :parse_result + attr_reader :parse_result #: ParseResult # Initialize a new set of errors from the given parse result. + #-- + #: (ParseResult parse_result) -> void def initialize(parse_result) @parse_result = parse_result end # Formats the errors in a human-readable way and return them as a string. + #-- + #: () -> String def format error_lines = {} #: Hash[Integer, Array[ParseError]] parse_result.errors.each do |error| diff --git a/lib/prism/parse_result/newlines.rb b/lib/prism/parse_result/newlines.rb index e7fd62cafe..82e72bd564 100644 --- a/lib/prism/parse_result/newlines.rb +++ b/lib/prism/parse_result/newlines.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled module Prism class ParseResult < Result @@ -24,13 +26,20 @@ class ParseResult < Result # that case. We do that to avoid storing the extra `@newline` instance # variable on every node if we don't need it. class Newlines < Visitor + # The map of lines indices to whether or not they have been marked as + # emitting a newline event. + # @rbs @lines: Array[bool] + # Create a new Newlines visitor with the given newline offsets. + #-- + #: (Integer lines) -> void def initialize(lines) - # @type var lines: Integer @lines = Array.new(1 + lines, false) end - # Permit block/lambda nodes to mark newlines within themselves. + # Permit block nodes to mark newlines within themselves. + #-- + #: (BlockNode node) -> void def visit_block_node(node) old_lines = @lines @lines = Array.new(old_lines.size, false) @@ -42,17 +51,39 @@ def visit_block_node(node) end end - alias_method :visit_lambda_node, :visit_block_node + # Permit lambda nodes to mark newlines within themselves. + #-- + #: (LambdaNode node) -> void + def visit_lambda_node(node) + old_lines = @lines + @lines = Array.new(old_lines.size, false) + + begin + super(node) + ensure + @lines = old_lines + end + end - # Mark if/unless nodes as newlines. + # Mark if nodes as newlines. + #-- + #: (IfNode node) -> void def visit_if_node(node) node.newline_flag!(@lines) super(node) end - alias_method :visit_unless_node, :visit_if_node + # Mark unless nodes as newlines. + #-- + #: (UnlessNode node) -> void + def visit_unless_node(node) + node.newline_flag!(@lines) + super(node) + end # Permit statements lists to mark newlines within themselves. + #-- + #: (StatementsNode node) -> void def visit_statements_node(node) node.body.each do |child| child.newline_flag!(@lines) @@ -63,10 +94,16 @@ def visit_statements_node(node) end class Node + # Tracks whether or not this node should emit a newline event when the + # instructions that it represents are executed. + # @rbs @newline_flag: bool + + #: () -> bool def newline_flag? # :nodoc: !!defined?(@newline_flag) end + #: (Array[bool] lines) -> void def newline_flag!(lines) # :nodoc: line = location.start_line unless lines[line] @@ -77,48 +114,56 @@ def newline_flag!(lines) # :nodoc: end class BeginNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: # Never mark BeginNode with a newline flag, mark children instead. end end class ParenthesesNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: # Never mark ParenthesesNode with a newline flag, mark children instead. end end class IfNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: predicate.newline_flag!(lines) end end class UnlessNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: predicate.newline_flag!(lines) end end class UntilNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: predicate.newline_flag!(lines) end end class WhileNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: predicate.newline_flag!(lines) end end class RescueModifierNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: expression.newline_flag!(lines) end end class InterpolatedMatchLastLineNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: first = parts.first first.newline_flag!(lines) if first @@ -126,6 +171,7 @@ def newline_flag!(lines) # :nodoc: end class InterpolatedRegularExpressionNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: first = parts.first first.newline_flag!(lines) if first @@ -133,6 +179,7 @@ def newline_flag!(lines) # :nodoc: end class InterpolatedStringNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: first = parts.first first.newline_flag!(lines) if first @@ -140,6 +187,7 @@ def newline_flag!(lines) # :nodoc: end class InterpolatedSymbolNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: first = parts.first first.newline_flag!(lines) if first @@ -147,6 +195,7 @@ def newline_flag!(lines) # :nodoc: end class InterpolatedXStringNode < Node + # @rbs override def newline_flag!(lines) # :nodoc: first = parts.first first.newline_flag!(lines) if first diff --git a/lib/prism/pattern.rb b/lib/prism/pattern.rb index dde9d3b6f9..cbfb2c69b7 100644 --- a/lib/prism/pattern.rb +++ b/lib/prism/pattern.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled module Prism # A pattern is an object that wraps a Ruby pattern matching expression. The @@ -41,6 +43,8 @@ class Pattern class CompilationError < StandardError # Create a new CompilationError with the given representation of the node # that caused the error. + #-- + #: (String repr) -> void def initialize(repr) # :nodoc: super(<<~ERROR) prism was unable to compile the pattern you provided into a usable @@ -57,10 +61,13 @@ def initialize(repr) # :nodoc: end # The query that this pattern was initialized with. - attr_reader :query + attr_reader :query #: String + # @rbs @compiled: Proc? # Create a new pattern with the given query. The query should be a string # containing a Ruby pattern matching expression. + #-- + #: (String query) -> void def initialize(query) @query = query @compiled = nil @@ -68,6 +75,8 @@ def initialize(query) # Compile the query into a callable object that can be used to match against # nodes. + #-- + #: () -> Proc def compile result = Prism.parse("case nil\nin #{query}\nend") @@ -84,6 +93,9 @@ def compile # pattern. If a block is given, it will be called with each node that # matches the pattern. If no block is given, an enumerator will be returned # that will yield each node that matches the pattern. + #-- + #: (node root) { (node) -> void } -> void + #: (node root) -> Enumerator[node, void] def scan(root) return to_enum(:scan, root) unless block_given? @@ -100,22 +112,32 @@ def scan(root) # Shortcut for combining two procs into one that returns true if both return # true. + #-- + #: (Proc left, Proc right) -> Proc def combine_and(left, right) # :nodoc: ->(other) { left.call(other) && right.call(other) } end # Shortcut for combining two procs into one that returns true if either # returns true. + #-- + #: (Proc left, Proc right) -> Proc def combine_or(left, right) # :nodoc: ->(other) { left.call(other) || right.call(other) } end - # Raise an error because the given node is not supported. + # Raise an error because the given node is not supported. Note purposefully + # not typing this method since it is a no return method that Steep does not + # understand. + #-- + #: (node node) -> bot def compile_error(node) # :nodoc: raise CompilationError, node.inspect end # in [foo, bar, baz] + #-- + #: (ArrayPatternNode node) -> Proc def compile_array_pattern_node(node) # :nodoc: compile_error(node) if !node.rest.nil? || node.posts.any? @@ -141,11 +163,15 @@ def compile_array_pattern_node(node) # :nodoc: end # in foo | bar + #-- + #: (AlternationPatternNode node) -> Proc def compile_alternation_pattern_node(node) # :nodoc: combine_or(compile_node(node.left), compile_node(node.right)) end # in Prism::ConstantReadNode + #-- + #: (ConstantPathNode node) -> Proc def compile_constant_path_node(node) # :nodoc: parent = node.parent @@ -161,11 +187,15 @@ def compile_constant_path_node(node) # :nodoc: # in ConstantReadNode # in String + #-- + #: (ConstantReadNode node) -> Proc def compile_constant_read_node(node) # :nodoc: compile_constant_name(node, node.name) end # Compile a name associated with a constant. + #-- + #: ((ConstantPathNode | ConstantReadNode) node, Symbol name) -> Proc def compile_constant_name(node, name) # :nodoc: if Prism.const_defined?(name, false) clazz = Prism.const_get(name) @@ -182,9 +212,14 @@ def compile_constant_name(node, name) # :nodoc: # in InstanceVariableReadNode[name: Symbol] # in { name: Symbol } + #-- + #: (HashPatternNode node) -> Proc def compile_hash_pattern_node(node) # :nodoc: compile_error(node) if node.rest - compiled_constant = compile_node(node.constant) if node.constant + + if (constant = node.constant) + compiled_constant = compile_node(constant) + end preprocessed = node.elements.to_h do |element| @@ -212,11 +247,15 @@ def compile_hash_pattern_node(node) # :nodoc: end # in nil + #-- + #: (NilNode node) -> Proc def compile_nil_node(node) # :nodoc: ->(attribute) { attribute.nil? } end # in /foo/ + #-- + #: (RegularExpressionNode node) -> Proc def compile_regular_expression_node(node) # :nodoc: regexp = Regexp.new(node.unescaped, node.closing[1..]) @@ -225,6 +264,8 @@ def compile_regular_expression_node(node) # :nodoc: # in "" # in "foo" + #-- + #: (StringNode node) -> Proc def compile_string_node(node) # :nodoc: string = node.unescaped @@ -233,6 +274,8 @@ def compile_string_node(node) # :nodoc: # in :+ # in :foo + #-- + #: (SymbolNode node) -> Proc def compile_symbol_node(node) # :nodoc: symbol = node.unescaped.to_sym @@ -241,6 +284,8 @@ def compile_symbol_node(node) # :nodoc: # Compile any kind of node. Dispatch out to the individual compilation # methods based on the type of node. + #-- + #: (node node) -> Proc def compile_node(node) # :nodoc: case node when AlternationPatternNode diff --git a/lib/prism/relocation.rb b/lib/prism/relocation.rb index 3e9210a785..af0f792827 100644 --- a/lib/prism/relocation.rb +++ b/lib/prism/relocation.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled module Prism # Prism parses deterministically for the same input. This provides a nice @@ -12,6 +14,33 @@ module Prism # "save" nodes and locations using a minimal amount of memory (just the # node_id and a field identifier) and then reify them later. module Relocation + # @rbs! + # type entry_value = untyped + # type entry_values = Hash[Symbol, entry_value] + # + # interface _Value + # def start_line: () -> Integer + # def end_line: () -> Integer + # def start_offset: () -> Integer + # def end_offset: () -> Integer + # def start_character_offset: () -> Integer + # def end_character_offset: () -> Integer + # def cached_start_code_units_offset: (_CodeUnitsCache cache) -> Integer + # def cached_end_code_units_offset: (_CodeUnitsCache cache) -> Integer + # def start_column: () -> Integer + # def end_column: () -> Integer + # def start_character_column: () -> Integer + # def end_character_column: () -> Integer + # def cached_start_code_units_column: (_CodeUnitsCache cache) -> Integer + # def cached_end_code_units_column: (_CodeUnitsCache cache) -> Integer + # def leading_comments: () -> Array[Comment] + # def trailing_comments: () -> Array[Comment] + # end + # + # interface _Field + # def fields: (_Value value) -> entry_values + # end + # An entry in a repository that will lazily reify its values when they are # first accessed. class Entry @@ -21,109 +50,152 @@ class Entry class MissingValueError < StandardError end + # @rbs @repository: Repository? + # @rbs @values: Hash[Symbol, untyped]? + # Initialize a new entry with the given repository. + #-- + #: (Repository repository) -> void def initialize(repository) @repository = repository @values = nil end # Fetch the filepath of the value. + #-- + #: () -> String def filepath fetch_value(:filepath) end # Fetch the start line of the value. + #-- + #: () -> Integer def start_line fetch_value(:start_line) end # Fetch the end line of the value. + #-- + #: () -> Integer def end_line fetch_value(:end_line) end # Fetch the start byte offset of the value. + #-- + #: () -> Integer def start_offset fetch_value(:start_offset) end # Fetch the end byte offset of the value. + #-- + #: () -> Integer def end_offset fetch_value(:end_offset) end # Fetch the start character offset of the value. + #-- + #: () -> Integer def start_character_offset fetch_value(:start_character_offset) end # Fetch the end character offset of the value. + #-- + #: () -> Integer def end_character_offset fetch_value(:end_character_offset) end # Fetch the start code units offset of the value, for the encoding that # was configured on the repository. + #-- + #: () -> Integer def start_code_units_offset fetch_value(:start_code_units_offset) end # Fetch the end code units offset of the value, for the encoding that was # configured on the repository. + #-- + #: () -> Integer def end_code_units_offset fetch_value(:end_code_units_offset) end # Fetch the start byte column of the value. + #-- + #: () -> Integer def start_column fetch_value(:start_column) end # Fetch the end byte column of the value. + #-- + #: () -> Integer def end_column fetch_value(:end_column) end # Fetch the start character column of the value. + #-- + #: () -> Integer def start_character_column fetch_value(:start_character_column) end # Fetch the end character column of the value. + #-- + #: () -> Integer def end_character_column fetch_value(:end_character_column) end # Fetch the start code units column of the value, for the encoding that # was configured on the repository. + #-- + #: () -> Integer def start_code_units_column fetch_value(:start_code_units_column) end # Fetch the end code units column of the value, for the encoding that was # configured on the repository. + #-- + #: () -> Integer def end_code_units_column fetch_value(:end_code_units_column) end # Fetch the leading comments of the value. + #-- + #: () -> Array[CommentsField::Comment] def leading_comments fetch_value(:leading_comments) end # Fetch the trailing comments of the value. + #-- + #: () -> Array[CommentsField::Comment] def trailing_comments fetch_value(:trailing_comments) end # Fetch the leading and trailing comments of the value. + #-- + #: () -> Array[CommentsField::Comment] def comments - leading_comments.concat(trailing_comments) + [*leading_comments, *trailing_comments] end # Reify the values on this entry with the given values. This is an # internal-only API that is called from the repository when it is time to # reify the values. + #-- + #: (entry_values values) -> void def reify!(values) # :nodoc: @repository = nil @values = values @@ -132,6 +204,8 @@ def reify!(values) # :nodoc: private # Fetch a value from the entry, raising an error if it is missing. + #-- + #: (Symbol name) -> entry_value def fetch_value(name) values.fetch(name) do raise MissingValueError, "No value for #{name}, make sure the " \ @@ -140,27 +214,35 @@ def fetch_value(name) end # Return the values from the repository, reifying them if necessary. + #-- + #: () -> entry_values def values - @values || (@repository.reify!; @values) + @values || (@repository&.reify!; @values) #: entry_values end end # Represents the source of a repository that will be reparsed. class Source # The value that will need to be reparsed. - attr_reader :value + attr_reader :value #: untyped # Initialize the source with the given value. + #-- + #: (untyped value) -> void def initialize(value) @value = value end # Reparse the value and return the parse result. + #-- + #: () -> ParseResult def result raise NotImplementedError, "Subclasses must implement #result" end # Create a code units cache for the given encoding. + #-- + #: (Encoding encoding) -> _CodeUnitsCache def code_units_cache(encoding) result.code_units_cache(encoding) end @@ -169,6 +251,8 @@ def code_units_cache(encoding) # A source that is represented by a file path. class SourceFilepath < Source # Reparse the file and return the parse result. + #-- + #: () -> ParseResult def result Prism.parse_file(value) end @@ -177,6 +261,8 @@ def result # A source that is represented by a string. class SourceString < Source # Reparse the string and return the parse result. + #-- + #: () -> ParseResult def result Prism.parse(value) end @@ -185,14 +271,18 @@ def result # A field that represents the file path. class FilepathField # The file path that this field represents. - attr_reader :value + attr_reader :value #: String # Initialize a new field with the given file path. + #-- + #: (String value) -> void def initialize(value) @value = value end # Fetch the file path. + #-- + #: (_Value _value) -> entry_values def fields(_value) { filepath: value } end @@ -201,6 +291,8 @@ def fields(_value) # A field representing the start and end lines. class LinesField # Fetches the start and end line of a value. + #-- + #: (_Value value) -> entry_values def fields(value) { start_line: value.start_line, end_line: value.end_line } end @@ -209,6 +301,8 @@ def fields(value) # A field representing the start and end byte offsets. class OffsetsField # Fetches the start and end byte offset of a value. + #-- + #: (_Value value) -> entry_values def fields(value) { start_offset: value.start_offset, end_offset: value.end_offset } end @@ -217,6 +311,8 @@ def fields(value) # A field representing the start and end character offsets. class CharacterOffsetsField # Fetches the start and end character offset of a value. + #-- + #: (_Value value) -> entry_values def fields(value) { start_character_offset: value.start_character_offset, @@ -229,12 +325,16 @@ def fields(value) class CodeUnitOffsetsField # A pointer to the repository object that is used for lazily creating a # code units cache. - attr_reader :repository + attr_reader :repository #: Repository # The associated encoding for the code units. - attr_reader :encoding + attr_reader :encoding #: Encoding + + # @rbs @cache: _CodeUnitsCache? # Initialize a new field with the associated repository and encoding. + #-- + #: (Repository repository, Encoding encoding) -> void def initialize(repository, encoding) @repository = repository @encoding = encoding @@ -243,6 +343,8 @@ def initialize(repository, encoding) # Fetches the start and end code units offset of a value for a particular # encoding. + #-- + #: (_Value value) -> entry_values def fields(value) { start_code_units_offset: value.cached_start_code_units_offset(cache), @@ -253,6 +355,8 @@ def fields(value) private # Lazily create a code units cache for the associated encoding. + #-- + #: () -> _CodeUnitsCache def cache @cache ||= repository.code_units_cache(encoding) end @@ -261,6 +365,8 @@ def cache # A field representing the start and end byte columns. class ColumnsField # Fetches the start and end byte column of a value. + #-- + #: (_Value value) -> entry_values def fields(value) { start_column: value.start_column, end_column: value.end_column } end @@ -269,6 +375,8 @@ def fields(value) # A field representing the start and end character columns. class CharacterColumnsField # Fetches the start and end character column of a value. + #-- + #: (_Value value) -> entry_values def fields(value) { start_character_column: value.start_character_column, @@ -282,12 +390,16 @@ def fields(value) class CodeUnitColumnsField # The repository object that is used for lazily creating a code units # cache. - attr_reader :repository + attr_reader :repository #: Repository # The associated encoding for the code units. - attr_reader :encoding + attr_reader :encoding #: Encoding + + # @rbs @cache: _CodeUnitsCache? # Initialize a new field with the associated repository and encoding. + #-- + #: (Repository repository, Encoding encoding) -> void def initialize(repository, encoding) @repository = repository @encoding = encoding @@ -296,6 +408,8 @@ def initialize(repository, encoding) # Fetches the start and end code units column of a value for a particular # encoding. + #-- + #: (_Value value) -> entry_values def fields(value) { start_code_units_column: value.cached_start_code_units_column(cache), @@ -306,6 +420,8 @@ def fields(value) private # Lazily create a code units cache for the associated encoding. + #-- + #: () -> _CodeUnitsCache def cache @cache ||= repository.code_units_cache(encoding) end @@ -316,9 +432,11 @@ class CommentsField # An object that represents a slice of a comment. class Comment # The slice of the comment. - attr_reader :slice + attr_reader :slice #: String # Initialize a new comment with the given slice. + # + #: (String slice) -> void def initialize(slice) @slice = slice end @@ -327,6 +445,8 @@ def initialize(slice) private # Create comment objects from the given values. + #-- + #: (entry_value values) -> Array[Comment] def comments(values) values.map { |value| Comment.new(value.slice) } end @@ -335,6 +455,8 @@ def comments(values) # A field representing the leading comments. class LeadingCommentsField < CommentsField # Fetches the leading comments of a value. + #-- + #: (_Value value) -> entry_values def fields(value) { leading_comments: comments(value.leading_comments) } end @@ -343,6 +465,8 @@ def fields(value) # A field representing the trailing comments. class TrailingCommentsField < CommentsField # Fetches the trailing comments of a value. + #-- + #: (_Value value) -> entry_values def fields(value) { trailing_comments: comments(value.trailing_comments) } end @@ -358,15 +482,17 @@ class ConfigurationError < StandardError # The source associated with this repository. This will be either a # SourceFilepath (the most common use case) or a SourceString. - attr_reader :source + attr_reader :source #: Source # The fields that have been configured on this repository. - attr_reader :fields + attr_reader :fields #: Hash[Symbol, _Field] # The entries that have been saved on this repository. - attr_reader :entries + attr_reader :entries #: Hash[Integer, Hash[Symbol, Entry]] # Initialize a new repository with the given source. + #-- + #: (Source source) -> void def initialize(source) @source = source @fields = {} @@ -374,69 +500,93 @@ def initialize(source) end # Create a code units cache for the given encoding from the source. + #-- + #: (Encoding encoding) -> _CodeUnitsCache def code_units_cache(encoding) source.code_units_cache(encoding) end # Configure the filepath field for this repository and return self. + #-- + #: () -> self def filepath raise ConfigurationError, "Can only specify filepath for a filepath source" unless source.is_a?(SourceFilepath) field(:filepath, FilepathField.new(source.value)) end # Configure the lines field for this repository and return self. + #-- + #: () -> self def lines field(:lines, LinesField.new) end # Configure the offsets field for this repository and return self. + #-- + #: () -> self def offsets field(:offsets, OffsetsField.new) end # Configure the character offsets field for this repository and return # self. + #-- + #: () -> self def character_offsets field(:character_offsets, CharacterOffsetsField.new) end # Configure the code unit offsets field for this repository for a specific # encoding and return self. + #-- + #: (Encoding encoding) -> self def code_unit_offsets(encoding) field(:code_unit_offsets, CodeUnitOffsetsField.new(self, encoding)) end # Configure the columns field for this repository and return self. + #-- + #: () -> self def columns field(:columns, ColumnsField.new) end # Configure the character columns field for this repository and return # self. + #-- + #: () -> self def character_columns field(:character_columns, CharacterColumnsField.new) end # Configure the code unit columns field for this repository for a specific # encoding and return self. + #-- + #: (Encoding encoding) -> self def code_unit_columns(encoding) field(:code_unit_columns, CodeUnitColumnsField.new(self, encoding)) end # Configure the leading comments field for this repository and return # self. + #-- + #: () -> self def leading_comments field(:leading_comments, LeadingCommentsField.new) end # Configure the trailing comments field for this repository and return # self. + #-- + #: () -> self def trailing_comments field(:trailing_comments, TrailingCommentsField.new) end # Configure both the leading and trailing comment fields for this # repository and return self. + #-- + #: () -> self def comments leading_comments.trailing_comments end @@ -444,6 +594,8 @@ def comments # This method is called from nodes and locations when they want to enter # themselves into the repository. It it internal-only and meant to be # called from the #save* APIs. + #-- + #: (Integer node_id, Symbol field_name) -> Entry def enter(node_id, field_name) # :nodoc: entry = Entry.new(self) @entries[node_id][field_name] = entry @@ -453,6 +605,8 @@ def enter(node_id, field_name) # :nodoc: # This method is called from the entries in the repository when they need # to reify their values. It is internal-only and meant to be called from # the various value APIs. + #-- + #: () -> void def reify! # :nodoc: result = source.result @@ -466,7 +620,7 @@ def reify! # :nodoc: while (node = queue.shift) @entries[node.node_id].each do |field_name, entry| value = node.public_send(field_name) - values = {} #: Hash[Symbol, untyped] + values = {} #: entry_values fields.each_value do |field| values.merge!(field.fields(value)) @@ -485,6 +639,8 @@ def reify! # :nodoc: # Append the given field to the repository and return the repository so # that these calls can be chained. + #-- + #: (Symbol name, _Field) -> self def field(name, value) raise ConfigurationError, "Cannot specify multiple #{name} fields" if @fields.key?(name) @fields[name] = value @@ -493,11 +649,15 @@ def field(name, value) end # Create a new repository for the given filepath. + #-- + #: (String value) -> Repository def self.filepath(value) Repository.new(SourceFilepath.new(value)) end # Create a new repository for the given string. + #-- + #: (String value) -> Repository def self.string(value) Repository.new(SourceString.new(value)) end diff --git a/lib/prism/string_query.rb b/lib/prism/string_query.rb index 547f58d2fa..99ce57e5fe 100644 --- a/lib/prism/string_query.rb +++ b/lib/prism/string_query.rb @@ -1,29 +1,44 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled module Prism # Query methods that allow categorizing strings based on their context for # where they could be valid in a Ruby syntax tree. class StringQuery + # @rbs! + # def self.local?: (String string) -> bool + # def self.constant?: (String string) -> bool + # def self.method_name?: (String string) -> bool + # The string that this query is wrapping. - attr_reader :string + attr_reader :string #: String # Initialize a new query with the given string. + #-- + #: (String string) -> void def initialize(string) @string = string end # Whether or not this string is a valid local variable name. + #-- + #: () -> bool def local? StringQuery.local?(string) end # Whether or not this string is a valid constant name. + #-- + #: () -> bool def constant? StringQuery.constant?(string) end # Whether or not this string is a valid method name. + #-- + #: () -> bool def method_name? StringQuery.method_name?(string) end diff --git a/lib/prism/translation.rb b/lib/prism/translation.rb index 57b57135bc..5a086a7542 100644 --- a/lib/prism/translation.rb +++ b/lib/prism/translation.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true # :markup: markdown +#-- +# rbs_inline: enabled module Prism # This module is responsible for converting the prism syntax tree into other diff --git a/lib/prism/translation/parser_current.rb b/lib/prism/translation/parser_current.rb index f13eff6bbe..f7c1070e30 100644 --- a/lib/prism/translation/parser_current.rb +++ b/lib/prism/translation/parser_current.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true # :markup: markdown +#-- # typed: ignore -# module Prism module Translation case RUBY_VERSION diff --git a/prism.gemspec b/prism.gemspec index a155dc3da4..a8a30026f9 100644 --- a/prism.gemspec +++ b/prism.gemspec @@ -122,24 +122,28 @@ Gem::Specification.new do |spec| "rbi/prism/translation/parser_versions.rbi", "rbi/prism/translation/ripper.rbi", "rbi/prism/visitor.rbi", - "sig/prism.rbs", - "sig/prism/compiler.rbs", - "sig/prism/dispatcher.rbs", - "sig/prism/dot_visitor.rbs", - "sig/prism/dsl.rbs", - "sig/prism/inspect_visitor.rbs", - "sig/prism/lex_compat.rbs", - "sig/prism/mutation_compiler.rbs", - "sig/prism/node_ext.rbs", - "sig/prism/node.rbs", - "sig/prism/parse_result.rbs", - "sig/prism/parse_result/comments.rbs", - "sig/prism/pattern.rbs", - "sig/prism/reflection.rbs", - "sig/prism/relocation.rbs", - "sig/prism/serialize.rbs", - "sig/prism/string_query.rbs", - "sig/prism/visitor.rbs", + "sig/generated/prism.rbs", + "sig/generated/prism/compiler.rbs", + "sig/generated/prism/desugar_compiler.rbs", + "sig/generated/prism/dispatcher.rbs", + "sig/generated/prism/dot_visitor.rbs", + "sig/generated/prism/dsl.rbs", + "sig/generated/prism/inspect_visitor.rbs", + "sig/generated/prism/lex_compat.rbs", + "sig/generated/prism/mutation_compiler.rbs", + "sig/generated/prism/node.rbs", + "sig/generated/prism/node_ext.rbs", + "sig/generated/prism/parse_result.rbs", + "sig/generated/prism/pattern.rbs", + "sig/generated/prism/reflection.rbs", + "sig/generated/prism/relocation.rbs", + "sig/generated/prism/serialize.rbs", + "sig/generated/prism/string_query.rbs", + "sig/generated/prism/translation.rbs", + "sig/generated/prism/visitor.rbs", + "sig/generated/prism/parse_result/comments.rbs", + "sig/generated/prism/parse_result/errors.rbs", + "sig/generated/prism/parse_result/newlines.rbs", "src/diagnostic.c", "src/encoding.c", "src/node.c", diff --git a/rakelib/typecheck.rake b/rakelib/typecheck.rake index 55a8730106..52cc0d17f1 100644 --- a/rakelib/typecheck.rake +++ b/rakelib/typecheck.rake @@ -38,6 +38,7 @@ namespace :typecheck do - ./lib/prism/translation/ripper/sexp.rb - ./lib/prism/translation/ruby_parser.rb - ./lib/prism/inspect_visitor.rb + - ./lib/prism/serialize.rb - ./sample/prism/multiplex_constants.rb # We want to treat all polyfill files as "typed: false" <% polyfills.each do |file| -%> @@ -76,6 +77,13 @@ namespace :typecheck do end end + desc "Generate RBS with rbs-inline" + task rbs_inline: :templates do + with_gemfile do + sh "bundle", "exec", "rbs-inline", "lib", "--output", "lib" + end + end + desc "Typecheck with Steep" task steep: :templates do with_gemfile do diff --git a/sig/generated/prism.rbs b/sig/generated/prism.rbs new file mode 100644 index 0000000000..4777914d3e --- /dev/null +++ b/sig/generated/prism.rbs @@ -0,0 +1,76 @@ +# Generated from lib/prism.rb with RBS::Inline + +# The Prism Ruby parser. +# +# "Parsing Ruby is suddenly manageable!" +# - You, hopefully +module Prism + # Raised when requested to parse as the currently running Ruby version but Prism has no support for it. + class CurrentVersionError < ArgumentError + # Initialize a new exception for the given ruby version string. + # -- + # : (String version) -> void + def initialize: (String version) -> void + end + + # :call-seq: + # lex_compat(source, **options) -> LexCompat::Result + # + # Returns a parse result whose value is an array of tokens that closely + # resembles the return value of Ripper.lex. + # + # For supported options, see Prism.parse. + # -- + # : (String source, **untyped options) -> LexCompat::Result + def self.lex_compat: (String source, **untyped options) -> LexCompat::Result + + # :call-seq: + # load(source, serialized, freeze) -> ParseResult + # + # Load the serialized AST using the source as a reference into a tree. + # -- + # : (String source, String serialized, ?bool freeze) -> ParseResult + def self.load: (String source, String serialized, ?bool freeze) -> ParseResult + + VERSION: String + + BACKEND: :CEXT | :FFI + + interface _Stream + def gets: (?Integer integer) -> (String | nil) + end + + def self.parse: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult + + def self.profile: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> void + + def self.lex: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> LexResult + + def self.parse_lex: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseLexResult + + def self.dump: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> String + + def self.parse_comments: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> Array[Comment] + + def self.parse_success?: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool + + def self.parse_failure?: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool + + def self.parse_stream: (_Stream stream, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult + + def self.parse_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult + + def self.profile_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> void + + def self.lex_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> LexResult + + def self.parse_lex_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseLexResult + + def self.dump_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> String + + def self.parse_file_comments: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> Array[Comment] + + def self.parse_file_success?: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool + + def self.parse_file_failure?: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool +end diff --git a/sig/generated/prism/compiler.rbs b/sig/generated/prism/compiler.rbs new file mode 100644 index 0000000000..c2e4db0ace --- /dev/null +++ b/sig/generated/prism/compiler.rbs @@ -0,0 +1,492 @@ +# Generated from lib/prism/compiler.rb with RBS::Inline + +module Prism + # A compiler is a visitor that returns the value of each node as it visits. + # This is as opposed to a visitor which will only walk the tree. This can be + # useful when you are trying to compile a tree into a different format. + # + # For example, to build a representation of the tree as s-expressions, you + # could write: + # + # class SExpressions < Prism::Compiler + # def visit_arguments_node(node) = [:arguments, super] + # def visit_call_node(node) = [:call, super] + # def visit_integer_node(node) = [:integer] + # def visit_program_node(node) = [:program, super] + # end + # + # Prism.parse("1 + 2").value.accept(SExpressions.new) + # # => [:program, [[[:call, [[:integer], [:arguments, [[:integer]]]]]]]] + class Compiler < Visitor + # Visit an individual node. + # -- + # : (node?) -> untyped + def visit: (node?) -> untyped + + # Visit a list of nodes. + # -- + # : (Array[node?]) -> untyped + def visit_all: (Array[node?]) -> untyped + + # Visit the child nodes of the given node. + # -- + # : (node) -> Array[untyped] + def visit_child_nodes: (node) -> Array[untyped] + + # : (AliasGlobalVariableNode) -> Array[untyped] + def visit_alias_global_variable_node: (AliasGlobalVariableNode) -> Array[untyped] + + # : (AliasMethodNode) -> Array[untyped] + def visit_alias_method_node: (AliasMethodNode) -> Array[untyped] + + # : (AlternationPatternNode) -> Array[untyped] + def visit_alternation_pattern_node: (AlternationPatternNode) -> Array[untyped] + + # : (AndNode) -> Array[untyped] + def visit_and_node: (AndNode) -> Array[untyped] + + # : (ArgumentsNode) -> Array[untyped] + def visit_arguments_node: (ArgumentsNode) -> Array[untyped] + + # : (ArrayNode) -> Array[untyped] + def visit_array_node: (ArrayNode) -> Array[untyped] + + # : (ArrayPatternNode) -> Array[untyped] + def visit_array_pattern_node: (ArrayPatternNode) -> Array[untyped] + + # : (AssocNode) -> Array[untyped] + def visit_assoc_node: (AssocNode) -> Array[untyped] + + # : (AssocSplatNode) -> Array[untyped] + def visit_assoc_splat_node: (AssocSplatNode) -> Array[untyped] + + # : (BackReferenceReadNode) -> Array[untyped] + def visit_back_reference_read_node: (BackReferenceReadNode) -> Array[untyped] + + # : (BeginNode) -> Array[untyped] + def visit_begin_node: (BeginNode) -> Array[untyped] + + # : (BlockArgumentNode) -> Array[untyped] + def visit_block_argument_node: (BlockArgumentNode) -> Array[untyped] + + # : (BlockLocalVariableNode) -> Array[untyped] + def visit_block_local_variable_node: (BlockLocalVariableNode) -> Array[untyped] + + # : (BlockNode) -> Array[untyped] + def visit_block_node: (BlockNode) -> Array[untyped] + + # : (BlockParameterNode) -> Array[untyped] + def visit_block_parameter_node: (BlockParameterNode) -> Array[untyped] + + # : (BlockParametersNode) -> Array[untyped] + def visit_block_parameters_node: (BlockParametersNode) -> Array[untyped] + + # : (BreakNode) -> Array[untyped] + def visit_break_node: (BreakNode) -> Array[untyped] + + # : (CallAndWriteNode) -> Array[untyped] + def visit_call_and_write_node: (CallAndWriteNode) -> Array[untyped] + + # : (CallNode) -> Array[untyped] + def visit_call_node: (CallNode) -> Array[untyped] + + # : (CallOperatorWriteNode) -> Array[untyped] + def visit_call_operator_write_node: (CallOperatorWriteNode) -> Array[untyped] + + # : (CallOrWriteNode) -> Array[untyped] + def visit_call_or_write_node: (CallOrWriteNode) -> Array[untyped] + + # : (CallTargetNode) -> Array[untyped] + def visit_call_target_node: (CallTargetNode) -> Array[untyped] + + # : (CapturePatternNode) -> Array[untyped] + def visit_capture_pattern_node: (CapturePatternNode) -> Array[untyped] + + # : (CaseMatchNode) -> Array[untyped] + def visit_case_match_node: (CaseMatchNode) -> Array[untyped] + + # : (CaseNode) -> Array[untyped] + def visit_case_node: (CaseNode) -> Array[untyped] + + # : (ClassNode) -> Array[untyped] + def visit_class_node: (ClassNode) -> Array[untyped] + + # : (ClassVariableAndWriteNode) -> Array[untyped] + def visit_class_variable_and_write_node: (ClassVariableAndWriteNode) -> Array[untyped] + + # : (ClassVariableOperatorWriteNode) -> Array[untyped] + def visit_class_variable_operator_write_node: (ClassVariableOperatorWriteNode) -> Array[untyped] + + # : (ClassVariableOrWriteNode) -> Array[untyped] + def visit_class_variable_or_write_node: (ClassVariableOrWriteNode) -> Array[untyped] + + # : (ClassVariableReadNode) -> Array[untyped] + def visit_class_variable_read_node: (ClassVariableReadNode) -> Array[untyped] + + # : (ClassVariableTargetNode) -> Array[untyped] + def visit_class_variable_target_node: (ClassVariableTargetNode) -> Array[untyped] + + # : (ClassVariableWriteNode) -> Array[untyped] + def visit_class_variable_write_node: (ClassVariableWriteNode) -> Array[untyped] + + # : (ConstantAndWriteNode) -> Array[untyped] + def visit_constant_and_write_node: (ConstantAndWriteNode) -> Array[untyped] + + # : (ConstantOperatorWriteNode) -> Array[untyped] + def visit_constant_operator_write_node: (ConstantOperatorWriteNode) -> Array[untyped] + + # : (ConstantOrWriteNode) -> Array[untyped] + def visit_constant_or_write_node: (ConstantOrWriteNode) -> Array[untyped] + + # : (ConstantPathAndWriteNode) -> Array[untyped] + def visit_constant_path_and_write_node: (ConstantPathAndWriteNode) -> Array[untyped] + + # : (ConstantPathNode) -> Array[untyped] + def visit_constant_path_node: (ConstantPathNode) -> Array[untyped] + + # : (ConstantPathOperatorWriteNode) -> Array[untyped] + def visit_constant_path_operator_write_node: (ConstantPathOperatorWriteNode) -> Array[untyped] + + # : (ConstantPathOrWriteNode) -> Array[untyped] + def visit_constant_path_or_write_node: (ConstantPathOrWriteNode) -> Array[untyped] + + # : (ConstantPathTargetNode) -> Array[untyped] + def visit_constant_path_target_node: (ConstantPathTargetNode) -> Array[untyped] + + # : (ConstantPathWriteNode) -> Array[untyped] + def visit_constant_path_write_node: (ConstantPathWriteNode) -> Array[untyped] + + # : (ConstantReadNode) -> Array[untyped] + def visit_constant_read_node: (ConstantReadNode) -> Array[untyped] + + # : (ConstantTargetNode) -> Array[untyped] + def visit_constant_target_node: (ConstantTargetNode) -> Array[untyped] + + # : (ConstantWriteNode) -> Array[untyped] + def visit_constant_write_node: (ConstantWriteNode) -> Array[untyped] + + # : (DefNode) -> Array[untyped] + def visit_def_node: (DefNode) -> Array[untyped] + + # : (DefinedNode) -> Array[untyped] + def visit_defined_node: (DefinedNode) -> Array[untyped] + + # : (ElseNode) -> Array[untyped] + def visit_else_node: (ElseNode) -> Array[untyped] + + # : (EmbeddedStatementsNode) -> Array[untyped] + def visit_embedded_statements_node: (EmbeddedStatementsNode) -> Array[untyped] + + # : (EmbeddedVariableNode) -> Array[untyped] + def visit_embedded_variable_node: (EmbeddedVariableNode) -> Array[untyped] + + # : (EnsureNode) -> Array[untyped] + def visit_ensure_node: (EnsureNode) -> Array[untyped] + + # : (FalseNode) -> Array[untyped] + def visit_false_node: (FalseNode) -> Array[untyped] + + # : (FindPatternNode) -> Array[untyped] + def visit_find_pattern_node: (FindPatternNode) -> Array[untyped] + + # : (FlipFlopNode) -> Array[untyped] + def visit_flip_flop_node: (FlipFlopNode) -> Array[untyped] + + # : (FloatNode) -> Array[untyped] + def visit_float_node: (FloatNode) -> Array[untyped] + + # : (ForNode) -> Array[untyped] + def visit_for_node: (ForNode) -> Array[untyped] + + # : (ForwardingArgumentsNode) -> Array[untyped] + def visit_forwarding_arguments_node: (ForwardingArgumentsNode) -> Array[untyped] + + # : (ForwardingParameterNode) -> Array[untyped] + def visit_forwarding_parameter_node: (ForwardingParameterNode) -> Array[untyped] + + # : (ForwardingSuperNode) -> Array[untyped] + def visit_forwarding_super_node: (ForwardingSuperNode) -> Array[untyped] + + # : (GlobalVariableAndWriteNode) -> Array[untyped] + def visit_global_variable_and_write_node: (GlobalVariableAndWriteNode) -> Array[untyped] + + # : (GlobalVariableOperatorWriteNode) -> Array[untyped] + def visit_global_variable_operator_write_node: (GlobalVariableOperatorWriteNode) -> Array[untyped] + + # : (GlobalVariableOrWriteNode) -> Array[untyped] + def visit_global_variable_or_write_node: (GlobalVariableOrWriteNode) -> Array[untyped] + + # : (GlobalVariableReadNode) -> Array[untyped] + def visit_global_variable_read_node: (GlobalVariableReadNode) -> Array[untyped] + + # : (GlobalVariableTargetNode) -> Array[untyped] + def visit_global_variable_target_node: (GlobalVariableTargetNode) -> Array[untyped] + + # : (GlobalVariableWriteNode) -> Array[untyped] + def visit_global_variable_write_node: (GlobalVariableWriteNode) -> Array[untyped] + + # : (HashNode) -> Array[untyped] + def visit_hash_node: (HashNode) -> Array[untyped] + + # : (HashPatternNode) -> Array[untyped] + def visit_hash_pattern_node: (HashPatternNode) -> Array[untyped] + + # : (IfNode) -> Array[untyped] + def visit_if_node: (IfNode) -> Array[untyped] + + # : (ImaginaryNode) -> Array[untyped] + def visit_imaginary_node: (ImaginaryNode) -> Array[untyped] + + # : (ImplicitNode) -> Array[untyped] + def visit_implicit_node: (ImplicitNode) -> Array[untyped] + + # : (ImplicitRestNode) -> Array[untyped] + def visit_implicit_rest_node: (ImplicitRestNode) -> Array[untyped] + + # : (InNode) -> Array[untyped] + def visit_in_node: (InNode) -> Array[untyped] + + # : (IndexAndWriteNode) -> Array[untyped] + def visit_index_and_write_node: (IndexAndWriteNode) -> Array[untyped] + + # : (IndexOperatorWriteNode) -> Array[untyped] + def visit_index_operator_write_node: (IndexOperatorWriteNode) -> Array[untyped] + + # : (IndexOrWriteNode) -> Array[untyped] + def visit_index_or_write_node: (IndexOrWriteNode) -> Array[untyped] + + # : (IndexTargetNode) -> Array[untyped] + def visit_index_target_node: (IndexTargetNode) -> Array[untyped] + + # : (InstanceVariableAndWriteNode) -> Array[untyped] + def visit_instance_variable_and_write_node: (InstanceVariableAndWriteNode) -> Array[untyped] + + # : (InstanceVariableOperatorWriteNode) -> Array[untyped] + def visit_instance_variable_operator_write_node: (InstanceVariableOperatorWriteNode) -> Array[untyped] + + # : (InstanceVariableOrWriteNode) -> Array[untyped] + def visit_instance_variable_or_write_node: (InstanceVariableOrWriteNode) -> Array[untyped] + + # : (InstanceVariableReadNode) -> Array[untyped] + def visit_instance_variable_read_node: (InstanceVariableReadNode) -> Array[untyped] + + # : (InstanceVariableTargetNode) -> Array[untyped] + def visit_instance_variable_target_node: (InstanceVariableTargetNode) -> Array[untyped] + + # : (InstanceVariableWriteNode) -> Array[untyped] + def visit_instance_variable_write_node: (InstanceVariableWriteNode) -> Array[untyped] + + # : (IntegerNode) -> Array[untyped] + def visit_integer_node: (IntegerNode) -> Array[untyped] + + # : (InterpolatedMatchLastLineNode) -> Array[untyped] + def visit_interpolated_match_last_line_node: (InterpolatedMatchLastLineNode) -> Array[untyped] + + # : (InterpolatedRegularExpressionNode) -> Array[untyped] + def visit_interpolated_regular_expression_node: (InterpolatedRegularExpressionNode) -> Array[untyped] + + # : (InterpolatedStringNode) -> Array[untyped] + def visit_interpolated_string_node: (InterpolatedStringNode) -> Array[untyped] + + # : (InterpolatedSymbolNode) -> Array[untyped] + def visit_interpolated_symbol_node: (InterpolatedSymbolNode) -> Array[untyped] + + # : (InterpolatedXStringNode) -> Array[untyped] + def visit_interpolated_x_string_node: (InterpolatedXStringNode) -> Array[untyped] + + # : (ItLocalVariableReadNode) -> Array[untyped] + def visit_it_local_variable_read_node: (ItLocalVariableReadNode) -> Array[untyped] + + # : (ItParametersNode) -> Array[untyped] + def visit_it_parameters_node: (ItParametersNode) -> Array[untyped] + + # : (KeywordHashNode) -> Array[untyped] + def visit_keyword_hash_node: (KeywordHashNode) -> Array[untyped] + + # : (KeywordRestParameterNode) -> Array[untyped] + def visit_keyword_rest_parameter_node: (KeywordRestParameterNode) -> Array[untyped] + + # : (LambdaNode) -> Array[untyped] + def visit_lambda_node: (LambdaNode) -> Array[untyped] + + # : (LocalVariableAndWriteNode) -> Array[untyped] + def visit_local_variable_and_write_node: (LocalVariableAndWriteNode) -> Array[untyped] + + # : (LocalVariableOperatorWriteNode) -> Array[untyped] + def visit_local_variable_operator_write_node: (LocalVariableOperatorWriteNode) -> Array[untyped] + + # : (LocalVariableOrWriteNode) -> Array[untyped] + def visit_local_variable_or_write_node: (LocalVariableOrWriteNode) -> Array[untyped] + + # : (LocalVariableReadNode) -> Array[untyped] + def visit_local_variable_read_node: (LocalVariableReadNode) -> Array[untyped] + + # : (LocalVariableTargetNode) -> Array[untyped] + def visit_local_variable_target_node: (LocalVariableTargetNode) -> Array[untyped] + + # : (LocalVariableWriteNode) -> Array[untyped] + def visit_local_variable_write_node: (LocalVariableWriteNode) -> Array[untyped] + + # : (MatchLastLineNode) -> Array[untyped] + def visit_match_last_line_node: (MatchLastLineNode) -> Array[untyped] + + # : (MatchPredicateNode) -> Array[untyped] + def visit_match_predicate_node: (MatchPredicateNode) -> Array[untyped] + + # : (MatchRequiredNode) -> Array[untyped] + def visit_match_required_node: (MatchRequiredNode) -> Array[untyped] + + # : (MatchWriteNode) -> Array[untyped] + def visit_match_write_node: (MatchWriteNode) -> Array[untyped] + + # : (MissingNode) -> Array[untyped] + def visit_missing_node: (MissingNode) -> Array[untyped] + + # : (ModuleNode) -> Array[untyped] + def visit_module_node: (ModuleNode) -> Array[untyped] + + # : (MultiTargetNode) -> Array[untyped] + def visit_multi_target_node: (MultiTargetNode) -> Array[untyped] + + # : (MultiWriteNode) -> Array[untyped] + def visit_multi_write_node: (MultiWriteNode) -> Array[untyped] + + # : (NextNode) -> Array[untyped] + def visit_next_node: (NextNode) -> Array[untyped] + + # : (NilNode) -> Array[untyped] + def visit_nil_node: (NilNode) -> Array[untyped] + + # : (NoBlockParameterNode) -> Array[untyped] + def visit_no_block_parameter_node: (NoBlockParameterNode) -> Array[untyped] + + # : (NoKeywordsParameterNode) -> Array[untyped] + def visit_no_keywords_parameter_node: (NoKeywordsParameterNode) -> Array[untyped] + + # : (NumberedParametersNode) -> Array[untyped] + def visit_numbered_parameters_node: (NumberedParametersNode) -> Array[untyped] + + # : (NumberedReferenceReadNode) -> Array[untyped] + def visit_numbered_reference_read_node: (NumberedReferenceReadNode) -> Array[untyped] + + # : (OptionalKeywordParameterNode) -> Array[untyped] + def visit_optional_keyword_parameter_node: (OptionalKeywordParameterNode) -> Array[untyped] + + # : (OptionalParameterNode) -> Array[untyped] + def visit_optional_parameter_node: (OptionalParameterNode) -> Array[untyped] + + # : (OrNode) -> Array[untyped] + def visit_or_node: (OrNode) -> Array[untyped] + + # : (ParametersNode) -> Array[untyped] + def visit_parameters_node: (ParametersNode) -> Array[untyped] + + # : (ParenthesesNode) -> Array[untyped] + def visit_parentheses_node: (ParenthesesNode) -> Array[untyped] + + # : (PinnedExpressionNode) -> Array[untyped] + def visit_pinned_expression_node: (PinnedExpressionNode) -> Array[untyped] + + # : (PinnedVariableNode) -> Array[untyped] + def visit_pinned_variable_node: (PinnedVariableNode) -> Array[untyped] + + # : (PostExecutionNode) -> Array[untyped] + def visit_post_execution_node: (PostExecutionNode) -> Array[untyped] + + # : (PreExecutionNode) -> Array[untyped] + def visit_pre_execution_node: (PreExecutionNode) -> Array[untyped] + + # : (ProgramNode) -> Array[untyped] + def visit_program_node: (ProgramNode) -> Array[untyped] + + # : (RangeNode) -> Array[untyped] + def visit_range_node: (RangeNode) -> Array[untyped] + + # : (RationalNode) -> Array[untyped] + def visit_rational_node: (RationalNode) -> Array[untyped] + + # : (RedoNode) -> Array[untyped] + def visit_redo_node: (RedoNode) -> Array[untyped] + + # : (RegularExpressionNode) -> Array[untyped] + def visit_regular_expression_node: (RegularExpressionNode) -> Array[untyped] + + # : (RequiredKeywordParameterNode) -> Array[untyped] + def visit_required_keyword_parameter_node: (RequiredKeywordParameterNode) -> Array[untyped] + + # : (RequiredParameterNode) -> Array[untyped] + def visit_required_parameter_node: (RequiredParameterNode) -> Array[untyped] + + # : (RescueModifierNode) -> Array[untyped] + def visit_rescue_modifier_node: (RescueModifierNode) -> Array[untyped] + + # : (RescueNode) -> Array[untyped] + def visit_rescue_node: (RescueNode) -> Array[untyped] + + # : (RestParameterNode) -> Array[untyped] + def visit_rest_parameter_node: (RestParameterNode) -> Array[untyped] + + # : (RetryNode) -> Array[untyped] + def visit_retry_node: (RetryNode) -> Array[untyped] + + # : (ReturnNode) -> Array[untyped] + def visit_return_node: (ReturnNode) -> Array[untyped] + + # : (SelfNode) -> Array[untyped] + def visit_self_node: (SelfNode) -> Array[untyped] + + # : (ShareableConstantNode) -> Array[untyped] + def visit_shareable_constant_node: (ShareableConstantNode) -> Array[untyped] + + # : (SingletonClassNode) -> Array[untyped] + def visit_singleton_class_node: (SingletonClassNode) -> Array[untyped] + + # : (SourceEncodingNode) -> Array[untyped] + def visit_source_encoding_node: (SourceEncodingNode) -> Array[untyped] + + # : (SourceFileNode) -> Array[untyped] + def visit_source_file_node: (SourceFileNode) -> Array[untyped] + + # : (SourceLineNode) -> Array[untyped] + def visit_source_line_node: (SourceLineNode) -> Array[untyped] + + # : (SplatNode) -> Array[untyped] + def visit_splat_node: (SplatNode) -> Array[untyped] + + # : (StatementsNode) -> Array[untyped] + def visit_statements_node: (StatementsNode) -> Array[untyped] + + # : (StringNode) -> Array[untyped] + def visit_string_node: (StringNode) -> Array[untyped] + + # : (SuperNode) -> Array[untyped] + def visit_super_node: (SuperNode) -> Array[untyped] + + # : (SymbolNode) -> Array[untyped] + def visit_symbol_node: (SymbolNode) -> Array[untyped] + + # : (TrueNode) -> Array[untyped] + def visit_true_node: (TrueNode) -> Array[untyped] + + # : (UndefNode) -> Array[untyped] + def visit_undef_node: (UndefNode) -> Array[untyped] + + # : (UnlessNode) -> Array[untyped] + def visit_unless_node: (UnlessNode) -> Array[untyped] + + # : (UntilNode) -> Array[untyped] + def visit_until_node: (UntilNode) -> Array[untyped] + + # : (WhenNode) -> Array[untyped] + def visit_when_node: (WhenNode) -> Array[untyped] + + # : (WhileNode) -> Array[untyped] + def visit_while_node: (WhileNode) -> Array[untyped] + + # : (XStringNode) -> Array[untyped] + def visit_x_string_node: (XStringNode) -> Array[untyped] + + # : (YieldNode) -> Array[untyped] + def visit_yield_node: (YieldNode) -> Array[untyped] + end +end diff --git a/sig/generated/prism/desugar_compiler.rbs b/sig/generated/prism/desugar_compiler.rbs new file mode 100644 index 0000000000..d5bb07edf1 --- /dev/null +++ b/sig/generated/prism/desugar_compiler.rbs @@ -0,0 +1,305 @@ +# Generated from lib/prism/desugar_compiler.rb with RBS::Inline + +module Prism + class DesugarAndWriteNode + include DSL + + attr_reader node: ClassVariableAndWriteNode | ConstantAndWriteNode | GlobalVariableAndWriteNode | InstanceVariableAndWriteNode | LocalVariableAndWriteNode + + attr_reader default_source: Source + + attr_reader read_class: Symbol + + attr_reader write_class: Symbol + + attr_reader arguments: Hash[Symbol, untyped] + + # : ((ClassVariableAndWriteNode | ConstantAndWriteNode | GlobalVariableAndWriteNode | InstanceVariableAndWriteNode | LocalVariableAndWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void + def initialize: (ClassVariableAndWriteNode | ConstantAndWriteNode | GlobalVariableAndWriteNode | InstanceVariableAndWriteNode | LocalVariableAndWriteNode node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void + + # Desugar `x &&= y` to `x && x = y` + # -- + # : () -> node + def compile: () -> node + end + + class DesugarOrWriteDefinedNode + include DSL + + attr_reader node: ClassVariableOrWriteNode | ConstantOrWriteNode | GlobalVariableOrWriteNode + + attr_reader default_source: Source + + attr_reader read_class: Symbol + + attr_reader write_class: Symbol + + attr_reader arguments: Hash[Symbol, untyped] + + # : ((ClassVariableOrWriteNode | ConstantOrWriteNode | GlobalVariableOrWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void + def initialize: (ClassVariableOrWriteNode | ConstantOrWriteNode | GlobalVariableOrWriteNode node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void + + # Desugar `x ||= y` to `defined?(x) ? x : x = y` + # -- + # : () -> node + def compile: () -> node + end + + class DesugarOperatorWriteNode + include DSL + + attr_reader node: ClassVariableOperatorWriteNode | ConstantOperatorWriteNode | GlobalVariableOperatorWriteNode | InstanceVariableOperatorWriteNode | LocalVariableOperatorWriteNode + + attr_reader default_source: Source + + attr_reader read_class: Symbol + + attr_reader write_class: Symbol + + attr_reader arguments: Hash[Symbol, untyped] + + # : ((ClassVariableOperatorWriteNode | ConstantOperatorWriteNode | GlobalVariableOperatorWriteNode | InstanceVariableOperatorWriteNode | LocalVariableOperatorWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void + def initialize: (ClassVariableOperatorWriteNode | ConstantOperatorWriteNode | GlobalVariableOperatorWriteNode | InstanceVariableOperatorWriteNode | LocalVariableOperatorWriteNode node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void + + # Desugar `x += y` to `x = x + y` + # -- + # : () -> node + def compile: () -> node + end + + class DesugarOrWriteNode + include DSL + + attr_reader node: InstanceVariableOrWriteNode | LocalVariableOrWriteNode + + attr_reader default_source: Source + + attr_reader read_class: Symbol + + attr_reader write_class: Symbol + + attr_reader arguments: Hash[Symbol, untyped] + + # : ((InstanceVariableOrWriteNode | LocalVariableOrWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void + def initialize: (InstanceVariableOrWriteNode | LocalVariableOrWriteNode node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void + + # Desugar `x ||= y` to `x || x = y` + # -- + # : () -> node + def compile: () -> node + end + + class ClassVariableAndWriteNode + # : () -> node + def desugar: () -> node + end + + class ClassVariableOrWriteNode + # : () -> node + def desugar: () -> node + end + + class ClassVariableOperatorWriteNode + # : () -> node + def desugar: () -> node + end + + class ConstantAndWriteNode + # : () -> node + def desugar: () -> node + end + + class ConstantOrWriteNode + # : () -> node + def desugar: () -> node + end + + class ConstantOperatorWriteNode + # : () -> node + def desugar: () -> node + end + + class GlobalVariableAndWriteNode + # : () -> node + def desugar: () -> node + end + + class GlobalVariableOrWriteNode + # : () -> node + def desugar: () -> node + end + + class GlobalVariableOperatorWriteNode + # : () -> node + def desugar: () -> node + end + + class InstanceVariableAndWriteNode + # : () -> node + def desugar: () -> node + end + + class InstanceVariableOrWriteNode + # : () -> node + def desugar: () -> node + end + + class InstanceVariableOperatorWriteNode + # : () -> node + def desugar: () -> node + end + + class LocalVariableAndWriteNode + # : () -> node + def desugar: () -> node + end + + class LocalVariableOrWriteNode + # : () -> node + def desugar: () -> node + end + + class LocalVariableOperatorWriteNode + # : () -> node + def desugar: () -> node + end + + # DesugarCompiler is a compiler that desugars Ruby code into a more primitive + # form. This is useful for consumers that want to deal with fewer node types. + class DesugarCompiler < MutationCompiler + # `@@foo &&= bar` + # + # becomes + # + # `@@foo && @@foo = bar` + # -- + # : (ClassVariableAndWriteNode node) -> node + def visit_class_variable_and_write_node: (ClassVariableAndWriteNode node) -> node + + # `@@foo ||= bar` + # + # becomes + # + # `defined?(@@foo) ? @@foo : @@foo = bar` + # -- + # : (ClassVariableOrWriteNode node) -> node + def visit_class_variable_or_write_node: (ClassVariableOrWriteNode node) -> node + + # `@@foo += bar` + # + # becomes + # + # `@@foo = @@foo + bar` + # -- + # : (ClassVariableOperatorWriteNode node) -> node + def visit_class_variable_operator_write_node: (ClassVariableOperatorWriteNode node) -> node + + # `Foo &&= bar` + # + # becomes + # + # `Foo && Foo = bar` + # -- + # : (ConstantAndWriteNode node) -> node + def visit_constant_and_write_node: (ConstantAndWriteNode node) -> node + + # `Foo ||= bar` + # + # becomes + # + # `defined?(Foo) ? Foo : Foo = bar` + # -- + # : (ConstantOrWriteNode node) -> node + def visit_constant_or_write_node: (ConstantOrWriteNode node) -> node + + # `Foo += bar` + # + # becomes + # + # `Foo = Foo + bar` + # -- + # : (ConstantOperatorWriteNode node) -> node + def visit_constant_operator_write_node: (ConstantOperatorWriteNode node) -> node + + # `$foo &&= bar` + # + # becomes + # + # `$foo && $foo = bar` + # -- + # : (GlobalVariableAndWriteNode node) -> node + def visit_global_variable_and_write_node: (GlobalVariableAndWriteNode node) -> node + + # `$foo ||= bar` + # + # becomes + # + # `defined?($foo) ? $foo : $foo = bar` + # -- + # : (GlobalVariableOrWriteNode node) -> node + def visit_global_variable_or_write_node: (GlobalVariableOrWriteNode node) -> node + + # `$foo += bar` + # + # becomes + # + # `$foo = $foo + bar` + # -- + # : (GlobalVariableOperatorWriteNode node) -> node + def visit_global_variable_operator_write_node: (GlobalVariableOperatorWriteNode node) -> node + + # `@foo &&= bar` + # + # becomes + # + # `@foo && @foo = bar` + # -- + # : (InstanceVariableAndWriteNode node) -> node + def visit_instance_variable_and_write_node: (InstanceVariableAndWriteNode node) -> node + + # `@foo ||= bar` + # + # becomes + # + # `@foo || @foo = bar` + # -- + # : (InstanceVariableOrWriteNode node) -> node + def visit_instance_variable_or_write_node: (InstanceVariableOrWriteNode node) -> node + + # `@foo += bar` + # + # becomes + # + # `@foo = @foo + bar` + # -- + # : (InstanceVariableOperatorWriteNode node) -> node + def visit_instance_variable_operator_write_node: (InstanceVariableOperatorWriteNode node) -> node + + # `foo &&= bar` + # + # becomes + # + # `foo && foo = bar` + # -- + # : (LocalVariableAndWriteNode node) -> node + def visit_local_variable_and_write_node: (LocalVariableAndWriteNode node) -> node + + # `foo ||= bar` + # + # becomes + # + # `foo || foo = bar` + # -- + # : (LocalVariableOrWriteNode node) -> node + def visit_local_variable_or_write_node: (LocalVariableOrWriteNode node) -> node + + # `foo += bar` + # + # becomes + # + # `foo = foo + bar` + # -- + # : (LocalVariableOperatorWriteNode node) -> node + def visit_local_variable_operator_write_node: (LocalVariableOperatorWriteNode node) -> node + end +end diff --git a/sig/generated/prism/dispatcher.rbs b/sig/generated/prism/dispatcher.rbs new file mode 100644 index 0000000000..0463d2b0ba --- /dev/null +++ b/sig/generated/prism/dispatcher.rbs @@ -0,0 +1,1292 @@ +# Generated from lib/prism/dispatcher.rb with RBS::Inline + +module Prism + # The dispatcher class fires events for nodes that are found while walking an + # AST to all registered listeners. It's useful for performing different types + # of analysis on the AST while only having to walk the tree once. + # + # To use the dispatcher, you would first instantiate it and register listeners + # for the events you're interested in: + # + # class OctalListener + # def on_integer_node_enter(node) + # if node.octal? && !node.slice.start_with?("0o") + # warn("Octal integers should be written with the 0o prefix") + # end + # end + # end + # + # listener = OctalListener.new + # dispatcher = Prism::Dispatcher.new + # dispatcher.register(listener, :on_integer_node_enter) + # + # Then, you can walk any number of trees and dispatch events to the listeners: + # + # result = Prism.parse("001 + 002 + 003") + # dispatcher.dispatch(result.value) + # + # Optionally, you can also use `#dispatch_once` to dispatch enter and leave + # events for a single node without recursing further down the tree. This can + # be useful in circumstances where you want to reuse the listeners you already + # have registers but want to stop walking the tree at a certain point. + # + # integer = result.value.statements.body.first.receiver.receiver + # dispatcher.dispatch_once(integer) + class Dispatcher < Visitor + # A hash mapping event names to arrays of listeners that should be notified + # when that event is fired. + attr_reader listeners: Hash[Symbol, Array[untyped]] + + # Initialize a new dispatcher. + # -- + # : () -> void + def initialize: () -> void + + # Register a listener for one or more events. + # -- + # : (untyped, *Symbol) -> void + def register: (untyped, *Symbol) -> void + + # Register all public methods of a listener that match the pattern + # `on__(enter|leave)`. + # -- + # : (untyped) -> void + def register_public_methods: (untyped) -> void + + # Register a listener for the given events. + # -- + # : (untyped, Array[Symbol]) -> void + private def register_events: (untyped, Array[Symbol]) -> void + + # Walks `root` dispatching events to all registered listeners. + alias dispatch visit + + # Dispatches a single event for `node` to all registered listeners. + # -- + # : (node node) -> void + def dispatch_once: (node node) -> void + + # : (AliasGlobalVariableNode node) -> void + def visit_alias_global_variable_node: (AliasGlobalVariableNode node) -> void + + # : (AliasMethodNode node) -> void + def visit_alias_method_node: (AliasMethodNode node) -> void + + # : (AlternationPatternNode node) -> void + def visit_alternation_pattern_node: (AlternationPatternNode node) -> void + + # : (AndNode node) -> void + def visit_and_node: (AndNode node) -> void + + # : (ArgumentsNode node) -> void + def visit_arguments_node: (ArgumentsNode node) -> void + + # : (ArrayNode node) -> void + def visit_array_node: (ArrayNode node) -> void + + # : (ArrayPatternNode node) -> void + def visit_array_pattern_node: (ArrayPatternNode node) -> void + + # : (AssocNode node) -> void + def visit_assoc_node: (AssocNode node) -> void + + # : (AssocSplatNode node) -> void + def visit_assoc_splat_node: (AssocSplatNode node) -> void + + # : (BackReferenceReadNode node) -> void + def visit_back_reference_read_node: (BackReferenceReadNode node) -> void + + # : (BeginNode node) -> void + def visit_begin_node: (BeginNode node) -> void + + # : (BlockArgumentNode node) -> void + def visit_block_argument_node: (BlockArgumentNode node) -> void + + # : (BlockLocalVariableNode node) -> void + def visit_block_local_variable_node: (BlockLocalVariableNode node) -> void + + # : (BlockNode node) -> void + def visit_block_node: (BlockNode node) -> void + + # : (BlockParameterNode node) -> void + def visit_block_parameter_node: (BlockParameterNode node) -> void + + # : (BlockParametersNode node) -> void + def visit_block_parameters_node: (BlockParametersNode node) -> void + + # : (BreakNode node) -> void + def visit_break_node: (BreakNode node) -> void + + # : (CallAndWriteNode node) -> void + def visit_call_and_write_node: (CallAndWriteNode node) -> void + + # : (CallNode node) -> void + def visit_call_node: (CallNode node) -> void + + # : (CallOperatorWriteNode node) -> void + def visit_call_operator_write_node: (CallOperatorWriteNode node) -> void + + # : (CallOrWriteNode node) -> void + def visit_call_or_write_node: (CallOrWriteNode node) -> void + + # : (CallTargetNode node) -> void + def visit_call_target_node: (CallTargetNode node) -> void + + # : (CapturePatternNode node) -> void + def visit_capture_pattern_node: (CapturePatternNode node) -> void + + # : (CaseMatchNode node) -> void + def visit_case_match_node: (CaseMatchNode node) -> void + + # : (CaseNode node) -> void + def visit_case_node: (CaseNode node) -> void + + # : (ClassNode node) -> void + def visit_class_node: (ClassNode node) -> void + + # : (ClassVariableAndWriteNode node) -> void + def visit_class_variable_and_write_node: (ClassVariableAndWriteNode node) -> void + + # : (ClassVariableOperatorWriteNode node) -> void + def visit_class_variable_operator_write_node: (ClassVariableOperatorWriteNode node) -> void + + # : (ClassVariableOrWriteNode node) -> void + def visit_class_variable_or_write_node: (ClassVariableOrWriteNode node) -> void + + # : (ClassVariableReadNode node) -> void + def visit_class_variable_read_node: (ClassVariableReadNode node) -> void + + # : (ClassVariableTargetNode node) -> void + def visit_class_variable_target_node: (ClassVariableTargetNode node) -> void + + # : (ClassVariableWriteNode node) -> void + def visit_class_variable_write_node: (ClassVariableWriteNode node) -> void + + # : (ConstantAndWriteNode node) -> void + def visit_constant_and_write_node: (ConstantAndWriteNode node) -> void + + # : (ConstantOperatorWriteNode node) -> void + def visit_constant_operator_write_node: (ConstantOperatorWriteNode node) -> void + + # : (ConstantOrWriteNode node) -> void + def visit_constant_or_write_node: (ConstantOrWriteNode node) -> void + + # : (ConstantPathAndWriteNode node) -> void + def visit_constant_path_and_write_node: (ConstantPathAndWriteNode node) -> void + + # : (ConstantPathNode node) -> void + def visit_constant_path_node: (ConstantPathNode node) -> void + + # : (ConstantPathOperatorWriteNode node) -> void + def visit_constant_path_operator_write_node: (ConstantPathOperatorWriteNode node) -> void + + # : (ConstantPathOrWriteNode node) -> void + def visit_constant_path_or_write_node: (ConstantPathOrWriteNode node) -> void + + # : (ConstantPathTargetNode node) -> void + def visit_constant_path_target_node: (ConstantPathTargetNode node) -> void + + # : (ConstantPathWriteNode node) -> void + def visit_constant_path_write_node: (ConstantPathWriteNode node) -> void + + # : (ConstantReadNode node) -> void + def visit_constant_read_node: (ConstantReadNode node) -> void + + # : (ConstantTargetNode node) -> void + def visit_constant_target_node: (ConstantTargetNode node) -> void + + # : (ConstantWriteNode node) -> void + def visit_constant_write_node: (ConstantWriteNode node) -> void + + # : (DefNode node) -> void + def visit_def_node: (DefNode node) -> void + + # : (DefinedNode node) -> void + def visit_defined_node: (DefinedNode node) -> void + + # : (ElseNode node) -> void + def visit_else_node: (ElseNode node) -> void + + # : (EmbeddedStatementsNode node) -> void + def visit_embedded_statements_node: (EmbeddedStatementsNode node) -> void + + # : (EmbeddedVariableNode node) -> void + def visit_embedded_variable_node: (EmbeddedVariableNode node) -> void + + # : (EnsureNode node) -> void + def visit_ensure_node: (EnsureNode node) -> void + + # : (FalseNode node) -> void + def visit_false_node: (FalseNode node) -> void + + # : (FindPatternNode node) -> void + def visit_find_pattern_node: (FindPatternNode node) -> void + + # : (FlipFlopNode node) -> void + def visit_flip_flop_node: (FlipFlopNode node) -> void + + # : (FloatNode node) -> void + def visit_float_node: (FloatNode node) -> void + + # : (ForNode node) -> void + def visit_for_node: (ForNode node) -> void + + # : (ForwardingArgumentsNode node) -> void + def visit_forwarding_arguments_node: (ForwardingArgumentsNode node) -> void + + # : (ForwardingParameterNode node) -> void + def visit_forwarding_parameter_node: (ForwardingParameterNode node) -> void + + # : (ForwardingSuperNode node) -> void + def visit_forwarding_super_node: (ForwardingSuperNode node) -> void + + # : (GlobalVariableAndWriteNode node) -> void + def visit_global_variable_and_write_node: (GlobalVariableAndWriteNode node) -> void + + # : (GlobalVariableOperatorWriteNode node) -> void + def visit_global_variable_operator_write_node: (GlobalVariableOperatorWriteNode node) -> void + + # : (GlobalVariableOrWriteNode node) -> void + def visit_global_variable_or_write_node: (GlobalVariableOrWriteNode node) -> void + + # : (GlobalVariableReadNode node) -> void + def visit_global_variable_read_node: (GlobalVariableReadNode node) -> void + + # : (GlobalVariableTargetNode node) -> void + def visit_global_variable_target_node: (GlobalVariableTargetNode node) -> void + + # : (GlobalVariableWriteNode node) -> void + def visit_global_variable_write_node: (GlobalVariableWriteNode node) -> void + + # : (HashNode node) -> void + def visit_hash_node: (HashNode node) -> void + + # : (HashPatternNode node) -> void + def visit_hash_pattern_node: (HashPatternNode node) -> void + + # : (IfNode node) -> void + def visit_if_node: (IfNode node) -> void + + # : (ImaginaryNode node) -> void + def visit_imaginary_node: (ImaginaryNode node) -> void + + # : (ImplicitNode node) -> void + def visit_implicit_node: (ImplicitNode node) -> void + + # : (ImplicitRestNode node) -> void + def visit_implicit_rest_node: (ImplicitRestNode node) -> void + + # : (InNode node) -> void + def visit_in_node: (InNode node) -> void + + # : (IndexAndWriteNode node) -> void + def visit_index_and_write_node: (IndexAndWriteNode node) -> void + + # : (IndexOperatorWriteNode node) -> void + def visit_index_operator_write_node: (IndexOperatorWriteNode node) -> void + + # : (IndexOrWriteNode node) -> void + def visit_index_or_write_node: (IndexOrWriteNode node) -> void + + # : (IndexTargetNode node) -> void + def visit_index_target_node: (IndexTargetNode node) -> void + + # : (InstanceVariableAndWriteNode node) -> void + def visit_instance_variable_and_write_node: (InstanceVariableAndWriteNode node) -> void + + # : (InstanceVariableOperatorWriteNode node) -> void + def visit_instance_variable_operator_write_node: (InstanceVariableOperatorWriteNode node) -> void + + # : (InstanceVariableOrWriteNode node) -> void + def visit_instance_variable_or_write_node: (InstanceVariableOrWriteNode node) -> void + + # : (InstanceVariableReadNode node) -> void + def visit_instance_variable_read_node: (InstanceVariableReadNode node) -> void + + # : (InstanceVariableTargetNode node) -> void + def visit_instance_variable_target_node: (InstanceVariableTargetNode node) -> void + + # : (InstanceVariableWriteNode node) -> void + def visit_instance_variable_write_node: (InstanceVariableWriteNode node) -> void + + # : (IntegerNode node) -> void + def visit_integer_node: (IntegerNode node) -> void + + # : (InterpolatedMatchLastLineNode node) -> void + def visit_interpolated_match_last_line_node: (InterpolatedMatchLastLineNode node) -> void + + # : (InterpolatedRegularExpressionNode node) -> void + def visit_interpolated_regular_expression_node: (InterpolatedRegularExpressionNode node) -> void + + # : (InterpolatedStringNode node) -> void + def visit_interpolated_string_node: (InterpolatedStringNode node) -> void + + # : (InterpolatedSymbolNode node) -> void + def visit_interpolated_symbol_node: (InterpolatedSymbolNode node) -> void + + # : (InterpolatedXStringNode node) -> void + def visit_interpolated_x_string_node: (InterpolatedXStringNode node) -> void + + # : (ItLocalVariableReadNode node) -> void + def visit_it_local_variable_read_node: (ItLocalVariableReadNode node) -> void + + # : (ItParametersNode node) -> void + def visit_it_parameters_node: (ItParametersNode node) -> void + + # : (KeywordHashNode node) -> void + def visit_keyword_hash_node: (KeywordHashNode node) -> void + + # : (KeywordRestParameterNode node) -> void + def visit_keyword_rest_parameter_node: (KeywordRestParameterNode node) -> void + + # : (LambdaNode node) -> void + def visit_lambda_node: (LambdaNode node) -> void + + # : (LocalVariableAndWriteNode node) -> void + def visit_local_variable_and_write_node: (LocalVariableAndWriteNode node) -> void + + # : (LocalVariableOperatorWriteNode node) -> void + def visit_local_variable_operator_write_node: (LocalVariableOperatorWriteNode node) -> void + + # : (LocalVariableOrWriteNode node) -> void + def visit_local_variable_or_write_node: (LocalVariableOrWriteNode node) -> void + + # : (LocalVariableReadNode node) -> void + def visit_local_variable_read_node: (LocalVariableReadNode node) -> void + + # : (LocalVariableTargetNode node) -> void + def visit_local_variable_target_node: (LocalVariableTargetNode node) -> void + + # : (LocalVariableWriteNode node) -> void + def visit_local_variable_write_node: (LocalVariableWriteNode node) -> void + + # : (MatchLastLineNode node) -> void + def visit_match_last_line_node: (MatchLastLineNode node) -> void + + # : (MatchPredicateNode node) -> void + def visit_match_predicate_node: (MatchPredicateNode node) -> void + + # : (MatchRequiredNode node) -> void + def visit_match_required_node: (MatchRequiredNode node) -> void + + # : (MatchWriteNode node) -> void + def visit_match_write_node: (MatchWriteNode node) -> void + + # : (MissingNode node) -> void + def visit_missing_node: (MissingNode node) -> void + + # : (ModuleNode node) -> void + def visit_module_node: (ModuleNode node) -> void + + # : (MultiTargetNode node) -> void + def visit_multi_target_node: (MultiTargetNode node) -> void + + # : (MultiWriteNode node) -> void + def visit_multi_write_node: (MultiWriteNode node) -> void + + # : (NextNode node) -> void + def visit_next_node: (NextNode node) -> void + + # : (NilNode node) -> void + def visit_nil_node: (NilNode node) -> void + + # : (NoBlockParameterNode node) -> void + def visit_no_block_parameter_node: (NoBlockParameterNode node) -> void + + # : (NoKeywordsParameterNode node) -> void + def visit_no_keywords_parameter_node: (NoKeywordsParameterNode node) -> void + + # : (NumberedParametersNode node) -> void + def visit_numbered_parameters_node: (NumberedParametersNode node) -> void + + # : (NumberedReferenceReadNode node) -> void + def visit_numbered_reference_read_node: (NumberedReferenceReadNode node) -> void + + # : (OptionalKeywordParameterNode node) -> void + def visit_optional_keyword_parameter_node: (OptionalKeywordParameterNode node) -> void + + # : (OptionalParameterNode node) -> void + def visit_optional_parameter_node: (OptionalParameterNode node) -> void + + # : (OrNode node) -> void + def visit_or_node: (OrNode node) -> void + + # : (ParametersNode node) -> void + def visit_parameters_node: (ParametersNode node) -> void + + # : (ParenthesesNode node) -> void + def visit_parentheses_node: (ParenthesesNode node) -> void + + # : (PinnedExpressionNode node) -> void + def visit_pinned_expression_node: (PinnedExpressionNode node) -> void + + # : (PinnedVariableNode node) -> void + def visit_pinned_variable_node: (PinnedVariableNode node) -> void + + # : (PostExecutionNode node) -> void + def visit_post_execution_node: (PostExecutionNode node) -> void + + # : (PreExecutionNode node) -> void + def visit_pre_execution_node: (PreExecutionNode node) -> void + + # : (ProgramNode node) -> void + def visit_program_node: (ProgramNode node) -> void + + # : (RangeNode node) -> void + def visit_range_node: (RangeNode node) -> void + + # : (RationalNode node) -> void + def visit_rational_node: (RationalNode node) -> void + + # : (RedoNode node) -> void + def visit_redo_node: (RedoNode node) -> void + + # : (RegularExpressionNode node) -> void + def visit_regular_expression_node: (RegularExpressionNode node) -> void + + # : (RequiredKeywordParameterNode node) -> void + def visit_required_keyword_parameter_node: (RequiredKeywordParameterNode node) -> void + + # : (RequiredParameterNode node) -> void + def visit_required_parameter_node: (RequiredParameterNode node) -> void + + # : (RescueModifierNode node) -> void + def visit_rescue_modifier_node: (RescueModifierNode node) -> void + + # : (RescueNode node) -> void + def visit_rescue_node: (RescueNode node) -> void + + # : (RestParameterNode node) -> void + def visit_rest_parameter_node: (RestParameterNode node) -> void + + # : (RetryNode node) -> void + def visit_retry_node: (RetryNode node) -> void + + # : (ReturnNode node) -> void + def visit_return_node: (ReturnNode node) -> void + + # : (SelfNode node) -> void + def visit_self_node: (SelfNode node) -> void + + # : (ShareableConstantNode node) -> void + def visit_shareable_constant_node: (ShareableConstantNode node) -> void + + # : (SingletonClassNode node) -> void + def visit_singleton_class_node: (SingletonClassNode node) -> void + + # : (SourceEncodingNode node) -> void + def visit_source_encoding_node: (SourceEncodingNode node) -> void + + # : (SourceFileNode node) -> void + def visit_source_file_node: (SourceFileNode node) -> void + + # : (SourceLineNode node) -> void + def visit_source_line_node: (SourceLineNode node) -> void + + # : (SplatNode node) -> void + def visit_splat_node: (SplatNode node) -> void + + # : (StatementsNode node) -> void + def visit_statements_node: (StatementsNode node) -> void + + # : (StringNode node) -> void + def visit_string_node: (StringNode node) -> void + + # : (SuperNode node) -> void + def visit_super_node: (SuperNode node) -> void + + # : (SymbolNode node) -> void + def visit_symbol_node: (SymbolNode node) -> void + + # : (TrueNode node) -> void + def visit_true_node: (TrueNode node) -> void + + # : (UndefNode node) -> void + def visit_undef_node: (UndefNode node) -> void + + # : (UnlessNode node) -> void + def visit_unless_node: (UnlessNode node) -> void + + # : (UntilNode node) -> void + def visit_until_node: (UntilNode node) -> void + + # : (WhenNode node) -> void + def visit_when_node: (WhenNode node) -> void + + # : (WhileNode node) -> void + def visit_while_node: (WhileNode node) -> void + + # : (XStringNode node) -> void + def visit_x_string_node: (XStringNode node) -> void + + # : (YieldNode node) -> void + def visit_yield_node: (YieldNode node) -> void + + class DispatchOnce < Visitor + attr_reader listeners: Hash[Symbol, Array[untyped]] + + # : (Hash[Symbol, Array[untyped]] listeners) -> void + def initialize: (Hash[Symbol, Array[untyped]] listeners) -> void + + # Dispatch enter and leave events for AliasGlobalVariableNode nodes. + # -- + # : (AliasGlobalVariableNode node) -> void + def visit_alias_global_variable_node: (AliasGlobalVariableNode node) -> void + + # Dispatch enter and leave events for AliasMethodNode nodes. + # -- + # : (AliasMethodNode node) -> void + def visit_alias_method_node: (AliasMethodNode node) -> void + + # Dispatch enter and leave events for AlternationPatternNode nodes. + # -- + # : (AlternationPatternNode node) -> void + def visit_alternation_pattern_node: (AlternationPatternNode node) -> void + + # Dispatch enter and leave events for AndNode nodes. + # -- + # : (AndNode node) -> void + def visit_and_node: (AndNode node) -> void + + # Dispatch enter and leave events for ArgumentsNode nodes. + # -- + # : (ArgumentsNode node) -> void + def visit_arguments_node: (ArgumentsNode node) -> void + + # Dispatch enter and leave events for ArrayNode nodes. + # -- + # : (ArrayNode node) -> void + def visit_array_node: (ArrayNode node) -> void + + # Dispatch enter and leave events for ArrayPatternNode nodes. + # -- + # : (ArrayPatternNode node) -> void + def visit_array_pattern_node: (ArrayPatternNode node) -> void + + # Dispatch enter and leave events for AssocNode nodes. + # -- + # : (AssocNode node) -> void + def visit_assoc_node: (AssocNode node) -> void + + # Dispatch enter and leave events for AssocSplatNode nodes. + # -- + # : (AssocSplatNode node) -> void + def visit_assoc_splat_node: (AssocSplatNode node) -> void + + # Dispatch enter and leave events for BackReferenceReadNode nodes. + # -- + # : (BackReferenceReadNode node) -> void + def visit_back_reference_read_node: (BackReferenceReadNode node) -> void + + # Dispatch enter and leave events for BeginNode nodes. + # -- + # : (BeginNode node) -> void + def visit_begin_node: (BeginNode node) -> void + + # Dispatch enter and leave events for BlockArgumentNode nodes. + # -- + # : (BlockArgumentNode node) -> void + def visit_block_argument_node: (BlockArgumentNode node) -> void + + # Dispatch enter and leave events for BlockLocalVariableNode nodes. + # -- + # : (BlockLocalVariableNode node) -> void + def visit_block_local_variable_node: (BlockLocalVariableNode node) -> void + + # Dispatch enter and leave events for BlockNode nodes. + # -- + # : (BlockNode node) -> void + def visit_block_node: (BlockNode node) -> void + + # Dispatch enter and leave events for BlockParameterNode nodes. + # -- + # : (BlockParameterNode node) -> void + def visit_block_parameter_node: (BlockParameterNode node) -> void + + # Dispatch enter and leave events for BlockParametersNode nodes. + # -- + # : (BlockParametersNode node) -> void + def visit_block_parameters_node: (BlockParametersNode node) -> void + + # Dispatch enter and leave events for BreakNode nodes. + # -- + # : (BreakNode node) -> void + def visit_break_node: (BreakNode node) -> void + + # Dispatch enter and leave events for CallAndWriteNode nodes. + # -- + # : (CallAndWriteNode node) -> void + def visit_call_and_write_node: (CallAndWriteNode node) -> void + + # Dispatch enter and leave events for CallNode nodes. + # -- + # : (CallNode node) -> void + def visit_call_node: (CallNode node) -> void + + # Dispatch enter and leave events for CallOperatorWriteNode nodes. + # -- + # : (CallOperatorWriteNode node) -> void + def visit_call_operator_write_node: (CallOperatorWriteNode node) -> void + + # Dispatch enter and leave events for CallOrWriteNode nodes. + # -- + # : (CallOrWriteNode node) -> void + def visit_call_or_write_node: (CallOrWriteNode node) -> void + + # Dispatch enter and leave events for CallTargetNode nodes. + # -- + # : (CallTargetNode node) -> void + def visit_call_target_node: (CallTargetNode node) -> void + + # Dispatch enter and leave events for CapturePatternNode nodes. + # -- + # : (CapturePatternNode node) -> void + def visit_capture_pattern_node: (CapturePatternNode node) -> void + + # Dispatch enter and leave events for CaseMatchNode nodes. + # -- + # : (CaseMatchNode node) -> void + def visit_case_match_node: (CaseMatchNode node) -> void + + # Dispatch enter and leave events for CaseNode nodes. + # -- + # : (CaseNode node) -> void + def visit_case_node: (CaseNode node) -> void + + # Dispatch enter and leave events for ClassNode nodes. + # -- + # : (ClassNode node) -> void + def visit_class_node: (ClassNode node) -> void + + # Dispatch enter and leave events for ClassVariableAndWriteNode nodes. + # -- + # : (ClassVariableAndWriteNode node) -> void + def visit_class_variable_and_write_node: (ClassVariableAndWriteNode node) -> void + + # Dispatch enter and leave events for ClassVariableOperatorWriteNode nodes. + # -- + # : (ClassVariableOperatorWriteNode node) -> void + def visit_class_variable_operator_write_node: (ClassVariableOperatorWriteNode node) -> void + + # Dispatch enter and leave events for ClassVariableOrWriteNode nodes. + # -- + # : (ClassVariableOrWriteNode node) -> void + def visit_class_variable_or_write_node: (ClassVariableOrWriteNode node) -> void + + # Dispatch enter and leave events for ClassVariableReadNode nodes. + # -- + # : (ClassVariableReadNode node) -> void + def visit_class_variable_read_node: (ClassVariableReadNode node) -> void + + # Dispatch enter and leave events for ClassVariableTargetNode nodes. + # -- + # : (ClassVariableTargetNode node) -> void + def visit_class_variable_target_node: (ClassVariableTargetNode node) -> void + + # Dispatch enter and leave events for ClassVariableWriteNode nodes. + # -- + # : (ClassVariableWriteNode node) -> void + def visit_class_variable_write_node: (ClassVariableWriteNode node) -> void + + # Dispatch enter and leave events for ConstantAndWriteNode nodes. + # -- + # : (ConstantAndWriteNode node) -> void + def visit_constant_and_write_node: (ConstantAndWriteNode node) -> void + + # Dispatch enter and leave events for ConstantOperatorWriteNode nodes. + # -- + # : (ConstantOperatorWriteNode node) -> void + def visit_constant_operator_write_node: (ConstantOperatorWriteNode node) -> void + + # Dispatch enter and leave events for ConstantOrWriteNode nodes. + # -- + # : (ConstantOrWriteNode node) -> void + def visit_constant_or_write_node: (ConstantOrWriteNode node) -> void + + # Dispatch enter and leave events for ConstantPathAndWriteNode nodes. + # -- + # : (ConstantPathAndWriteNode node) -> void + def visit_constant_path_and_write_node: (ConstantPathAndWriteNode node) -> void + + # Dispatch enter and leave events for ConstantPathNode nodes. + # -- + # : (ConstantPathNode node) -> void + def visit_constant_path_node: (ConstantPathNode node) -> void + + # Dispatch enter and leave events for ConstantPathOperatorWriteNode nodes. + # -- + # : (ConstantPathOperatorWriteNode node) -> void + def visit_constant_path_operator_write_node: (ConstantPathOperatorWriteNode node) -> void + + # Dispatch enter and leave events for ConstantPathOrWriteNode nodes. + # -- + # : (ConstantPathOrWriteNode node) -> void + def visit_constant_path_or_write_node: (ConstantPathOrWriteNode node) -> void + + # Dispatch enter and leave events for ConstantPathTargetNode nodes. + # -- + # : (ConstantPathTargetNode node) -> void + def visit_constant_path_target_node: (ConstantPathTargetNode node) -> void + + # Dispatch enter and leave events for ConstantPathWriteNode nodes. + # -- + # : (ConstantPathWriteNode node) -> void + def visit_constant_path_write_node: (ConstantPathWriteNode node) -> void + + # Dispatch enter and leave events for ConstantReadNode nodes. + # -- + # : (ConstantReadNode node) -> void + def visit_constant_read_node: (ConstantReadNode node) -> void + + # Dispatch enter and leave events for ConstantTargetNode nodes. + # -- + # : (ConstantTargetNode node) -> void + def visit_constant_target_node: (ConstantTargetNode node) -> void + + # Dispatch enter and leave events for ConstantWriteNode nodes. + # -- + # : (ConstantWriteNode node) -> void + def visit_constant_write_node: (ConstantWriteNode node) -> void + + # Dispatch enter and leave events for DefNode nodes. + # -- + # : (DefNode node) -> void + def visit_def_node: (DefNode node) -> void + + # Dispatch enter and leave events for DefinedNode nodes. + # -- + # : (DefinedNode node) -> void + def visit_defined_node: (DefinedNode node) -> void + + # Dispatch enter and leave events for ElseNode nodes. + # -- + # : (ElseNode node) -> void + def visit_else_node: (ElseNode node) -> void + + # Dispatch enter and leave events for EmbeddedStatementsNode nodes. + # -- + # : (EmbeddedStatementsNode node) -> void + def visit_embedded_statements_node: (EmbeddedStatementsNode node) -> void + + # Dispatch enter and leave events for EmbeddedVariableNode nodes. + # -- + # : (EmbeddedVariableNode node) -> void + def visit_embedded_variable_node: (EmbeddedVariableNode node) -> void + + # Dispatch enter and leave events for EnsureNode nodes. + # -- + # : (EnsureNode node) -> void + def visit_ensure_node: (EnsureNode node) -> void + + # Dispatch enter and leave events for FalseNode nodes. + # -- + # : (FalseNode node) -> void + def visit_false_node: (FalseNode node) -> void + + # Dispatch enter and leave events for FindPatternNode nodes. + # -- + # : (FindPatternNode node) -> void + def visit_find_pattern_node: (FindPatternNode node) -> void + + # Dispatch enter and leave events for FlipFlopNode nodes. + # -- + # : (FlipFlopNode node) -> void + def visit_flip_flop_node: (FlipFlopNode node) -> void + + # Dispatch enter and leave events for FloatNode nodes. + # -- + # : (FloatNode node) -> void + def visit_float_node: (FloatNode node) -> void + + # Dispatch enter and leave events for ForNode nodes. + # -- + # : (ForNode node) -> void + def visit_for_node: (ForNode node) -> void + + # Dispatch enter and leave events for ForwardingArgumentsNode nodes. + # -- + # : (ForwardingArgumentsNode node) -> void + def visit_forwarding_arguments_node: (ForwardingArgumentsNode node) -> void + + # Dispatch enter and leave events for ForwardingParameterNode nodes. + # -- + # : (ForwardingParameterNode node) -> void + def visit_forwarding_parameter_node: (ForwardingParameterNode node) -> void + + # Dispatch enter and leave events for ForwardingSuperNode nodes. + # -- + # : (ForwardingSuperNode node) -> void + def visit_forwarding_super_node: (ForwardingSuperNode node) -> void + + # Dispatch enter and leave events for GlobalVariableAndWriteNode nodes. + # -- + # : (GlobalVariableAndWriteNode node) -> void + def visit_global_variable_and_write_node: (GlobalVariableAndWriteNode node) -> void + + # Dispatch enter and leave events for GlobalVariableOperatorWriteNode nodes. + # -- + # : (GlobalVariableOperatorWriteNode node) -> void + def visit_global_variable_operator_write_node: (GlobalVariableOperatorWriteNode node) -> void + + # Dispatch enter and leave events for GlobalVariableOrWriteNode nodes. + # -- + # : (GlobalVariableOrWriteNode node) -> void + def visit_global_variable_or_write_node: (GlobalVariableOrWriteNode node) -> void + + # Dispatch enter and leave events for GlobalVariableReadNode nodes. + # -- + # : (GlobalVariableReadNode node) -> void + def visit_global_variable_read_node: (GlobalVariableReadNode node) -> void + + # Dispatch enter and leave events for GlobalVariableTargetNode nodes. + # -- + # : (GlobalVariableTargetNode node) -> void + def visit_global_variable_target_node: (GlobalVariableTargetNode node) -> void + + # Dispatch enter and leave events for GlobalVariableWriteNode nodes. + # -- + # : (GlobalVariableWriteNode node) -> void + def visit_global_variable_write_node: (GlobalVariableWriteNode node) -> void + + # Dispatch enter and leave events for HashNode nodes. + # -- + # : (HashNode node) -> void + def visit_hash_node: (HashNode node) -> void + + # Dispatch enter and leave events for HashPatternNode nodes. + # -- + # : (HashPatternNode node) -> void + def visit_hash_pattern_node: (HashPatternNode node) -> void + + # Dispatch enter and leave events for IfNode nodes. + # -- + # : (IfNode node) -> void + def visit_if_node: (IfNode node) -> void + + # Dispatch enter and leave events for ImaginaryNode nodes. + # -- + # : (ImaginaryNode node) -> void + def visit_imaginary_node: (ImaginaryNode node) -> void + + # Dispatch enter and leave events for ImplicitNode nodes. + # -- + # : (ImplicitNode node) -> void + def visit_implicit_node: (ImplicitNode node) -> void + + # Dispatch enter and leave events for ImplicitRestNode nodes. + # -- + # : (ImplicitRestNode node) -> void + def visit_implicit_rest_node: (ImplicitRestNode node) -> void + + # Dispatch enter and leave events for InNode nodes. + # -- + # : (InNode node) -> void + def visit_in_node: (InNode node) -> void + + # Dispatch enter and leave events for IndexAndWriteNode nodes. + # -- + # : (IndexAndWriteNode node) -> void + def visit_index_and_write_node: (IndexAndWriteNode node) -> void + + # Dispatch enter and leave events for IndexOperatorWriteNode nodes. + # -- + # : (IndexOperatorWriteNode node) -> void + def visit_index_operator_write_node: (IndexOperatorWriteNode node) -> void + + # Dispatch enter and leave events for IndexOrWriteNode nodes. + # -- + # : (IndexOrWriteNode node) -> void + def visit_index_or_write_node: (IndexOrWriteNode node) -> void + + # Dispatch enter and leave events for IndexTargetNode nodes. + # -- + # : (IndexTargetNode node) -> void + def visit_index_target_node: (IndexTargetNode node) -> void + + # Dispatch enter and leave events for InstanceVariableAndWriteNode nodes. + # -- + # : (InstanceVariableAndWriteNode node) -> void + def visit_instance_variable_and_write_node: (InstanceVariableAndWriteNode node) -> void + + # Dispatch enter and leave events for InstanceVariableOperatorWriteNode nodes. + # -- + # : (InstanceVariableOperatorWriteNode node) -> void + def visit_instance_variable_operator_write_node: (InstanceVariableOperatorWriteNode node) -> void + + # Dispatch enter and leave events for InstanceVariableOrWriteNode nodes. + # -- + # : (InstanceVariableOrWriteNode node) -> void + def visit_instance_variable_or_write_node: (InstanceVariableOrWriteNode node) -> void + + # Dispatch enter and leave events for InstanceVariableReadNode nodes. + # -- + # : (InstanceVariableReadNode node) -> void + def visit_instance_variable_read_node: (InstanceVariableReadNode node) -> void + + # Dispatch enter and leave events for InstanceVariableTargetNode nodes. + # -- + # : (InstanceVariableTargetNode node) -> void + def visit_instance_variable_target_node: (InstanceVariableTargetNode node) -> void + + # Dispatch enter and leave events for InstanceVariableWriteNode nodes. + # -- + # : (InstanceVariableWriteNode node) -> void + def visit_instance_variable_write_node: (InstanceVariableWriteNode node) -> void + + # Dispatch enter and leave events for IntegerNode nodes. + # -- + # : (IntegerNode node) -> void + def visit_integer_node: (IntegerNode node) -> void + + # Dispatch enter and leave events for InterpolatedMatchLastLineNode nodes. + # -- + # : (InterpolatedMatchLastLineNode node) -> void + def visit_interpolated_match_last_line_node: (InterpolatedMatchLastLineNode node) -> void + + # Dispatch enter and leave events for InterpolatedRegularExpressionNode nodes. + # -- + # : (InterpolatedRegularExpressionNode node) -> void + def visit_interpolated_regular_expression_node: (InterpolatedRegularExpressionNode node) -> void + + # Dispatch enter and leave events for InterpolatedStringNode nodes. + # -- + # : (InterpolatedStringNode node) -> void + def visit_interpolated_string_node: (InterpolatedStringNode node) -> void + + # Dispatch enter and leave events for InterpolatedSymbolNode nodes. + # -- + # : (InterpolatedSymbolNode node) -> void + def visit_interpolated_symbol_node: (InterpolatedSymbolNode node) -> void + + # Dispatch enter and leave events for InterpolatedXStringNode nodes. + # -- + # : (InterpolatedXStringNode node) -> void + def visit_interpolated_x_string_node: (InterpolatedXStringNode node) -> void + + # Dispatch enter and leave events for ItLocalVariableReadNode nodes. + # -- + # : (ItLocalVariableReadNode node) -> void + def visit_it_local_variable_read_node: (ItLocalVariableReadNode node) -> void + + # Dispatch enter and leave events for ItParametersNode nodes. + # -- + # : (ItParametersNode node) -> void + def visit_it_parameters_node: (ItParametersNode node) -> void + + # Dispatch enter and leave events for KeywordHashNode nodes. + # -- + # : (KeywordHashNode node) -> void + def visit_keyword_hash_node: (KeywordHashNode node) -> void + + # Dispatch enter and leave events for KeywordRestParameterNode nodes. + # -- + # : (KeywordRestParameterNode node) -> void + def visit_keyword_rest_parameter_node: (KeywordRestParameterNode node) -> void + + # Dispatch enter and leave events for LambdaNode nodes. + # -- + # : (LambdaNode node) -> void + def visit_lambda_node: (LambdaNode node) -> void + + # Dispatch enter and leave events for LocalVariableAndWriteNode nodes. + # -- + # : (LocalVariableAndWriteNode node) -> void + def visit_local_variable_and_write_node: (LocalVariableAndWriteNode node) -> void + + # Dispatch enter and leave events for LocalVariableOperatorWriteNode nodes. + # -- + # : (LocalVariableOperatorWriteNode node) -> void + def visit_local_variable_operator_write_node: (LocalVariableOperatorWriteNode node) -> void + + # Dispatch enter and leave events for LocalVariableOrWriteNode nodes. + # -- + # : (LocalVariableOrWriteNode node) -> void + def visit_local_variable_or_write_node: (LocalVariableOrWriteNode node) -> void + + # Dispatch enter and leave events for LocalVariableReadNode nodes. + # -- + # : (LocalVariableReadNode node) -> void + def visit_local_variable_read_node: (LocalVariableReadNode node) -> void + + # Dispatch enter and leave events for LocalVariableTargetNode nodes. + # -- + # : (LocalVariableTargetNode node) -> void + def visit_local_variable_target_node: (LocalVariableTargetNode node) -> void + + # Dispatch enter and leave events for LocalVariableWriteNode nodes. + # -- + # : (LocalVariableWriteNode node) -> void + def visit_local_variable_write_node: (LocalVariableWriteNode node) -> void + + # Dispatch enter and leave events for MatchLastLineNode nodes. + # -- + # : (MatchLastLineNode node) -> void + def visit_match_last_line_node: (MatchLastLineNode node) -> void + + # Dispatch enter and leave events for MatchPredicateNode nodes. + # -- + # : (MatchPredicateNode node) -> void + def visit_match_predicate_node: (MatchPredicateNode node) -> void + + # Dispatch enter and leave events for MatchRequiredNode nodes. + # -- + # : (MatchRequiredNode node) -> void + def visit_match_required_node: (MatchRequiredNode node) -> void + + # Dispatch enter and leave events for MatchWriteNode nodes. + # -- + # : (MatchWriteNode node) -> void + def visit_match_write_node: (MatchWriteNode node) -> void + + # Dispatch enter and leave events for MissingNode nodes. + # -- + # : (MissingNode node) -> void + def visit_missing_node: (MissingNode node) -> void + + # Dispatch enter and leave events for ModuleNode nodes. + # -- + # : (ModuleNode node) -> void + def visit_module_node: (ModuleNode node) -> void + + # Dispatch enter and leave events for MultiTargetNode nodes. + # -- + # : (MultiTargetNode node) -> void + def visit_multi_target_node: (MultiTargetNode node) -> void + + # Dispatch enter and leave events for MultiWriteNode nodes. + # -- + # : (MultiWriteNode node) -> void + def visit_multi_write_node: (MultiWriteNode node) -> void + + # Dispatch enter and leave events for NextNode nodes. + # -- + # : (NextNode node) -> void + def visit_next_node: (NextNode node) -> void + + # Dispatch enter and leave events for NilNode nodes. + # -- + # : (NilNode node) -> void + def visit_nil_node: (NilNode node) -> void + + # Dispatch enter and leave events for NoBlockParameterNode nodes. + # -- + # : (NoBlockParameterNode node) -> void + def visit_no_block_parameter_node: (NoBlockParameterNode node) -> void + + # Dispatch enter and leave events for NoKeywordsParameterNode nodes. + # -- + # : (NoKeywordsParameterNode node) -> void + def visit_no_keywords_parameter_node: (NoKeywordsParameterNode node) -> void + + # Dispatch enter and leave events for NumberedParametersNode nodes. + # -- + # : (NumberedParametersNode node) -> void + def visit_numbered_parameters_node: (NumberedParametersNode node) -> void + + # Dispatch enter and leave events for NumberedReferenceReadNode nodes. + # -- + # : (NumberedReferenceReadNode node) -> void + def visit_numbered_reference_read_node: (NumberedReferenceReadNode node) -> void + + # Dispatch enter and leave events for OptionalKeywordParameterNode nodes. + # -- + # : (OptionalKeywordParameterNode node) -> void + def visit_optional_keyword_parameter_node: (OptionalKeywordParameterNode node) -> void + + # Dispatch enter and leave events for OptionalParameterNode nodes. + # -- + # : (OptionalParameterNode node) -> void + def visit_optional_parameter_node: (OptionalParameterNode node) -> void + + # Dispatch enter and leave events for OrNode nodes. + # -- + # : (OrNode node) -> void + def visit_or_node: (OrNode node) -> void + + # Dispatch enter and leave events for ParametersNode nodes. + # -- + # : (ParametersNode node) -> void + def visit_parameters_node: (ParametersNode node) -> void + + # Dispatch enter and leave events for ParenthesesNode nodes. + # -- + # : (ParenthesesNode node) -> void + def visit_parentheses_node: (ParenthesesNode node) -> void + + # Dispatch enter and leave events for PinnedExpressionNode nodes. + # -- + # : (PinnedExpressionNode node) -> void + def visit_pinned_expression_node: (PinnedExpressionNode node) -> void + + # Dispatch enter and leave events for PinnedVariableNode nodes. + # -- + # : (PinnedVariableNode node) -> void + def visit_pinned_variable_node: (PinnedVariableNode node) -> void + + # Dispatch enter and leave events for PostExecutionNode nodes. + # -- + # : (PostExecutionNode node) -> void + def visit_post_execution_node: (PostExecutionNode node) -> void + + # Dispatch enter and leave events for PreExecutionNode nodes. + # -- + # : (PreExecutionNode node) -> void + def visit_pre_execution_node: (PreExecutionNode node) -> void + + # Dispatch enter and leave events for ProgramNode nodes. + # -- + # : (ProgramNode node) -> void + def visit_program_node: (ProgramNode node) -> void + + # Dispatch enter and leave events for RangeNode nodes. + # -- + # : (RangeNode node) -> void + def visit_range_node: (RangeNode node) -> void + + # Dispatch enter and leave events for RationalNode nodes. + # -- + # : (RationalNode node) -> void + def visit_rational_node: (RationalNode node) -> void + + # Dispatch enter and leave events for RedoNode nodes. + # -- + # : (RedoNode node) -> void + def visit_redo_node: (RedoNode node) -> void + + # Dispatch enter and leave events for RegularExpressionNode nodes. + # -- + # : (RegularExpressionNode node) -> void + def visit_regular_expression_node: (RegularExpressionNode node) -> void + + # Dispatch enter and leave events for RequiredKeywordParameterNode nodes. + # -- + # : (RequiredKeywordParameterNode node) -> void + def visit_required_keyword_parameter_node: (RequiredKeywordParameterNode node) -> void + + # Dispatch enter and leave events for RequiredParameterNode nodes. + # -- + # : (RequiredParameterNode node) -> void + def visit_required_parameter_node: (RequiredParameterNode node) -> void + + # Dispatch enter and leave events for RescueModifierNode nodes. + # -- + # : (RescueModifierNode node) -> void + def visit_rescue_modifier_node: (RescueModifierNode node) -> void + + # Dispatch enter and leave events for RescueNode nodes. + # -- + # : (RescueNode node) -> void + def visit_rescue_node: (RescueNode node) -> void + + # Dispatch enter and leave events for RestParameterNode nodes. + # -- + # : (RestParameterNode node) -> void + def visit_rest_parameter_node: (RestParameterNode node) -> void + + # Dispatch enter and leave events for RetryNode nodes. + # -- + # : (RetryNode node) -> void + def visit_retry_node: (RetryNode node) -> void + + # Dispatch enter and leave events for ReturnNode nodes. + # -- + # : (ReturnNode node) -> void + def visit_return_node: (ReturnNode node) -> void + + # Dispatch enter and leave events for SelfNode nodes. + # -- + # : (SelfNode node) -> void + def visit_self_node: (SelfNode node) -> void + + # Dispatch enter and leave events for ShareableConstantNode nodes. + # -- + # : (ShareableConstantNode node) -> void + def visit_shareable_constant_node: (ShareableConstantNode node) -> void + + # Dispatch enter and leave events for SingletonClassNode nodes. + # -- + # : (SingletonClassNode node) -> void + def visit_singleton_class_node: (SingletonClassNode node) -> void + + # Dispatch enter and leave events for SourceEncodingNode nodes. + # -- + # : (SourceEncodingNode node) -> void + def visit_source_encoding_node: (SourceEncodingNode node) -> void + + # Dispatch enter and leave events for SourceFileNode nodes. + # -- + # : (SourceFileNode node) -> void + def visit_source_file_node: (SourceFileNode node) -> void + + # Dispatch enter and leave events for SourceLineNode nodes. + # -- + # : (SourceLineNode node) -> void + def visit_source_line_node: (SourceLineNode node) -> void + + # Dispatch enter and leave events for SplatNode nodes. + # -- + # : (SplatNode node) -> void + def visit_splat_node: (SplatNode node) -> void + + # Dispatch enter and leave events for StatementsNode nodes. + # -- + # : (StatementsNode node) -> void + def visit_statements_node: (StatementsNode node) -> void + + # Dispatch enter and leave events for StringNode nodes. + # -- + # : (StringNode node) -> void + def visit_string_node: (StringNode node) -> void + + # Dispatch enter and leave events for SuperNode nodes. + # -- + # : (SuperNode node) -> void + def visit_super_node: (SuperNode node) -> void + + # Dispatch enter and leave events for SymbolNode nodes. + # -- + # : (SymbolNode node) -> void + def visit_symbol_node: (SymbolNode node) -> void + + # Dispatch enter and leave events for TrueNode nodes. + # -- + # : (TrueNode node) -> void + def visit_true_node: (TrueNode node) -> void + + # Dispatch enter and leave events for UndefNode nodes. + # -- + # : (UndefNode node) -> void + def visit_undef_node: (UndefNode node) -> void + + # Dispatch enter and leave events for UnlessNode nodes. + # -- + # : (UnlessNode node) -> void + def visit_unless_node: (UnlessNode node) -> void + + # Dispatch enter and leave events for UntilNode nodes. + # -- + # : (UntilNode node) -> void + def visit_until_node: (UntilNode node) -> void + + # Dispatch enter and leave events for WhenNode nodes. + # -- + # : (WhenNode node) -> void + def visit_when_node: (WhenNode node) -> void + + # Dispatch enter and leave events for WhileNode nodes. + # -- + # : (WhileNode node) -> void + def visit_while_node: (WhileNode node) -> void + + # Dispatch enter and leave events for XStringNode nodes. + # -- + # : (XStringNode node) -> void + def visit_x_string_node: (XStringNode node) -> void + + # Dispatch enter and leave events for YieldNode nodes. + # -- + # : (YieldNode node) -> void + def visit_yield_node: (YieldNode node) -> void + end + end +end diff --git a/sig/generated/prism/dot_visitor.rbs b/sig/generated/prism/dot_visitor.rbs new file mode 100644 index 0000000000..b471ec741f --- /dev/null +++ b/sig/generated/prism/dot_visitor.rbs @@ -0,0 +1,635 @@ +# Generated from lib/prism/dot_visitor.rb with RBS::Inline + +module Prism + # This visitor provides the ability to call Node#to_dot, which converts a + # subtree into a graphviz dot graph. + class DotVisitor < Visitor + class Field + # :nodoc: + attr_reader name: String + + attr_reader value: String? + + attr_reader port: bool + + # : (String name, String? value, bool port) -> void + def initialize: (String name, String? value, bool port) -> void + + # : () -> String + def to_dot: () -> String + end + + class Table + # :nodoc: + attr_reader name: String + + attr_reader fields: Array[Field] + + # : (String name) -> void + def initialize: (String name) -> void + + # : (String name, ?String? value, ?port: bool) -> void + def field: (String name, ?String? value, ?port: bool) -> void + + # : () -> String + def to_dot: () -> String + end + + class Digraph + # :nodoc: + attr_reader nodes: Array[String] + + # :nodoc: + attr_reader waypoints: Array[String] + + # :nodoc: + attr_reader edges: Array[String] + + # : () -> void + def initialize: () -> void + + # : (String value) -> void + def node: (String value) -> void + + # : (String value) -> void + def waypoint: (String value) -> void + + # : (String value) -> void + def edge: (String value) -> void + + # : () -> String + def to_dot: () -> String + end + + # The digraph that is being built. + attr_reader digraph: Digraph + + # Initialize a new dot visitor. + # -- + # : () -> void + def initialize: () -> void + + # Convert this visitor into a graphviz dot graph string. + # -- + # : () -> String + def to_dot: () -> String + + # (AliasGlobalVariableNode) -> void + def visit_alias_global_variable_node: (untyped node) -> untyped + + # (AliasMethodNode) -> void + def visit_alias_method_node: (untyped node) -> untyped + + # (AlternationPatternNode) -> void + def visit_alternation_pattern_node: (untyped node) -> untyped + + # (AndNode) -> void + def visit_and_node: (untyped node) -> untyped + + # (ArgumentsNode) -> void + def visit_arguments_node: (untyped node) -> untyped + + # (ArrayNode) -> void + def visit_array_node: (untyped node) -> untyped + + # (ArrayPatternNode) -> void + def visit_array_pattern_node: (untyped node) -> untyped + + # (AssocNode) -> void + def visit_assoc_node: (untyped node) -> untyped + + # (AssocSplatNode) -> void + def visit_assoc_splat_node: (untyped node) -> untyped + + # (BackReferenceReadNode) -> void + def visit_back_reference_read_node: (untyped node) -> untyped + + # (BeginNode) -> void + def visit_begin_node: (untyped node) -> untyped + + # (BlockArgumentNode) -> void + def visit_block_argument_node: (untyped node) -> untyped + + # (BlockLocalVariableNode) -> void + def visit_block_local_variable_node: (untyped node) -> untyped + + # (BlockNode) -> void + def visit_block_node: (untyped node) -> untyped + + # (BlockParameterNode) -> void + def visit_block_parameter_node: (untyped node) -> untyped + + # (BlockParametersNode) -> void + def visit_block_parameters_node: (untyped node) -> untyped + + # (BreakNode) -> void + def visit_break_node: (untyped node) -> untyped + + # (CallAndWriteNode) -> void + def visit_call_and_write_node: (untyped node) -> untyped + + # (CallNode) -> void + def visit_call_node: (untyped node) -> untyped + + # (CallOperatorWriteNode) -> void + def visit_call_operator_write_node: (untyped node) -> untyped + + # (CallOrWriteNode) -> void + def visit_call_or_write_node: (untyped node) -> untyped + + # (CallTargetNode) -> void + def visit_call_target_node: (untyped node) -> untyped + + # (CapturePatternNode) -> void + def visit_capture_pattern_node: (untyped node) -> untyped + + # (CaseMatchNode) -> void + def visit_case_match_node: (untyped node) -> untyped + + # (CaseNode) -> void + def visit_case_node: (untyped node) -> untyped + + # (ClassNode) -> void + def visit_class_node: (untyped node) -> untyped + + # (ClassVariableAndWriteNode) -> void + def visit_class_variable_and_write_node: (untyped node) -> untyped + + # (ClassVariableOperatorWriteNode) -> void + def visit_class_variable_operator_write_node: (untyped node) -> untyped + + # (ClassVariableOrWriteNode) -> void + def visit_class_variable_or_write_node: (untyped node) -> untyped + + # (ClassVariableReadNode) -> void + def visit_class_variable_read_node: (untyped node) -> untyped + + # (ClassVariableTargetNode) -> void + def visit_class_variable_target_node: (untyped node) -> untyped + + # (ClassVariableWriteNode) -> void + def visit_class_variable_write_node: (untyped node) -> untyped + + # (ConstantAndWriteNode) -> void + def visit_constant_and_write_node: (untyped node) -> untyped + + # (ConstantOperatorWriteNode) -> void + def visit_constant_operator_write_node: (untyped node) -> untyped + + # (ConstantOrWriteNode) -> void + def visit_constant_or_write_node: (untyped node) -> untyped + + # (ConstantPathAndWriteNode) -> void + def visit_constant_path_and_write_node: (untyped node) -> untyped + + # (ConstantPathNode) -> void + def visit_constant_path_node: (untyped node) -> untyped + + # (ConstantPathOperatorWriteNode) -> void + def visit_constant_path_operator_write_node: (untyped node) -> untyped + + # (ConstantPathOrWriteNode) -> void + def visit_constant_path_or_write_node: (untyped node) -> untyped + + # (ConstantPathTargetNode) -> void + def visit_constant_path_target_node: (untyped node) -> untyped + + # (ConstantPathWriteNode) -> void + def visit_constant_path_write_node: (untyped node) -> untyped + + # (ConstantReadNode) -> void + def visit_constant_read_node: (untyped node) -> untyped + + # (ConstantTargetNode) -> void + def visit_constant_target_node: (untyped node) -> untyped + + # (ConstantWriteNode) -> void + def visit_constant_write_node: (untyped node) -> untyped + + # (DefNode) -> void + def visit_def_node: (untyped node) -> untyped + + # (DefinedNode) -> void + def visit_defined_node: (untyped node) -> untyped + + # (ElseNode) -> void + def visit_else_node: (untyped node) -> untyped + + # (EmbeddedStatementsNode) -> void + def visit_embedded_statements_node: (untyped node) -> untyped + + # (EmbeddedVariableNode) -> void + def visit_embedded_variable_node: (untyped node) -> untyped + + # (EnsureNode) -> void + def visit_ensure_node: (untyped node) -> untyped + + # (FalseNode) -> void + def visit_false_node: (untyped node) -> untyped + + # (FindPatternNode) -> void + def visit_find_pattern_node: (untyped node) -> untyped + + # (FlipFlopNode) -> void + def visit_flip_flop_node: (untyped node) -> untyped + + # (FloatNode) -> void + def visit_float_node: (untyped node) -> untyped + + # (ForNode) -> void + def visit_for_node: (untyped node) -> untyped + + # (ForwardingArgumentsNode) -> void + def visit_forwarding_arguments_node: (untyped node) -> untyped + + # (ForwardingParameterNode) -> void + def visit_forwarding_parameter_node: (untyped node) -> untyped + + # (ForwardingSuperNode) -> void + def visit_forwarding_super_node: (untyped node) -> untyped + + # (GlobalVariableAndWriteNode) -> void + def visit_global_variable_and_write_node: (untyped node) -> untyped + + # (GlobalVariableOperatorWriteNode) -> void + def visit_global_variable_operator_write_node: (untyped node) -> untyped + + # (GlobalVariableOrWriteNode) -> void + def visit_global_variable_or_write_node: (untyped node) -> untyped + + # (GlobalVariableReadNode) -> void + def visit_global_variable_read_node: (untyped node) -> untyped + + # (GlobalVariableTargetNode) -> void + def visit_global_variable_target_node: (untyped node) -> untyped + + # (GlobalVariableWriteNode) -> void + def visit_global_variable_write_node: (untyped node) -> untyped + + # (HashNode) -> void + def visit_hash_node: (untyped node) -> untyped + + # (HashPatternNode) -> void + def visit_hash_pattern_node: (untyped node) -> untyped + + # (IfNode) -> void + def visit_if_node: (untyped node) -> untyped + + # (ImaginaryNode) -> void + def visit_imaginary_node: (untyped node) -> untyped + + # (ImplicitNode) -> void + def visit_implicit_node: (untyped node) -> untyped + + # (ImplicitRestNode) -> void + def visit_implicit_rest_node: (untyped node) -> untyped + + # (InNode) -> void + def visit_in_node: (untyped node) -> untyped + + # (IndexAndWriteNode) -> void + def visit_index_and_write_node: (untyped node) -> untyped + + # (IndexOperatorWriteNode) -> void + def visit_index_operator_write_node: (untyped node) -> untyped + + # (IndexOrWriteNode) -> void + def visit_index_or_write_node: (untyped node) -> untyped + + # (IndexTargetNode) -> void + def visit_index_target_node: (untyped node) -> untyped + + # (InstanceVariableAndWriteNode) -> void + def visit_instance_variable_and_write_node: (untyped node) -> untyped + + # (InstanceVariableOperatorWriteNode) -> void + def visit_instance_variable_operator_write_node: (untyped node) -> untyped + + # (InstanceVariableOrWriteNode) -> void + def visit_instance_variable_or_write_node: (untyped node) -> untyped + + # (InstanceVariableReadNode) -> void + def visit_instance_variable_read_node: (untyped node) -> untyped + + # (InstanceVariableTargetNode) -> void + def visit_instance_variable_target_node: (untyped node) -> untyped + + # (InstanceVariableWriteNode) -> void + def visit_instance_variable_write_node: (untyped node) -> untyped + + # (IntegerNode) -> void + def visit_integer_node: (untyped node) -> untyped + + # (InterpolatedMatchLastLineNode) -> void + def visit_interpolated_match_last_line_node: (untyped node) -> untyped + + # (InterpolatedRegularExpressionNode) -> void + def visit_interpolated_regular_expression_node: (untyped node) -> untyped + + # (InterpolatedStringNode) -> void + def visit_interpolated_string_node: (untyped node) -> untyped + + # (InterpolatedSymbolNode) -> void + def visit_interpolated_symbol_node: (untyped node) -> untyped + + # (InterpolatedXStringNode) -> void + def visit_interpolated_x_string_node: (untyped node) -> untyped + + # (ItLocalVariableReadNode) -> void + def visit_it_local_variable_read_node: (untyped node) -> untyped + + # (ItParametersNode) -> void + def visit_it_parameters_node: (untyped node) -> untyped + + # (KeywordHashNode) -> void + def visit_keyword_hash_node: (untyped node) -> untyped + + # (KeywordRestParameterNode) -> void + def visit_keyword_rest_parameter_node: (untyped node) -> untyped + + # (LambdaNode) -> void + def visit_lambda_node: (untyped node) -> untyped + + # (LocalVariableAndWriteNode) -> void + def visit_local_variable_and_write_node: (untyped node) -> untyped + + # (LocalVariableOperatorWriteNode) -> void + def visit_local_variable_operator_write_node: (untyped node) -> untyped + + # (LocalVariableOrWriteNode) -> void + def visit_local_variable_or_write_node: (untyped node) -> untyped + + # (LocalVariableReadNode) -> void + def visit_local_variable_read_node: (untyped node) -> untyped + + # (LocalVariableTargetNode) -> void + def visit_local_variable_target_node: (untyped node) -> untyped + + # (LocalVariableWriteNode) -> void + def visit_local_variable_write_node: (untyped node) -> untyped + + # (MatchLastLineNode) -> void + def visit_match_last_line_node: (untyped node) -> untyped + + # (MatchPredicateNode) -> void + def visit_match_predicate_node: (untyped node) -> untyped + + # (MatchRequiredNode) -> void + def visit_match_required_node: (untyped node) -> untyped + + # (MatchWriteNode) -> void + def visit_match_write_node: (untyped node) -> untyped + + # (MissingNode) -> void + def visit_missing_node: (untyped node) -> untyped + + # (ModuleNode) -> void + def visit_module_node: (untyped node) -> untyped + + # (MultiTargetNode) -> void + def visit_multi_target_node: (untyped node) -> untyped + + # (MultiWriteNode) -> void + def visit_multi_write_node: (untyped node) -> untyped + + # (NextNode) -> void + def visit_next_node: (untyped node) -> untyped + + # (NilNode) -> void + def visit_nil_node: (untyped node) -> untyped + + # (NoBlockParameterNode) -> void + def visit_no_block_parameter_node: (untyped node) -> untyped + + # (NoKeywordsParameterNode) -> void + def visit_no_keywords_parameter_node: (untyped node) -> untyped + + # (NumberedParametersNode) -> void + def visit_numbered_parameters_node: (untyped node) -> untyped + + # (NumberedReferenceReadNode) -> void + def visit_numbered_reference_read_node: (untyped node) -> untyped + + # (OptionalKeywordParameterNode) -> void + def visit_optional_keyword_parameter_node: (untyped node) -> untyped + + # (OptionalParameterNode) -> void + def visit_optional_parameter_node: (untyped node) -> untyped + + # (OrNode) -> void + def visit_or_node: (untyped node) -> untyped + + # (ParametersNode) -> void + def visit_parameters_node: (untyped node) -> untyped + + # (ParenthesesNode) -> void + def visit_parentheses_node: (untyped node) -> untyped + + # (PinnedExpressionNode) -> void + def visit_pinned_expression_node: (untyped node) -> untyped + + # (PinnedVariableNode) -> void + def visit_pinned_variable_node: (untyped node) -> untyped + + # (PostExecutionNode) -> void + def visit_post_execution_node: (untyped node) -> untyped + + # (PreExecutionNode) -> void + def visit_pre_execution_node: (untyped node) -> untyped + + # (ProgramNode) -> void + def visit_program_node: (untyped node) -> untyped + + # (RangeNode) -> void + def visit_range_node: (untyped node) -> untyped + + # (RationalNode) -> void + def visit_rational_node: (untyped node) -> untyped + + # (RedoNode) -> void + def visit_redo_node: (untyped node) -> untyped + + # (RegularExpressionNode) -> void + def visit_regular_expression_node: (untyped node) -> untyped + + # (RequiredKeywordParameterNode) -> void + def visit_required_keyword_parameter_node: (untyped node) -> untyped + + # (RequiredParameterNode) -> void + def visit_required_parameter_node: (untyped node) -> untyped + + # (RescueModifierNode) -> void + def visit_rescue_modifier_node: (untyped node) -> untyped + + # (RescueNode) -> void + def visit_rescue_node: (untyped node) -> untyped + + # (RestParameterNode) -> void + def visit_rest_parameter_node: (untyped node) -> untyped + + # (RetryNode) -> void + def visit_retry_node: (untyped node) -> untyped + + # (ReturnNode) -> void + def visit_return_node: (untyped node) -> untyped + + # (SelfNode) -> void + def visit_self_node: (untyped node) -> untyped + + # (ShareableConstantNode) -> void + def visit_shareable_constant_node: (untyped node) -> untyped + + # (SingletonClassNode) -> void + def visit_singleton_class_node: (untyped node) -> untyped + + # (SourceEncodingNode) -> void + def visit_source_encoding_node: (untyped node) -> untyped + + # (SourceFileNode) -> void + def visit_source_file_node: (untyped node) -> untyped + + # (SourceLineNode) -> void + def visit_source_line_node: (untyped node) -> untyped + + # (SplatNode) -> void + def visit_splat_node: (untyped node) -> untyped + + # (StatementsNode) -> void + def visit_statements_node: (untyped node) -> untyped + + # (StringNode) -> void + def visit_string_node: (untyped node) -> untyped + + # (SuperNode) -> void + def visit_super_node: (untyped node) -> untyped + + # (SymbolNode) -> void + def visit_symbol_node: (untyped node) -> untyped + + # (TrueNode) -> void + def visit_true_node: (untyped node) -> untyped + + # (UndefNode) -> void + def visit_undef_node: (untyped node) -> untyped + + # (UnlessNode) -> void + def visit_unless_node: (untyped node) -> untyped + + # (UntilNode) -> void + def visit_until_node: (untyped node) -> untyped + + # (WhenNode) -> void + def visit_when_node: (untyped node) -> untyped + + # (WhileNode) -> void + def visit_while_node: (untyped node) -> untyped + + # (XStringNode) -> void + def visit_x_string_node: (untyped node) -> untyped + + # (YieldNode) -> void + def visit_yield_node: (untyped node) -> untyped + + private + + # Generate a unique node ID for a node throughout the digraph. + # -- + # : (node) -> String + def node_id: (node) -> String + + # Inspect a location to display the start and end line and columns in bytes. + # -- + # : (Location) -> String + def location_inspect: (Location) -> String + + # Inspect a node that has arguments_node_flags flags to display the flags as a + # comma-separated list. + # -- + # : (ArgumentsNode node) -> String + def arguments_node_flags_inspect: (ArgumentsNode node) -> String + + # Inspect a node that has array_node_flags flags to display the flags as a + # comma-separated list. + # -- + # : (ArrayNode node) -> String + def array_node_flags_inspect: (ArrayNode node) -> String + + # Inspect a node that has call_node_flags flags to display the flags as a + # comma-separated list. + # -- + # : (CallAndWriteNode | CallNode | CallOperatorWriteNode | CallOrWriteNode | CallTargetNode | IndexAndWriteNode | IndexOperatorWriteNode | IndexOrWriteNode | IndexTargetNode node) -> String + def call_node_flags_inspect: (CallAndWriteNode | CallNode | CallOperatorWriteNode | CallOrWriteNode | CallTargetNode | IndexAndWriteNode | IndexOperatorWriteNode | IndexOrWriteNode | IndexTargetNode node) -> String + + # Inspect a node that has encoding_flags flags to display the flags as a + # comma-separated list. + # -- + # : (XStringNode node) -> String + def encoding_flags_inspect: (XStringNode node) -> String + + # Inspect a node that has integer_base_flags flags to display the flags as a + # comma-separated list. + # -- + # : (IntegerNode | RationalNode node) -> String + def integer_base_flags_inspect: (IntegerNode | RationalNode node) -> String + + # Inspect a node that has interpolated_string_node_flags flags to display the flags as a + # comma-separated list. + # -- + # : (InterpolatedStringNode node) -> String + def interpolated_string_node_flags_inspect: (InterpolatedStringNode node) -> String + + # Inspect a node that has keyword_hash_node_flags flags to display the flags as a + # comma-separated list. + # -- + # : (KeywordHashNode node) -> String + def keyword_hash_node_flags_inspect: (KeywordHashNode node) -> String + + # Inspect a node that has loop_flags flags to display the flags as a + # comma-separated list. + # -- + # : (UntilNode | WhileNode node) -> String + def loop_flags_inspect: (UntilNode | WhileNode node) -> String + + # Inspect a node that has parameter_flags flags to display the flags as a + # comma-separated list. + # -- + # : (BlockLocalVariableNode | BlockParameterNode | KeywordRestParameterNode | OptionalKeywordParameterNode | OptionalParameterNode | RequiredKeywordParameterNode | RequiredParameterNode | RestParameterNode node) -> String + def parameter_flags_inspect: (BlockLocalVariableNode | BlockParameterNode | KeywordRestParameterNode | OptionalKeywordParameterNode | OptionalParameterNode | RequiredKeywordParameterNode | RequiredParameterNode | RestParameterNode node) -> String + + # Inspect a node that has parentheses_node_flags flags to display the flags as a + # comma-separated list. + # -- + # : (ParenthesesNode node) -> String + def parentheses_node_flags_inspect: (ParenthesesNode node) -> String + + # Inspect a node that has range_flags flags to display the flags as a + # comma-separated list. + # -- + # : (FlipFlopNode | RangeNode node) -> String + def range_flags_inspect: (FlipFlopNode | RangeNode node) -> String + + # Inspect a node that has regular_expression_flags flags to display the flags as a + # comma-separated list. + # -- + # : (InterpolatedMatchLastLineNode | InterpolatedRegularExpressionNode | MatchLastLineNode | RegularExpressionNode node) -> String + def regular_expression_flags_inspect: (InterpolatedMatchLastLineNode | InterpolatedRegularExpressionNode | MatchLastLineNode | RegularExpressionNode node) -> String + + # Inspect a node that has shareable_constant_node_flags flags to display the flags as a + # comma-separated list. + # -- + # : (ShareableConstantNode node) -> String + def shareable_constant_node_flags_inspect: (ShareableConstantNode node) -> String + + # Inspect a node that has string_flags flags to display the flags as a + # comma-separated list. + # -- + # : (SourceFileNode | StringNode node) -> String + def string_flags_inspect: (SourceFileNode | StringNode node) -> String + + # Inspect a node that has symbol_flags flags to display the flags as a + # comma-separated list. + # -- + # : (SymbolNode node) -> String + def symbol_flags_inspect: (SymbolNode node) -> String + end +end diff --git a/sig/generated/prism/dsl.rbs b/sig/generated/prism/dsl.rbs new file mode 100644 index 0000000000..6b5e4bbc75 --- /dev/null +++ b/sig/generated/prism/dsl.rbs @@ -0,0 +1,921 @@ +# Generated from lib/prism/dsl.rb with RBS::Inline + +module Prism + # The DSL module provides a set of methods that can be used to create prism + # nodes in a more concise manner. For example, instead of writing: + # + # source = Prism::Source.for("[1]") + # + # Prism::ArrayNode.new( + # source, + # 0, + # Prism::Location.new(source, 0, 3), + # 0, + # [ + # Prism::IntegerNode.new( + # source, + # 0, + # Prism::Location.new(source, 1, 1), + # Prism::IntegerBaseFlags::DECIMAL, + # 1 + # ) + # ], + # Prism::Location.new(source, 0, 1), + # Prism::Location.new(source, 2, 1) + # ) + # + # you could instead write: + # + # class Builder + # include Prism::DSL + # + # attr_reader :default_source + # + # def initialize + # @default_source = source("[1]") + # end + # + # def build + # array_node( + # location: location(start_offset: 0, length: 3), + # elements: [ + # integer_node( + # location: location(start_offset: 1, length: 1), + # flags: integer_base_flag(:decimal), + # value: 1 + # ) + # ], + # opening_loc: location(start_offset: 0, length: 1), + # closing_loc: location(start_offset: 2, length: 1) + # ) + # end + # end + # + # This is mostly helpful in the context of generating trees programmatically. + module DSL + # Create a new Source object. + # -- + # : (String string) -> Source + def source: (String string) -> Source + + # Create a new Location object. + # -- + # : (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location + def location: (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location + + # Create a new AliasGlobalVariableNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?new_name: (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode), ?old_name: (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | SymbolNode | MissingNode), ?keyword_loc: Location) -> AliasGlobalVariableNode + def alias_global_variable_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?new_name: GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode, ?old_name: GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | SymbolNode | MissingNode, ?keyword_loc: Location) -> AliasGlobalVariableNode + + # Create a new AliasMethodNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?new_name: (SymbolNode | InterpolatedSymbolNode), ?old_name: (SymbolNode | InterpolatedSymbolNode | GlobalVariableReadNode | MissingNode), ?keyword_loc: Location) -> AliasMethodNode + def alias_method_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?new_name: SymbolNode | InterpolatedSymbolNode, ?old_name: SymbolNode | InterpolatedSymbolNode | GlobalVariableReadNode | MissingNode, ?keyword_loc: Location) -> AliasMethodNode + + # Create a new AlternationPatternNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> AlternationPatternNode + def alternation_pattern_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> AlternationPatternNode + + # Create a new AndNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> AndNode + def and_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> AndNode + + # Create a new ArgumentsNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: Array[Prism::node]) -> ArgumentsNode + def arguments_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: Array[Prism::node]) -> ArgumentsNode + + # Create a new ArrayNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?elements: Array[Prism::node], ?opening_loc: Location?, ?closing_loc: Location?) -> ArrayNode + def array_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?elements: Array[Prism::node], ?opening_loc: Location?, ?closing_loc: Location?) -> ArrayNode + + # Create a new ArrayPatternNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?requireds: Array[Prism::node], ?rest: Prism::node?, ?posts: Array[Prism::node], ?opening_loc: Location?, ?closing_loc: Location?) -> ArrayPatternNode + def array_pattern_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?requireds: Array[Prism::node], ?rest: Prism::node?, ?posts: Array[Prism::node], ?opening_loc: Location?, ?closing_loc: Location?) -> ArrayPatternNode + + # Create a new AssocNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?key: Prism::node, ?value: Prism::node, ?operator_loc: Location?) -> AssocNode + def assoc_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?key: Prism::node, ?value: Prism::node, ?operator_loc: Location?) -> AssocNode + + # Create a new AssocSplatNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node?, ?operator_loc: Location) -> AssocSplatNode + def assoc_splat_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node?, ?operator_loc: Location) -> AssocSplatNode + + # Create a new BackReferenceReadNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BackReferenceReadNode + def back_reference_read_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BackReferenceReadNode + + # Create a new BeginNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?begin_keyword_loc: Location?, ?statements: StatementsNode?, ?rescue_clause: RescueNode?, ?else_clause: ElseNode?, ?ensure_clause: EnsureNode?, ?end_keyword_loc: Location?) -> BeginNode + def begin_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?begin_keyword_loc: Location?, ?statements: StatementsNode?, ?rescue_clause: RescueNode?, ?else_clause: ElseNode?, ?ensure_clause: EnsureNode?, ?end_keyword_loc: Location?) -> BeginNode + + # Create a new BlockArgumentNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node?, ?operator_loc: Location) -> BlockArgumentNode + def block_argument_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node?, ?operator_loc: Location) -> BlockArgumentNode + + # Create a new BlockLocalVariableNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BlockLocalVariableNode + def block_local_variable_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BlockLocalVariableNode + + # Create a new BlockNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)?, ?body: (StatementsNode | BeginNode)?, ?opening_loc: Location, ?closing_loc: Location) -> BlockNode + def block_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)?, ?body: (StatementsNode | BeginNode)?, ?opening_loc: Location, ?closing_loc: Location) -> BlockNode + + # Create a new BlockParameterNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> BlockParameterNode + def block_parameter_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> BlockParameterNode + + # Create a new BlockParametersNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?parameters: ParametersNode?, ?locals: Array[BlockLocalVariableNode], ?opening_loc: Location?, ?closing_loc: Location?) -> BlockParametersNode + def block_parameters_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?parameters: ParametersNode?, ?locals: Array[BlockLocalVariableNode], ?opening_loc: Location?, ?closing_loc: Location?) -> BlockParametersNode + + # Create a new BreakNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> BreakNode + def break_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> BreakNode + + # Create a new CallAndWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?operator_loc: Location, ?value: Prism::node) -> CallAndWriteNode + def call_and_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?operator_loc: Location, ?value: Prism::node) -> CallAndWriteNode + + # Create a new CallNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?name: Symbol, ?message_loc: Location?, ?opening_loc: Location?, ?arguments: ArgumentsNode?, ?closing_loc: Location?, ?equal_loc: Location?, ?block: (BlockNode | BlockArgumentNode)?) -> CallNode + def call_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?name: Symbol, ?message_loc: Location?, ?opening_loc: Location?, ?arguments: ArgumentsNode?, ?closing_loc: Location?, ?equal_loc: Location?, ?block: (BlockNode | BlockArgumentNode)?) -> CallNode + + # Create a new CallOperatorWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> CallOperatorWriteNode + def call_operator_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> CallOperatorWriteNode + + # Create a new CallOrWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?operator_loc: Location, ?value: Prism::node) -> CallOrWriteNode + def call_or_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?operator_loc: Location, ?value: Prism::node) -> CallOrWriteNode + + # Create a new CallTargetNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?call_operator_loc: Location, ?name: Symbol, ?message_loc: Location) -> CallTargetNode + def call_target_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?call_operator_loc: Location, ?name: Symbol, ?message_loc: Location) -> CallTargetNode + + # Create a new CapturePatternNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?target: LocalVariableTargetNode, ?operator_loc: Location) -> CapturePatternNode + def capture_pattern_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?target: LocalVariableTargetNode, ?operator_loc: Location) -> CapturePatternNode + + # Create a new CaseMatchNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?predicate: Prism::node?, ?conditions: Array[InNode], ?else_clause: ElseNode?, ?case_keyword_loc: Location, ?end_keyword_loc: Location) -> CaseMatchNode + def case_match_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?predicate: Prism::node?, ?conditions: Array[InNode], ?else_clause: ElseNode?, ?case_keyword_loc: Location, ?end_keyword_loc: Location) -> CaseMatchNode + + # Create a new CaseNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?predicate: Prism::node?, ?conditions: Array[WhenNode], ?else_clause: ElseNode?, ?case_keyword_loc: Location, ?end_keyword_loc: Location) -> CaseNode + def case_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?predicate: Prism::node?, ?conditions: Array[WhenNode], ?else_clause: ElseNode?, ?case_keyword_loc: Location, ?end_keyword_loc: Location) -> CaseNode + + # Create a new ClassNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?class_keyword_loc: Location, ?constant_path: (ConstantReadNode | ConstantPathNode | CallNode), ?inheritance_operator_loc: Location?, ?superclass: Prism::node?, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location, ?name: Symbol) -> ClassNode + def class_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?class_keyword_loc: Location, ?constant_path: ConstantReadNode | ConstantPathNode | CallNode, ?inheritance_operator_loc: Location?, ?superclass: Prism::node?, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location, ?name: Symbol) -> ClassNode + + # Create a new ClassVariableAndWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ClassVariableAndWriteNode + def class_variable_and_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ClassVariableAndWriteNode + + # Create a new ClassVariableOperatorWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ClassVariableOperatorWriteNode + def class_variable_operator_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ClassVariableOperatorWriteNode + + # Create a new ClassVariableOrWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ClassVariableOrWriteNode + def class_variable_or_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ClassVariableOrWriteNode + + # Create a new ClassVariableReadNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ClassVariableReadNode + def class_variable_read_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ClassVariableReadNode + + # Create a new ClassVariableTargetNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ClassVariableTargetNode + def class_variable_target_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ClassVariableTargetNode + + # Create a new ClassVariableWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> ClassVariableWriteNode + def class_variable_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> ClassVariableWriteNode + + # Create a new ConstantAndWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantAndWriteNode + def constant_and_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantAndWriteNode + + # Create a new ConstantOperatorWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ConstantOperatorWriteNode + def constant_operator_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ConstantOperatorWriteNode + + # Create a new ConstantOrWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantOrWriteNode + def constant_or_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantOrWriteNode + + # Create a new ConstantPathAndWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathAndWriteNode + def constant_path_and_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathAndWriteNode + + # Create a new ConstantPathNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) -> ConstantPathNode + def constant_path_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) -> ConstantPathNode + + # Create a new ConstantPathOperatorWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ConstantPathOperatorWriteNode + def constant_path_operator_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ConstantPathOperatorWriteNode + + # Create a new ConstantPathOrWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathOrWriteNode + def constant_path_or_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathOrWriteNode + + # Create a new ConstantPathTargetNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) -> ConstantPathTargetNode + def constant_path_target_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) -> ConstantPathTargetNode + + # Create a new ConstantPathWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathWriteNode + def constant_path_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathWriteNode + + # Create a new ConstantReadNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantReadNode + def constant_read_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantReadNode + + # Create a new ConstantTargetNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantTargetNode + def constant_target_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantTargetNode + + # Create a new ConstantWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> ConstantWriteNode + def constant_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> ConstantWriteNode + + # Create a new DefNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?receiver: Prism::node?, ?parameters: ParametersNode?, ?body: (StatementsNode | BeginNode)?, ?locals: Array[Symbol], ?def_keyword_loc: Location, ?operator_loc: Location?, ?lparen_loc: Location?, ?rparen_loc: Location?, ?equal_loc: Location?, ?end_keyword_loc: Location?) -> DefNode + def def_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?receiver: Prism::node?, ?parameters: ParametersNode?, ?body: (StatementsNode | BeginNode)?, ?locals: Array[Symbol], ?def_keyword_loc: Location, ?operator_loc: Location?, ?lparen_loc: Location?, ?rparen_loc: Location?, ?equal_loc: Location?, ?end_keyword_loc: Location?) -> DefNode + + # Create a new DefinedNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?lparen_loc: Location?, ?value: Prism::node, ?rparen_loc: Location?, ?keyword_loc: Location) -> DefinedNode + def defined_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?lparen_loc: Location?, ?value: Prism::node, ?rparen_loc: Location?, ?keyword_loc: Location) -> DefinedNode + + # Create a new ElseNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?else_keyword_loc: Location, ?statements: StatementsNode?, ?end_keyword_loc: Location?) -> ElseNode + def else_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?else_keyword_loc: Location, ?statements: StatementsNode?, ?end_keyword_loc: Location?) -> ElseNode + + # Create a new EmbeddedStatementsNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?statements: StatementsNode?, ?closing_loc: Location) -> EmbeddedStatementsNode + def embedded_statements_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?statements: StatementsNode?, ?closing_loc: Location) -> EmbeddedStatementsNode + + # Create a new EmbeddedVariableNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?variable: (InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode)) -> EmbeddedVariableNode + def embedded_variable_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) -> EmbeddedVariableNode + + # Create a new EnsureNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?ensure_keyword_loc: Location, ?statements: StatementsNode?, ?end_keyword_loc: Location) -> EnsureNode + def ensure_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?ensure_keyword_loc: Location, ?statements: StatementsNode?, ?end_keyword_loc: Location) -> EnsureNode + + # Create a new FalseNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> FalseNode + def false_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> FalseNode + + # Create a new FindPatternNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?left: SplatNode, ?requireds: Array[Prism::node], ?right: (SplatNode | MissingNode), ?opening_loc: Location?, ?closing_loc: Location?) -> FindPatternNode + def find_pattern_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?left: SplatNode, ?requireds: Array[Prism::node], ?right: SplatNode | MissingNode, ?opening_loc: Location?, ?closing_loc: Location?) -> FindPatternNode + + # Create a new FlipFlopNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node?, ?right: Prism::node?, ?operator_loc: Location) -> FlipFlopNode + def flip_flop_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node?, ?right: Prism::node?, ?operator_loc: Location) -> FlipFlopNode + + # Create a new FloatNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Float) -> FloatNode + def float_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Float) -> FloatNode + + # Create a new ForNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?index: (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode), ?collection: Prism::node, ?statements: StatementsNode?, ?for_keyword_loc: Location, ?in_keyword_loc: Location, ?do_keyword_loc: Location?, ?end_keyword_loc: Location) -> ForNode + def for_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?index: LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode, ?collection: Prism::node, ?statements: StatementsNode?, ?for_keyword_loc: Location, ?in_keyword_loc: Location, ?do_keyword_loc: Location?, ?end_keyword_loc: Location) -> ForNode + + # Create a new ForwardingArgumentsNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ForwardingArgumentsNode + def forwarding_arguments_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ForwardingArgumentsNode + + # Create a new ForwardingParameterNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ForwardingParameterNode + def forwarding_parameter_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ForwardingParameterNode + + # Create a new ForwardingSuperNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?block: BlockNode?) -> ForwardingSuperNode + def forwarding_super_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?block: BlockNode?) -> ForwardingSuperNode + + # Create a new GlobalVariableAndWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> GlobalVariableAndWriteNode + def global_variable_and_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> GlobalVariableAndWriteNode + + # Create a new GlobalVariableOperatorWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> GlobalVariableOperatorWriteNode + def global_variable_operator_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> GlobalVariableOperatorWriteNode + + # Create a new GlobalVariableOrWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> GlobalVariableOrWriteNode + def global_variable_or_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> GlobalVariableOrWriteNode + + # Create a new GlobalVariableReadNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> GlobalVariableReadNode + def global_variable_read_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> GlobalVariableReadNode + + # Create a new GlobalVariableTargetNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> GlobalVariableTargetNode + def global_variable_target_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> GlobalVariableTargetNode + + # Create a new GlobalVariableWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> GlobalVariableWriteNode + def global_variable_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> GlobalVariableWriteNode + + # Create a new HashNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?elements: Array[AssocNode | AssocSplatNode], ?closing_loc: Location) -> HashNode + def hash_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?elements: Array[AssocNode | AssocSplatNode], ?closing_loc: Location) -> HashNode + + # Create a new HashPatternNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?elements: Array[AssocNode], ?rest: (AssocSplatNode | NoKeywordsParameterNode)?, ?opening_loc: Location?, ?closing_loc: Location?) -> HashPatternNode + def hash_pattern_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?elements: Array[AssocNode], ?rest: (AssocSplatNode | NoKeywordsParameterNode)?, ?opening_loc: Location?, ?closing_loc: Location?) -> HashPatternNode + + # Create a new IfNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?if_keyword_loc: Location?, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?subsequent: (ElseNode | IfNode)?, ?end_keyword_loc: Location?) -> IfNode + def if_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?if_keyword_loc: Location?, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?subsequent: (ElseNode | IfNode)?, ?end_keyword_loc: Location?) -> IfNode + + # Create a new ImaginaryNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?numeric: (FloatNode | IntegerNode | RationalNode)) -> ImaginaryNode + def imaginary_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?numeric: FloatNode | IntegerNode | RationalNode) -> ImaginaryNode + + # Create a new ImplicitNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: (LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode)) -> ImplicitNode + def implicit_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode) -> ImplicitNode + + # Create a new ImplicitRestNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ImplicitRestNode + def implicit_rest_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ImplicitRestNode + + # Create a new InNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?pattern: Prism::node, ?statements: StatementsNode?, ?in_loc: Location, ?then_loc: Location?) -> InNode + def in_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?pattern: Prism::node, ?statements: StatementsNode?, ?in_loc: Location, ?then_loc: Location?) -> InNode + + # Create a new IndexAndWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?operator_loc: Location, ?value: Prism::node) -> IndexAndWriteNode + def index_and_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?operator_loc: Location, ?value: Prism::node) -> IndexAndWriteNode + + # Create a new IndexOperatorWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> IndexOperatorWriteNode + def index_operator_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> IndexOperatorWriteNode + + # Create a new IndexOrWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?operator_loc: Location, ?value: Prism::node) -> IndexOrWriteNode + def index_or_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?operator_loc: Location, ?value: Prism::node) -> IndexOrWriteNode + + # Create a new IndexTargetNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?) -> IndexTargetNode + def index_target_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?) -> IndexTargetNode + + # Create a new InstanceVariableAndWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> InstanceVariableAndWriteNode + def instance_variable_and_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> InstanceVariableAndWriteNode + + # Create a new InstanceVariableOperatorWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> InstanceVariableOperatorWriteNode + def instance_variable_operator_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> InstanceVariableOperatorWriteNode + + # Create a new InstanceVariableOrWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> InstanceVariableOrWriteNode + def instance_variable_or_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> InstanceVariableOrWriteNode + + # Create a new InstanceVariableReadNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> InstanceVariableReadNode + def instance_variable_read_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> InstanceVariableReadNode + + # Create a new InstanceVariableTargetNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> InstanceVariableTargetNode + def instance_variable_target_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> InstanceVariableTargetNode + + # Create a new InstanceVariableWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> InstanceVariableWriteNode + def instance_variable_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> InstanceVariableWriteNode + + # Create a new IntegerNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Integer) -> IntegerNode + def integer_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Integer) -> IntegerNode + + # Create a new InterpolatedMatchLastLineNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedMatchLastLineNode + def interpolated_match_last_line_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedMatchLastLineNode + + # Create a new InterpolatedRegularExpressionNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedRegularExpressionNode + def interpolated_regular_expression_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedRegularExpressionNode + + # Create a new InterpolatedStringNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode], ?closing_loc: Location?) -> InterpolatedStringNode + def interpolated_string_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode], ?closing_loc: Location?) -> InterpolatedStringNode + + # Create a new InterpolatedSymbolNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location?) -> InterpolatedSymbolNode + def interpolated_symbol_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location?) -> InterpolatedSymbolNode + + # Create a new InterpolatedXStringNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedXStringNode + def interpolated_x_string_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedXStringNode + + # Create a new ItLocalVariableReadNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ItLocalVariableReadNode + def it_local_variable_read_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ItLocalVariableReadNode + + # Create a new ItParametersNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ItParametersNode + def it_parameters_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> ItParametersNode + + # Create a new KeywordHashNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?elements: Array[AssocNode | AssocSplatNode]) -> KeywordHashNode + def keyword_hash_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?elements: Array[AssocNode | AssocSplatNode]) -> KeywordHashNode + + # Create a new KeywordRestParameterNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> KeywordRestParameterNode + def keyword_rest_parameter_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> KeywordRestParameterNode + + # Create a new LambdaNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?operator_loc: Location, ?opening_loc: Location, ?closing_loc: Location, ?parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)?, ?body: (StatementsNode | BeginNode)?) -> LambdaNode + def lambda_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?operator_loc: Location, ?opening_loc: Location, ?closing_loc: Location, ?parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)?, ?body: (StatementsNode | BeginNode)?) -> LambdaNode + + # Create a new LocalVariableAndWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?depth: Integer) -> LocalVariableAndWriteNode + def local_variable_and_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?depth: Integer) -> LocalVariableAndWriteNode + + # Create a new LocalVariableOperatorWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?binary_operator: Symbol, ?depth: Integer) -> LocalVariableOperatorWriteNode + def local_variable_operator_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?binary_operator: Symbol, ?depth: Integer) -> LocalVariableOperatorWriteNode + + # Create a new LocalVariableOrWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?depth: Integer) -> LocalVariableOrWriteNode + def local_variable_or_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?depth: Integer) -> LocalVariableOrWriteNode + + # Create a new LocalVariableReadNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer) -> LocalVariableReadNode + def local_variable_read_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer) -> LocalVariableReadNode + + # Create a new LocalVariableTargetNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer) -> LocalVariableTargetNode + def local_variable_target_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer) -> LocalVariableTargetNode + + # Create a new LocalVariableWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> LocalVariableWriteNode + def local_variable_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> LocalVariableWriteNode + + # Create a new MatchLastLineNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> MatchLastLineNode + def match_last_line_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> MatchLastLineNode + + # Create a new MatchPredicateNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?operator_loc: Location) -> MatchPredicateNode + def match_predicate_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?operator_loc: Location) -> MatchPredicateNode + + # Create a new MatchRequiredNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?operator_loc: Location) -> MatchRequiredNode + def match_required_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?operator_loc: Location) -> MatchRequiredNode + + # Create a new MatchWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?call: CallNode, ?targets: Array[LocalVariableTargetNode]) -> MatchWriteNode + def match_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?call: CallNode, ?targets: Array[LocalVariableTargetNode]) -> MatchWriteNode + + # Create a new MissingNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> MissingNode + def missing_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> MissingNode + + # Create a new ModuleNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?module_keyword_loc: Location, ?constant_path: (ConstantReadNode | ConstantPathNode | MissingNode), ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location, ?name: Symbol) -> ModuleNode + def module_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?module_keyword_loc: Location, ?constant_path: ConstantReadNode | ConstantPathNode | MissingNode, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location, ?name: Symbol) -> ModuleNode + + # Create a new MultiTargetNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode], ?lparen_loc: Location?, ?rparen_loc: Location?) -> MultiTargetNode + def multi_target_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode], ?lparen_loc: Location?, ?rparen_loc: Location?) -> MultiTargetNode + + # Create a new MultiWriteNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode], ?lparen_loc: Location?, ?rparen_loc: Location?, ?operator_loc: Location, ?value: Prism::node) -> MultiWriteNode + def multi_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode], ?lparen_loc: Location?, ?rparen_loc: Location?, ?operator_loc: Location, ?value: Prism::node) -> MultiWriteNode + + # Create a new NextNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> NextNode + def next_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> NextNode + + # Create a new NilNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> NilNode + def nil_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> NilNode + + # Create a new NoBlockParameterNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?keyword_loc: Location) -> NoBlockParameterNode + def no_block_parameter_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?keyword_loc: Location) -> NoBlockParameterNode + + # Create a new NoKeywordsParameterNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?keyword_loc: Location) -> NoKeywordsParameterNode + def no_keywords_parameter_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?keyword_loc: Location) -> NoKeywordsParameterNode + + # Create a new NumberedParametersNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?maximum: Integer) -> NumberedParametersNode + def numbered_parameters_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?maximum: Integer) -> NumberedParametersNode + + # Create a new NumberedReferenceReadNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?number: Integer) -> NumberedReferenceReadNode + def numbered_reference_read_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?number: Integer) -> NumberedReferenceReadNode + + # Create a new OptionalKeywordParameterNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node) -> OptionalKeywordParameterNode + def optional_keyword_parameter_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node) -> OptionalKeywordParameterNode + + # Create a new OptionalParameterNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> OptionalParameterNode + def optional_parameter_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> OptionalParameterNode + + # Create a new OrNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> OrNode + def or_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> OrNode + + # Create a new ParametersNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?requireds: Array[RequiredParameterNode | MultiTargetNode], ?optionals: Array[OptionalParameterNode], ?rest: (RestParameterNode | ImplicitRestNode)?, ?posts: Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode | BlockParameterNode | NoBlockParameterNode], ?keywords: Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode], ?keyword_rest: (KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode)?, ?block: (BlockParameterNode | NoBlockParameterNode)?) -> ParametersNode + def parameters_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?requireds: Array[RequiredParameterNode | MultiTargetNode], ?optionals: Array[OptionalParameterNode], ?rest: (RestParameterNode | ImplicitRestNode)?, ?posts: Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode | BlockParameterNode | NoBlockParameterNode], ?keywords: Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode], ?keyword_rest: (KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode)?, ?block: (BlockParameterNode | NoBlockParameterNode)?) -> ParametersNode + + # Create a new ParenthesesNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Prism::node?, ?opening_loc: Location, ?closing_loc: Location) -> ParenthesesNode + def parentheses_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Prism::node?, ?opening_loc: Location, ?closing_loc: Location) -> ParenthesesNode + + # Create a new PinnedExpressionNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?operator_loc: Location, ?lparen_loc: Location, ?rparen_loc: Location) -> PinnedExpressionNode + def pinned_expression_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?operator_loc: Location, ?lparen_loc: Location, ?rparen_loc: Location) -> PinnedExpressionNode + + # Create a new PinnedVariableNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?variable: (LocalVariableReadNode | InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | ItLocalVariableReadNode | MissingNode), ?operator_loc: Location) -> PinnedVariableNode + def pinned_variable_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?variable: LocalVariableReadNode | InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | ItLocalVariableReadNode | MissingNode, ?operator_loc: Location) -> PinnedVariableNode + + # Create a new PostExecutionNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?statements: StatementsNode?, ?keyword_loc: Location, ?opening_loc: Location, ?closing_loc: Location) -> PostExecutionNode + def post_execution_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?statements: StatementsNode?, ?keyword_loc: Location, ?opening_loc: Location, ?closing_loc: Location) -> PostExecutionNode + + # Create a new PreExecutionNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?statements: StatementsNode?, ?keyword_loc: Location, ?opening_loc: Location, ?closing_loc: Location) -> PreExecutionNode + def pre_execution_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?statements: StatementsNode?, ?keyword_loc: Location, ?opening_loc: Location, ?closing_loc: Location) -> PreExecutionNode + + # Create a new ProgramNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?statements: StatementsNode) -> ProgramNode + def program_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?statements: StatementsNode) -> ProgramNode + + # Create a new RangeNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node?, ?right: Prism::node?, ?operator_loc: Location) -> RangeNode + def range_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node?, ?right: Prism::node?, ?operator_loc: Location) -> RangeNode + + # Create a new RationalNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?numerator: Integer, ?denominator: Integer) -> RationalNode + def rational_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?numerator: Integer, ?denominator: Integer) -> RationalNode + + # Create a new RedoNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> RedoNode + def redo_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> RedoNode + + # Create a new RegularExpressionNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> RegularExpressionNode + def regular_expression_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> RegularExpressionNode + + # Create a new RequiredKeywordParameterNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location) -> RequiredKeywordParameterNode + def required_keyword_parameter_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location) -> RequiredKeywordParameterNode + + # Create a new RequiredParameterNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> RequiredParameterNode + def required_parameter_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> RequiredParameterNode + + # Create a new RescueModifierNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?keyword_loc: Location, ?rescue_expression: Prism::node) -> RescueModifierNode + def rescue_modifier_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?keyword_loc: Location, ?rescue_expression: Prism::node) -> RescueModifierNode + + # Create a new RescueNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?exceptions: Array[Prism::node], ?operator_loc: Location?, ?reference: (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode)?, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?subsequent: RescueNode?) -> RescueNode + def rescue_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?exceptions: Array[Prism::node], ?operator_loc: Location?, ?reference: (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode)?, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?subsequent: RescueNode?) -> RescueNode + + # Create a new RestParameterNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> RestParameterNode + def rest_parameter_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> RestParameterNode + + # Create a new RetryNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> RetryNode + def retry_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> RetryNode + + # Create a new ReturnNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?arguments: ArgumentsNode?) -> ReturnNode + def return_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?arguments: ArgumentsNode?) -> ReturnNode + + # Create a new SelfNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> SelfNode + def self_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> SelfNode + + # Create a new ShareableConstantNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?write: (ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode)) -> ShareableConstantNode + def shareable_constant_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?write: ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode) -> ShareableConstantNode + + # Create a new SingletonClassNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?class_keyword_loc: Location, ?operator_loc: Location, ?expression: Prism::node, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location) -> SingletonClassNode + def singleton_class_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?class_keyword_loc: Location, ?operator_loc: Location, ?expression: Prism::node, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location) -> SingletonClassNode + + # Create a new SourceEncodingNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> SourceEncodingNode + def source_encoding_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> SourceEncodingNode + + # Create a new SourceFileNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?filepath: String) -> SourceFileNode + def source_file_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?filepath: String) -> SourceFileNode + + # Create a new SourceLineNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> SourceLineNode + def source_line_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> SourceLineNode + + # Create a new SplatNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?expression: Prism::node?) -> SplatNode + def splat_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?expression: Prism::node?) -> SplatNode + + # Create a new StatementsNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Array[Prism::node]) -> StatementsNode + def statements_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Array[Prism::node]) -> StatementsNode + + # Create a new StringNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?content_loc: Location, ?closing_loc: Location?, ?unescaped: String) -> StringNode + def string_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?content_loc: Location, ?closing_loc: Location?, ?unescaped: String) -> StringNode + + # Create a new SuperNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?, ?block: (BlockNode | BlockArgumentNode)?) -> SuperNode + def super_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?, ?block: (BlockNode | BlockArgumentNode)?) -> SuperNode + + # Create a new SymbolNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?value_loc: Location?, ?closing_loc: Location?, ?unescaped: String) -> SymbolNode + def symbol_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?value_loc: Location?, ?closing_loc: Location?, ?unescaped: String) -> SymbolNode + + # Create a new TrueNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> TrueNode + def true_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer) -> TrueNode + + # Create a new UndefNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?names: Array[SymbolNode | InterpolatedSymbolNode], ?keyword_loc: Location) -> UndefNode + def undef_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?names: Array[SymbolNode | InterpolatedSymbolNode], ?keyword_loc: Location) -> UndefNode + + # Create a new UnlessNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?else_clause: ElseNode?, ?end_keyword_loc: Location?) -> UnlessNode + def unless_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?else_clause: ElseNode?, ?end_keyword_loc: Location?) -> UnlessNode + + # Create a new UntilNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?do_keyword_loc: Location?, ?closing_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) -> UntilNode + def until_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?do_keyword_loc: Location?, ?closing_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) -> UntilNode + + # Create a new WhenNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?conditions: Array[Prism::node], ?then_keyword_loc: Location?, ?statements: StatementsNode?) -> WhenNode + def when_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?conditions: Array[Prism::node], ?then_keyword_loc: Location?, ?statements: StatementsNode?) -> WhenNode + + # Create a new WhileNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?do_keyword_loc: Location?, ?closing_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) -> WhileNode + def while_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?do_keyword_loc: Location?, ?closing_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) -> WhileNode + + # Create a new XStringNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> XStringNode + def x_string_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> XStringNode + + # Create a new YieldNode node. + # -- + # : (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?) -> YieldNode + def yield_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?) -> YieldNode + + # Retrieve the value of one of the ArgumentsNodeFlags flags. + # -- + # : (Symbol name) -> Integer + def arguments_node_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the ArrayNodeFlags flags. + # -- + # : (Symbol name) -> Integer + def array_node_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the CallNodeFlags flags. + # -- + # : (Symbol name) -> Integer + def call_node_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the EncodingFlags flags. + # -- + # : (Symbol name) -> Integer + def encoding_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the IntegerBaseFlags flags. + # -- + # : (Symbol name) -> Integer + def integer_base_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the InterpolatedStringNodeFlags flags. + # -- + # : (Symbol name) -> Integer + def interpolated_string_node_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the KeywordHashNodeFlags flags. + # -- + # : (Symbol name) -> Integer + def keyword_hash_node_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the LoopFlags flags. + # -- + # : (Symbol name) -> Integer + def loop_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the ParameterFlags flags. + # -- + # : (Symbol name) -> Integer + def parameter_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the ParenthesesNodeFlags flags. + # -- + # : (Symbol name) -> Integer + def parentheses_node_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the RangeFlags flags. + # -- + # : (Symbol name) -> Integer + def range_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the RegularExpressionFlags flags. + # -- + # : (Symbol name) -> Integer + def regular_expression_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the ShareableConstantNodeFlags flags. + # -- + # : (Symbol name) -> Integer + def shareable_constant_node_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the StringFlags flags. + # -- + # : (Symbol name) -> Integer + def string_flag: (Symbol name) -> Integer + + # Retrieve the value of one of the SymbolFlags flags. + # -- + # : (Symbol name) -> Integer + def symbol_flag: (Symbol name) -> Integer + + private + + # The default source object that gets attached to nodes and locations if no + # source is specified. + # -- + # : () -> Source + def default_source: () -> Source + + # The default location object that gets attached to nodes if no location is + # specified, which uses the given source. + # -- + # : () -> Location + def default_location: () -> Location + + # The default node that gets attached to nodes if no node is specified for a + # required node field. + # -- + # : (Source source, Location location) -> node + def default_node: (Source source, Location location) -> node + end +end diff --git a/sig/generated/prism/inspect_visitor.rbs b/sig/generated/prism/inspect_visitor.rbs new file mode 100644 index 0000000000..1219427ceb --- /dev/null +++ b/sig/generated/prism/inspect_visitor.rbs @@ -0,0 +1,509 @@ +# Generated from lib/prism/inspect_visitor.rb with RBS::Inline + +module Prism + # This visitor is responsible for composing the strings that get returned by + # the various #inspect methods defined on each of the nodes. + class InspectVisitor < Visitor + # Most of the time, we can simply pass down the indent to the next node. + # However, when we are inside a list we want some extra special formatting + # when we hit an element in that list. In this case, we have a special + # command that replaces the subsequent indent with the given value. + class Replace + # :nodoc: + attr_reader value: String + + # : (String value) -> void + def initialize: (String value) -> void + end + + # The current prefix string. + # :stopdoc: + attr_reader indent: String + + # The list of commands that we need to execute in order to compose the + # final string. + # : stopdoc: + attr_reader commands: Array[[ String | node | Replace, String ]] + + # : (?String indent) -> void + def initialize: (?String indent) -> void + + # Compose an inspect string for the given node. + # -- + # : (node node) -> String + def self.compose: (node node) -> String + + # Compose the final string. + # -- + # : () -> String + def compose: () -> String + + # : (AliasGlobalVariableNode node) -> void + def visit_alias_global_variable_node: (AliasGlobalVariableNode node) -> void + + # : (AliasMethodNode node) -> void + def visit_alias_method_node: (AliasMethodNode node) -> void + + # : (AlternationPatternNode node) -> void + def visit_alternation_pattern_node: (AlternationPatternNode node) -> void + + # : (AndNode node) -> void + def visit_and_node: (AndNode node) -> void + + # : (ArgumentsNode node) -> void + def visit_arguments_node: (ArgumentsNode node) -> void + + # : (ArrayNode node) -> void + def visit_array_node: (ArrayNode node) -> void + + # : (ArrayPatternNode node) -> void + def visit_array_pattern_node: (ArrayPatternNode node) -> void + + # : (AssocNode node) -> void + def visit_assoc_node: (AssocNode node) -> void + + # : (AssocSplatNode node) -> void + def visit_assoc_splat_node: (AssocSplatNode node) -> void + + # : (BackReferenceReadNode node) -> void + def visit_back_reference_read_node: (BackReferenceReadNode node) -> void + + # : (BeginNode node) -> void + def visit_begin_node: (BeginNode node) -> void + + # : (BlockArgumentNode node) -> void + def visit_block_argument_node: (BlockArgumentNode node) -> void + + # : (BlockLocalVariableNode node) -> void + def visit_block_local_variable_node: (BlockLocalVariableNode node) -> void + + # : (BlockNode node) -> void + def visit_block_node: (BlockNode node) -> void + + # : (BlockParameterNode node) -> void + def visit_block_parameter_node: (BlockParameterNode node) -> void + + # : (BlockParametersNode node) -> void + def visit_block_parameters_node: (BlockParametersNode node) -> void + + # : (BreakNode node) -> void + def visit_break_node: (BreakNode node) -> void + + # : (CallAndWriteNode node) -> void + def visit_call_and_write_node: (CallAndWriteNode node) -> void + + # : (CallNode node) -> void + def visit_call_node: (CallNode node) -> void + + # : (CallOperatorWriteNode node) -> void + def visit_call_operator_write_node: (CallOperatorWriteNode node) -> void + + # : (CallOrWriteNode node) -> void + def visit_call_or_write_node: (CallOrWriteNode node) -> void + + # : (CallTargetNode node) -> void + def visit_call_target_node: (CallTargetNode node) -> void + + # : (CapturePatternNode node) -> void + def visit_capture_pattern_node: (CapturePatternNode node) -> void + + # : (CaseMatchNode node) -> void + def visit_case_match_node: (CaseMatchNode node) -> void + + # : (CaseNode node) -> void + def visit_case_node: (CaseNode node) -> void + + # : (ClassNode node) -> void + def visit_class_node: (ClassNode node) -> void + + # : (ClassVariableAndWriteNode node) -> void + def visit_class_variable_and_write_node: (ClassVariableAndWriteNode node) -> void + + # : (ClassVariableOperatorWriteNode node) -> void + def visit_class_variable_operator_write_node: (ClassVariableOperatorWriteNode node) -> void + + # : (ClassVariableOrWriteNode node) -> void + def visit_class_variable_or_write_node: (ClassVariableOrWriteNode node) -> void + + # : (ClassVariableReadNode node) -> void + def visit_class_variable_read_node: (ClassVariableReadNode node) -> void + + # : (ClassVariableTargetNode node) -> void + def visit_class_variable_target_node: (ClassVariableTargetNode node) -> void + + # : (ClassVariableWriteNode node) -> void + def visit_class_variable_write_node: (ClassVariableWriteNode node) -> void + + # : (ConstantAndWriteNode node) -> void + def visit_constant_and_write_node: (ConstantAndWriteNode node) -> void + + # : (ConstantOperatorWriteNode node) -> void + def visit_constant_operator_write_node: (ConstantOperatorWriteNode node) -> void + + # : (ConstantOrWriteNode node) -> void + def visit_constant_or_write_node: (ConstantOrWriteNode node) -> void + + # : (ConstantPathAndWriteNode node) -> void + def visit_constant_path_and_write_node: (ConstantPathAndWriteNode node) -> void + + # : (ConstantPathNode node) -> void + def visit_constant_path_node: (ConstantPathNode node) -> void + + # : (ConstantPathOperatorWriteNode node) -> void + def visit_constant_path_operator_write_node: (ConstantPathOperatorWriteNode node) -> void + + # : (ConstantPathOrWriteNode node) -> void + def visit_constant_path_or_write_node: (ConstantPathOrWriteNode node) -> void + + # : (ConstantPathTargetNode node) -> void + def visit_constant_path_target_node: (ConstantPathTargetNode node) -> void + + # : (ConstantPathWriteNode node) -> void + def visit_constant_path_write_node: (ConstantPathWriteNode node) -> void + + # : (ConstantReadNode node) -> void + def visit_constant_read_node: (ConstantReadNode node) -> void + + # : (ConstantTargetNode node) -> void + def visit_constant_target_node: (ConstantTargetNode node) -> void + + # : (ConstantWriteNode node) -> void + def visit_constant_write_node: (ConstantWriteNode node) -> void + + # : (DefNode node) -> void + def visit_def_node: (DefNode node) -> void + + # : (DefinedNode node) -> void + def visit_defined_node: (DefinedNode node) -> void + + # : (ElseNode node) -> void + def visit_else_node: (ElseNode node) -> void + + # : (EmbeddedStatementsNode node) -> void + def visit_embedded_statements_node: (EmbeddedStatementsNode node) -> void + + # : (EmbeddedVariableNode node) -> void + def visit_embedded_variable_node: (EmbeddedVariableNode node) -> void + + # : (EnsureNode node) -> void + def visit_ensure_node: (EnsureNode node) -> void + + # : (FalseNode node) -> void + def visit_false_node: (FalseNode node) -> void + + # : (FindPatternNode node) -> void + def visit_find_pattern_node: (FindPatternNode node) -> void + + # : (FlipFlopNode node) -> void + def visit_flip_flop_node: (FlipFlopNode node) -> void + + # : (FloatNode node) -> void + def visit_float_node: (FloatNode node) -> void + + # : (ForNode node) -> void + def visit_for_node: (ForNode node) -> void + + # : (ForwardingArgumentsNode node) -> void + def visit_forwarding_arguments_node: (ForwardingArgumentsNode node) -> void + + # : (ForwardingParameterNode node) -> void + def visit_forwarding_parameter_node: (ForwardingParameterNode node) -> void + + # : (ForwardingSuperNode node) -> void + def visit_forwarding_super_node: (ForwardingSuperNode node) -> void + + # : (GlobalVariableAndWriteNode node) -> void + def visit_global_variable_and_write_node: (GlobalVariableAndWriteNode node) -> void + + # : (GlobalVariableOperatorWriteNode node) -> void + def visit_global_variable_operator_write_node: (GlobalVariableOperatorWriteNode node) -> void + + # : (GlobalVariableOrWriteNode node) -> void + def visit_global_variable_or_write_node: (GlobalVariableOrWriteNode node) -> void + + # : (GlobalVariableReadNode node) -> void + def visit_global_variable_read_node: (GlobalVariableReadNode node) -> void + + # : (GlobalVariableTargetNode node) -> void + def visit_global_variable_target_node: (GlobalVariableTargetNode node) -> void + + # : (GlobalVariableWriteNode node) -> void + def visit_global_variable_write_node: (GlobalVariableWriteNode node) -> void + + # : (HashNode node) -> void + def visit_hash_node: (HashNode node) -> void + + # : (HashPatternNode node) -> void + def visit_hash_pattern_node: (HashPatternNode node) -> void + + # : (IfNode node) -> void + def visit_if_node: (IfNode node) -> void + + # : (ImaginaryNode node) -> void + def visit_imaginary_node: (ImaginaryNode node) -> void + + # : (ImplicitNode node) -> void + def visit_implicit_node: (ImplicitNode node) -> void + + # : (ImplicitRestNode node) -> void + def visit_implicit_rest_node: (ImplicitRestNode node) -> void + + # : (InNode node) -> void + def visit_in_node: (InNode node) -> void + + # : (IndexAndWriteNode node) -> void + def visit_index_and_write_node: (IndexAndWriteNode node) -> void + + # : (IndexOperatorWriteNode node) -> void + def visit_index_operator_write_node: (IndexOperatorWriteNode node) -> void + + # : (IndexOrWriteNode node) -> void + def visit_index_or_write_node: (IndexOrWriteNode node) -> void + + # : (IndexTargetNode node) -> void + def visit_index_target_node: (IndexTargetNode node) -> void + + # : (InstanceVariableAndWriteNode node) -> void + def visit_instance_variable_and_write_node: (InstanceVariableAndWriteNode node) -> void + + # : (InstanceVariableOperatorWriteNode node) -> void + def visit_instance_variable_operator_write_node: (InstanceVariableOperatorWriteNode node) -> void + + # : (InstanceVariableOrWriteNode node) -> void + def visit_instance_variable_or_write_node: (InstanceVariableOrWriteNode node) -> void + + # : (InstanceVariableReadNode node) -> void + def visit_instance_variable_read_node: (InstanceVariableReadNode node) -> void + + # : (InstanceVariableTargetNode node) -> void + def visit_instance_variable_target_node: (InstanceVariableTargetNode node) -> void + + # : (InstanceVariableWriteNode node) -> void + def visit_instance_variable_write_node: (InstanceVariableWriteNode node) -> void + + # : (IntegerNode node) -> void + def visit_integer_node: (IntegerNode node) -> void + + # : (InterpolatedMatchLastLineNode node) -> void + def visit_interpolated_match_last_line_node: (InterpolatedMatchLastLineNode node) -> void + + # : (InterpolatedRegularExpressionNode node) -> void + def visit_interpolated_regular_expression_node: (InterpolatedRegularExpressionNode node) -> void + + # : (InterpolatedStringNode node) -> void + def visit_interpolated_string_node: (InterpolatedStringNode node) -> void + + # : (InterpolatedSymbolNode node) -> void + def visit_interpolated_symbol_node: (InterpolatedSymbolNode node) -> void + + # : (InterpolatedXStringNode node) -> void + def visit_interpolated_x_string_node: (InterpolatedXStringNode node) -> void + + # : (ItLocalVariableReadNode node) -> void + def visit_it_local_variable_read_node: (ItLocalVariableReadNode node) -> void + + # : (ItParametersNode node) -> void + def visit_it_parameters_node: (ItParametersNode node) -> void + + # : (KeywordHashNode node) -> void + def visit_keyword_hash_node: (KeywordHashNode node) -> void + + # : (KeywordRestParameterNode node) -> void + def visit_keyword_rest_parameter_node: (KeywordRestParameterNode node) -> void + + # : (LambdaNode node) -> void + def visit_lambda_node: (LambdaNode node) -> void + + # : (LocalVariableAndWriteNode node) -> void + def visit_local_variable_and_write_node: (LocalVariableAndWriteNode node) -> void + + # : (LocalVariableOperatorWriteNode node) -> void + def visit_local_variable_operator_write_node: (LocalVariableOperatorWriteNode node) -> void + + # : (LocalVariableOrWriteNode node) -> void + def visit_local_variable_or_write_node: (LocalVariableOrWriteNode node) -> void + + # : (LocalVariableReadNode node) -> void + def visit_local_variable_read_node: (LocalVariableReadNode node) -> void + + # : (LocalVariableTargetNode node) -> void + def visit_local_variable_target_node: (LocalVariableTargetNode node) -> void + + # : (LocalVariableWriteNode node) -> void + def visit_local_variable_write_node: (LocalVariableWriteNode node) -> void + + # : (MatchLastLineNode node) -> void + def visit_match_last_line_node: (MatchLastLineNode node) -> void + + # : (MatchPredicateNode node) -> void + def visit_match_predicate_node: (MatchPredicateNode node) -> void + + # : (MatchRequiredNode node) -> void + def visit_match_required_node: (MatchRequiredNode node) -> void + + # : (MatchWriteNode node) -> void + def visit_match_write_node: (MatchWriteNode node) -> void + + # : (MissingNode node) -> void + def visit_missing_node: (MissingNode node) -> void + + # : (ModuleNode node) -> void + def visit_module_node: (ModuleNode node) -> void + + # : (MultiTargetNode node) -> void + def visit_multi_target_node: (MultiTargetNode node) -> void + + # : (MultiWriteNode node) -> void + def visit_multi_write_node: (MultiWriteNode node) -> void + + # : (NextNode node) -> void + def visit_next_node: (NextNode node) -> void + + # : (NilNode node) -> void + def visit_nil_node: (NilNode node) -> void + + # : (NoBlockParameterNode node) -> void + def visit_no_block_parameter_node: (NoBlockParameterNode node) -> void + + # : (NoKeywordsParameterNode node) -> void + def visit_no_keywords_parameter_node: (NoKeywordsParameterNode node) -> void + + # : (NumberedParametersNode node) -> void + def visit_numbered_parameters_node: (NumberedParametersNode node) -> void + + # : (NumberedReferenceReadNode node) -> void + def visit_numbered_reference_read_node: (NumberedReferenceReadNode node) -> void + + # : (OptionalKeywordParameterNode node) -> void + def visit_optional_keyword_parameter_node: (OptionalKeywordParameterNode node) -> void + + # : (OptionalParameterNode node) -> void + def visit_optional_parameter_node: (OptionalParameterNode node) -> void + + # : (OrNode node) -> void + def visit_or_node: (OrNode node) -> void + + # : (ParametersNode node) -> void + def visit_parameters_node: (ParametersNode node) -> void + + # : (ParenthesesNode node) -> void + def visit_parentheses_node: (ParenthesesNode node) -> void + + # : (PinnedExpressionNode node) -> void + def visit_pinned_expression_node: (PinnedExpressionNode node) -> void + + # : (PinnedVariableNode node) -> void + def visit_pinned_variable_node: (PinnedVariableNode node) -> void + + # : (PostExecutionNode node) -> void + def visit_post_execution_node: (PostExecutionNode node) -> void + + # : (PreExecutionNode node) -> void + def visit_pre_execution_node: (PreExecutionNode node) -> void + + # : (ProgramNode node) -> void + def visit_program_node: (ProgramNode node) -> void + + # : (RangeNode node) -> void + def visit_range_node: (RangeNode node) -> void + + # : (RationalNode node) -> void + def visit_rational_node: (RationalNode node) -> void + + # : (RedoNode node) -> void + def visit_redo_node: (RedoNode node) -> void + + # : (RegularExpressionNode node) -> void + def visit_regular_expression_node: (RegularExpressionNode node) -> void + + # : (RequiredKeywordParameterNode node) -> void + def visit_required_keyword_parameter_node: (RequiredKeywordParameterNode node) -> void + + # : (RequiredParameterNode node) -> void + def visit_required_parameter_node: (RequiredParameterNode node) -> void + + # : (RescueModifierNode node) -> void + def visit_rescue_modifier_node: (RescueModifierNode node) -> void + + # : (RescueNode node) -> void + def visit_rescue_node: (RescueNode node) -> void + + # : (RestParameterNode node) -> void + def visit_rest_parameter_node: (RestParameterNode node) -> void + + # : (RetryNode node) -> void + def visit_retry_node: (RetryNode node) -> void + + # : (ReturnNode node) -> void + def visit_return_node: (ReturnNode node) -> void + + # : (SelfNode node) -> void + def visit_self_node: (SelfNode node) -> void + + # : (ShareableConstantNode node) -> void + def visit_shareable_constant_node: (ShareableConstantNode node) -> void + + # : (SingletonClassNode node) -> void + def visit_singleton_class_node: (SingletonClassNode node) -> void + + # : (SourceEncodingNode node) -> void + def visit_source_encoding_node: (SourceEncodingNode node) -> void + + # : (SourceFileNode node) -> void + def visit_source_file_node: (SourceFileNode node) -> void + + # : (SourceLineNode node) -> void + def visit_source_line_node: (SourceLineNode node) -> void + + # : (SplatNode node) -> void + def visit_splat_node: (SplatNode node) -> void + + # : (StatementsNode node) -> void + def visit_statements_node: (StatementsNode node) -> void + + # : (StringNode node) -> void + def visit_string_node: (StringNode node) -> void + + # : (SuperNode node) -> void + def visit_super_node: (SuperNode node) -> void + + # : (SymbolNode node) -> void + def visit_symbol_node: (SymbolNode node) -> void + + # : (TrueNode node) -> void + def visit_true_node: (TrueNode node) -> void + + # : (UndefNode node) -> void + def visit_undef_node: (UndefNode node) -> void + + # : (UnlessNode node) -> void + def visit_unless_node: (UnlessNode node) -> void + + # : (UntilNode node) -> void + def visit_until_node: (UntilNode node) -> void + + # : (WhenNode node) -> void + def visit_when_node: (WhenNode node) -> void + + # : (WhileNode node) -> void + def visit_while_node: (WhileNode node) -> void + + # : (XStringNode node) -> void + def visit_x_string_node: (XStringNode node) -> void + + # : (YieldNode node) -> void + def visit_yield_node: (YieldNode node) -> void + + private + + # Compose a header for the given node. + # -- + # : (String name, node node) -> String + def inspect_node: (String name, node node) -> String + + # Compose a string representing the given inner location field. + # -- + # : (Location? location) -> String + def inspect_location: (Location? location) -> String + end +end diff --git a/sig/generated/prism/lex_compat.rbs b/sig/generated/prism/lex_compat.rbs new file mode 100644 index 0000000000..4c9e6d9c16 --- /dev/null +++ b/sig/generated/prism/lex_compat.rbs @@ -0,0 +1,151 @@ +# Generated from lib/prism/lex_compat.rb with RBS::Inline + +module Prism + module Translation + class Ripper + EXPR_BEG: Integer + + class Lexer < Ripper + class State + def self.[]: (Integer value) -> State + end + end + end + end + + # This class is responsible for lexing the source using prism and then + # converting those tokens to be compatible with Ripper. In the vast majority + # of cases, this is a one-to-one mapping of the token type. Everything else + # generally lines up. However, there are a few cases that require special + # handling. + class LexCompat + # A token produced by the Ripper lexer that Prism is replicating. + type lex_compat_token = [ [ Integer, Integer ], Symbol, String, untyped ] + + # A result class specialized for holding tokens produced by the lexer. + class Result < Prism::Result + # The list of tokens that were produced by the lexer. + attr_reader value: Array[lex_compat_token] + + # Create a new lex compat result object with the given values. + # -- + # : (Array[lex_compat_token] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void + def initialize: (Array[lex_compat_token] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void + + # Implement the hash pattern matching interface for Result. + # -- + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + end + + # This is a mapping of prism token types to Ripper token types. This is a + # many-to-one mapping because we split up our token types, whereas Ripper + # tends to group them. + RIPPER: untyped + + # A heredoc in this case is a list of tokens that belong to the body of the + # heredoc that should be appended onto the list of tokens when the heredoc + # closes. + module Heredoc + # Heredocs that are no dash or tilde heredocs are just a list of tokens. + # We need to keep them around so that we can insert them in the correct + # order back into the token stream and set the state of the last token to + # the state that the heredoc was opened in. + class PlainHeredoc + # :nodoc: + attr_reader tokens: Array[lex_compat_token] + + # : () -> void + def initialize: () -> void + + # : (lex_compat_token token) -> void + def <<: (lex_compat_token token) -> void + + # : () -> Array[lex_compat_token] + def to_a: () -> Array[lex_compat_token] + end + + # Dash heredocs are a little more complicated. They are a list of tokens + # that need to be split on "\\\n" to mimic Ripper's behavior. We also need + # to keep track of the state that the heredoc was opened in. + class DashHeredoc + # :nodoc: + attr_reader split: bool + + attr_reader tokens: Array[lex_compat_token] + + # : (bool split) -> void + def initialize: (bool split) -> void + + # : (lex_compat_token token) -> void + def <<: (lex_compat_token token) -> void + + # : () -> Array[lex_compat_token] + def to_a: () -> Array[lex_compat_token] + end + + # Heredocs that are dedenting heredocs are a little more complicated. + # Ripper outputs on_ignored_sp tokens for the whitespace that is being + # removed from the output. prism only modifies the node itself and keeps + # the token the same. This simplifies prism, but makes comparing against + # Ripper much harder because there is a length mismatch. + # + # Fortunately, we already have to pull out the heredoc tokens in order to + # insert them into the stream in the correct order. As such, we can do + # some extra manipulation on the tokens to make them match Ripper's + # output by mirroring the dedent logic that Ripper uses. + class DedentingHeredoc + # :nodoc: + TAB_WIDTH: ::Integer + + attr_reader tokens: Array[lex_compat_token] + + attr_reader dedent_next: bool + + attr_reader dedent: Integer? + + attr_reader embexpr_balance: Integer + + @ended_on_newline: bool + + # : () -> void + def initialize: () -> void + + # As tokens are coming in, we track the minimum amount of common leading + # whitespace on plain string content tokens. This allows us to later + # remove that amount of whitespace from the beginning of each line. + # + # : (lex_compat_token token) -> void + def <<: (lex_compat_token token) -> void + + # : () -> Array[lex_compat_token] + def to_a: () -> Array[lex_compat_token] + end + + # Here we will split between the two types of heredocs and return the + # object that will store their tokens. + # -- + # : (lex_compat_token opening) -> (PlainHeredoc | DashHeredoc | DedentingHeredoc) + def self.build: (lex_compat_token opening) -> (PlainHeredoc | DashHeredoc | DedentingHeredoc) + end + + # In previous versions of Ruby, Ripper wouldn't flush the bom before the + # first token, so we had to have a hack in place to account for that. + BOM_FLUSHED: untyped + + attr_reader options: Hash[Symbol, untyped] + + @source: String + + # : (String source, **untyped options) -> void + def initialize: (String source, **untyped options) -> void + + # : () -> Result + def result: () -> Result + + private + + # : (Array[lex_compat_token] tokens, Source source, Location? data_loc, bool bom, Token? eof_token) -> Array[lex_compat_token] + def post_process_tokens: (Array[lex_compat_token] tokens, Source source, Location? data_loc, bool bom, Token? eof_token) -> Array[lex_compat_token] + end +end diff --git a/sig/generated/prism/mutation_compiler.rbs b/sig/generated/prism/mutation_compiler.rbs new file mode 100644 index 0000000000..e79f254372 --- /dev/null +++ b/sig/generated/prism/mutation_compiler.rbs @@ -0,0 +1,464 @@ +# Generated from lib/prism/mutation_compiler.rb with RBS::Inline + +module Prism + # This visitor walks through the tree and copies each node as it is being + # visited. This is useful for consumers that want to mutate the tree, as you + # can change subtrees in place without effecting the rest of the tree. + class MutationCompiler < Compiler + # : (AliasGlobalVariableNode) -> node? + def visit_alias_global_variable_node: (AliasGlobalVariableNode) -> node? + + # : (AliasMethodNode) -> node? + def visit_alias_method_node: (AliasMethodNode) -> node? + + # : (AlternationPatternNode) -> node? + def visit_alternation_pattern_node: (AlternationPatternNode) -> node? + + # : (AndNode) -> node? + def visit_and_node: (AndNode) -> node? + + # : (ArgumentsNode) -> node? + def visit_arguments_node: (ArgumentsNode) -> node? + + # : (ArrayNode) -> node? + def visit_array_node: (ArrayNode) -> node? + + # : (ArrayPatternNode) -> node? + def visit_array_pattern_node: (ArrayPatternNode) -> node? + + # : (AssocNode) -> node? + def visit_assoc_node: (AssocNode) -> node? + + # : (AssocSplatNode) -> node? + def visit_assoc_splat_node: (AssocSplatNode) -> node? + + # : (BackReferenceReadNode) -> node? + def visit_back_reference_read_node: (BackReferenceReadNode) -> node? + + # : (BeginNode) -> node? + def visit_begin_node: (BeginNode) -> node? + + # : (BlockArgumentNode) -> node? + def visit_block_argument_node: (BlockArgumentNode) -> node? + + # : (BlockLocalVariableNode) -> node? + def visit_block_local_variable_node: (BlockLocalVariableNode) -> node? + + # : (BlockNode) -> node? + def visit_block_node: (BlockNode) -> node? + + # : (BlockParameterNode) -> node? + def visit_block_parameter_node: (BlockParameterNode) -> node? + + # : (BlockParametersNode) -> node? + def visit_block_parameters_node: (BlockParametersNode) -> node? + + # : (BreakNode) -> node? + def visit_break_node: (BreakNode) -> node? + + # : (CallAndWriteNode) -> node? + def visit_call_and_write_node: (CallAndWriteNode) -> node? + + # : (CallNode) -> node? + def visit_call_node: (CallNode) -> node? + + # : (CallOperatorWriteNode) -> node? + def visit_call_operator_write_node: (CallOperatorWriteNode) -> node? + + # : (CallOrWriteNode) -> node? + def visit_call_or_write_node: (CallOrWriteNode) -> node? + + # : (CallTargetNode) -> node? + def visit_call_target_node: (CallTargetNode) -> node? + + # : (CapturePatternNode) -> node? + def visit_capture_pattern_node: (CapturePatternNode) -> node? + + # : (CaseMatchNode) -> node? + def visit_case_match_node: (CaseMatchNode) -> node? + + # : (CaseNode) -> node? + def visit_case_node: (CaseNode) -> node? + + # : (ClassNode) -> node? + def visit_class_node: (ClassNode) -> node? + + # : (ClassVariableAndWriteNode) -> node? + def visit_class_variable_and_write_node: (ClassVariableAndWriteNode) -> node? + + # : (ClassVariableOperatorWriteNode) -> node? + def visit_class_variable_operator_write_node: (ClassVariableOperatorWriteNode) -> node? + + # : (ClassVariableOrWriteNode) -> node? + def visit_class_variable_or_write_node: (ClassVariableOrWriteNode) -> node? + + # : (ClassVariableReadNode) -> node? + def visit_class_variable_read_node: (ClassVariableReadNode) -> node? + + # : (ClassVariableTargetNode) -> node? + def visit_class_variable_target_node: (ClassVariableTargetNode) -> node? + + # : (ClassVariableWriteNode) -> node? + def visit_class_variable_write_node: (ClassVariableWriteNode) -> node? + + # : (ConstantAndWriteNode) -> node? + def visit_constant_and_write_node: (ConstantAndWriteNode) -> node? + + # : (ConstantOperatorWriteNode) -> node? + def visit_constant_operator_write_node: (ConstantOperatorWriteNode) -> node? + + # : (ConstantOrWriteNode) -> node? + def visit_constant_or_write_node: (ConstantOrWriteNode) -> node? + + # : (ConstantPathAndWriteNode) -> node? + def visit_constant_path_and_write_node: (ConstantPathAndWriteNode) -> node? + + # : (ConstantPathNode) -> node? + def visit_constant_path_node: (ConstantPathNode) -> node? + + # : (ConstantPathOperatorWriteNode) -> node? + def visit_constant_path_operator_write_node: (ConstantPathOperatorWriteNode) -> node? + + # : (ConstantPathOrWriteNode) -> node? + def visit_constant_path_or_write_node: (ConstantPathOrWriteNode) -> node? + + # : (ConstantPathTargetNode) -> node? + def visit_constant_path_target_node: (ConstantPathTargetNode) -> node? + + # : (ConstantPathWriteNode) -> node? + def visit_constant_path_write_node: (ConstantPathWriteNode) -> node? + + # : (ConstantReadNode) -> node? + def visit_constant_read_node: (ConstantReadNode) -> node? + + # : (ConstantTargetNode) -> node? + def visit_constant_target_node: (ConstantTargetNode) -> node? + + # : (ConstantWriteNode) -> node? + def visit_constant_write_node: (ConstantWriteNode) -> node? + + # : (DefNode) -> node? + def visit_def_node: (DefNode) -> node? + + # : (DefinedNode) -> node? + def visit_defined_node: (DefinedNode) -> node? + + # : (ElseNode) -> node? + def visit_else_node: (ElseNode) -> node? + + # : (EmbeddedStatementsNode) -> node? + def visit_embedded_statements_node: (EmbeddedStatementsNode) -> node? + + # : (EmbeddedVariableNode) -> node? + def visit_embedded_variable_node: (EmbeddedVariableNode) -> node? + + # : (EnsureNode) -> node? + def visit_ensure_node: (EnsureNode) -> node? + + # : (FalseNode) -> node? + def visit_false_node: (FalseNode) -> node? + + # : (FindPatternNode) -> node? + def visit_find_pattern_node: (FindPatternNode) -> node? + + # : (FlipFlopNode) -> node? + def visit_flip_flop_node: (FlipFlopNode) -> node? + + # : (FloatNode) -> node? + def visit_float_node: (FloatNode) -> node? + + # : (ForNode) -> node? + def visit_for_node: (ForNode) -> node? + + # : (ForwardingArgumentsNode) -> node? + def visit_forwarding_arguments_node: (ForwardingArgumentsNode) -> node? + + # : (ForwardingParameterNode) -> node? + def visit_forwarding_parameter_node: (ForwardingParameterNode) -> node? + + # : (ForwardingSuperNode) -> node? + def visit_forwarding_super_node: (ForwardingSuperNode) -> node? + + # : (GlobalVariableAndWriteNode) -> node? + def visit_global_variable_and_write_node: (GlobalVariableAndWriteNode) -> node? + + # : (GlobalVariableOperatorWriteNode) -> node? + def visit_global_variable_operator_write_node: (GlobalVariableOperatorWriteNode) -> node? + + # : (GlobalVariableOrWriteNode) -> node? + def visit_global_variable_or_write_node: (GlobalVariableOrWriteNode) -> node? + + # : (GlobalVariableReadNode) -> node? + def visit_global_variable_read_node: (GlobalVariableReadNode) -> node? + + # : (GlobalVariableTargetNode) -> node? + def visit_global_variable_target_node: (GlobalVariableTargetNode) -> node? + + # : (GlobalVariableWriteNode) -> node? + def visit_global_variable_write_node: (GlobalVariableWriteNode) -> node? + + # : (HashNode) -> node? + def visit_hash_node: (HashNode) -> node? + + # : (HashPatternNode) -> node? + def visit_hash_pattern_node: (HashPatternNode) -> node? + + # : (IfNode) -> node? + def visit_if_node: (IfNode) -> node? + + # : (ImaginaryNode) -> node? + def visit_imaginary_node: (ImaginaryNode) -> node? + + # : (ImplicitNode) -> node? + def visit_implicit_node: (ImplicitNode) -> node? + + # : (ImplicitRestNode) -> node? + def visit_implicit_rest_node: (ImplicitRestNode) -> node? + + # : (InNode) -> node? + def visit_in_node: (InNode) -> node? + + # : (IndexAndWriteNode) -> node? + def visit_index_and_write_node: (IndexAndWriteNode) -> node? + + # : (IndexOperatorWriteNode) -> node? + def visit_index_operator_write_node: (IndexOperatorWriteNode) -> node? + + # : (IndexOrWriteNode) -> node? + def visit_index_or_write_node: (IndexOrWriteNode) -> node? + + # : (IndexTargetNode) -> node? + def visit_index_target_node: (IndexTargetNode) -> node? + + # : (InstanceVariableAndWriteNode) -> node? + def visit_instance_variable_and_write_node: (InstanceVariableAndWriteNode) -> node? + + # : (InstanceVariableOperatorWriteNode) -> node? + def visit_instance_variable_operator_write_node: (InstanceVariableOperatorWriteNode) -> node? + + # : (InstanceVariableOrWriteNode) -> node? + def visit_instance_variable_or_write_node: (InstanceVariableOrWriteNode) -> node? + + # : (InstanceVariableReadNode) -> node? + def visit_instance_variable_read_node: (InstanceVariableReadNode) -> node? + + # : (InstanceVariableTargetNode) -> node? + def visit_instance_variable_target_node: (InstanceVariableTargetNode) -> node? + + # : (InstanceVariableWriteNode) -> node? + def visit_instance_variable_write_node: (InstanceVariableWriteNode) -> node? + + # : (IntegerNode) -> node? + def visit_integer_node: (IntegerNode) -> node? + + # : (InterpolatedMatchLastLineNode) -> node? + def visit_interpolated_match_last_line_node: (InterpolatedMatchLastLineNode) -> node? + + # : (InterpolatedRegularExpressionNode) -> node? + def visit_interpolated_regular_expression_node: (InterpolatedRegularExpressionNode) -> node? + + # : (InterpolatedStringNode) -> node? + def visit_interpolated_string_node: (InterpolatedStringNode) -> node? + + # : (InterpolatedSymbolNode) -> node? + def visit_interpolated_symbol_node: (InterpolatedSymbolNode) -> node? + + # : (InterpolatedXStringNode) -> node? + def visit_interpolated_x_string_node: (InterpolatedXStringNode) -> node? + + # : (ItLocalVariableReadNode) -> node? + def visit_it_local_variable_read_node: (ItLocalVariableReadNode) -> node? + + # : (ItParametersNode) -> node? + def visit_it_parameters_node: (ItParametersNode) -> node? + + # : (KeywordHashNode) -> node? + def visit_keyword_hash_node: (KeywordHashNode) -> node? + + # : (KeywordRestParameterNode) -> node? + def visit_keyword_rest_parameter_node: (KeywordRestParameterNode) -> node? + + # : (LambdaNode) -> node? + def visit_lambda_node: (LambdaNode) -> node? + + # : (LocalVariableAndWriteNode) -> node? + def visit_local_variable_and_write_node: (LocalVariableAndWriteNode) -> node? + + # : (LocalVariableOperatorWriteNode) -> node? + def visit_local_variable_operator_write_node: (LocalVariableOperatorWriteNode) -> node? + + # : (LocalVariableOrWriteNode) -> node? + def visit_local_variable_or_write_node: (LocalVariableOrWriteNode) -> node? + + # : (LocalVariableReadNode) -> node? + def visit_local_variable_read_node: (LocalVariableReadNode) -> node? + + # : (LocalVariableTargetNode) -> node? + def visit_local_variable_target_node: (LocalVariableTargetNode) -> node? + + # : (LocalVariableWriteNode) -> node? + def visit_local_variable_write_node: (LocalVariableWriteNode) -> node? + + # : (MatchLastLineNode) -> node? + def visit_match_last_line_node: (MatchLastLineNode) -> node? + + # : (MatchPredicateNode) -> node? + def visit_match_predicate_node: (MatchPredicateNode) -> node? + + # : (MatchRequiredNode) -> node? + def visit_match_required_node: (MatchRequiredNode) -> node? + + # : (MatchWriteNode) -> node? + def visit_match_write_node: (MatchWriteNode) -> node? + + # : (MissingNode) -> node? + def visit_missing_node: (MissingNode) -> node? + + # : (ModuleNode) -> node? + def visit_module_node: (ModuleNode) -> node? + + # : (MultiTargetNode) -> node? + def visit_multi_target_node: (MultiTargetNode) -> node? + + # : (MultiWriteNode) -> node? + def visit_multi_write_node: (MultiWriteNode) -> node? + + # : (NextNode) -> node? + def visit_next_node: (NextNode) -> node? + + # : (NilNode) -> node? + def visit_nil_node: (NilNode) -> node? + + # : (NoBlockParameterNode) -> node? + def visit_no_block_parameter_node: (NoBlockParameterNode) -> node? + + # : (NoKeywordsParameterNode) -> node? + def visit_no_keywords_parameter_node: (NoKeywordsParameterNode) -> node? + + # : (NumberedParametersNode) -> node? + def visit_numbered_parameters_node: (NumberedParametersNode) -> node? + + # : (NumberedReferenceReadNode) -> node? + def visit_numbered_reference_read_node: (NumberedReferenceReadNode) -> node? + + # : (OptionalKeywordParameterNode) -> node? + def visit_optional_keyword_parameter_node: (OptionalKeywordParameterNode) -> node? + + # : (OptionalParameterNode) -> node? + def visit_optional_parameter_node: (OptionalParameterNode) -> node? + + # : (OrNode) -> node? + def visit_or_node: (OrNode) -> node? + + # : (ParametersNode) -> node? + def visit_parameters_node: (ParametersNode) -> node? + + # : (ParenthesesNode) -> node? + def visit_parentheses_node: (ParenthesesNode) -> node? + + # : (PinnedExpressionNode) -> node? + def visit_pinned_expression_node: (PinnedExpressionNode) -> node? + + # : (PinnedVariableNode) -> node? + def visit_pinned_variable_node: (PinnedVariableNode) -> node? + + # : (PostExecutionNode) -> node? + def visit_post_execution_node: (PostExecutionNode) -> node? + + # : (PreExecutionNode) -> node? + def visit_pre_execution_node: (PreExecutionNode) -> node? + + # : (ProgramNode) -> node? + def visit_program_node: (ProgramNode) -> node? + + # : (RangeNode) -> node? + def visit_range_node: (RangeNode) -> node? + + # : (RationalNode) -> node? + def visit_rational_node: (RationalNode) -> node? + + # : (RedoNode) -> node? + def visit_redo_node: (RedoNode) -> node? + + # : (RegularExpressionNode) -> node? + def visit_regular_expression_node: (RegularExpressionNode) -> node? + + # : (RequiredKeywordParameterNode) -> node? + def visit_required_keyword_parameter_node: (RequiredKeywordParameterNode) -> node? + + # : (RequiredParameterNode) -> node? + def visit_required_parameter_node: (RequiredParameterNode) -> node? + + # : (RescueModifierNode) -> node? + def visit_rescue_modifier_node: (RescueModifierNode) -> node? + + # : (RescueNode) -> node? + def visit_rescue_node: (RescueNode) -> node? + + # : (RestParameterNode) -> node? + def visit_rest_parameter_node: (RestParameterNode) -> node? + + # : (RetryNode) -> node? + def visit_retry_node: (RetryNode) -> node? + + # : (ReturnNode) -> node? + def visit_return_node: (ReturnNode) -> node? + + # : (SelfNode) -> node? + def visit_self_node: (SelfNode) -> node? + + # : (ShareableConstantNode) -> node? + def visit_shareable_constant_node: (ShareableConstantNode) -> node? + + # : (SingletonClassNode) -> node? + def visit_singleton_class_node: (SingletonClassNode) -> node? + + # : (SourceEncodingNode) -> node? + def visit_source_encoding_node: (SourceEncodingNode) -> node? + + # : (SourceFileNode) -> node? + def visit_source_file_node: (SourceFileNode) -> node? + + # : (SourceLineNode) -> node? + def visit_source_line_node: (SourceLineNode) -> node? + + # : (SplatNode) -> node? + def visit_splat_node: (SplatNode) -> node? + + # : (StatementsNode) -> node? + def visit_statements_node: (StatementsNode) -> node? + + # : (StringNode) -> node? + def visit_string_node: (StringNode) -> node? + + # : (SuperNode) -> node? + def visit_super_node: (SuperNode) -> node? + + # : (SymbolNode) -> node? + def visit_symbol_node: (SymbolNode) -> node? + + # : (TrueNode) -> node? + def visit_true_node: (TrueNode) -> node? + + # : (UndefNode) -> node? + def visit_undef_node: (UndefNode) -> node? + + # : (UnlessNode) -> node? + def visit_unless_node: (UnlessNode) -> node? + + # : (UntilNode) -> node? + def visit_until_node: (UntilNode) -> node? + + # : (WhenNode) -> node? + def visit_when_node: (WhenNode) -> node? + + # : (WhileNode) -> node? + def visit_while_node: (WhileNode) -> node? + + # : (XStringNode) -> node? + def visit_x_string_node: (XStringNode) -> node? + + # : (YieldNode) -> node? + def visit_yield_node: (YieldNode) -> node? + end +end diff --git a/sig/generated/prism/node.rbs b/sig/generated/prism/node.rbs new file mode 100644 index 0000000000..032c26056a --- /dev/null +++ b/sig/generated/prism/node.rbs @@ -0,0 +1,20896 @@ +# Generated from lib/prism/node.rb with RBS::Inline + +module Prism + interface _Repository + def enter: (Integer node_id, Symbol field_name) -> Relocation::Entry + end + + interface _Node + def deconstruct: () -> Array[Prism::node?] + + def inspect: () -> String + end + + type node = Node & _Node + + # This represents a node in the tree. It is the parent class of all of the + # various node types. + class Node + # A pointer to the source that this node was created from. + # :stopdoc: + attr_reader source: Source + + # A unique identifier for this node. This is used in a very specific + # use case where you want to keep around a reference to a node without + # having to keep around the syntax tree in memory. This unique identifier + # will be consistent across multiple parses of the same source code. + attr_reader node_id: Integer + + @location: Location | Integer + + # Save this node using a saved source so that it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save: (_Repository repository) -> Relocation::Entry + + # A Location instance that represents the location of this node in the + # source. + # -- + # : () -> Location + def location: () -> Location + + # Save the location using a saved source so that it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_location: (_Repository repository) -> Relocation::Entry + + # Delegates to [`start_line`](rdoc-ref:Location#start_line) of the associated location object. + # -- + # : () -> Integer + def start_line: () -> Integer + + # Delegates to [`end_line`](rdoc-ref:Location#end_line) of the associated location object. + # -- + # : () -> Integer + def end_line: () -> Integer + + # Delegates to [`start_offset`](rdoc-ref:Location#start_offset) of the associated location object. + # -- + # : () -> Integer + def start_offset: () -> Integer + + # Delegates to [`end_offset`](rdoc-ref:Location#end_offset) of the associated location object. + # -- + # : () -> Integer + def end_offset: () -> Integer + + # Delegates to [`start_character_offset`](rdoc-ref:Location#start_character_offset) + # of the associated location object. + # -- + # : () -> Integer + def start_character_offset: () -> Integer + + # Delegates to [`end_character_offset`](rdoc-ref:Location#end_character_offset) + # of the associated location object. + # -- + # : () -> Integer + def end_character_offset: () -> Integer + + # Delegates to [`cached_start_code_units_offset`](rdoc-ref:Location#cached_start_code_units_offset) + # of the associated location object. + # -- + # : (_CodeUnitsCache cache) -> Integer + def cached_start_code_units_offset: (_CodeUnitsCache cache) -> Integer + + # Delegates to [`cached_end_code_units_offset`](rdoc-ref:Location#cached_end_code_units_offset) + # of the associated location object. + # -- + # : (_CodeUnitsCache cache) -> Integer + def cached_end_code_units_offset: (_CodeUnitsCache cache) -> Integer + + # Delegates to [`start_column`](rdoc-ref:Location#start_column) of the associated location object. + # -- + # : () -> Integer + def start_column: () -> Integer + + # Delegates to [`end_column`](rdoc-ref:Location#end_column) of the associated location object. + # -- + # : () -> Integer + def end_column: () -> Integer + + # Delegates to [`start_character_column`](rdoc-ref:Location#start_character_column) + # of the associated location object. + # -- + # : () -> Integer + def start_character_column: () -> Integer + + # Delegates to [`end_character_column`](rdoc-ref:Location#end_character_column) + # of the associated location object. + # -- + # : () -> Integer + def end_character_column: () -> Integer + + # Delegates to [`cached_start_code_units_column`](rdoc-ref:Location#cached_start_code_units_column) + # of the associated location object. + # -- + # : (_CodeUnitsCache cache) -> Integer + def cached_start_code_units_column: (_CodeUnitsCache cache) -> Integer + + # Delegates to [`cached_end_code_units_column`](rdoc-ref:Location#cached_end_code_units_column) + # of the associated location object. + # -- + # : (_CodeUnitsCache cache) -> Integer + def cached_end_code_units_column: (_CodeUnitsCache cache) -> Integer + + # Delegates to [`leading_comments`](rdoc-ref:Location#leading_comments) of the associated location object. + # -- + # : () -> Array[Comment] + def leading_comments: () -> Array[Comment] + + # Delegates to [`trailing_comments`](rdoc-ref:Location#trailing_comments) of the associated location object. + # -- + # : () -> Array[Comment] + def trailing_comments: () -> Array[Comment] + + # Delegates to [`comments`](rdoc-ref:Location#comments) of the associated location object. + # -- + # : () -> Array[Comment] + def comments: () -> Array[Comment] + + # Returns all of the lines of the source code associated with this node. + # -- + # : () -> Array[String] + def source_lines: () -> Array[String] + + # An alias for source_lines, used to mimic the API from + # RubyVM::AbstractSyntaxTree to make it easier to migrate. + alias script_lines source_lines + + # Slice the location of the node from the source. + # -- + # : () -> String + def slice: () -> String + + # Slice the location of the node from the source, starting at the beginning + # of the line that the location starts on, ending at the end of the line + # that the location ends on. + # -- + # : () -> String + def slice_lines: () -> String + + # An bitset of flags for this node. There are certain flags that are common + # for all nodes, and then some nodes have specific flags. + # :stopdoc: + attr_reader flags: Integer + + # Returns true if the node has the newline flag set. + # -- + # : () -> bool + def newline?: () -> bool + + # Returns true if the node has the static literal flag set. + # -- + # : () -> bool + def static_literal?: () -> bool + + # Similar to inspect, but respects the current level of indentation given by + # the pretty print object. + # -- + # : (PP q) -> void + def pretty_print: (PP q) -> void + + # Convert this node into a graphviz dot graph string. + # -- + # : () -> String + def to_dot: () -> String + + # Returns a list of nodes that are descendants of this node that contain the + # given line and column. This is useful for locating a node that is selected + # based on the line and column of the source code. + # + # Important to note is that the column given to this method should be in + # bytes, as opposed to characters or code units. + # -- + # : (Integer line, Integer column) -> Array[node] + def tunnel: (Integer line, Integer column) -> Array[node] + + # Returns the first node that matches the given block when visited in a + # breadth-first search. This is useful for finding a node that matches a + # particular condition. + # + # node.breadth_first_search { |node| node.node_id == node_id } + # -- + # : () { (node) -> bool } -> node? + def breadth_first_search: () { (node) -> bool } -> node? + + alias find breadth_first_search + + # Returns all of the nodes that match the given block when visited in a + # breadth-first search. This is useful for finding all nodes that match a + # particular condition. + # + # node.breadth_first_search_all { |node| node.is_a?(Prism::CallNode) } + # -- + # : () { (node) -> bool } -> Array[node] + def breadth_first_search_all: () { (node) -> bool } -> Array[node] + + alias find_all breadth_first_search_all + + # Returns a list of the fields that exist for this node class. Fields + # describe the structure of the node. This kind of reflection is useful for + # things like recursively visiting each node _and_ field in the tree. + # -- + # : () -> Array[Reflection::Field] + def self.fields: () -> Array[Reflection::Field] + + # Accepts a visitor and calls back into the specialized visit function. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # Returns an array of child nodes, including `nil`s in the place of optional + # nodes that were not present. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + alias deconstruct child_nodes + + # With a block given, yields each child node. Without a block, returns + # an enumerator that contains each child node. Excludes any `nil`s in + # the place of optional nodes that were not present. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # Returns an array of child nodes, excluding any `nil`s in the place of + # optional nodes that were not present. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # Returns an array of child nodes and locations that could potentially have + # comments attached to them. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # Returns a string representation of the node. + # -- + # : () -> String + def inspect: () -> String + + # Sometimes you want to check an instance of a node against a list of + # classes to see what kind of behavior to perform. Usually this is done by + # calling `[cls1, cls2].include?(node.class)` or putting the node into a + # case statement and doing `case node; when cls1; when cls2; end`. Both of + # these approaches are relatively slow because of the constant lookups, + # method calls, and/or array allocations. + # + # Instead, you can call #type, which will return to you a symbol that you + # can use for comparison. This is faster than the other approaches because + # it uses a single integer comparison, but also because if you're on CRuby + # you can take advantage of the fact that case statements with all symbol + # keys will use a jump table. + # -- + # : () -> Symbol + def type: () -> Symbol + + # Similar to #type, this method returns a symbol that you can use for + # splitting on the type of the node without having to do a long === chain. + # Note that like #type, it will still be slower than using == for a single + # class, but should be faster in a case statement or an array comparison. + # -- + # : () -> Symbol + def self.type: () -> Symbol + end + + # Represents the use of the `alias` keyword to alias a global variable. + # + # alias $foo $bar + # ^^^^^^^^^^^^^^^ + class AliasGlobalVariableNode < Node + @keyword_loc: Location + + @old_name: GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | SymbolNode | MissingNode + + @new_name: GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode + + # Initialize a new AliasGlobalVariableNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) new_name, (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | SymbolNode | MissingNode) old_name, Location keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode new_name, GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | SymbolNode | MissingNode old_name, Location keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> AliasGlobalVariableNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?new_name: (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode), ?old_name: (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | SymbolNode | MissingNode), ?keyword_loc: Location) -> AliasGlobalVariableNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?new_name: GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode, ?old_name: GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | SymbolNode | MissingNode, ?keyword_loc: Location) -> AliasGlobalVariableNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :alias_global_variable_node + def type: () -> :alias_global_variable_node + + # See `Node.type`. + # -- + # : () -> :alias_global_variable_node + def self.type: () -> :alias_global_variable_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # new_name -> GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode + # + # Represents the new name of the global variable that can be used after aliasing. + # + # alias $foo $bar + # ^^^^ + # -- + # : () -> (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) + def new_name: () -> (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) + + # :call-seq: + # old_name -> GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | SymbolNode | MissingNode + # + # Represents the old name of the global variable that can be used before aliasing. + # + # alias $foo $bar + # ^^^^ + # -- + # : () -> (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | SymbolNode | MissingNode) + def old_name: () -> (GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | SymbolNode | MissingNode) + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # The Location of the `alias` keyword. + # + # alias $foo $bar + # ^^^^^ + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `alias` keyword to alias a method. + # + # alias foo bar + # ^^^^^^^^^^^^^ + class AliasMethodNode < Node + @keyword_loc: Location + + @old_name: SymbolNode | InterpolatedSymbolNode | GlobalVariableReadNode | MissingNode + + @new_name: SymbolNode | InterpolatedSymbolNode + + # Initialize a new AliasMethodNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, (SymbolNode | InterpolatedSymbolNode) new_name, (SymbolNode | InterpolatedSymbolNode | GlobalVariableReadNode | MissingNode) old_name, Location keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, SymbolNode | InterpolatedSymbolNode new_name, SymbolNode | InterpolatedSymbolNode | GlobalVariableReadNode | MissingNode old_name, Location keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> AliasMethodNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?new_name: (SymbolNode | InterpolatedSymbolNode), ?old_name: (SymbolNode | InterpolatedSymbolNode | GlobalVariableReadNode | MissingNode), ?keyword_loc: Location) -> AliasMethodNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?new_name: SymbolNode | InterpolatedSymbolNode, ?old_name: SymbolNode | InterpolatedSymbolNode | GlobalVariableReadNode | MissingNode, ?keyword_loc: Location) -> AliasMethodNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :alias_method_node + def type: () -> :alias_method_node + + # See `Node.type`. + # -- + # : () -> :alias_method_node + def self.type: () -> :alias_method_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # new_name -> SymbolNode | InterpolatedSymbolNode + # + # Represents the new name of the method that will be aliased. + # + # alias foo bar + # ^^^ + # + # alias :foo :bar + # ^^^^ + # + # alias :"#{foo}" :"#{bar}" + # ^^^^^^^^^ + # -- + # : () -> (SymbolNode | InterpolatedSymbolNode) + def new_name: () -> (SymbolNode | InterpolatedSymbolNode) + + # :call-seq: + # old_name -> SymbolNode | InterpolatedSymbolNode | GlobalVariableReadNode | MissingNode + # + # Represents the old name of the method that will be aliased. + # + # alias foo bar + # ^^^ + # + # alias :foo :bar + # ^^^^ + # + # alias :"#{foo}" :"#{bar}" + # ^^^^^^^^^ + # -- + # : () -> (SymbolNode | InterpolatedSymbolNode | GlobalVariableReadNode | MissingNode) + def old_name: () -> (SymbolNode | InterpolatedSymbolNode | GlobalVariableReadNode | MissingNode) + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Represents the Location of the `alias` keyword. + # + # alias foo bar + # ^^^^^ + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an alternation pattern in pattern matching. + # + # foo => bar | baz + # ^^^^^^^^^ + class AlternationPatternNode < Node + @operator_loc: Location + + @right: Prism::node + + @left: Prism::node + + # Initialize a new AlternationPatternNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node left, Prism::node right, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node left, Prism::node right, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> AlternationPatternNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> AlternationPatternNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> AlternationPatternNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :alternation_pattern_node + def type: () -> :alternation_pattern_node + + # See `Node.type`. + # -- + # : () -> :alternation_pattern_node + def self.type: () -> :alternation_pattern_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # left -> Node + # + # Represents the left side of the expression. + # + # foo => bar | baz + # ^^^ + # -- + # : () -> Prism::node + def left: () -> Prism::node + + # :call-seq: + # right -> Node + # + # Represents the right side of the expression. + # + # foo => bar | baz + # ^^^ + # -- + # : () -> Prism::node + def right: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Represents the alternation operator Location. + # + # foo => bar | baz + # ^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `&&` operator or the `and` keyword. + # + # left and right + # ^^^^^^^^^^^^^^ + class AndNode < Node + @operator_loc: Location + + @right: Prism::node + + @left: Prism::node + + # Initialize a new AndNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node left, Prism::node right, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node left, Prism::node right, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> AndNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> AndNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> AndNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :and_node + def type: () -> :and_node + + # See `Node.type`. + # -- + # : () -> :and_node + def self.type: () -> :and_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # left -> Node + # + # Represents the left side of the expression. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # left and right + # ^^^^ + # + # 1 && 2 + # ^ + # -- + # : () -> Prism::node + def left: () -> Prism::node + + # :call-seq: + # right -> Node + # + # Represents the right side of the expression. + # + # left && right + # ^^^^^ + # + # 1 and 2 + # ^ + # -- + # : () -> Prism::node + def right: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `and` keyword or the `&&` operator. + # + # left and right + # ^^^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a set of arguments to a method or a keyword. + # + # return foo, bar, baz + # ^^^^^^^^^^^^^ + class ArgumentsNode < Node + @arguments: Array[Prism::node] + + # Initialize a new ArgumentsNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[Prism::node] arguments) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[Prism::node] arguments) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ArgumentsNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: Array[Prism::node]) -> ArgumentsNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: Array[Prism::node]) -> ArgumentsNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :arguments_node + def type: () -> :arguments_node + + # See `Node.type`. + # -- + # : () -> :arguments_node + def self.type: () -> :arguments_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # if the arguments contain forwarding + # -- + # : () -> bool + def contains_forwarding?: () -> bool + + # :category: Flags + # if the arguments contain keywords + # -- + # : () -> bool + def contains_keywords?: () -> bool + + # :category: Flags + # if the arguments contain a keyword splat + # -- + # : () -> bool + def contains_keyword_splat?: () -> bool + + # :category: Flags + # if the arguments contain a splat + # -- + # : () -> bool + def contains_splat?: () -> bool + + # :category: Flags + # if the arguments contain multiple splats + # -- + # : () -> bool + def contains_multiple_splats?: () -> bool + + # :call-seq: + # arguments -> Array[Node] + # + # The list of arguments, if present. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # foo(bar, baz) + # ^^^^^^^^ + # -- + # : () -> Array[Prism::node] + def arguments: () -> Array[Prism::node] + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an array literal. This can be a regular array using brackets or a special array using % like %w or %i. + # + # [1, 2, 3] + # ^^^^^^^^^ + class ArrayNode < Node + @closing_loc: Location? + + @opening_loc: Location? + + @elements: Array[Prism::node] + + # Initialize a new ArrayNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[Prism::node] elements, Location? opening_loc, Location? closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[Prism::node] elements, Location? opening_loc, Location? closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ArrayNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?elements: Array[Prism::node], ?opening_loc: Location?, ?closing_loc: Location?) -> ArrayNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?elements: Array[Prism::node], ?opening_loc: Location?, ?closing_loc: Location?) -> ArrayNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :array_node + def type: () -> :array_node + + # See `Node.type`. + # -- + # : () -> :array_node + def self.type: () -> :array_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # if array contains splat nodes + # -- + # : () -> bool + def contains_splat?: () -> bool + + # :call-seq: + # elements -> Array[Node] + # + # Represent the list of zero or more [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression) within the array. + # -- + # : () -> Array[Prism::node] + def elements: () -> Array[Prism::node] + + # :category: Locations + # :call-seq: + # opening_loc -> Location | nil + # + # Represents the optional source Location for the opening token. + # + # [1,2,3] # "[" + # %w[foo bar baz] # "%w[" + # %I(apple orange banana) # "%I(" + # foo = 1, 2, 3 # nil + # -- + # : () -> Location? + def opening_loc: () -> Location? + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_opening_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # Represents the optional source Location for the closing token. + # + # [1,2,3] # "]" + # %w[foo bar baz] # "]" + # %I(apple orange banana) # ")" + # foo = 1, 2, 3 # nil + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # opening -> String | nil + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String? + def opening: () -> String? + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an array pattern in pattern matching. + # + # foo in 1, 2 + # ^^^^^^^^^^^ + # + # foo in [1, 2] + # ^^^^^^^^^^^^^ + # + # foo in *bar + # ^^^^^^^^^^^ + # + # foo in Bar[] + # ^^^^^^^^^^^^ + # + # foo in Bar[1, 2, 3] + # ^^^^^^^^^^^^^^^^^^^ + class ArrayPatternNode < Node + @closing_loc: Location? + + @opening_loc: Location? + + @posts: Array[Prism::node] + + @rest: Prism::node? + + @requireds: Array[Prism::node] + + @constant: (ConstantPathNode | ConstantReadNode)? + + # Initialize a new ArrayPatternNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, (ConstantPathNode | ConstantReadNode)? constant, Array[Prism::node] requireds, Prism::node? rest, Array[Prism::node] posts, Location? opening_loc, Location? closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, (ConstantPathNode | ConstantReadNode)? constant, Array[Prism::node] requireds, Prism::node? rest, Array[Prism::node] posts, Location? opening_loc, Location? closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ArrayPatternNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?requireds: Array[Prism::node], ?rest: Prism::node?, ?posts: Array[Prism::node], ?opening_loc: Location?, ?closing_loc: Location?) -> ArrayPatternNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?requireds: Array[Prism::node], ?rest: Prism::node?, ?posts: Array[Prism::node], ?opening_loc: Location?, ?closing_loc: Location?) -> ArrayPatternNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :array_pattern_node + def type: () -> :array_pattern_node + + # See `Node.type`. + # -- + # : () -> :array_pattern_node + def self.type: () -> :array_pattern_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # constant -> ConstantPathNode | ConstantReadNode | nil + # + # Represents the optional constant preceding the Array + # + # foo in Bar[] + # ^^^ + # + # foo in Bar[1, 2, 3] + # ^^^ + # + # foo in Bar::Baz[1, 2, 3] + # ^^^^^^^^ + # -- + # : () -> (ConstantPathNode | ConstantReadNode)? + def constant: () -> (ConstantPathNode | ConstantReadNode)? + + # :call-seq: + # requireds -> Array[Node] + # + # Represents the required elements of the array pattern. + # + # foo in [1, 2] + # ^ ^ + # -- + # : () -> Array[Prism::node] + def requireds: () -> Array[Prism::node] + + # :call-seq: + # rest -> Node | nil + # + # Represents the rest element of the array pattern. + # + # foo in *bar + # ^^^^ + # -- + # : () -> Prism::node? + def rest: () -> Prism::node? + + # :call-seq: + # posts -> Array[Node] + # + # Represents the elements after the rest element of the array pattern. + # + # foo in *bar, baz + # ^^^ + # -- + # : () -> Array[Prism::node] + def posts: () -> Array[Prism::node] + + # :category: Locations + # :call-seq: + # opening_loc -> Location | nil + # + # Represents the opening Location of the array pattern. + # + # foo in [1, 2] + # ^ + # -- + # : () -> Location? + def opening_loc: () -> Location? + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_opening_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # Represents the closing Location of the array pattern. + # + # foo in [1, 2] + # ^ + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # opening -> String | nil + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String? + def opening: () -> String? + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a hash key/value pair. + # + # { a => b } + # ^^^^^^ + class AssocNode < Node + @operator_loc: Location? + + @value: Prism::node + + @key: Prism::node + + # Initialize a new AssocNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node key, Prism::node value, Location? operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node key, Prism::node value, Location? operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> AssocNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?key: Prism::node, ?value: Prism::node, ?operator_loc: Location?) -> AssocNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?key: Prism::node, ?value: Prism::node, ?operator_loc: Location?) -> AssocNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :assoc_node + def type: () -> :assoc_node + + # See `Node.type`. + # -- + # : () -> :assoc_node + def self.type: () -> :assoc_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # key -> Node + # + # The key of the association. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # { a: b } + # ^ + # + # { foo => bar } + # ^^^ + # + # { def a; end => 1 } + # ^^^^^^^^^^ + # -- + # : () -> Prism::node + def key: () -> Prism::node + + # :call-seq: + # value -> Node + # + # The value of the association, if present. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # { foo => bar } + # ^^^ + # + # { x: 1 } + # ^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location | nil + # + # The Location of the `=>` operator, if present. + # + # { foo => bar } + # ^^ + # -- + # : () -> Location? + def operator_loc: () -> Location? + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_operator_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # operator -> String | nil + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String? + def operator: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a splat in a hash literal. + # + # { **foo } + # ^^^^^ + class AssocSplatNode < Node + @operator_loc: Location + + @value: Prism::node? + + # Initialize a new AssocSplatNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? value, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? value, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> AssocSplatNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node?, ?operator_loc: Location) -> AssocSplatNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node?, ?operator_loc: Location) -> AssocSplatNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :assoc_splat_node + def type: () -> :assoc_splat_node + + # See `Node.type`. + # -- + # : () -> :assoc_splat_node + def self.type: () -> :assoc_splat_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # value -> Node | nil + # + # The value to be splatted, if present. Will be missing when keyword rest argument forwarding is used. + # + # { **foo } + # ^^^ + # -- + # : () -> Prism::node? + def value: () -> Prism::node? + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `**` operator. + # + # { **x } + # ^^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents reading a reference to a field in the previous match. + # + # $' + # ^^ + class BackReferenceReadNode < Node + @name: Symbol + + # Initialize a new BackReferenceReadNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> BackReferenceReadNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BackReferenceReadNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BackReferenceReadNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :back_reference_read_node + def type: () -> :back_reference_read_node + + # See `Node.type`. + # -- + # : () -> :back_reference_read_node + def self.type: () -> :back_reference_read_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the back-reference variable, including the leading `$`. + # + # $& # name `:$&` + # + # $+ # name `:$+` + # -- + # : () -> Symbol + def name: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a begin statement. + # + # begin + # foo + # end + # ^^^^^ + class BeginNode < Node + @end_keyword_loc: Location? + + @ensure_clause: EnsureNode? + + @else_clause: ElseNode? + + @rescue_clause: RescueNode? + + @statements: StatementsNode? + + @begin_keyword_loc: Location? + + # Initialize a new BeginNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location? begin_keyword_loc, StatementsNode? statements, RescueNode? rescue_clause, ElseNode? else_clause, EnsureNode? ensure_clause, Location? end_keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location? begin_keyword_loc, StatementsNode? statements, RescueNode? rescue_clause, ElseNode? else_clause, EnsureNode? ensure_clause, Location? end_keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> BeginNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?begin_keyword_loc: Location?, ?statements: StatementsNode?, ?rescue_clause: RescueNode?, ?else_clause: ElseNode?, ?ensure_clause: EnsureNode?, ?end_keyword_loc: Location?) -> BeginNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?begin_keyword_loc: Location?, ?statements: StatementsNode?, ?rescue_clause: RescueNode?, ?else_clause: ElseNode?, ?ensure_clause: EnsureNode?, ?end_keyword_loc: Location?) -> BeginNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :begin_node + def type: () -> :begin_node + + # See `Node.type`. + # -- + # : () -> :begin_node + def self.type: () -> :begin_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # begin_keyword_loc -> Location | nil + # + # Represents the Location of the `begin` keyword. + # + # begin x end + # ^^^^^ + # -- + # : () -> Location? + def begin_keyword_loc: () -> Location? + + # :category: Repository + # Save the begin_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_begin_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # statements -> StatementsNode | nil + # + # Represents the statements within the begin block. + # + # begin x end + # ^ + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :call-seq: + # rescue_clause -> RescueNode | nil + # + # Represents the rescue clause within the begin block. + # + # begin x; rescue y; end + # ^^^^^^^^ + # -- + # : () -> RescueNode? + def rescue_clause: () -> RescueNode? + + # :call-seq: + # else_clause -> ElseNode | nil + # + # Represents the else clause within the begin block. + # + # begin x; rescue y; else z; end + # ^^^^^^ + # -- + # : () -> ElseNode? + def else_clause: () -> ElseNode? + + # :call-seq: + # ensure_clause -> EnsureNode | nil + # + # Represents the ensure clause within the begin block. + # + # begin x; ensure y; end + # ^^^^^^^^ + # -- + # : () -> EnsureNode? + def ensure_clause: () -> EnsureNode? + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location | nil + # + # Represents the Location of the `end` keyword. + # + # begin x end + # ^^^ + # -- + # : () -> Location? + def end_keyword_loc: () -> Location? + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # begin_keyword -> String | nil + # + # Slice the location of begin_keyword_loc from the source. + # -- + # : () -> String? + def begin_keyword: () -> String? + + # :call-seq: + # end_keyword -> String | nil + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String? + def end_keyword: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a block argument using `&`. + # + # bar(&args) + # ^^^^^^^^^^ + class BlockArgumentNode < Node + @operator_loc: Location + + @expression: Prism::node? + + # Initialize a new BlockArgumentNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? expression, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? expression, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> BlockArgumentNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node?, ?operator_loc: Location) -> BlockArgumentNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node?, ?operator_loc: Location) -> BlockArgumentNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :block_argument_node + def type: () -> :block_argument_node + + # See `Node.type`. + # -- + # : () -> :block_argument_node + def self.type: () -> :block_argument_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # expression -> Node | nil + # + # The expression that is being passed as a block argument. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # foo(&args) + # ^^^^^ + # -- + # : () -> Prism::node? + def expression: () -> Prism::node? + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Represents the Location of the `&` operator. + # + # foo(&args) + # ^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a block local variable. + # + # a { |; b| } + # ^ + class BlockLocalVariableNode < Node + @name: Symbol + + # Initialize a new BlockLocalVariableNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> BlockLocalVariableNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BlockLocalVariableNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BlockLocalVariableNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :block_local_variable_node + def type: () -> :block_local_variable_node + + # See `Node.type`. + # -- + # : () -> :block_local_variable_node + def self.type: () -> :block_local_variable_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # a parameter name that has been repeated in the method signature + # -- + # : () -> bool + def repeated_parameter?: () -> bool + + # :call-seq: + # name -> Symbol + # + # The name of the block local variable. + # + # a { |; b| } # name `:b` + # ^ + # -- + # : () -> Symbol + def name: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a block of ruby code. + # + # [1, 2, 3].each { |i| puts x } + # ^^^^^^^^^^^^^^ + class BlockNode < Node + @closing_loc: Location + + @opening_loc: Location + + @body: (StatementsNode | BeginNode)? + + @parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)? + + @locals: Array[Symbol] + + # Initialize a new BlockNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, (BlockParametersNode | NumberedParametersNode | ItParametersNode)? parameters, (StatementsNode | BeginNode)? body, Location opening_loc, Location closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, (BlockParametersNode | NumberedParametersNode | ItParametersNode)? parameters, (StatementsNode | BeginNode)? body, Location opening_loc, Location closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> BlockNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)?, ?body: (StatementsNode | BeginNode)?, ?opening_loc: Location, ?closing_loc: Location) -> BlockNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)?, ?body: (StatementsNode | BeginNode)?, ?opening_loc: Location, ?closing_loc: Location) -> BlockNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :block_node + def type: () -> :block_node + + # See `Node.type`. + # -- + # : () -> :block_node + def self.type: () -> :block_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # locals -> Array[Symbol] + # + # The local variables declared in the block. + # + # [1, 2, 3].each { |i| puts x } # locals: [:i] + # ^ + # -- + # : () -> Array[Symbol] + def locals: () -> Array[Symbol] + + # :call-seq: + # parameters -> BlockParametersNode | NumberedParametersNode | ItParametersNode | nil + # + # The parameters of the block. + # + # [1, 2, 3].each { |i| puts x } + # ^^^ + # [1, 2, 3].each { puts _1 } + # ^^^^^^^^^^^ + # [1, 2, 3].each { puts it } + # ^^^^^^^^^^^ + # -- + # : () -> (BlockParametersNode | NumberedParametersNode | ItParametersNode)? + def parameters: () -> (BlockParametersNode | NumberedParametersNode | ItParametersNode)? + + # :call-seq: + # body -> StatementsNode | BeginNode | nil + # + # The body of the block. + # + # [1, 2, 3].each { |i| puts x } + # ^^^^^^ + # -- + # : () -> (StatementsNode | BeginNode)? + def body: () -> (StatementsNode | BeginNode)? + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Represents the Location of the opening `{` or `do`. + # + # [1, 2, 3].each { |i| puts x } + # ^ + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Represents the Location of the closing `}` or `end`. + # + # [1, 2, 3].each { |i| puts x } + # ^ + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a block parameter of a method, block, or lambda definition. + # + # def a(&b) + # ^^ + # end + class BlockParameterNode < Node + @operator_loc: Location + + @name_loc: Location? + + @name: Symbol? + + # Initialize a new BlockParameterNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol? name, Location? name_loc, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol? name, Location? name_loc, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> BlockParameterNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> BlockParameterNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> BlockParameterNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :block_parameter_node + def type: () -> :block_parameter_node + + # See `Node.type`. + # -- + # : () -> :block_parameter_node + def self.type: () -> :block_parameter_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # a parameter name that has been repeated in the method signature + # -- + # : () -> bool + def repeated_parameter?: () -> bool + + # :call-seq: + # name -> Symbol | nil + # + # The name of the block parameter. + # + # def a(&b) # name `:b` + # ^ + # end + # -- + # : () -> Symbol? + def name: () -> Symbol? + + # :category: Locations + # :call-seq: + # name_loc -> Location | nil + # + # Represents the Location of the block parameter name. + # + # def a(&b) + # ^ + # -- + # : () -> Location? + def name_loc: () -> Location? + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_name_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Represents the Location of the `&` operator. + # + # def a(&b) + # ^ + # end + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a block's parameters declaration. + # + # -> (a, b = 1; local) { } + # ^^^^^^^^^^^^^^^^^ + # + # foo do |a, b = 1; local| + # ^^^^^^^^^^^^^^^^^ + # end + class BlockParametersNode < Node + @closing_loc: Location? + + @opening_loc: Location? + + @locals: Array[BlockLocalVariableNode] + + @parameters: ParametersNode? + + # Initialize a new BlockParametersNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ParametersNode? parameters, Array[BlockLocalVariableNode] locals, Location? opening_loc, Location? closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, ParametersNode? parameters, Array[BlockLocalVariableNode] locals, Location? opening_loc, Location? closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> BlockParametersNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?parameters: ParametersNode?, ?locals: Array[BlockLocalVariableNode], ?opening_loc: Location?, ?closing_loc: Location?) -> BlockParametersNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?parameters: ParametersNode?, ?locals: Array[BlockLocalVariableNode], ?opening_loc: Location?, ?closing_loc: Location?) -> BlockParametersNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :block_parameters_node + def type: () -> :block_parameters_node + + # See `Node.type`. + # -- + # : () -> :block_parameters_node + def self.type: () -> :block_parameters_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # parameters -> ParametersNode | nil + # + # Represents the parameters of the block. + # + # -> (a, b = 1; local) { } + # ^^^^^^^^ + # + # foo do |a, b = 1; local| + # ^^^^^^^^ + # end + # -- + # : () -> ParametersNode? + def parameters: () -> ParametersNode? + + # :call-seq: + # locals -> Array[BlockLocalVariableNode] + # + # Represents the local variables of the block. + # + # -> (a, b = 1; local) { } + # ^^^^^ + # + # foo do |a, b = 1; local| + # ^^^^^ + # end + # -- + # : () -> Array[BlockLocalVariableNode] + def locals: () -> Array[BlockLocalVariableNode] + + # :category: Locations + # :call-seq: + # opening_loc -> Location | nil + # + # Represents the opening Location of the block parameters. + # + # -> (a, b = 1; local) { } + # ^ + # + # foo do |a, b = 1; local| + # ^ + # end + # -- + # : () -> Location? + def opening_loc: () -> Location? + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_opening_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # Represents the closing Location of the block parameters. + # + # -> (a, b = 1; local) { } + # ^ + # + # foo do |a, b = 1; local| + # ^ + # end + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # opening -> String | nil + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String? + def opening: () -> String? + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `break` keyword. + # + # break foo + # ^^^^^^^^^ + class BreakNode < Node + @keyword_loc: Location + + @arguments: ArgumentsNode? + + # Initialize a new BreakNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ArgumentsNode? arguments, Location keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, ArgumentsNode? arguments, Location keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> BreakNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> BreakNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> BreakNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :break_node + def type: () -> :break_node + + # See `Node.type`. + # -- + # : () -> :break_node + def self.type: () -> :break_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # arguments -> ArgumentsNode | nil + # + # The arguments to the break statement, if present. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # break foo + # ^^^ + # -- + # : () -> ArgumentsNode? + def arguments: () -> ArgumentsNode? + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # The Location of the `break` keyword. + # + # break foo + # ^^^^^ + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `&&=` operator on a call. + # + # foo.bar &&= value + # ^^^^^^^^^^^^^^^^^ + class CallAndWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @write_name: Symbol + + @read_name: Symbol + + @message_loc: Location? + + @call_operator_loc: Location? + + @receiver: Prism::node? + + # Initialize a new CallAndWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> CallAndWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?operator_loc: Location, ?value: Prism::node) -> CallAndWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?operator_loc: Location, ?value: Prism::node) -> CallAndWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :call_and_write_node + def type: () -> :call_and_write_node + + # See `Node.type`. + # -- + # : () -> :call_and_write_node + def self.type: () -> :call_and_write_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # &. operator + # -- + # : () -> bool + def safe_navigation?: () -> bool + + # :category: Flags + # a call that could have been a local variable + # -- + # : () -> bool + def variable_call?: () -> bool + + # :category: Flags + # a call that is an attribute write, so the value being written should be returned + # -- + # : () -> bool + def attribute_write?: () -> bool + + # :category: Flags + # a call that ignores method visibility + # -- + # : () -> bool + def ignore_visibility?: () -> bool + + # :call-seq: + # receiver -> Node | nil + # + # The object that the method is being called on. This can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # foo.bar &&= value + # ^^^ + # -- + # : () -> Prism::node? + def receiver: () -> Prism::node? + + # :category: Locations + # :call-seq: + # call_operator_loc -> Location | nil + # + # Represents the Location of the call operator. + # + # foo.bar &&= value + # ^ + # -- + # : () -> Location? + def call_operator_loc: () -> Location? + + # :category: Repository + # Save the call_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_call_operator_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # message_loc -> Location | nil + # + # Represents the Location of the message. + # + # foo.bar &&= value + # ^^^ + # -- + # : () -> Location? + def message_loc: () -> Location? + + # :category: Repository + # Save the message_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_message_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # read_name -> Symbol + # + # Represents the name of the method being called. + # + # foo.bar &&= value # read_name `:bar` + # ^^^ + # -- + # : () -> Symbol + def read_name: () -> Symbol + + # :call-seq: + # write_name -> Symbol + # + # Represents the name of the method being written to. + # + # foo.bar &&= value # write_name `:bar=` + # ^^^ + # -- + # : () -> Symbol + def write_name: () -> Symbol + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Represents the Location of the operator. + # + # foo.bar &&= value + # ^^^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Represents the value being assigned. + # + # foo.bar &&= value + # ^^^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # call_operator -> String | nil + # + # Slice the location of call_operator_loc from the source. + # -- + # : () -> String? + def call_operator: () -> String? + + # :call-seq: + # message -> String | nil + # + # Slice the location of message_loc from the source. + # -- + # : () -> String? + def message: () -> String? + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a method call, in all of the various forms that can take. + # + # foo + # ^^^ + # + # foo() + # ^^^^^ + # + # +foo + # ^^^^ + # + # foo + bar + # ^^^^^^^^^ + # + # foo.bar + # ^^^^^^^ + # + # foo&.bar + # ^^^^^^^^ + class CallNode < Node + @block: (BlockNode | BlockArgumentNode)? + + @equal_loc: Location? + + @closing_loc: Location? + + @arguments: ArgumentsNode? + + @opening_loc: Location? + + @message_loc: Location? + + @name: Symbol + + @call_operator_loc: Location? + + @receiver: Prism::node? + + # Initialize a new CallNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Symbol name, Location? message_loc, Location? opening_loc, ArgumentsNode? arguments, Location? closing_loc, Location? equal_loc, (BlockNode | BlockArgumentNode)? block) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Symbol name, Location? message_loc, Location? opening_loc, ArgumentsNode? arguments, Location? closing_loc, Location? equal_loc, (BlockNode | BlockArgumentNode)? block) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> CallNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?name: Symbol, ?message_loc: Location?, ?opening_loc: Location?, ?arguments: ArgumentsNode?, ?closing_loc: Location?, ?equal_loc: Location?, ?block: (BlockNode | BlockArgumentNode)?) -> CallNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?name: Symbol, ?message_loc: Location?, ?opening_loc: Location?, ?arguments: ArgumentsNode?, ?closing_loc: Location?, ?equal_loc: Location?, ?block: (BlockNode | BlockArgumentNode)?) -> CallNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :call_node + def type: () -> :call_node + + # See `Node.type`. + # -- + # : () -> :call_node + def self.type: () -> :call_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # &. operator + # -- + # : () -> bool + def safe_navigation?: () -> bool + + # :category: Flags + # a call that could have been a local variable + # -- + # : () -> bool + def variable_call?: () -> bool + + # :category: Flags + # a call that is an attribute write, so the value being written should be returned + # -- + # : () -> bool + def attribute_write?: () -> bool + + # :category: Flags + # a call that ignores method visibility + # -- + # : () -> bool + def ignore_visibility?: () -> bool + + # :call-seq: + # receiver -> Node | nil + # + # The object that the method is being called on. This can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # foo.bar + # ^^^ + # + # +foo + # ^^^ + # + # foo + bar + # ^^^ + # -- + # : () -> Prism::node? + def receiver: () -> Prism::node? + + # :category: Locations + # :call-seq: + # call_operator_loc -> Location | nil + # + # Represents the Location of the call operator. + # + # foo.bar + # ^ + # + # foo&.bar + # ^^ + # -- + # : () -> Location? + def call_operator_loc: () -> Location? + + # :category: Repository + # Save the call_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_call_operator_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # name -> Symbol + # + # Represents the name of the method being called. + # + # foo.bar # name `:foo` + # ^^^ + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # message_loc -> Location | nil + # + # Represents the Location of the message. + # + # foo.bar + # ^^^ + # -- + # : () -> Location? + def message_loc: () -> Location? + + # :category: Repository + # Save the message_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_message_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # opening_loc -> Location | nil + # + # Represents the Location of the left parenthesis. + # + # foo(bar) + # ^ + # -- + # : () -> Location? + def opening_loc: () -> Location? + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_opening_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # arguments -> ArgumentsNode | nil + # + # Represents the arguments to the method call. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # foo(bar) + # ^^^ + # -- + # : () -> ArgumentsNode? + def arguments: () -> ArgumentsNode? + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # Represents the Location of the right parenthesis. + # + # foo(bar) + # ^ + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # equal_loc -> Location | nil + # + # Represents the Location of the equal sign, in the case that this is an attribute write. + # + # foo.bar = value + # ^ + # + # foo[bar] = value + # ^ + # -- + # : () -> Location? + def equal_loc: () -> Location? + + # :category: Repository + # Save the equal_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_equal_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # block -> BlockNode | BlockArgumentNode | nil + # + # Represents the block that is being passed to the method. + # + # foo { |a| a } + # ^^^^^^^^^ + # -- + # : () -> (BlockNode | BlockArgumentNode)? + def block: () -> (BlockNode | BlockArgumentNode)? + + # :call-seq: + # call_operator -> String | nil + # + # Slice the location of call_operator_loc from the source. + # -- + # : () -> String? + def call_operator: () -> String? + + # :call-seq: + # message -> String | nil + # + # Slice the location of message_loc from the source. + # -- + # : () -> String? + def message: () -> String? + + # :call-seq: + # opening -> String | nil + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String? + def opening: () -> String? + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # :call-seq: + # equal -> String | nil + # + # Slice the location of equal_loc from the source. + # -- + # : () -> String? + def equal: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of an assignment operator on a call. + # + # foo.bar += baz + # ^^^^^^^^^^^^^^ + class CallOperatorWriteNode < Node + @value: Prism::node + + @binary_operator_loc: Location + + @binary_operator: Symbol + + @write_name: Symbol + + @read_name: Symbol + + @message_loc: Location? + + @call_operator_loc: Location? + + @receiver: Prism::node? + + # Initialize a new CallOperatorWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Symbol binary_operator, Location binary_operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Symbol binary_operator, Location binary_operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> CallOperatorWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> CallOperatorWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> CallOperatorWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :call_operator_write_node + def type: () -> :call_operator_write_node + + # See `Node.type`. + # -- + # : () -> :call_operator_write_node + def self.type: () -> :call_operator_write_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # &. operator + # -- + # : () -> bool + def safe_navigation?: () -> bool + + # :category: Flags + # a call that could have been a local variable + # -- + # : () -> bool + def variable_call?: () -> bool + + # :category: Flags + # a call that is an attribute write, so the value being written should be returned + # -- + # : () -> bool + def attribute_write?: () -> bool + + # :category: Flags + # a call that ignores method visibility + # -- + # : () -> bool + def ignore_visibility?: () -> bool + + # :call-seq: + # receiver -> Node | nil + # + # The object that the method is being called on. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # foo.bar += value + # ^^^ + # -- + # : () -> Prism::node? + def receiver: () -> Prism::node? + + # :category: Locations + # :call-seq: + # call_operator_loc -> Location | nil + # + # Represents the Location of the call operator. + # + # foo.bar += value + # ^ + # -- + # : () -> Location? + def call_operator_loc: () -> Location? + + # :category: Repository + # Save the call_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_call_operator_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # message_loc -> Location | nil + # + # Represents the Location of the message. + # + # foo.bar += value + # ^^^ + # -- + # : () -> Location? + def message_loc: () -> Location? + + # :category: Repository + # Save the message_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_message_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # read_name -> Symbol + # + # Represents the name of the method being called. + # + # foo.bar += value # read_name `:bar` + # ^^^ + # -- + # : () -> Symbol + def read_name: () -> Symbol + + # :call-seq: + # write_name -> Symbol + # + # Represents the name of the method being written to. + # + # foo.bar += value # write_name `:bar=` + # ^^^ + # -- + # : () -> Symbol + def write_name: () -> Symbol + + # :call-seq: + # binary_operator -> Symbol + # + # Represents the binary operator being used. + # + # foo.bar += value # binary_operator `:+` + # ^ + # -- + # : () -> Symbol + def binary_operator: () -> Symbol + + # :category: Locations + # :call-seq: + # binary_operator_loc -> Location + # + # Represents the Location of the binary operator. + # + # foo.bar += value + # ^^ + # -- + # : () -> Location + def binary_operator_loc: () -> Location + + # :category: Repository + # Save the binary_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_binary_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Represents the value being assigned. + # + # foo.bar += value + # ^^^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # call_operator -> String | nil + # + # Slice the location of call_operator_loc from the source. + # -- + # : () -> String? + def call_operator: () -> String? + + # :call-seq: + # message -> String | nil + # + # Slice the location of message_loc from the source. + # -- + # : () -> String? + def message: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `||=` operator on a call. + # + # foo.bar ||= value + # ^^^^^^^^^^^^^^^^^ + class CallOrWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @write_name: Symbol + + @read_name: Symbol + + @message_loc: Location? + + @call_operator_loc: Location? + + @receiver: Prism::node? + + # Initialize a new CallOrWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> CallOrWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?operator_loc: Location, ?value: Prism::node) -> CallOrWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?operator_loc: Location, ?value: Prism::node) -> CallOrWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :call_or_write_node + def type: () -> :call_or_write_node + + # See `Node.type`. + # -- + # : () -> :call_or_write_node + def self.type: () -> :call_or_write_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # &. operator + # -- + # : () -> bool + def safe_navigation?: () -> bool + + # :category: Flags + # a call that could have been a local variable + # -- + # : () -> bool + def variable_call?: () -> bool + + # :category: Flags + # a call that is an attribute write, so the value being written should be returned + # -- + # : () -> bool + def attribute_write?: () -> bool + + # :category: Flags + # a call that ignores method visibility + # -- + # : () -> bool + def ignore_visibility?: () -> bool + + # :call-seq: + # receiver -> Node | nil + # + # The object that the method is being called on. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # foo.bar ||= value + # ^^^ + # -- + # : () -> Prism::node? + def receiver: () -> Prism::node? + + # :category: Locations + # :call-seq: + # call_operator_loc -> Location | nil + # + # Represents the Location of the call operator. + # + # foo.bar ||= value + # ^ + # -- + # : () -> Location? + def call_operator_loc: () -> Location? + + # :category: Repository + # Save the call_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_call_operator_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # message_loc -> Location | nil + # + # Represents the Location of the message. + # + # foo.bar ||= value + # ^^^ + # -- + # : () -> Location? + def message_loc: () -> Location? + + # :category: Repository + # Save the message_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_message_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # read_name -> Symbol + # + # Represents the name of the method being called. + # + # foo.bar ||= value # read_name `:bar` + # ^^^ + # -- + # : () -> Symbol + def read_name: () -> Symbol + + # :call-seq: + # write_name -> Symbol + # + # Represents the name of the method being written to. + # + # foo.bar ||= value # write_name `:bar=` + # ^^^ + # -- + # : () -> Symbol + def write_name: () -> Symbol + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Represents the Location of the operator. + # + # foo.bar ||= value + # ^^^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Represents the value being assigned. + # + # foo.bar ||= value + # ^^^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # call_operator -> String | nil + # + # Slice the location of call_operator_loc from the source. + # -- + # : () -> String? + def call_operator: () -> String? + + # :call-seq: + # message -> String | nil + # + # Slice the location of message_loc from the source. + # -- + # : () -> String? + def message: () -> String? + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents assigning to a method call. + # + # foo.bar, = 1 + # ^^^^^^^ + # + # begin + # rescue => foo.bar + # ^^^^^^^ + # end + # + # for foo.bar in baz do end + # ^^^^^^^ + class CallTargetNode < Node + @message_loc: Location + + @name: Symbol + + @call_operator_loc: Location + + @receiver: Prism::node + + # Initialize a new CallTargetNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node receiver, Location call_operator_loc, Symbol name, Location message_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node receiver, Location call_operator_loc, Symbol name, Location message_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> CallTargetNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?call_operator_loc: Location, ?name: Symbol, ?message_loc: Location) -> CallTargetNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?call_operator_loc: Location, ?name: Symbol, ?message_loc: Location) -> CallTargetNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :call_target_node + def type: () -> :call_target_node + + # See `Node.type`. + # -- + # : () -> :call_target_node + def self.type: () -> :call_target_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # &. operator + # -- + # : () -> bool + def safe_navigation?: () -> bool + + # :category: Flags + # a call that could have been a local variable + # -- + # : () -> bool + def variable_call?: () -> bool + + # :category: Flags + # a call that is an attribute write, so the value being written should be returned + # -- + # : () -> bool + def attribute_write?: () -> bool + + # :category: Flags + # a call that ignores method visibility + # -- + # : () -> bool + def ignore_visibility?: () -> bool + + # :call-seq: + # receiver -> Node + # + # The object that the method is being called on. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # foo.bar = 1 + # ^^^ + # -- + # : () -> Prism::node + def receiver: () -> Prism::node + + # :category: Locations + # :call-seq: + # call_operator_loc -> Location + # + # Represents the Location of the call operator. + # + # foo.bar = 1 + # ^ + # -- + # : () -> Location + def call_operator_loc: () -> Location + + # :category: Repository + # Save the call_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_call_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # name -> Symbol + # + # Represents the name of the method being called. + # + # foo.bar = 1 # name `:foo` + # ^^^ + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # message_loc -> Location + # + # Represents the Location of the message. + # + # foo.bar = 1 + # ^^^ + # -- + # : () -> Location + def message_loc: () -> Location + + # :category: Repository + # Save the message_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_message_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # call_operator -> String + # + # Slice the location of call_operator_loc from the source. + # -- + # : () -> String + def call_operator: () -> String + + # :call-seq: + # message -> String + # + # Slice the location of message_loc from the source. + # -- + # : () -> String + def message: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents assigning to a local variable in pattern matching. + # + # foo => [bar => baz] + # ^^^^^^^^^^^^ + class CapturePatternNode < Node + @operator_loc: Location + + @target: LocalVariableTargetNode + + @value: Prism::node + + # Initialize a new CapturePatternNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node value, LocalVariableTargetNode target, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node value, LocalVariableTargetNode target, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> CapturePatternNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?target: LocalVariableTargetNode, ?operator_loc: Location) -> CapturePatternNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?target: LocalVariableTargetNode, ?operator_loc: Location) -> CapturePatternNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :capture_pattern_node + def type: () -> :capture_pattern_node + + # See `Node.type`. + # -- + # : () -> :capture_pattern_node + def self.type: () -> :capture_pattern_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # value -> Node + # + # Represents the value to capture. + # + # foo => bar + # ^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # target -> LocalVariableTargetNode + # + # Represents the target of the capture. + # + # foo => bar + # ^^^ + # -- + # : () -> LocalVariableTargetNode + def target: () -> LocalVariableTargetNode + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Represents the Location of the `=>` operator. + # + # foo => bar + # ^^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of a case statement for pattern matching. + # + # case true + # in false + # end + # ^^^^^^^^^ + class CaseMatchNode < Node + @end_keyword_loc: Location + + @case_keyword_loc: Location + + @else_clause: ElseNode? + + @conditions: Array[InNode] + + @predicate: Prism::node? + + # Initialize a new CaseMatchNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? predicate, Array[InNode] conditions, ElseNode? else_clause, Location case_keyword_loc, Location end_keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? predicate, Array[InNode] conditions, ElseNode? else_clause, Location case_keyword_loc, Location end_keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> CaseMatchNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?predicate: Prism::node?, ?conditions: Array[InNode], ?else_clause: ElseNode?, ?case_keyword_loc: Location, ?end_keyword_loc: Location) -> CaseMatchNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?predicate: Prism::node?, ?conditions: Array[InNode], ?else_clause: ElseNode?, ?case_keyword_loc: Location, ?end_keyword_loc: Location) -> CaseMatchNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :case_match_node + def type: () -> :case_match_node + + # See `Node.type`. + # -- + # : () -> :case_match_node + def self.type: () -> :case_match_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # predicate -> Node | nil + # + # Represents the predicate of the case match. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # case true; in false; end + # ^^^^ + # -- + # : () -> Prism::node? + def predicate: () -> Prism::node? + + # :call-seq: + # conditions -> Array[InNode] + # + # Represents the conditions of the case match. + # + # case true; in false; end + # ^^^^^^^^ + # -- + # : () -> Array[InNode] + def conditions: () -> Array[InNode] + + # :call-seq: + # else_clause -> ElseNode | nil + # + # Represents the else clause of the case match. + # + # case true; in false; else; end + # ^^^^ + # -- + # : () -> ElseNode? + def else_clause: () -> ElseNode? + + # :category: Locations + # :call-seq: + # case_keyword_loc -> Location + # + # Represents the Location of the `case` keyword. + # + # case true; in false; end + # ^^^^ + # -- + # : () -> Location + def case_keyword_loc: () -> Location + + # :category: Repository + # Save the case_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_case_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location + # + # Represents the Location of the `end` keyword. + # + # case true; in false; end + # ^^^ + # -- + # : () -> Location + def end_keyword_loc: () -> Location + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # case_keyword -> String + # + # Slice the location of case_keyword_loc from the source. + # -- + # : () -> String + def case_keyword: () -> String + + # :call-seq: + # end_keyword -> String + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String + def end_keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of a case statement. + # + # case true + # when false + # end + # ^^^^^^^^^^ + class CaseNode < Node + @end_keyword_loc: Location + + @case_keyword_loc: Location + + @else_clause: ElseNode? + + @conditions: Array[WhenNode] + + @predicate: Prism::node? + + # Initialize a new CaseNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? predicate, Array[WhenNode] conditions, ElseNode? else_clause, Location case_keyword_loc, Location end_keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? predicate, Array[WhenNode] conditions, ElseNode? else_clause, Location case_keyword_loc, Location end_keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> CaseNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?predicate: Prism::node?, ?conditions: Array[WhenNode], ?else_clause: ElseNode?, ?case_keyword_loc: Location, ?end_keyword_loc: Location) -> CaseNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?predicate: Prism::node?, ?conditions: Array[WhenNode], ?else_clause: ElseNode?, ?case_keyword_loc: Location, ?end_keyword_loc: Location) -> CaseNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :case_node + def type: () -> :case_node + + # See `Node.type`. + # -- + # : () -> :case_node + def self.type: () -> :case_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # predicate -> Node | nil + # + # Represents the predicate of the case statement. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # case true; when false; end + # ^^^^ + # -- + # : () -> Prism::node? + def predicate: () -> Prism::node? + + # :call-seq: + # conditions -> Array[WhenNode] + # + # Represents the conditions of the case statement. + # + # case true; when false; end + # ^^^^^^^^^^ + # -- + # : () -> Array[WhenNode] + def conditions: () -> Array[WhenNode] + + # :call-seq: + # else_clause -> ElseNode | nil + # + # Represents the else clause of the case statement. + # + # case true; when false; else; end + # ^^^^ + # -- + # : () -> ElseNode? + def else_clause: () -> ElseNode? + + # :category: Locations + # :call-seq: + # case_keyword_loc -> Location + # + # Represents the Location of the `case` keyword. + # + # case true; when false; end + # ^^^^ + # -- + # : () -> Location + def case_keyword_loc: () -> Location + + # :category: Repository + # Save the case_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_case_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location + # + # Represents the Location of the `end` keyword. + # + # case true; when false; end + # ^^^ + # -- + # : () -> Location + def end_keyword_loc: () -> Location + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # case_keyword -> String + # + # Slice the location of case_keyword_loc from the source. + # -- + # : () -> String + def case_keyword: () -> String + + # :call-seq: + # end_keyword -> String + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String + def end_keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a class declaration involving the `class` keyword. + # + # class Foo end + # ^^^^^^^^^^^^^ + class ClassNode < Node + @name: Symbol + + @end_keyword_loc: Location + + @body: (StatementsNode | BeginNode)? + + @superclass: Prism::node? + + @inheritance_operator_loc: Location? + + @constant_path: ConstantReadNode | ConstantPathNode | CallNode + + @class_keyword_loc: Location + + @locals: Array[Symbol] + + # Initialize a new ClassNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, Location class_keyword_loc, (ConstantReadNode | ConstantPathNode | CallNode) constant_path, Location? inheritance_operator_loc, Prism::node? superclass, (StatementsNode | BeginNode)? body, Location end_keyword_loc, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, Location class_keyword_loc, ConstantReadNode | ConstantPathNode | CallNode constant_path, Location? inheritance_operator_loc, Prism::node? superclass, (StatementsNode | BeginNode)? body, Location end_keyword_loc, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ClassNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?class_keyword_loc: Location, ?constant_path: (ConstantReadNode | ConstantPathNode | CallNode), ?inheritance_operator_loc: Location?, ?superclass: Prism::node?, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location, ?name: Symbol) -> ClassNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?class_keyword_loc: Location, ?constant_path: ConstantReadNode | ConstantPathNode | CallNode, ?inheritance_operator_loc: Location?, ?superclass: Prism::node?, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location, ?name: Symbol) -> ClassNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :class_node + def type: () -> :class_node + + # See `Node.type`. + # -- + # : () -> :class_node + def self.type: () -> :class_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # locals -> Array[Symbol] + # + # Returns the `locals` attribute. + # -- + # : () -> Array[Symbol] + def locals: () -> Array[Symbol] + + # :category: Locations + # :call-seq: + # class_keyword_loc -> Location + # + # Represents the Location of the `class` keyword. + # + # class Foo end + # ^^^^^ + # -- + # : () -> Location + def class_keyword_loc: () -> Location + + # :category: Repository + # Save the class_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_class_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # constant_path -> ConstantReadNode | ConstantPathNode | CallNode + # + # Returns the `constant_path` attribute. + # -- + # : () -> (ConstantReadNode | ConstantPathNode | CallNode) + def constant_path: () -> (ConstantReadNode | ConstantPathNode | CallNode) + + # :category: Locations + # :call-seq: + # inheritance_operator_loc -> Location | nil + # + # Represents the Location of the `<` operator. + # + # class Foo < Bar + # ^ + # -- + # : () -> Location? + def inheritance_operator_loc: () -> Location? + + # :category: Repository + # Save the inheritance_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_inheritance_operator_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # superclass -> Node | nil + # + # Represents the superclass of the class. + # + # class Foo < Bar + # ^^^ + # -- + # : () -> Prism::node? + def superclass: () -> Prism::node? + + # :call-seq: + # body -> StatementsNode | BeginNode | nil + # + # Represents the body of the class. + # + # class Foo + # foo + # ^^^ + # -- + # : () -> (StatementsNode | BeginNode)? + def body: () -> (StatementsNode | BeginNode)? + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location + # + # Represents the Location of the `end` keyword. + # + # class Foo end + # ^^^ + # -- + # : () -> Location + def end_keyword_loc: () -> Location + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # name -> Symbol + # + # The name of the class. + # + # class Foo end # name `:Foo` + # -- + # : () -> Symbol + def name: () -> Symbol + + # :call-seq: + # class_keyword -> String + # + # Slice the location of class_keyword_loc from the source. + # -- + # : () -> String + def class_keyword: () -> String + + # :call-seq: + # inheritance_operator -> String | nil + # + # Slice the location of inheritance_operator_loc from the source. + # -- + # : () -> String? + def inheritance_operator: () -> String? + + # :call-seq: + # end_keyword -> String + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String + def end_keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `&&=` operator for assignment to a class variable. + # + # @@target &&= value + # ^^^^^^^^^^^^^^^^^^ + class ClassVariableAndWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new ClassVariableAndWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ClassVariableAndWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ClassVariableAndWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ClassVariableAndWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :class_variable_and_write_node + def type: () -> :class_variable_and_write_node + + # See `Node.type`. + # -- + # : () -> :class_variable_and_write_node + def self.type: () -> :class_variable_and_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers). + # + # @@target &&= value # name `:@@target` + # ^^^^^^^^ + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Represents the Location of the variable name. + # + # @@target &&= value + # ^^^^^^^^ + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Represents the Location of the `&&=` operator. + # + # @@target &&= value + # ^^^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Represents the value being assigned. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # @@target &&= value + # ^^^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents assigning to a class variable using an operator that isn't `=`. + # + # @@target += value + # ^^^^^^^^^^^^^^^^^ + class ClassVariableOperatorWriteNode < Node + @binary_operator: Symbol + + @value: Prism::node + + @binary_operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new ClassVariableOperatorWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ClassVariableOperatorWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ClassVariableOperatorWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ClassVariableOperatorWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :class_variable_operator_write_node + def type: () -> :class_variable_operator_write_node + + # See `Node.type`. + # -- + # : () -> :class_variable_operator_write_node + def self.type: () -> :class_variable_operator_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # binary_operator_loc -> Location + # + # Returns the Location represented by `binary_operator_loc`. + # -- + # : () -> Location + def binary_operator_loc: () -> Location + + # :category: Repository + # Save the binary_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_binary_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # binary_operator -> Symbol + # + # Returns the `binary_operator` attribute. + # -- + # : () -> Symbol + def binary_operator: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `||=` operator for assignment to a class variable. + # + # @@target ||= value + # ^^^^^^^^^^^^^^^^^^ + class ClassVariableOrWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new ClassVariableOrWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ClassVariableOrWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ClassVariableOrWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ClassVariableOrWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :class_variable_or_write_node + def type: () -> :class_variable_or_write_node + + # See `Node.type`. + # -- + # : () -> :class_variable_or_write_node + def self.type: () -> :class_variable_or_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents referencing a class variable. + # + # @@foo + # ^^^^^ + class ClassVariableReadNode < Node + @name: Symbol + + # Initialize a new ClassVariableReadNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ClassVariableReadNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ClassVariableReadNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ClassVariableReadNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :class_variable_read_node + def type: () -> :class_variable_read_node + + # See `Node.type`. + # -- + # : () -> :class_variable_read_node + def self.type: () -> :class_variable_read_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers). + # + # @@abc # name `:@@abc` + # + # @@_test # name `:@@_test` + # -- + # : () -> Symbol + def name: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to a class variable in a context that doesn't have an explicit value. + # + # @@foo, @@bar = baz + # ^^^^^ ^^^^^ + class ClassVariableTargetNode < Node + @name: Symbol + + # Initialize a new ClassVariableTargetNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ClassVariableTargetNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ClassVariableTargetNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ClassVariableTargetNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :class_variable_target_node + def type: () -> :class_variable_target_node + + # See `Node.type`. + # -- + # : () -> :class_variable_target_node + def self.type: () -> :class_variable_target_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to a class variable. + # + # @@foo = 1 + # ^^^^^^^^^ + class ClassVariableWriteNode < Node + @operator_loc: Location + + @value: Prism::node + + @name_loc: Location + + @name: Symbol + + # Initialize a new ClassVariableWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ClassVariableWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> ClassVariableWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> ClassVariableWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :class_variable_write_node + def type: () -> :class_variable_write_node + + # See `Node.type`. + # -- + # : () -> :class_variable_write_node + def self.type: () -> :class_variable_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers). + # + # @@abc = 123 # name `@@abc` + # + # @@_test = :test # name `@@_test` + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # The Location of the variable name. + # + # @@foo = :bar + # ^^^^^ + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # The value to write to the class variable. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # @@foo = :bar + # ^^^^ + # + # @@_xyz = 123 + # ^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `=` operator. + # + # @@foo = :bar + # ^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `&&=` operator for assignment to a constant. + # + # Target &&= value + # ^^^^^^^^^^^^^^^^ + class ConstantAndWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new ConstantAndWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantAndWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantAndWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantAndWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_and_write_node + def type: () -> :constant_and_write_node + + # See `Node.type`. + # -- + # : () -> :constant_and_write_node + def self.type: () -> :constant_and_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents assigning to a constant using an operator that isn't `=`. + # + # Target += value + # ^^^^^^^^^^^^^^^ + class ConstantOperatorWriteNode < Node + @binary_operator: Symbol + + @value: Prism::node + + @binary_operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new ConstantOperatorWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantOperatorWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ConstantOperatorWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ConstantOperatorWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_operator_write_node + def type: () -> :constant_operator_write_node + + # See `Node.type`. + # -- + # : () -> :constant_operator_write_node + def self.type: () -> :constant_operator_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # binary_operator_loc -> Location + # + # Returns the Location represented by `binary_operator_loc`. + # -- + # : () -> Location + def binary_operator_loc: () -> Location + + # :category: Repository + # Save the binary_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_binary_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # binary_operator -> Symbol + # + # Returns the `binary_operator` attribute. + # -- + # : () -> Symbol + def binary_operator: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `||=` operator for assignment to a constant. + # + # Target ||= value + # ^^^^^^^^^^^^^^^^ + class ConstantOrWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new ConstantOrWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantOrWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantOrWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantOrWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_or_write_node + def type: () -> :constant_or_write_node + + # See `Node.type`. + # -- + # : () -> :constant_or_write_node + def self.type: () -> :constant_or_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `&&=` operator for assignment to a constant path. + # + # Parent::Child &&= value + # ^^^^^^^^^^^^^^^^^^^^^^^ + class ConstantPathAndWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @target: ConstantPathNode + + # Initialize a new ConstantPathAndWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ConstantPathNode target, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, ConstantPathNode target, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantPathAndWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathAndWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathAndWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_path_and_write_node + def type: () -> :constant_path_and_write_node + + # See `Node.type`. + # -- + # : () -> :constant_path_and_write_node + def self.type: () -> :constant_path_and_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # target -> ConstantPathNode + # + # Returns the `target` attribute. + # -- + # : () -> ConstantPathNode + def target: () -> ConstantPathNode + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents accessing a constant through a path of `::` operators. + # + # Foo::Bar + # ^^^^^^^^ + class ConstantPathNode < Node + @name_loc: Location + + @delimiter_loc: Location + + @name: Symbol? + + @parent: Prism::node? + + # Initialize a new ConstantPathNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantPathNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) -> ConstantPathNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) -> ConstantPathNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_path_node + def type: () -> :constant_path_node + + # See `Node.type`. + # -- + # : () -> :constant_path_node + def self.type: () -> :constant_path_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # parent -> Node | nil + # + # The left-hand node of the path, if present. It can be `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). It will be `nil` when the constant lookup is at the root of the module tree. + # + # Foo::Bar + # ^^^ + # + # self::Test + # ^^^^ + # + # a.b::C + # ^^^ + # -- + # : () -> Prism::node? + def parent: () -> Prism::node? + + # :call-seq: + # name -> Symbol | nil + # + # The name of the constant being accessed. This could be `nil` in the event of a syntax error. + # -- + # : () -> Symbol? + def name: () -> Symbol? + + # :category: Locations + # :call-seq: + # delimiter_loc -> Location + # + # The Location of the `::` delimiter. + # + # ::Foo + # ^^ + # + # One::Two + # ^^ + # -- + # : () -> Location + def delimiter_loc: () -> Location + + # :category: Repository + # Save the delimiter_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_delimiter_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # The Location of the name of the constant. + # + # ::Foo + # ^^^ + # + # One::Two + # ^^^ + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # delimiter -> String + # + # Slice the location of delimiter_loc from the source. + # -- + # : () -> String + def delimiter: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents assigning to a constant path using an operator that isn't `=`. + # + # Parent::Child += value + # ^^^^^^^^^^^^^^^^^^^^^^ + class ConstantPathOperatorWriteNode < Node + @binary_operator: Symbol + + @value: Prism::node + + @binary_operator_loc: Location + + @target: ConstantPathNode + + # Initialize a new ConstantPathOperatorWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ConstantPathNode target, Location binary_operator_loc, Prism::node value, Symbol binary_operator) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, ConstantPathNode target, Location binary_operator_loc, Prism::node value, Symbol binary_operator) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantPathOperatorWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ConstantPathOperatorWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> ConstantPathOperatorWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_path_operator_write_node + def type: () -> :constant_path_operator_write_node + + # See `Node.type`. + # -- + # : () -> :constant_path_operator_write_node + def self.type: () -> :constant_path_operator_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # target -> ConstantPathNode + # + # Returns the `target` attribute. + # -- + # : () -> ConstantPathNode + def target: () -> ConstantPathNode + + # :category: Locations + # :call-seq: + # binary_operator_loc -> Location + # + # Returns the Location represented by `binary_operator_loc`. + # -- + # : () -> Location + def binary_operator_loc: () -> Location + + # :category: Repository + # Save the binary_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_binary_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # binary_operator -> Symbol + # + # Returns the `binary_operator` attribute. + # -- + # : () -> Symbol + def binary_operator: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `||=` operator for assignment to a constant path. + # + # Parent::Child ||= value + # ^^^^^^^^^^^^^^^^^^^^^^^ + class ConstantPathOrWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @target: ConstantPathNode + + # Initialize a new ConstantPathOrWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ConstantPathNode target, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, ConstantPathNode target, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantPathOrWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathOrWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathOrWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_path_or_write_node + def type: () -> :constant_path_or_write_node + + # See `Node.type`. + # -- + # : () -> :constant_path_or_write_node + def self.type: () -> :constant_path_or_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # target -> ConstantPathNode + # + # Returns the `target` attribute. + # -- + # : () -> ConstantPathNode + def target: () -> ConstantPathNode + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to a constant path in a context that doesn't have an explicit value. + # + # Foo::Foo, Bar::Bar = baz + # ^^^^^^^^ ^^^^^^^^ + class ConstantPathTargetNode < Node + @name_loc: Location + + @delimiter_loc: Location + + @name: Symbol? + + @parent: Prism::node? + + # Initialize a new ConstantPathTargetNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantPathTargetNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) -> ConstantPathTargetNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) -> ConstantPathTargetNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_path_target_node + def type: () -> :constant_path_target_node + + # See `Node.type`. + # -- + # : () -> :constant_path_target_node + def self.type: () -> :constant_path_target_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # parent -> Node | nil + # + # Returns the `parent` attribute. + # -- + # : () -> Prism::node? + def parent: () -> Prism::node? + + # :call-seq: + # name -> Symbol | nil + # + # Returns the `name` attribute. + # -- + # : () -> Symbol? + def name: () -> Symbol? + + # :category: Locations + # :call-seq: + # delimiter_loc -> Location + # + # Returns the Location represented by `delimiter_loc`. + # -- + # : () -> Location + def delimiter_loc: () -> Location + + # :category: Repository + # Save the delimiter_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_delimiter_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # delimiter -> String + # + # Slice the location of delimiter_loc from the source. + # -- + # : () -> String + def delimiter: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to a constant path. + # + # ::Foo = 1 + # ^^^^^^^^^ + # + # Foo::Bar = 1 + # ^^^^^^^^^^^^ + # + # ::Foo::Bar = 1 + # ^^^^^^^^^^^^^^ + class ConstantPathWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @target: ConstantPathNode + + # Initialize a new ConstantPathWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ConstantPathNode target, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, ConstantPathNode target, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantPathWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?target: ConstantPathNode, ?operator_loc: Location, ?value: Prism::node) -> ConstantPathWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_path_write_node + def type: () -> :constant_path_write_node + + # See `Node.type`. + # -- + # : () -> :constant_path_write_node + def self.type: () -> :constant_path_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # target -> ConstantPathNode + # + # A node representing the constant path being written to. + # + # Foo::Bar = 1 + # ^^^^^^^^ + # + # ::Foo = :abc + # ^^^^^ + # -- + # : () -> ConstantPathNode + def target: () -> ConstantPathNode + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `=` operator. + # + # ::ABC = 123 + # ^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # The value to write to the constant path. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # FOO::BAR = :abc + # ^^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents referencing a constant. + # + # Foo + # ^^^ + class ConstantReadNode < Node + @name: Symbol + + # Initialize a new ConstantReadNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantReadNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantReadNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantReadNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_read_node + def type: () -> :constant_read_node + + # See `Node.type`. + # -- + # : () -> :constant_read_node + def self.type: () -> :constant_read_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the [constant](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#constants). + # + # X # name `:X` + # + # SOME_CONSTANT # name `:SOME_CONSTANT` + # -- + # : () -> Symbol + def name: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to a constant in a context that doesn't have an explicit value. + # + # Foo, Bar = baz + # ^^^ ^^^ + class ConstantTargetNode < Node + @name: Symbol + + # Initialize a new ConstantTargetNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantTargetNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantTargetNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> ConstantTargetNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_target_node + def type: () -> :constant_target_node + + # See `Node.type`. + # -- + # : () -> :constant_target_node + def self.type: () -> :constant_target_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to a constant. + # + # Foo = 1 + # ^^^^^^^ + class ConstantWriteNode < Node + @operator_loc: Location + + @value: Prism::node + + @name_loc: Location + + @name: Symbol + + # Initialize a new ConstantWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ConstantWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> ConstantWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> ConstantWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :constant_write_node + def type: () -> :constant_write_node + + # See `Node.type`. + # -- + # : () -> :constant_write_node + def self.type: () -> :constant_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the [constant](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#constants). + # + # Foo = :bar # name `:Foo` + # + # XYZ = 1 # name `:XYZ` + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # The Location of the constant name. + # + # FOO = 1 + # ^^^ + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # The value to write to the constant. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # FOO = :bar + # ^^^^ + # + # MyClass = Class.new + # ^^^^^^^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `=` operator. + # + # FOO = :bar + # ^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a method definition. + # + # def method + # end + # ^^^^^^^^^^ + class DefNode < Node + @end_keyword_loc: Location? + + @equal_loc: Location? + + @rparen_loc: Location? + + @lparen_loc: Location? + + @operator_loc: Location? + + @def_keyword_loc: Location + + @locals: Array[Symbol] + + @body: (StatementsNode | BeginNode)? + + @parameters: ParametersNode? + + @receiver: Prism::node? + + @name_loc: Location + + @name: Symbol + + # Initialize a new DefNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node? receiver, ParametersNode? parameters, (StatementsNode | BeginNode)? body, Array[Symbol] locals, Location def_keyword_loc, Location? operator_loc, Location? lparen_loc, Location? rparen_loc, Location? equal_loc, Location? end_keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node? receiver, ParametersNode? parameters, (StatementsNode | BeginNode)? body, Array[Symbol] locals, Location def_keyword_loc, Location? operator_loc, Location? lparen_loc, Location? rparen_loc, Location? equal_loc, Location? end_keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> DefNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?receiver: Prism::node?, ?parameters: ParametersNode?, ?body: (StatementsNode | BeginNode)?, ?locals: Array[Symbol], ?def_keyword_loc: Location, ?operator_loc: Location?, ?lparen_loc: Location?, ?rparen_loc: Location?, ?equal_loc: Location?, ?end_keyword_loc: Location?) -> DefNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?receiver: Prism::node?, ?parameters: ParametersNode?, ?body: (StatementsNode | BeginNode)?, ?locals: Array[Symbol], ?def_keyword_loc: Location, ?operator_loc: Location?, ?lparen_loc: Location?, ?rparen_loc: Location?, ?equal_loc: Location?, ?end_keyword_loc: Location?) -> DefNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :def_node + def type: () -> :def_node + + # See `Node.type`. + # -- + # : () -> :def_node + def self.type: () -> :def_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # receiver -> Node | nil + # + # Returns the `receiver` attribute. + # -- + # : () -> Prism::node? + def receiver: () -> Prism::node? + + # :call-seq: + # parameters -> ParametersNode | nil + # + # Returns the `parameters` attribute. + # -- + # : () -> ParametersNode? + def parameters: () -> ParametersNode? + + # :call-seq: + # body -> StatementsNode | BeginNode | nil + # + # Returns the `body` attribute. + # -- + # : () -> (StatementsNode | BeginNode)? + def body: () -> (StatementsNode | BeginNode)? + + # :call-seq: + # locals -> Array[Symbol] + # + # Returns the `locals` attribute. + # -- + # : () -> Array[Symbol] + def locals: () -> Array[Symbol] + + # :category: Locations + # :call-seq: + # def_keyword_loc -> Location + # + # Returns the Location represented by `def_keyword_loc`. + # -- + # : () -> Location + def def_keyword_loc: () -> Location + + # :category: Repository + # Save the def_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_def_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location | nil + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location? + def operator_loc: () -> Location? + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_operator_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # lparen_loc -> Location | nil + # + # Returns the Location represented by `lparen_loc`. + # -- + # : () -> Location? + def lparen_loc: () -> Location? + + # :category: Repository + # Save the lparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_lparen_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # rparen_loc -> Location | nil + # + # Returns the Location represented by `rparen_loc`. + # -- + # : () -> Location? + def rparen_loc: () -> Location? + + # :category: Repository + # Save the rparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_rparen_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # equal_loc -> Location | nil + # + # Returns the Location represented by `equal_loc`. + # -- + # : () -> Location? + def equal_loc: () -> Location? + + # :category: Repository + # Save the equal_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_equal_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location | nil + # + # Returns the Location represented by `end_keyword_loc`. + # -- + # : () -> Location? + def end_keyword_loc: () -> Location? + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # def_keyword -> String + # + # Slice the location of def_keyword_loc from the source. + # -- + # : () -> String + def def_keyword: () -> String + + # :call-seq: + # operator -> String | nil + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String? + def operator: () -> String? + + # :call-seq: + # lparen -> String | nil + # + # Slice the location of lparen_loc from the source. + # -- + # : () -> String? + def lparen: () -> String? + + # :call-seq: + # rparen -> String | nil + # + # Slice the location of rparen_loc from the source. + # -- + # : () -> String? + def rparen: () -> String? + + # :call-seq: + # equal -> String | nil + # + # Slice the location of equal_loc from the source. + # -- + # : () -> String? + def equal: () -> String? + + # :call-seq: + # end_keyword -> String | nil + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String? + def end_keyword: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `defined?` keyword. + # + # defined?(a) + # ^^^^^^^^^^^ + class DefinedNode < Node + @keyword_loc: Location + + @rparen_loc: Location? + + @value: Prism::node + + @lparen_loc: Location? + + # Initialize a new DefinedNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location? lparen_loc, Prism::node value, Location? rparen_loc, Location keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location? lparen_loc, Prism::node value, Location? rparen_loc, Location keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> DefinedNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?lparen_loc: Location?, ?value: Prism::node, ?rparen_loc: Location?, ?keyword_loc: Location) -> DefinedNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?lparen_loc: Location?, ?value: Prism::node, ?rparen_loc: Location?, ?keyword_loc: Location) -> DefinedNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :defined_node + def type: () -> :defined_node + + # See `Node.type`. + # -- + # : () -> :defined_node + def self.type: () -> :defined_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # lparen_loc -> Location | nil + # + # Returns the Location represented by `lparen_loc`. + # -- + # : () -> Location? + def lparen_loc: () -> Location? + + # :category: Repository + # Save the lparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_lparen_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :category: Locations + # :call-seq: + # rparen_loc -> Location | nil + # + # Returns the Location represented by `rparen_loc`. + # -- + # : () -> Location? + def rparen_loc: () -> Location? + + # :category: Repository + # Save the rparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_rparen_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # lparen -> String | nil + # + # Slice the location of lparen_loc from the source. + # -- + # : () -> String? + def lparen: () -> String? + + # :call-seq: + # rparen -> String | nil + # + # Slice the location of rparen_loc from the source. + # -- + # : () -> String? + def rparen: () -> String? + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an `else` clause in a `case`, `if`, or `unless` statement. + # + # if a then b else c end + # ^^^^^^^^^^ + class ElseNode < Node + @end_keyword_loc: Location? + + @statements: StatementsNode? + + @else_keyword_loc: Location + + # Initialize a new ElseNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location else_keyword_loc, StatementsNode? statements, Location? end_keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location else_keyword_loc, StatementsNode? statements, Location? end_keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ElseNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?else_keyword_loc: Location, ?statements: StatementsNode?, ?end_keyword_loc: Location?) -> ElseNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?else_keyword_loc: Location, ?statements: StatementsNode?, ?end_keyword_loc: Location?) -> ElseNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :else_node + def type: () -> :else_node + + # See `Node.type`. + # -- + # : () -> :else_node + def self.type: () -> :else_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # else_keyword_loc -> Location + # + # Returns the Location represented by `else_keyword_loc`. + # -- + # : () -> Location + def else_keyword_loc: () -> Location + + # :category: Repository + # Save the else_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_else_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # statements -> StatementsNode | nil + # + # Returns the `statements` attribute. + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location | nil + # + # Returns the Location represented by `end_keyword_loc`. + # -- + # : () -> Location? + def end_keyword_loc: () -> Location? + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # else_keyword -> String + # + # Slice the location of else_keyword_loc from the source. + # -- + # : () -> String + def else_keyword: () -> String + + # :call-seq: + # end_keyword -> String | nil + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String? + def end_keyword: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an interpolated set of statements. + # + # "foo #{bar}" + # ^^^^^^ + class EmbeddedStatementsNode < Node + @closing_loc: Location + + @statements: StatementsNode? + + @opening_loc: Location + + # Initialize a new EmbeddedStatementsNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, StatementsNode? statements, Location closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, StatementsNode? statements, Location closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> EmbeddedStatementsNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?statements: StatementsNode?, ?closing_loc: Location) -> EmbeddedStatementsNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?statements: StatementsNode?, ?closing_loc: Location) -> EmbeddedStatementsNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :embedded_statements_node + def type: () -> :embedded_statements_node + + # See `Node.type`. + # -- + # : () -> :embedded_statements_node + def self.type: () -> :embedded_statements_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # statements -> StatementsNode | nil + # + # Returns the `statements` attribute. + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an interpolated variable. + # + # "foo #@bar" + # ^^^^^ + class EmbeddedVariableNode < Node + @variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode + + @operator_loc: Location + + # Initialize a new EmbeddedVariableNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location operator_loc, (InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) variable) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location operator_loc, InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode variable) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> EmbeddedVariableNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?variable: (InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode)) -> EmbeddedVariableNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) -> EmbeddedVariableNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :embedded_variable_node + def type: () -> :embedded_variable_node + + # See `Node.type`. + # -- + # : () -> :embedded_variable_node + def self.type: () -> :embedded_variable_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # variable -> InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode + # + # Returns the `variable` attribute. + # -- + # : () -> (InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) + def variable: () -> (InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an `ensure` clause in a `begin` statement. + # + # begin + # foo + # ensure + # ^^^^^^ + # bar + # end + class EnsureNode < Node + @end_keyword_loc: Location + + @statements: StatementsNode? + + @ensure_keyword_loc: Location + + # Initialize a new EnsureNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location ensure_keyword_loc, StatementsNode? statements, Location end_keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location ensure_keyword_loc, StatementsNode? statements, Location end_keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> EnsureNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?ensure_keyword_loc: Location, ?statements: StatementsNode?, ?end_keyword_loc: Location) -> EnsureNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?ensure_keyword_loc: Location, ?statements: StatementsNode?, ?end_keyword_loc: Location) -> EnsureNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :ensure_node + def type: () -> :ensure_node + + # See `Node.type`. + # -- + # : () -> :ensure_node + def self.type: () -> :ensure_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # ensure_keyword_loc -> Location + # + # Returns the Location represented by `ensure_keyword_loc`. + # -- + # : () -> Location + def ensure_keyword_loc: () -> Location + + # :category: Repository + # Save the ensure_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_ensure_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # statements -> StatementsNode | nil + # + # Returns the `statements` attribute. + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location + # + # Returns the Location represented by `end_keyword_loc`. + # -- + # : () -> Location + def end_keyword_loc: () -> Location + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # ensure_keyword -> String + # + # Slice the location of ensure_keyword_loc from the source. + # -- + # : () -> String + def ensure_keyword: () -> String + + # :call-seq: + # end_keyword -> String + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String + def end_keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the literal `false` keyword. + # + # false + # ^^^^^ + class FalseNode < Node + # Initialize a new FalseNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> FalseNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> FalseNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> FalseNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :false_node + def type: () -> :false_node + + # See `Node.type`. + # -- + # : () -> :false_node + def self.type: () -> :false_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a find pattern in pattern matching. + # + # foo in *bar, baz, *qux + # ^^^^^^^^^^^^^^^ + # + # foo in [*bar, baz, *qux] + # ^^^^^^^^^^^^^^^^^ + # + # foo in Foo(*bar, baz, *qux) + # ^^^^^^^^^^^^^^^^^^^^ + # + # foo => *bar, baz, *qux + # ^^^^^^^^^^^^^^^ + class FindPatternNode < Node + @closing_loc: Location? + + @opening_loc: Location? + + @right: SplatNode | MissingNode + + @requireds: Array[Prism::node] + + @left: SplatNode + + @constant: (ConstantPathNode | ConstantReadNode)? + + # Initialize a new FindPatternNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, (ConstantPathNode | ConstantReadNode)? constant, SplatNode left, Array[Prism::node] requireds, (SplatNode | MissingNode) right, Location? opening_loc, Location? closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, (ConstantPathNode | ConstantReadNode)? constant, SplatNode left, Array[Prism::node] requireds, SplatNode | MissingNode right, Location? opening_loc, Location? closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> FindPatternNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?left: SplatNode, ?requireds: Array[Prism::node], ?right: (SplatNode | MissingNode), ?opening_loc: Location?, ?closing_loc: Location?) -> FindPatternNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?left: SplatNode, ?requireds: Array[Prism::node], ?right: SplatNode | MissingNode, ?opening_loc: Location?, ?closing_loc: Location?) -> FindPatternNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :find_pattern_node + def type: () -> :find_pattern_node + + # See `Node.type`. + # -- + # : () -> :find_pattern_node + def self.type: () -> :find_pattern_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # constant -> ConstantPathNode | ConstantReadNode | nil + # + # Represents the optional constant preceding the pattern + # + # foo in Foo(*bar, baz, *qux) + # ^^^ + # -- + # : () -> (ConstantPathNode | ConstantReadNode)? + def constant: () -> (ConstantPathNode | ConstantReadNode)? + + # :call-seq: + # left -> SplatNode + # + # Represents the first wildcard node in the pattern. + # + # foo in *bar, baz, *qux + # ^^^^ + # + # foo in Foo(*bar, baz, *qux) + # ^^^^ + # -- + # : () -> SplatNode + def left: () -> SplatNode + + # :call-seq: + # requireds -> Array[Node] + # + # Represents the nodes in between the wildcards. + # + # foo in *bar, baz, *qux + # ^^^ + # + # foo in Foo(*bar, baz, 1, *qux) + # ^^^^^^ + # -- + # : () -> Array[Prism::node] + def requireds: () -> Array[Prism::node] + + # :call-seq: + # right -> SplatNode | MissingNode + # + # Represents the second wildcard node in the pattern. + # + # foo in *bar, baz, *qux + # ^^^^ + # + # foo in Foo(*bar, baz, *qux) + # ^^^^ + # -- + # : () -> (SplatNode | MissingNode) + def right: () -> (SplatNode | MissingNode) + + # :category: Locations + # :call-seq: + # opening_loc -> Location | nil + # + # The Location of the opening brace. + # + # foo in [*bar, baz, *qux] + # ^ + # + # foo in Foo(*bar, baz, *qux) + # ^ + # -- + # : () -> Location? + def opening_loc: () -> Location? + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_opening_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # The Location of the closing brace. + # + # foo in [*bar, baz, *qux] + # ^ + # + # foo in Foo(*bar, baz, *qux) + # ^ + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # opening -> String | nil + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String? + def opening: () -> String? + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `..` or `...` operators to create flip flops. + # + # baz if foo .. bar + # ^^^^^^^^^^ + class FlipFlopNode < Node + @operator_loc: Location + + @right: Prism::node? + + @left: Prism::node? + + # Initialize a new FlipFlopNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? left, Prism::node? right, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? left, Prism::node? right, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> FlipFlopNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node?, ?right: Prism::node?, ?operator_loc: Location) -> FlipFlopNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node?, ?right: Prism::node?, ?operator_loc: Location) -> FlipFlopNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :flip_flop_node + def type: () -> :flip_flop_node + + # See `Node.type`. + # -- + # : () -> :flip_flop_node + def self.type: () -> :flip_flop_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # ... operator + # -- + # : () -> bool + def exclude_end?: () -> bool + + # :call-seq: + # left -> Node | nil + # + # Returns the `left` attribute. + # -- + # : () -> Prism::node? + def left: () -> Prism::node? + + # :call-seq: + # right -> Node | nil + # + # Returns the `right` attribute. + # -- + # : () -> Prism::node? + def right: () -> Prism::node? + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a floating point number literal. + # + # 1.0 + # ^^^ + class FloatNode < Node + @value: Float + + # Initialize a new FloatNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Float value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Float value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> FloatNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Float) -> FloatNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Float) -> FloatNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :float_node + def type: () -> :float_node + + # See `Node.type`. + # -- + # : () -> :float_node + def self.type: () -> :float_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # value -> Float + # + # The value of the floating point number as a Float. + # -- + # : () -> Float + def value: () -> Float + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `for` keyword. + # + # for i in a end + # ^^^^^^^^^^^^^^ + class ForNode < Node + @end_keyword_loc: Location + + @do_keyword_loc: Location? + + @in_keyword_loc: Location + + @for_keyword_loc: Location + + @statements: StatementsNode? + + @collection: Prism::node + + @index: LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode + + # Initialize a new ForNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode) index, Prism::node collection, StatementsNode? statements, Location for_keyword_loc, Location in_keyword_loc, Location? do_keyword_loc, Location end_keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode index, Prism::node collection, StatementsNode? statements, Location for_keyword_loc, Location in_keyword_loc, Location? do_keyword_loc, Location end_keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ForNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?index: (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode), ?collection: Prism::node, ?statements: StatementsNode?, ?for_keyword_loc: Location, ?in_keyword_loc: Location, ?do_keyword_loc: Location?, ?end_keyword_loc: Location) -> ForNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?index: LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode, ?collection: Prism::node, ?statements: StatementsNode?, ?for_keyword_loc: Location, ?in_keyword_loc: Location, ?do_keyword_loc: Location?, ?end_keyword_loc: Location) -> ForNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :for_node + def type: () -> :for_node + + # See `Node.type`. + # -- + # : () -> :for_node + def self.type: () -> :for_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # index -> LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode + # + # The index expression for `for` loops. + # + # for i in a end + # ^ + # -- + # : () -> (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode) + def index: () -> (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode) + + # :call-seq: + # collection -> Node + # + # The collection to iterate over. + # + # for i in a end + # ^ + # -- + # : () -> Prism::node + def collection: () -> Prism::node + + # :call-seq: + # statements -> StatementsNode | nil + # + # Represents the body of statements to execute for each iteration of the loop. + # + # for i in a + # foo(i) + # ^^^^^^ + # end + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :category: Locations + # :call-seq: + # for_keyword_loc -> Location + # + # The Location of the `for` keyword. + # + # for i in a end + # ^^^ + # -- + # : () -> Location + def for_keyword_loc: () -> Location + + # :category: Repository + # Save the for_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_for_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # in_keyword_loc -> Location + # + # The Location of the `in` keyword. + # + # for i in a end + # ^^ + # -- + # : () -> Location + def in_keyword_loc: () -> Location + + # :category: Repository + # Save the in_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_in_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # do_keyword_loc -> Location | nil + # + # The Location of the `do` keyword, if present. + # + # for i in a do end + # ^^ + # -- + # : () -> Location? + def do_keyword_loc: () -> Location? + + # :category: Repository + # Save the do_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_do_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location + # + # The Location of the `end` keyword. + # + # for i in a end + # ^^^ + # -- + # : () -> Location + def end_keyword_loc: () -> Location + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # for_keyword -> String + # + # Slice the location of for_keyword_loc from the source. + # -- + # : () -> String + def for_keyword: () -> String + + # :call-seq: + # in_keyword -> String + # + # Slice the location of in_keyword_loc from the source. + # -- + # : () -> String + def in_keyword: () -> String + + # :call-seq: + # do_keyword -> String | nil + # + # Slice the location of do_keyword_loc from the source. + # -- + # : () -> String? + def do_keyword: () -> String? + + # :call-seq: + # end_keyword -> String + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String + def end_keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents forwarding all arguments to this method to another method. + # + # def foo(...) + # bar(...) + # ^^^ + # end + class ForwardingArgumentsNode < Node + # Initialize a new ForwardingArgumentsNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ForwardingArgumentsNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> ForwardingArgumentsNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> ForwardingArgumentsNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :forwarding_arguments_node + def type: () -> :forwarding_arguments_node + + # See `Node.type`. + # -- + # : () -> :forwarding_arguments_node + def self.type: () -> :forwarding_arguments_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the forwarding parameter in a method, block, or lambda declaration. + # + # def foo(...) + # ^^^ + # end + class ForwardingParameterNode < Node + # Initialize a new ForwardingParameterNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ForwardingParameterNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> ForwardingParameterNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> ForwardingParameterNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :forwarding_parameter_node + def type: () -> :forwarding_parameter_node + + # See `Node.type`. + # -- + # : () -> :forwarding_parameter_node + def self.type: () -> :forwarding_parameter_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `super` keyword without parentheses or arguments, but which might have a block. + # + # super + # ^^^^^ + # + # super { 123 } + # ^^^^^^^^^^^^^ + # + # If it has any other arguments, it would be a `SuperNode` instead. + class ForwardingSuperNode < Node + @block: BlockNode? + + # Initialize a new ForwardingSuperNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, BlockNode? block) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, BlockNode? block) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :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, ?block: BlockNode?) -> ForwardingSuperNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?block: BlockNode?) -> ForwardingSuperNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :forwarding_super_node + def type: () -> :forwarding_super_node + + # See `Node.type`. + # -- + # : () -> :forwarding_super_node + def self.type: () -> :forwarding_super_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # block -> BlockNode | nil + # + # All other arguments are forwarded as normal, except the original block is replaced with the new block. + # -- + # : () -> BlockNode? + def block: () -> BlockNode? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `&&=` operator for assignment to a global variable. + # + # $target &&= value + # ^^^^^^^^^^^^^^^^^ + class GlobalVariableAndWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new GlobalVariableAndWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> GlobalVariableAndWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> GlobalVariableAndWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> GlobalVariableAndWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :global_variable_and_write_node + def type: () -> :global_variable_and_write_node + + # See `Node.type`. + # -- + # : () -> :global_variable_and_write_node + def self.type: () -> :global_variable_and_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents assigning to a global variable using an operator that isn't `=`. + # + # $target += value + # ^^^^^^^^^^^^^^^^ + class GlobalVariableOperatorWriteNode < Node + @binary_operator: Symbol + + @value: Prism::node + + @binary_operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new GlobalVariableOperatorWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> GlobalVariableOperatorWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> GlobalVariableOperatorWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> GlobalVariableOperatorWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :global_variable_operator_write_node + def type: () -> :global_variable_operator_write_node + + # See `Node.type`. + # -- + # : () -> :global_variable_operator_write_node + def self.type: () -> :global_variable_operator_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # binary_operator_loc -> Location + # + # Returns the Location represented by `binary_operator_loc`. + # -- + # : () -> Location + def binary_operator_loc: () -> Location + + # :category: Repository + # Save the binary_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_binary_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # binary_operator -> Symbol + # + # Returns the `binary_operator` attribute. + # -- + # : () -> Symbol + def binary_operator: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `||=` operator for assignment to a global variable. + # + # $target ||= value + # ^^^^^^^^^^^^^^^^^ + class GlobalVariableOrWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new GlobalVariableOrWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> GlobalVariableOrWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> GlobalVariableOrWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> GlobalVariableOrWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :global_variable_or_write_node + def type: () -> :global_variable_or_write_node + + # See `Node.type`. + # -- + # : () -> :global_variable_or_write_node + def self.type: () -> :global_variable_or_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents referencing a global variable. + # + # $foo + # ^^^^ + class GlobalVariableReadNode < Node + @name: Symbol + + # Initialize a new GlobalVariableReadNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> GlobalVariableReadNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> GlobalVariableReadNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> GlobalVariableReadNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :global_variable_read_node + def type: () -> :global_variable_read_node + + # See `Node.type`. + # -- + # : () -> :global_variable_read_node + def self.type: () -> :global_variable_read_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the global variable, which is a `$` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifier). Alternatively, it can be one of the special global variables designated by a symbol. + # + # $foo # name `:$foo` + # + # $_Test # name `:$_Test` + # -- + # : () -> Symbol + def name: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to a global variable in a context that doesn't have an explicit value. + # + # $foo, $bar = baz + # ^^^^ ^^^^ + class GlobalVariableTargetNode < Node + @name: Symbol + + # Initialize a new GlobalVariableTargetNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> GlobalVariableTargetNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> GlobalVariableTargetNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> GlobalVariableTargetNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :global_variable_target_node + def type: () -> :global_variable_target_node + + # See `Node.type`. + # -- + # : () -> :global_variable_target_node + def self.type: () -> :global_variable_target_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to a global variable. + # + # $foo = 1 + # ^^^^^^^^ + class GlobalVariableWriteNode < Node + @operator_loc: Location + + @value: Prism::node + + @name_loc: Location + + @name: Symbol + + # Initialize a new GlobalVariableWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> GlobalVariableWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> GlobalVariableWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> GlobalVariableWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :global_variable_write_node + def type: () -> :global_variable_write_node + + # See `Node.type`. + # -- + # : () -> :global_variable_write_node + def self.type: () -> :global_variable_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the global variable, which is a `$` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifier). Alternatively, it can be one of the special global variables designated by a symbol. + # + # $foo = :bar # name `:$foo` + # + # $_Test = 123 # name `:$_Test` + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # The Location of the global variable's name. + # + # $foo = :bar + # ^^^^ + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # The value to write to the global variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # $foo = :bar + # ^^^^ + # + # $-xyz = 123 + # ^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `=` operator. + # + # $foo = :bar + # ^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a hash literal. + # + # { a => b } + # ^^^^^^^^^^ + class HashNode < Node + @closing_loc: Location + + @elements: Array[AssocNode | AssocSplatNode] + + @opening_loc: Location + + # Initialize a new HashNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Array[AssocNode | AssocSplatNode] elements, Location closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Array[AssocNode | AssocSplatNode] elements, Location closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> HashNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?elements: Array[AssocNode | AssocSplatNode], ?closing_loc: Location) -> HashNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?elements: Array[AssocNode | AssocSplatNode], ?closing_loc: Location) -> HashNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :hash_node + def type: () -> :hash_node + + # See `Node.type`. + # -- + # : () -> :hash_node + def self.type: () -> :hash_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # The Location of the opening brace. + # + # { a => b } + # ^ + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # elements -> Array[AssocNode | AssocSplatNode] + # + # The elements of the hash. These can be either `AssocNode`s or `AssocSplatNode`s. + # + # { a: b } + # ^^^^ + # + # { **foo } + # ^^^^^ + # -- + # : () -> Array[AssocNode | AssocSplatNode] + def elements: () -> Array[AssocNode | AssocSplatNode] + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # The Location of the closing brace. + # + # { a => b } + # ^ + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a hash pattern in pattern matching. + # + # foo => { a: 1, b: 2 } + # ^^^^^^^^^^^^^^ + # + # foo => { a: 1, b: 2, **c } + # ^^^^^^^^^^^^^^^^^^^ + # + # foo => Bar[a: 1, b: 2] + # ^^^^^^^^^^^^^^^ + # + # foo in { a: 1, b: 2 } + # ^^^^^^^^^^^^^^ + class HashPatternNode < Node + @closing_loc: Location? + + @opening_loc: Location? + + @rest: (AssocSplatNode | NoKeywordsParameterNode)? + + @elements: Array[AssocNode] + + @constant: (ConstantPathNode | ConstantReadNode)? + + # Initialize a new HashPatternNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, (ConstantPathNode | ConstantReadNode)? constant, Array[AssocNode] elements, (AssocSplatNode | NoKeywordsParameterNode)? rest, Location? opening_loc, Location? closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, (ConstantPathNode | ConstantReadNode)? constant, Array[AssocNode] elements, (AssocSplatNode | NoKeywordsParameterNode)? rest, Location? opening_loc, Location? closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> HashPatternNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?elements: Array[AssocNode], ?rest: (AssocSplatNode | NoKeywordsParameterNode)?, ?opening_loc: Location?, ?closing_loc: Location?) -> HashPatternNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?constant: (ConstantPathNode | ConstantReadNode)?, ?elements: Array[AssocNode], ?rest: (AssocSplatNode | NoKeywordsParameterNode)?, ?opening_loc: Location?, ?closing_loc: Location?) -> HashPatternNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :hash_pattern_node + def type: () -> :hash_pattern_node + + # See `Node.type`. + # -- + # : () -> :hash_pattern_node + def self.type: () -> :hash_pattern_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # constant -> ConstantPathNode | ConstantReadNode | nil + # + # Represents the optional constant preceding the Hash. + # + # foo => Bar[a: 1, b: 2] + # ^^^ + # + # foo => Bar::Baz[a: 1, b: 2] + # ^^^^^^^^ + # -- + # : () -> (ConstantPathNode | ConstantReadNode)? + def constant: () -> (ConstantPathNode | ConstantReadNode)? + + # :call-seq: + # elements -> Array[AssocNode] + # + # Represents the explicit named hash keys and values. + # + # foo => { a: 1, b:, ** } + # ^^^^^^^^ + # -- + # : () -> Array[AssocNode] + def elements: () -> Array[AssocNode] + + # :call-seq: + # rest -> AssocSplatNode | NoKeywordsParameterNode | nil + # + # Represents the rest of the Hash keys and values. This can be named, unnamed, or explicitly forbidden via `**nil`, this last one results in a `NoKeywordsParameterNode`. + # + # foo => { a: 1, b:, **c } + # ^^^ + # + # foo => { a: 1, b:, ** } + # ^^ + # + # foo => { a: 1, b:, **nil } + # ^^^^^ + # -- + # : () -> (AssocSplatNode | NoKeywordsParameterNode)? + def rest: () -> (AssocSplatNode | NoKeywordsParameterNode)? + + # :category: Locations + # :call-seq: + # opening_loc -> Location | nil + # + # The Location of the opening brace. + # + # foo => { a: 1 } + # ^ + # + # foo => Bar[a: 1] + # ^ + # -- + # : () -> Location? + def opening_loc: () -> Location? + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_opening_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # The Location of the closing brace. + # + # foo => { a: 1 } + # ^ + # + # foo => Bar[a: 1] + # ^ + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # opening -> String | nil + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String? + def opening: () -> String? + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `if` keyword, either in the block form or the modifier form, or a ternary expression. + # + # bar if foo + # ^^^^^^^^^^ + # + # if foo then bar end + # ^^^^^^^^^^^^^^^^^^^ + # + # foo ? bar : baz + # ^^^^^^^^^^^^^^^ + class IfNode < Node + @end_keyword_loc: Location? + + @subsequent: (ElseNode | IfNode)? + + @statements: StatementsNode? + + @then_keyword_loc: Location? + + @predicate: Prism::node + + @if_keyword_loc: Location? + + # Initialize a new IfNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location? if_keyword_loc, Prism::node predicate, Location? then_keyword_loc, StatementsNode? statements, (ElseNode | IfNode)? subsequent, Location? end_keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location? if_keyword_loc, Prism::node predicate, Location? then_keyword_loc, StatementsNode? statements, (ElseNode | IfNode)? subsequent, Location? end_keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> IfNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?if_keyword_loc: Location?, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?subsequent: (ElseNode | IfNode)?, ?end_keyword_loc: Location?) -> IfNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?if_keyword_loc: Location?, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?subsequent: (ElseNode | IfNode)?, ?end_keyword_loc: Location?) -> IfNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :if_node + def type: () -> :if_node + + # See `Node.type`. + # -- + # : () -> :if_node + def self.type: () -> :if_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # if_keyword_loc -> Location | nil + # + # The Location of the `if` keyword if present. + # + # bar if foo + # ^^ + # + # The `if_keyword_loc` field will be `nil` when the `IfNode` represents a ternary expression. + # -- + # : () -> Location? + def if_keyword_loc: () -> Location? + + # :category: Repository + # Save the if_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_if_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # predicate -> Node + # + # The node for the condition the `IfNode` is testing. + # + # if foo + # ^^^ + # bar + # end + # + # bar if foo + # ^^^ + # + # foo ? bar : baz + # ^^^ + # -- + # : () -> Prism::node + def predicate: () -> Prism::node + + # :category: Locations + # :call-seq: + # then_keyword_loc -> Location | nil + # + # The Location of the `then` keyword (if present) or the `?` in a ternary expression, `nil` otherwise. + # + # if foo then bar end + # ^^^^ + # + # a ? b : c + # ^ + # -- + # : () -> Location? + def then_keyword_loc: () -> Location? + + # :category: Repository + # Save the then_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_then_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # statements -> StatementsNode | nil + # + # Represents the body of statements that will be executed when the predicate is evaluated as truthy. Will be `nil` when no body is provided. + # + # if foo + # bar + # ^^^ + # baz + # ^^^ + # end + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :call-seq: + # subsequent -> ElseNode | IfNode | nil + # + # Represents an `ElseNode` or an `IfNode` when there is an `else` or an `elsif` in the `if` statement. + # + # if foo + # bar + # elsif baz + # ^^^^^^^^^ + # qux + # ^^^ + # end + # ^^^ + # + # if foo then bar else baz end + # ^^^^^^^^^^^^ + # -- + # : () -> (ElseNode | IfNode)? + def subsequent: () -> (ElseNode | IfNode)? + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location | nil + # + # The Location of the `end` keyword if present, `nil` otherwise. + # + # if foo + # bar + # end + # ^^^ + # -- + # : () -> Location? + def end_keyword_loc: () -> Location? + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # if_keyword -> String | nil + # + # Slice the location of if_keyword_loc from the source. + # -- + # : () -> String? + def if_keyword: () -> String? + + # :call-seq: + # then_keyword -> String | nil + # + # Slice the location of then_keyword_loc from the source. + # -- + # : () -> String? + def then_keyword: () -> String? + + # :call-seq: + # end_keyword -> String | nil + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String? + def end_keyword: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an imaginary number literal. + # + # 1.0i + # ^^^^ + class ImaginaryNode < Node + @numeric: FloatNode | IntegerNode | RationalNode + + # Initialize a new ImaginaryNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, (FloatNode | IntegerNode | RationalNode) numeric) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, FloatNode | IntegerNode | RationalNode numeric) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ImaginaryNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?numeric: (FloatNode | IntegerNode | RationalNode)) -> ImaginaryNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?numeric: FloatNode | IntegerNode | RationalNode) -> ImaginaryNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :imaginary_node + def type: () -> :imaginary_node + + # See `Node.type`. + # -- + # : () -> :imaginary_node + def self.type: () -> :imaginary_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # numeric -> FloatNode | IntegerNode | RationalNode + # + # Returns the `numeric` attribute. + # -- + # : () -> (FloatNode | IntegerNode | RationalNode) + def numeric: () -> (FloatNode | IntegerNode | RationalNode) + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a node that is implicitly being added to the tree but doesn't correspond directly to a node in the source. + # + # { foo: } + # ^^^^ + # + # { Foo: } + # ^^^^ + # + # foo in { bar: } + # ^^^^ + class ImplicitNode < Node + @value: LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode + + # Initialize a new ImplicitNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, (LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode) value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ImplicitNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: (LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode)) -> ImplicitNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode) -> ImplicitNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :implicit_node + def type: () -> :implicit_node + + # See `Node.type`. + # -- + # : () -> :implicit_node + def self.type: () -> :implicit_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # value -> LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode + # + # Returns the `value` attribute. + # -- + # : () -> (LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode) + def value: () -> (LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode) + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents using a trailing comma to indicate an implicit rest parameter. + # + # foo { |bar,| } + # ^ + # + # foo in [bar,] + # ^ + # + # for foo, in bar do end + # ^ + # + # foo, = bar + # ^ + class ImplicitRestNode < Node + # Initialize a new ImplicitRestNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ImplicitRestNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> ImplicitRestNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> ImplicitRestNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :implicit_rest_node + def type: () -> :implicit_rest_node + + # See `Node.type`. + # -- + # : () -> :implicit_rest_node + def self.type: () -> :implicit_rest_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `in` keyword in a case statement. + # + # case a; in b then c end + # ^^^^^^^^^^^ + class InNode < Node + @then_loc: Location? + + @in_loc: Location + + @statements: StatementsNode? + + @pattern: Prism::node + + # Initialize a new InNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node pattern, StatementsNode? statements, Location in_loc, Location? then_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node pattern, StatementsNode? statements, Location in_loc, Location? then_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?pattern: Prism::node, ?statements: StatementsNode?, ?in_loc: Location, ?then_loc: Location?) -> InNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?pattern: Prism::node, ?statements: StatementsNode?, ?in_loc: Location, ?then_loc: Location?) -> InNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :in_node + def type: () -> :in_node + + # See `Node.type`. + # -- + # : () -> :in_node + def self.type: () -> :in_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # pattern -> Node + # + # Returns the `pattern` attribute. + # -- + # : () -> Prism::node + def pattern: () -> Prism::node + + # :call-seq: + # statements -> StatementsNode | nil + # + # Returns the `statements` attribute. + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :category: Locations + # :call-seq: + # in_loc -> Location + # + # Returns the Location represented by `in_loc`. + # -- + # : () -> Location + def in_loc: () -> Location + + # :category: Repository + # Save the in_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_in_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # then_loc -> Location | nil + # + # Returns the Location represented by `then_loc`. + # -- + # : () -> Location? + def then_loc: () -> Location? + + # :category: Repository + # Save the then_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_then_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # in -> String + # + # Slice the location of in_loc from the source. + # -- + # : () -> String + def in: () -> String + + # :call-seq: + # then -> String | nil + # + # Slice the location of then_loc from the source. + # -- + # : () -> String? + def then: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `&&=` operator on a call to the `[]` method. + # + # foo.bar[baz] &&= value + # ^^^^^^^^^^^^^^^^^^^^^^ + class IndexAndWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @block: BlockArgumentNode? + + @closing_loc: Location + + @arguments: ArgumentsNode? + + @opening_loc: Location + + @call_operator_loc: Location? + + @receiver: Prism::node? + + # Initialize a new IndexAndWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, BlockArgumentNode? block, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, BlockArgumentNode? block, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> IndexAndWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?operator_loc: Location, ?value: Prism::node) -> IndexAndWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?operator_loc: Location, ?value: Prism::node) -> IndexAndWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :index_and_write_node + def type: () -> :index_and_write_node + + # See `Node.type`. + # -- + # : () -> :index_and_write_node + def self.type: () -> :index_and_write_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # &. operator + # -- + # : () -> bool + def safe_navigation?: () -> bool + + # :category: Flags + # a call that could have been a local variable + # -- + # : () -> bool + def variable_call?: () -> bool + + # :category: Flags + # a call that is an attribute write, so the value being written should be returned + # -- + # : () -> bool + def attribute_write?: () -> bool + + # :category: Flags + # a call that ignores method visibility + # -- + # : () -> bool + def ignore_visibility?: () -> bool + + # :call-seq: + # receiver -> Node | nil + # + # Returns the `receiver` attribute. + # -- + # : () -> Prism::node? + def receiver: () -> Prism::node? + + # :category: Locations + # :call-seq: + # call_operator_loc -> Location | nil + # + # Returns the Location represented by `call_operator_loc`. + # -- + # : () -> Location? + def call_operator_loc: () -> Location? + + # :category: Repository + # Save the call_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_call_operator_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # arguments -> ArgumentsNode | nil + # + # Returns the `arguments` attribute. + # -- + # : () -> ArgumentsNode? + def arguments: () -> ArgumentsNode? + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # block -> BlockArgumentNode | nil + # + # Returns the `block` attribute. + # -- + # : () -> BlockArgumentNode? + def block: () -> BlockArgumentNode? + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # call_operator -> String | nil + # + # Slice the location of call_operator_loc from the source. + # -- + # : () -> String? + def call_operator: () -> String? + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of an assignment operator on a call to `[]`. + # + # foo.bar[baz] += value + # ^^^^^^^^^^^^^^^^^^^^^ + class IndexOperatorWriteNode < Node + @value: Prism::node + + @binary_operator_loc: Location + + @binary_operator: Symbol + + @block: BlockArgumentNode? + + @closing_loc: Location + + @arguments: ArgumentsNode? + + @opening_loc: Location + + @call_operator_loc: Location? + + @receiver: Prism::node? + + # Initialize a new IndexOperatorWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, BlockArgumentNode? block, Symbol binary_operator, Location binary_operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, BlockArgumentNode? block, Symbol binary_operator, Location binary_operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> IndexOperatorWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> IndexOperatorWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> IndexOperatorWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :index_operator_write_node + def type: () -> :index_operator_write_node + + # See `Node.type`. + # -- + # : () -> :index_operator_write_node + def self.type: () -> :index_operator_write_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # &. operator + # -- + # : () -> bool + def safe_navigation?: () -> bool + + # :category: Flags + # a call that could have been a local variable + # -- + # : () -> bool + def variable_call?: () -> bool + + # :category: Flags + # a call that is an attribute write, so the value being written should be returned + # -- + # : () -> bool + def attribute_write?: () -> bool + + # :category: Flags + # a call that ignores method visibility + # -- + # : () -> bool + def ignore_visibility?: () -> bool + + # :call-seq: + # receiver -> Node | nil + # + # Returns the `receiver` attribute. + # -- + # : () -> Prism::node? + def receiver: () -> Prism::node? + + # :category: Locations + # :call-seq: + # call_operator_loc -> Location | nil + # + # Returns the Location represented by `call_operator_loc`. + # -- + # : () -> Location? + def call_operator_loc: () -> Location? + + # :category: Repository + # Save the call_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_call_operator_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # arguments -> ArgumentsNode | nil + # + # Returns the `arguments` attribute. + # -- + # : () -> ArgumentsNode? + def arguments: () -> ArgumentsNode? + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # block -> BlockArgumentNode | nil + # + # Returns the `block` attribute. + # -- + # : () -> BlockArgumentNode? + def block: () -> BlockArgumentNode? + + # :call-seq: + # binary_operator -> Symbol + # + # Returns the `binary_operator` attribute. + # -- + # : () -> Symbol + def binary_operator: () -> Symbol + + # :category: Locations + # :call-seq: + # binary_operator_loc -> Location + # + # Returns the Location represented by `binary_operator_loc`. + # -- + # : () -> Location + def binary_operator_loc: () -> Location + + # :category: Repository + # Save the binary_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_binary_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # call_operator -> String | nil + # + # Slice the location of call_operator_loc from the source. + # -- + # : () -> String? + def call_operator: () -> String? + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `||=` operator on a call to `[]`. + # + # foo.bar[baz] ||= value + # ^^^^^^^^^^^^^^^^^^^^^^ + class IndexOrWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @block: BlockArgumentNode? + + @closing_loc: Location + + @arguments: ArgumentsNode? + + @opening_loc: Location + + @call_operator_loc: Location? + + @receiver: Prism::node? + + # Initialize a new IndexOrWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, BlockArgumentNode? block, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, BlockArgumentNode? block, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> IndexOrWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?operator_loc: Location, ?value: Prism::node) -> IndexOrWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?operator_loc: Location, ?value: Prism::node) -> IndexOrWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :index_or_write_node + def type: () -> :index_or_write_node + + # See `Node.type`. + # -- + # : () -> :index_or_write_node + def self.type: () -> :index_or_write_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # &. operator + # -- + # : () -> bool + def safe_navigation?: () -> bool + + # :category: Flags + # a call that could have been a local variable + # -- + # : () -> bool + def variable_call?: () -> bool + + # :category: Flags + # a call that is an attribute write, so the value being written should be returned + # -- + # : () -> bool + def attribute_write?: () -> bool + + # :category: Flags + # a call that ignores method visibility + # -- + # : () -> bool + def ignore_visibility?: () -> bool + + # :call-seq: + # receiver -> Node | nil + # + # Returns the `receiver` attribute. + # -- + # : () -> Prism::node? + def receiver: () -> Prism::node? + + # :category: Locations + # :call-seq: + # call_operator_loc -> Location | nil + # + # Returns the Location represented by `call_operator_loc`. + # -- + # : () -> Location? + def call_operator_loc: () -> Location? + + # :category: Repository + # Save the call_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_call_operator_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # arguments -> ArgumentsNode | nil + # + # Returns the `arguments` attribute. + # -- + # : () -> ArgumentsNode? + def arguments: () -> ArgumentsNode? + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # block -> BlockArgumentNode | nil + # + # Returns the `block` attribute. + # -- + # : () -> BlockArgumentNode? + def block: () -> BlockArgumentNode? + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # call_operator -> String | nil + # + # Slice the location of call_operator_loc from the source. + # -- + # : () -> String? + def call_operator: () -> String? + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents assigning to an index. + # + # foo[bar], = 1 + # ^^^^^^^^ + # + # begin + # rescue => foo[bar] + # ^^^^^^^^ + # end + # + # for foo[bar] in baz do end + # ^^^^^^^^ + class IndexTargetNode < Node + @block: BlockArgumentNode? + + @closing_loc: Location + + @arguments: ArgumentsNode? + + @opening_loc: Location + + @receiver: Prism::node + + # Initialize a new IndexTargetNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node receiver, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, BlockArgumentNode? block) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node receiver, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, BlockArgumentNode? block) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> IndexTargetNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?) -> IndexTargetNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?) -> IndexTargetNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :index_target_node + def type: () -> :index_target_node + + # See `Node.type`. + # -- + # : () -> :index_target_node + def self.type: () -> :index_target_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # &. operator + # -- + # : () -> bool + def safe_navigation?: () -> bool + + # :category: Flags + # a call that could have been a local variable + # -- + # : () -> bool + def variable_call?: () -> bool + + # :category: Flags + # a call that is an attribute write, so the value being written should be returned + # -- + # : () -> bool + def attribute_write?: () -> bool + + # :category: Flags + # a call that ignores method visibility + # -- + # : () -> bool + def ignore_visibility?: () -> bool + + # :call-seq: + # receiver -> Node + # + # Returns the `receiver` attribute. + # -- + # : () -> Prism::node + def receiver: () -> Prism::node + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # arguments -> ArgumentsNode | nil + # + # Returns the `arguments` attribute. + # -- + # : () -> ArgumentsNode? + def arguments: () -> ArgumentsNode? + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # block -> BlockArgumentNode | nil + # + # Returns the `block` attribute. + # -- + # : () -> BlockArgumentNode? + def block: () -> BlockArgumentNode? + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `&&=` operator for assignment to an instance variable. + # + # @target &&= value + # ^^^^^^^^^^^^^^^^^ + class InstanceVariableAndWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new InstanceVariableAndWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InstanceVariableAndWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> InstanceVariableAndWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> InstanceVariableAndWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :instance_variable_and_write_node + def type: () -> :instance_variable_and_write_node + + # See `Node.type`. + # -- + # : () -> :instance_variable_and_write_node + def self.type: () -> :instance_variable_and_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents assigning to an instance variable using an operator that isn't `=`. + # + # @target += value + # ^^^^^^^^^^^^^^^^ + class InstanceVariableOperatorWriteNode < Node + @binary_operator: Symbol + + @value: Prism::node + + @binary_operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new InstanceVariableOperatorWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InstanceVariableOperatorWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> InstanceVariableOperatorWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> InstanceVariableOperatorWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :instance_variable_operator_write_node + def type: () -> :instance_variable_operator_write_node + + # See `Node.type`. + # -- + # : () -> :instance_variable_operator_write_node + def self.type: () -> :instance_variable_operator_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # binary_operator_loc -> Location + # + # Returns the Location represented by `binary_operator_loc`. + # -- + # : () -> Location + def binary_operator_loc: () -> Location + + # :category: Repository + # Save the binary_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_binary_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # binary_operator -> Symbol + # + # Returns the `binary_operator` attribute. + # -- + # : () -> Symbol + def binary_operator: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `||=` operator for assignment to an instance variable. + # + # @target ||= value + # ^^^^^^^^^^^^^^^^^ + class InstanceVariableOrWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new InstanceVariableOrWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InstanceVariableOrWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> InstanceVariableOrWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> InstanceVariableOrWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :instance_variable_or_write_node + def type: () -> :instance_variable_or_write_node + + # See `Node.type`. + # -- + # : () -> :instance_variable_or_write_node + def self.type: () -> :instance_variable_or_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents referencing an instance variable. + # + # @foo + # ^^^^ + class InstanceVariableReadNode < Node + @name: Symbol + + # Initialize a new InstanceVariableReadNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InstanceVariableReadNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> InstanceVariableReadNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> InstanceVariableReadNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :instance_variable_read_node + def type: () -> :instance_variable_read_node + + # See `Node.type`. + # -- + # : () -> :instance_variable_read_node + def self.type: () -> :instance_variable_read_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the instance variable, which is a `@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers). + # + # @x # name `:@x` + # + # @_test # name `:@_test` + # -- + # : () -> Symbol + def name: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to an instance variable in a context that doesn't have an explicit value. + # + # @foo, @bar = baz + # ^^^^ ^^^^ + class InstanceVariableTargetNode < Node + @name: Symbol + + # Initialize a new InstanceVariableTargetNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InstanceVariableTargetNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> InstanceVariableTargetNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> InstanceVariableTargetNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :instance_variable_target_node + def type: () -> :instance_variable_target_node + + # See `Node.type`. + # -- + # : () -> :instance_variable_target_node + def self.type: () -> :instance_variable_target_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to an instance variable. + # + # @foo = 1 + # ^^^^^^^^ + class InstanceVariableWriteNode < Node + @operator_loc: Location + + @value: Prism::node + + @name_loc: Location + + @name: Symbol + + # Initialize a new InstanceVariableWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InstanceVariableWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> InstanceVariableWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> InstanceVariableWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :instance_variable_write_node + def type: () -> :instance_variable_write_node + + # See `Node.type`. + # -- + # : () -> :instance_variable_write_node + def self.type: () -> :instance_variable_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the instance variable, which is a `@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers). + # + # @x = :y # name `:@x` + # + # @_foo = "bar" # name `@_foo` + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # The Location of the variable name. + # + # @_x = 1 + # ^^^ + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # The value to write to the instance variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # @foo = :bar + # ^^^^ + # + # @_x = 1234 + # ^^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `=` operator. + # + # @x = y + # ^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an integer number literal. + # + # 1 + # ^ + class IntegerNode < Node + @value: Integer + + # Initialize a new IntegerNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Integer value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Integer value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> IntegerNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Integer) -> IntegerNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Integer) -> IntegerNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :integer_node + def type: () -> :integer_node + + # See `Node.type`. + # -- + # : () -> :integer_node + def self.type: () -> :integer_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # 0b prefix + # -- + # : () -> bool + def binary?: () -> bool + + # :category: Flags + # 0d or no prefix + # -- + # : () -> bool + def decimal?: () -> bool + + # :category: Flags + # 0o or 0 prefix + # -- + # : () -> bool + def octal?: () -> bool + + # :category: Flags + # 0x prefix + # -- + # : () -> bool + def hexadecimal?: () -> bool + + # :call-seq: + # value -> Integer + # + # The value of the integer literal as a number. + # -- + # : () -> Integer + def value: () -> Integer + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a regular expression literal that contains interpolation that is being used in the predicate of a conditional to implicitly match against the last line read by an IO object. + # + # if /foo #{bar} baz/ then end + # ^^^^^^^^^^^^^^^^ + class InterpolatedMatchLastLineNode < Node + @closing_loc: Location + + @parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + + @opening_loc: Location + + # Initialize a new InterpolatedMatchLastLineNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InterpolatedMatchLastLineNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedMatchLastLineNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedMatchLastLineNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :interpolated_match_last_line_node + def type: () -> :interpolated_match_last_line_node + + # See `Node.type`. + # -- + # : () -> :interpolated_match_last_line_node + def self.type: () -> :interpolated_match_last_line_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # i - ignores the case of characters when matching + # -- + # : () -> bool + def ignore_case?: () -> bool + + # :category: Flags + # x - ignores whitespace and allows comments in regular expressions + # -- + # : () -> bool + def extended?: () -> bool + + # :category: Flags + # m - allows $ to match the end of lines within strings + # -- + # : () -> bool + def multi_line?: () -> bool + + # :category: Flags + # o - only interpolates values into the regular expression once + # -- + # : () -> bool + def once?: () -> bool + + # :category: Flags + # e - forces the EUC-JP encoding + # -- + # : () -> bool + def euc_jp?: () -> bool + + # :category: Flags + # n - forces the ASCII-8BIT encoding + # -- + # : () -> bool + def ascii_8bit?: () -> bool + + # :category: Flags + # s - forces the Windows-31J encoding + # -- + # : () -> bool + def windows_31j?: () -> bool + + # :category: Flags + # u - forces the UTF-8 encoding + # -- + # : () -> bool + def utf_8?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to UTF-8 + # -- + # : () -> bool + def forced_utf8_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to binary + # -- + # : () -> bool + def forced_binary_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to US-ASCII + # -- + # : () -> bool + def forced_us_ascii_encoding?: () -> bool + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # parts -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + # + # Returns the `parts` attribute. + # -- + # : () -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + def parts: () -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a regular expression literal that contains interpolation. + # + # /foo #{bar} baz/ + # ^^^^^^^^^^^^^^^^ + class InterpolatedRegularExpressionNode < Node + @closing_loc: Location + + @parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + + @opening_loc: Location + + # Initialize a new InterpolatedRegularExpressionNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InterpolatedRegularExpressionNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedRegularExpressionNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedRegularExpressionNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :interpolated_regular_expression_node + def type: () -> :interpolated_regular_expression_node + + # See `Node.type`. + # -- + # : () -> :interpolated_regular_expression_node + def self.type: () -> :interpolated_regular_expression_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # i - ignores the case of characters when matching + # -- + # : () -> bool + def ignore_case?: () -> bool + + # :category: Flags + # x - ignores whitespace and allows comments in regular expressions + # -- + # : () -> bool + def extended?: () -> bool + + # :category: Flags + # m - allows $ to match the end of lines within strings + # -- + # : () -> bool + def multi_line?: () -> bool + + # :category: Flags + # o - only interpolates values into the regular expression once + # -- + # : () -> bool + def once?: () -> bool + + # :category: Flags + # e - forces the EUC-JP encoding + # -- + # : () -> bool + def euc_jp?: () -> bool + + # :category: Flags + # n - forces the ASCII-8BIT encoding + # -- + # : () -> bool + def ascii_8bit?: () -> bool + + # :category: Flags + # s - forces the Windows-31J encoding + # -- + # : () -> bool + def windows_31j?: () -> bool + + # :category: Flags + # u - forces the UTF-8 encoding + # -- + # : () -> bool + def utf_8?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to UTF-8 + # -- + # : () -> bool + def forced_utf8_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to binary + # -- + # : () -> bool + def forced_binary_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to US-ASCII + # -- + # : () -> bool + def forced_us_ascii_encoding?: () -> bool + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # parts -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + # + # Returns the `parts` attribute. + # -- + # : () -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + def parts: () -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a string literal that contains interpolation. + # + # "foo #{bar} baz" + # ^^^^^^^^^^^^^^^^ + class InterpolatedStringNode < Node + @closing_loc: Location? + + @parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode] + + @opening_loc: Location? + + # Initialize a new InterpolatedStringNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location? opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode] parts, Location? closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location? opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode] parts, Location? closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InterpolatedStringNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode], ?closing_loc: Location?) -> InterpolatedStringNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode], ?closing_loc: Location?) -> InterpolatedStringNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :interpolated_string_node + def type: () -> :interpolated_string_node + + # See `Node.type`. + # -- + # : () -> :interpolated_string_node + def self.type: () -> :interpolated_string_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal`; only for adjacent string literals like `'a' 'b'` + # -- + # : () -> bool + def frozen?: () -> bool + + # :category: Flags + # mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal`; only for adjacent string literals like `'a' 'b'` + # -- + # : () -> bool + def mutable?: () -> bool + + # :category: Locations + # :call-seq: + # opening_loc -> Location | nil + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location? + def opening_loc: () -> Location? + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_opening_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # parts -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode] + # + # Returns the `parts` attribute. + # -- + # : () -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode] + def parts: () -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode] + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # opening -> String | nil + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String? + def opening: () -> String? + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a symbol literal that contains interpolation. + # + # :"foo #{bar} baz" + # ^^^^^^^^^^^^^^^^^ + class InterpolatedSymbolNode < Node + @closing_loc: Location? + + @parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + + @opening_loc: Location? + + # Initialize a new InterpolatedSymbolNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location? opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location? closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location? opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location? closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InterpolatedSymbolNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location?) -> InterpolatedSymbolNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location?) -> InterpolatedSymbolNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :interpolated_symbol_node + def type: () -> :interpolated_symbol_node + + # See `Node.type`. + # -- + # : () -> :interpolated_symbol_node + def self.type: () -> :interpolated_symbol_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # opening_loc -> Location | nil + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location? + def opening_loc: () -> Location? + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_opening_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # parts -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + # + # Returns the `parts` attribute. + # -- + # : () -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + def parts: () -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # opening -> String | nil + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String? + def opening: () -> String? + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an xstring literal that contains interpolation. + # + # `foo #{bar} baz` + # ^^^^^^^^^^^^^^^^ + class InterpolatedXStringNode < Node + @closing_loc: Location + + @parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + + @opening_loc: Location + + # Initialize a new InterpolatedXStringNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] parts, Location closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> InterpolatedXStringNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedXStringNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedXStringNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :interpolated_x_string_node + def type: () -> :interpolated_x_string_node + + # See `Node.type`. + # -- + # : () -> :interpolated_x_string_node + def self.type: () -> :interpolated_x_string_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # parts -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + # + # Returns the `parts` attribute. + # -- + # : () -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + def parts: () -> Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode] + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents reading from the implicit `it` local variable. + # + # -> { it } + # ^^ + class ItLocalVariableReadNode < Node + # Initialize a new ItLocalVariableReadNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ItLocalVariableReadNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> ItLocalVariableReadNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> ItLocalVariableReadNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :it_local_variable_read_node + def type: () -> :it_local_variable_read_node + + # See `Node.type`. + # -- + # : () -> :it_local_variable_read_node + def self.type: () -> :it_local_variable_read_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an implicit set of parameters through the use of the `it` keyword within a block or lambda. + # + # -> { it + it } + # ^^^^^^^^^^^^^^ + class ItParametersNode < Node + # Initialize a new ItParametersNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ItParametersNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> ItParametersNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> ItParametersNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :it_parameters_node + def type: () -> :it_parameters_node + + # See `Node.type`. + # -- + # : () -> :it_parameters_node + def self.type: () -> :it_parameters_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a hash literal without opening and closing braces. + # + # foo(a: b) + # ^^^^ + class KeywordHashNode < Node + @elements: Array[AssocNode | AssocSplatNode] + + # Initialize a new KeywordHashNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[AssocNode | AssocSplatNode] elements) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[AssocNode | AssocSplatNode] elements) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> KeywordHashNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?elements: Array[AssocNode | AssocSplatNode]) -> KeywordHashNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?elements: Array[AssocNode | AssocSplatNode]) -> KeywordHashNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :keyword_hash_node + def type: () -> :keyword_hash_node + + # See `Node.type`. + # -- + # : () -> :keyword_hash_node + def self.type: () -> :keyword_hash_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # a keyword hash which only has `AssocNode` elements all with symbol keys, which means the elements can be treated as keyword arguments + # -- + # : () -> bool + def symbol_keys?: () -> bool + + # :call-seq: + # elements -> Array[AssocNode | AssocSplatNode] + # + # Returns the `elements` attribute. + # -- + # : () -> Array[AssocNode | AssocSplatNode] + def elements: () -> Array[AssocNode | AssocSplatNode] + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a keyword rest parameter to a method, block, or lambda definition. + # + # def a(**b) + # ^^^ + # end + class KeywordRestParameterNode < Node + @operator_loc: Location + + @name_loc: Location? + + @name: Symbol? + + # Initialize a new KeywordRestParameterNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol? name, Location? name_loc, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol? name, Location? name_loc, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> KeywordRestParameterNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> KeywordRestParameterNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> KeywordRestParameterNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :keyword_rest_parameter_node + def type: () -> :keyword_rest_parameter_node + + # See `Node.type`. + # -- + # : () -> :keyword_rest_parameter_node + def self.type: () -> :keyword_rest_parameter_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # a parameter name that has been repeated in the method signature + # -- + # : () -> bool + def repeated_parameter?: () -> bool + + # :call-seq: + # name -> Symbol | nil + # + # Returns the `name` attribute. + # -- + # : () -> Symbol? + def name: () -> Symbol? + + # :category: Locations + # :call-seq: + # name_loc -> Location | nil + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location? + def name_loc: () -> Location? + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_name_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents using a lambda literal (not the lambda method call). + # + # ->(value) { value * 2 } + # ^^^^^^^^^^^^^^^^^^^^^^^ + class LambdaNode < Node + @body: (StatementsNode | BeginNode)? + + @parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)? + + @closing_loc: Location + + @opening_loc: Location + + @operator_loc: Location + + @locals: Array[Symbol] + + # Initialize a new LambdaNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, Location operator_loc, Location opening_loc, Location closing_loc, (BlockParametersNode | NumberedParametersNode | ItParametersNode)? parameters, (StatementsNode | BeginNode)? body) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, Location operator_loc, Location opening_loc, Location closing_loc, (BlockParametersNode | NumberedParametersNode | ItParametersNode)? parameters, (StatementsNode | BeginNode)? body) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> LambdaNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?operator_loc: Location, ?opening_loc: Location, ?closing_loc: Location, ?parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)?, ?body: (StatementsNode | BeginNode)?) -> LambdaNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?operator_loc: Location, ?opening_loc: Location, ?closing_loc: Location, ?parameters: (BlockParametersNode | NumberedParametersNode | ItParametersNode)?, ?body: (StatementsNode | BeginNode)?) -> LambdaNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :lambda_node + def type: () -> :lambda_node + + # See `Node.type`. + # -- + # : () -> :lambda_node + def self.type: () -> :lambda_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # locals -> Array[Symbol] + # + # Returns the `locals` attribute. + # -- + # : () -> Array[Symbol] + def locals: () -> Array[Symbol] + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # parameters -> BlockParametersNode | NumberedParametersNode | ItParametersNode | nil + # + # Returns the `parameters` attribute. + # -- + # : () -> (BlockParametersNode | NumberedParametersNode | ItParametersNode)? + def parameters: () -> (BlockParametersNode | NumberedParametersNode | ItParametersNode)? + + # :call-seq: + # body -> StatementsNode | BeginNode | nil + # + # Returns the `body` attribute. + # -- + # : () -> (StatementsNode | BeginNode)? + def body: () -> (StatementsNode | BeginNode)? + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `&&=` operator for assignment to a local variable. + # + # target &&= value + # ^^^^^^^^^^^^^^^^ + class LocalVariableAndWriteNode < Node + @depth: Integer + + @name: Symbol + + @value: Prism::node + + @operator_loc: Location + + @name_loc: Location + + # Initialize a new LocalVariableAndWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location name_loc, Location operator_loc, Prism::node value, Symbol name, Integer depth) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location name_loc, Location operator_loc, Prism::node value, Symbol name, Integer depth) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> LocalVariableAndWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?depth: Integer) -> LocalVariableAndWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?depth: Integer) -> LocalVariableAndWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :local_variable_and_write_node + def type: () -> :local_variable_and_write_node + + # See `Node.type`. + # -- + # : () -> :local_variable_and_write_node + def self.type: () -> :local_variable_and_write_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :call-seq: + # depth -> Integer + # + # Returns the `depth` attribute. + # -- + # : () -> Integer + def depth: () -> Integer + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents assigning to a local variable using an operator that isn't `=`. + # + # target += value + # ^^^^^^^^^^^^^^^ + class LocalVariableOperatorWriteNode < Node + @depth: Integer + + @binary_operator: Symbol + + @name: Symbol + + @value: Prism::node + + @binary_operator_loc: Location + + @name_loc: Location + + # Initialize a new LocalVariableOperatorWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol name, Symbol binary_operator, Integer depth) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol name, Symbol binary_operator, Integer depth) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> LocalVariableOperatorWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?binary_operator: Symbol, ?depth: Integer) -> LocalVariableOperatorWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?binary_operator: Symbol, ?depth: Integer) -> LocalVariableOperatorWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :local_variable_operator_write_node + def type: () -> :local_variable_operator_write_node + + # See `Node.type`. + # -- + # : () -> :local_variable_operator_write_node + def self.type: () -> :local_variable_operator_write_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # binary_operator_loc -> Location + # + # Returns the Location represented by `binary_operator_loc`. + # -- + # : () -> Location + def binary_operator_loc: () -> Location + + # :category: Repository + # Save the binary_operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_binary_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :call-seq: + # binary_operator -> Symbol + # + # Returns the `binary_operator` attribute. + # -- + # : () -> Symbol + def binary_operator: () -> Symbol + + # :call-seq: + # depth -> Integer + # + # Returns the `depth` attribute. + # -- + # : () -> Integer + def depth: () -> Integer + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `||=` operator for assignment to a local variable. + # + # target ||= value + # ^^^^^^^^^^^^^^^^ + class LocalVariableOrWriteNode < Node + @depth: Integer + + @name: Symbol + + @value: Prism::node + + @operator_loc: Location + + @name_loc: Location + + # Initialize a new LocalVariableOrWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location name_loc, Location operator_loc, Prism::node value, Symbol name, Integer depth) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location name_loc, Location operator_loc, Prism::node value, Symbol name, Integer depth) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> LocalVariableOrWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?depth: Integer) -> LocalVariableOrWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?depth: Integer) -> LocalVariableOrWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :local_variable_or_write_node + def type: () -> :local_variable_or_write_node + + # See `Node.type`. + # -- + # : () -> :local_variable_or_write_node + def self.type: () -> :local_variable_or_write_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :call-seq: + # depth -> Integer + # + # Returns the `depth` attribute. + # -- + # : () -> Integer + def depth: () -> Integer + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents reading a local variable. Note that this requires that a local variable of the same name has already been written to in the same scope, otherwise it is parsed as a method call. + # + # foo + # ^^^ + class LocalVariableReadNode < Node + @depth: Integer + + @name: Symbol + + # Initialize a new LocalVariableReadNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Integer depth) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Integer depth) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> LocalVariableReadNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer) -> LocalVariableReadNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer) -> LocalVariableReadNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :local_variable_read_node + def type: () -> :local_variable_read_node + + # See `Node.type`. + # -- + # : () -> :local_variable_read_node + def self.type: () -> :local_variable_read_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the local variable, which is an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers). + # + # x # name `:x` + # + # _Test # name `:_Test` + # + # Note that this can also be an underscore followed by a number for the default block parameters. + # + # _1 # name `:_1` + # -- + # : () -> Symbol + def name: () -> Symbol + + # :call-seq: + # depth -> Integer + # + # The number of visible scopes that should be searched to find the origin of this local variable. + # + # foo = 1; foo # depth 0 + # + # bar = 2; tap { bar } # depth 1 + # + # The specific rules for calculating the depth may differ from individual Ruby implementations, as they are not specified by the language. For more information, see [the Prism documentation](https://github.com/ruby/prism/blob/main/docs/local_variable_depth.md). + # -- + # : () -> Integer + def depth: () -> Integer + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to a local variable in a context that doesn't have an explicit value. + # + # foo, bar = baz + # ^^^ ^^^ + # + # foo => baz + # ^^^ + class LocalVariableTargetNode < Node + @depth: Integer + + @name: Symbol + + # Initialize a new LocalVariableTargetNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Integer depth) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Integer depth) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> LocalVariableTargetNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer) -> LocalVariableTargetNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer) -> LocalVariableTargetNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :local_variable_target_node + def type: () -> :local_variable_target_node + + # See `Node.type`. + # -- + # : () -> :local_variable_target_node + def self.type: () -> :local_variable_target_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :call-seq: + # depth -> Integer + # + # Returns the `depth` attribute. + # -- + # : () -> Integer + def depth: () -> Integer + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing to a local variable. + # + # foo = 1 + # ^^^^^^^ + class LocalVariableWriteNode < Node + @operator_loc: Location + + @value: Prism::node + + @name_loc: Location + + @depth: Integer + + @name: Symbol + + # Initialize a new LocalVariableWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Integer depth, Location name_loc, Prism::node value, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Integer depth, Location name_loc, Prism::node value, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> LocalVariableWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> LocalVariableWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?depth: Integer, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> LocalVariableWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :local_variable_write_node + def type: () -> :local_variable_write_node + + # See `Node.type`. + # -- + # : () -> :local_variable_write_node + def self.type: () -> :local_variable_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # name -> Symbol + # + # The name of the local variable, which is an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers). + # + # foo = :bar # name `:foo` + # + # abc = 123 # name `:abc` + # -- + # : () -> Symbol + def name: () -> Symbol + + # :call-seq: + # depth -> Integer + # + # The number of semantic scopes we have to traverse to find the declaration of this variable. + # + # foo = 1 # depth 0 + # + # tap { foo = 1 } # depth 1 + # + # The specific rules for calculating the depth may differ from individual Ruby implementations, as they are not specified by the language. For more information, see [the Prism documentation](https://github.com/ruby/prism/blob/main/docs/local_variable_depth.md). + # -- + # : () -> Integer + def depth: () -> Integer + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # The Location of the variable name. + # + # foo = :bar + # ^^^ + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # The value to write to the local variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # foo = :bar + # ^^^^ + # + # abc = 1234 + # ^^^^ + # + # Note that since the name of a local variable is known before the value is parsed, it is valid for a local variable to appear within the value of its own write. + # + # foo = foo + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `=` operator. + # + # x = :y + # ^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a regular expression literal used in the predicate of a conditional to implicitly match against the last line read by an IO object. + # + # if /foo/i then end + # ^^^^^^ + class MatchLastLineNode < Node + @unescaped: String + + @closing_loc: Location + + @content_loc: Location + + @opening_loc: Location + + # Initialize a new MatchLastLineNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Location content_loc, Location closing_loc, String unescaped) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Location content_loc, Location closing_loc, String unescaped) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> MatchLastLineNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> MatchLastLineNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> MatchLastLineNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :match_last_line_node + def type: () -> :match_last_line_node + + # See `Node.type`. + # -- + # : () -> :match_last_line_node + def self.type: () -> :match_last_line_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # i - ignores the case of characters when matching + # -- + # : () -> bool + def ignore_case?: () -> bool + + # :category: Flags + # x - ignores whitespace and allows comments in regular expressions + # -- + # : () -> bool + def extended?: () -> bool + + # :category: Flags + # m - allows $ to match the end of lines within strings + # -- + # : () -> bool + def multi_line?: () -> bool + + # :category: Flags + # o - only interpolates values into the regular expression once + # -- + # : () -> bool + def once?: () -> bool + + # :category: Flags + # e - forces the EUC-JP encoding + # -- + # : () -> bool + def euc_jp?: () -> bool + + # :category: Flags + # n - forces the ASCII-8BIT encoding + # -- + # : () -> bool + def ascii_8bit?: () -> bool + + # :category: Flags + # s - forces the Windows-31J encoding + # -- + # : () -> bool + def windows_31j?: () -> bool + + # :category: Flags + # u - forces the UTF-8 encoding + # -- + # : () -> bool + def utf_8?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to UTF-8 + # -- + # : () -> bool + def forced_utf8_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to binary + # -- + # : () -> bool + def forced_binary_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to US-ASCII + # -- + # : () -> bool + def forced_us_ascii_encoding?: () -> bool + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # content_loc -> Location + # + # Returns the Location represented by `content_loc`. + # -- + # : () -> Location + def content_loc: () -> Location + + # :category: Repository + # Save the content_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_content_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # unescaped -> String + # + # Returns the `unescaped` attribute. + # -- + # : () -> String + def unescaped: () -> String + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # content -> String + # + # Slice the location of content_loc from the source. + # -- + # : () -> String + def content: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the modifier `in` operator. + # + # foo in bar + # ^^^^^^^^^^ + class MatchPredicateNode < Node + @operator_loc: Location + + @pattern: Prism::node + + @value: Prism::node + + # Initialize a new MatchPredicateNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node value, Prism::node pattern, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node value, Prism::node pattern, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> MatchPredicateNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?operator_loc: Location) -> MatchPredicateNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?operator_loc: Location) -> MatchPredicateNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :match_predicate_node + def type: () -> :match_predicate_node + + # See `Node.type`. + # -- + # : () -> :match_predicate_node + def self.type: () -> :match_predicate_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # pattern -> Node + # + # Returns the `pattern` attribute. + # -- + # : () -> Prism::node + def pattern: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `=>` operator. + # + # foo => bar + # ^^^^^^^^^^ + class MatchRequiredNode < Node + @operator_loc: Location + + @pattern: Prism::node + + @value: Prism::node + + # Initialize a new MatchRequiredNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node value, Prism::node pattern, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node value, Prism::node pattern, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> MatchRequiredNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?operator_loc: Location) -> MatchRequiredNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?operator_loc: Location) -> MatchRequiredNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :match_required_node + def type: () -> :match_required_node + + # See `Node.type`. + # -- + # : () -> :match_required_node + def self.type: () -> :match_required_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # value -> Node + # + # Represents the left-hand side of the operator. + # + # foo => bar + # ^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # pattern -> Node + # + # Represents the right-hand side of the operator. The type of the node depends on the expression. + # + # Anything that looks like a local variable name (including `_`) will result in a `LocalVariableTargetNode`. + # + # foo => a # This is equivalent to writing `a = foo` + # ^ + # + # Using an explicit `Array` or combining expressions with `,` will result in a `ArrayPatternNode`. This can be preceded by a constant. + # + # foo => [a] + # ^^^ + # + # foo => a, b + # ^^^^ + # + # foo => Bar[a, b] + # ^^^^^^^^^ + # + # If the array pattern contains at least two wildcard matches, a `FindPatternNode` is created instead. + # + # foo => *, 1, *a + # ^^^^^ + # + # Using an explicit `Hash` or a constant with square brackets and hash keys in the square brackets will result in a `HashPatternNode`. + # + # foo => { a: 1, b: } + # + # foo => Bar[a: 1, b:] + # + # foo => Bar[**] + # + # To use any variable that needs run time evaluation, pinning is required. This results in a `PinnedVariableNode` + # + # foo => ^a + # ^^ + # + # Similar, any expression can be used with pinning. This results in a `PinnedExpressionNode`. + # + # foo => ^(a + 1) + # + # Anything else will result in the regular node for that expression, for example a `ConstantReadNode`. + # + # foo => CONST + # -- + # : () -> Prism::node + def pattern: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the operator. + # + # foo => bar + # ^^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents writing local variables using a regular expression match with named capture groups. + # + # /(?bar)/ =~ baz + # ^^^^^^^^^^^^^^^^^^^^ + class MatchWriteNode < Node + @targets: Array[LocalVariableTargetNode] + + @call: CallNode + + # Initialize a new MatchWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, CallNode call, Array[LocalVariableTargetNode] targets) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, CallNode call, Array[LocalVariableTargetNode] targets) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> MatchWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?call: CallNode, ?targets: Array[LocalVariableTargetNode]) -> MatchWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?call: CallNode, ?targets: Array[LocalVariableTargetNode]) -> MatchWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :match_write_node + def type: () -> :match_write_node + + # See `Node.type`. + # -- + # : () -> :match_write_node + def self.type: () -> :match_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # call -> CallNode + # + # Returns the `call` attribute. + # -- + # : () -> CallNode + def call: () -> CallNode + + # :call-seq: + # targets -> Array[LocalVariableTargetNode] + # + # Returns the `targets` attribute. + # -- + # : () -> Array[LocalVariableTargetNode] + def targets: () -> Array[LocalVariableTargetNode] + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a node that is missing from the source and results in a syntax error. + class MissingNode < Node + # Initialize a new MissingNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> MissingNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> MissingNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> MissingNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :missing_node + def type: () -> :missing_node + + # See `Node.type`. + # -- + # : () -> :missing_node + def self.type: () -> :missing_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a module declaration involving the `module` keyword. + # + # module Foo end + # ^^^^^^^^^^^^^^ + class ModuleNode < Node + @name: Symbol + + @end_keyword_loc: Location + + @body: (StatementsNode | BeginNode)? + + @constant_path: ConstantReadNode | ConstantPathNode | MissingNode + + @module_keyword_loc: Location + + @locals: Array[Symbol] + + # Initialize a new ModuleNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, Location module_keyword_loc, (ConstantReadNode | ConstantPathNode | MissingNode) constant_path, (StatementsNode | BeginNode)? body, Location end_keyword_loc, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, Location module_keyword_loc, ConstantReadNode | ConstantPathNode | MissingNode constant_path, (StatementsNode | BeginNode)? body, Location end_keyword_loc, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ModuleNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?module_keyword_loc: Location, ?constant_path: (ConstantReadNode | ConstantPathNode | MissingNode), ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location, ?name: Symbol) -> ModuleNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?module_keyword_loc: Location, ?constant_path: ConstantReadNode | ConstantPathNode | MissingNode, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location, ?name: Symbol) -> ModuleNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :module_node + def type: () -> :module_node + + # See `Node.type`. + # -- + # : () -> :module_node + def self.type: () -> :module_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # locals -> Array[Symbol] + # + # Returns the `locals` attribute. + # -- + # : () -> Array[Symbol] + def locals: () -> Array[Symbol] + + # :category: Locations + # :call-seq: + # module_keyword_loc -> Location + # + # Returns the Location represented by `module_keyword_loc`. + # -- + # : () -> Location + def module_keyword_loc: () -> Location + + # :category: Repository + # Save the module_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_module_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # constant_path -> ConstantReadNode | ConstantPathNode | MissingNode + # + # Returns the `constant_path` attribute. + # -- + # : () -> (ConstantReadNode | ConstantPathNode | MissingNode) + def constant_path: () -> (ConstantReadNode | ConstantPathNode | MissingNode) + + # :call-seq: + # body -> StatementsNode | BeginNode | nil + # + # Returns the `body` attribute. + # -- + # : () -> (StatementsNode | BeginNode)? + def body: () -> (StatementsNode | BeginNode)? + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location + # + # Returns the Location represented by `end_keyword_loc`. + # -- + # : () -> Location + def end_keyword_loc: () -> Location + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :call-seq: + # module_keyword -> String + # + # Slice the location of module_keyword_loc from the source. + # -- + # : () -> String + def module_keyword: () -> String + + # :call-seq: + # end_keyword -> String + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String + def end_keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a multi-target expression. + # + # a, (b, c) = 1, 2, 3 + # ^^^^^^ + # + # This can be a part of `MultiWriteNode` as above, or the target of a `for` loop + # + # for a, b in [[1, 2], [3, 4]] + # ^^^^ + class MultiTargetNode < Node + @rparen_loc: Location? + + @lparen_loc: Location? + + @rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] + + @rest: (ImplicitRestNode | SplatNode)? + + @lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] + + # Initialize a new MultiTargetNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] lefts, (ImplicitRestNode | SplatNode)? rest, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] rights, Location? lparen_loc, Location? rparen_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] lefts, (ImplicitRestNode | SplatNode)? rest, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] rights, Location? lparen_loc, Location? rparen_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> MultiTargetNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode], ?lparen_loc: Location?, ?rparen_loc: Location?) -> MultiTargetNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode], ?lparen_loc: Location?, ?rparen_loc: Location?) -> MultiTargetNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :multi_target_node + def type: () -> :multi_target_node + + # See `Node.type`. + # -- + # : () -> :multi_target_node + def self.type: () -> :multi_target_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # lefts -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] + # + # Represents the targets expressions before a splat node. + # + # a, (b, c, *) = 1, 2, 3, 4, 5 + # ^^^^ + # + # The splat node can be absent, in that case all target expressions are in the left field. + # + # a, (b, c) = 1, 2, 3, 4, 5 + # ^^^^ + # -- + # : () -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] + def lefts: () -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] + + # :call-seq: + # rest -> ImplicitRestNode | SplatNode | nil + # + # Represents a splat node in the target expression. + # + # a, (b, *c) = 1, 2, 3, 4 + # ^^ + # + # The variable can be empty, this results in a `SplatNode` with a `nil` expression field. + # + # a, (b, *) = 1, 2, 3, 4 + # ^ + # + # If the `*` is omitted, this field will contain an `ImplicitRestNode` + # + # a, (b,) = 1, 2, 3, 4 + # ^ + # -- + # : () -> (ImplicitRestNode | SplatNode)? + def rest: () -> (ImplicitRestNode | SplatNode)? + + # :call-seq: + # rights -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] + # + # Represents the targets expressions after a splat node. + # + # a, (*, b, c) = 1, 2, 3, 4, 5 + # ^^^^ + # -- + # : () -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] + def rights: () -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode | BackReferenceReadNode | NumberedReferenceReadNode] + + # :category: Locations + # :call-seq: + # lparen_loc -> Location | nil + # + # The Location of the opening parenthesis. + # + # a, (b, c) = 1, 2, 3 + # ^ + # -- + # : () -> Location? + def lparen_loc: () -> Location? + + # :category: Repository + # Save the lparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_lparen_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # rparen_loc -> Location | nil + # + # The Location of the closing parenthesis. + # + # a, (b, c) = 1, 2, 3 + # ^ + # -- + # : () -> Location? + def rparen_loc: () -> Location? + + # :category: Repository + # Save the rparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_rparen_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # lparen -> String | nil + # + # Slice the location of lparen_loc from the source. + # -- + # : () -> String? + def lparen: () -> String? + + # :call-seq: + # rparen -> String | nil + # + # Slice the location of rparen_loc from the source. + # -- + # : () -> String? + def rparen: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a write to a multi-target expression. + # + # a, b, c = 1, 2, 3 + # ^^^^^^^^^^^^^^^^^ + class MultiWriteNode < Node + @value: Prism::node + + @operator_loc: Location + + @rparen_loc: Location? + + @lparen_loc: Location? + + @rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] + + @rest: (ImplicitRestNode | SplatNode)? + + @lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] + + # Initialize a new MultiWriteNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] lefts, (ImplicitRestNode | SplatNode)? rest, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] rights, Location? lparen_loc, Location? rparen_loc, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] lefts, (ImplicitRestNode | SplatNode)? rest, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] rights, Location? lparen_loc, Location? rparen_loc, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> MultiWriteNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode], ?lparen_loc: Location?, ?rparen_loc: Location?, ?operator_loc: Location, ?value: Prism::node) -> MultiWriteNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode], ?lparen_loc: Location?, ?rparen_loc: Location?, ?operator_loc: Location, ?value: Prism::node) -> MultiWriteNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :multi_write_node + def type: () -> :multi_write_node + + # See `Node.type`. + # -- + # : () -> :multi_write_node + def self.type: () -> :multi_write_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # lefts -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] + # + # Represents the targets expressions before a splat node. + # + # a, b, * = 1, 2, 3, 4, 5 + # ^^^^ + # + # The splat node can be absent, in that case all target expressions are in the left field. + # + # a, b, c = 1, 2, 3, 4, 5 + # ^^^^^^^ + # -- + # : () -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] + def lefts: () -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] + + # :call-seq: + # rest -> ImplicitRestNode | SplatNode | nil + # + # Represents a splat node in the target expression. + # + # a, b, *c = 1, 2, 3, 4 + # ^^ + # + # The variable can be empty, this results in a `SplatNode` with a `nil` expression field. + # + # a, b, * = 1, 2, 3, 4 + # ^ + # + # If the `*` is omitted, this field will contain an `ImplicitRestNode` + # + # a, b, = 1, 2, 3, 4 + # ^ + # -- + # : () -> (ImplicitRestNode | SplatNode)? + def rest: () -> (ImplicitRestNode | SplatNode)? + + # :call-seq: + # rights -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] + # + # Represents the targets expressions after a splat node. + # + # a, *, b, c = 1, 2, 3, 4, 5 + # ^^^^ + # -- + # : () -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] + def rights: () -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | BackReferenceReadNode | NumberedReferenceReadNode] + + # :category: Locations + # :call-seq: + # lparen_loc -> Location | nil + # + # The Location of the opening parenthesis. + # + # (a, b, c) = 1, 2, 3 + # ^ + # -- + # : () -> Location? + def lparen_loc: () -> Location? + + # :category: Repository + # Save the lparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_lparen_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # rparen_loc -> Location | nil + # + # The Location of the closing parenthesis. + # + # (a, b, c) = 1, 2, 3 + # ^ + # -- + # : () -> Location? + def rparen_loc: () -> Location? + + # :category: Repository + # Save the rparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_rparen_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the operator. + # + # a, b, c = 1, 2, 3 + # ^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # The value to write to the targets. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # a, b, c = 1, 2, 3 + # ^^^^^^^ + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # lparen -> String | nil + # + # Slice the location of lparen_loc from the source. + # -- + # : () -> String? + def lparen: () -> String? + + # :call-seq: + # rparen -> String | nil + # + # Slice the location of rparen_loc from the source. + # -- + # : () -> String? + def rparen: () -> String? + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `next` keyword. + # + # next 1 + # ^^^^^^ + class NextNode < Node + @keyword_loc: Location + + @arguments: ArgumentsNode? + + # Initialize a new NextNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ArgumentsNode? arguments, Location keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, ArgumentsNode? arguments, Location keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> NextNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> NextNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> NextNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :next_node + def type: () -> :next_node + + # See `Node.type`. + # -- + # : () -> :next_node + def self.type: () -> :next_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # arguments -> ArgumentsNode | nil + # + # Returns the `arguments` attribute. + # -- + # : () -> ArgumentsNode? + def arguments: () -> ArgumentsNode? + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `nil` keyword. + # + # nil + # ^^^ + class NilNode < Node + # Initialize a new NilNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> NilNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> NilNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> NilNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :nil_node + def type: () -> :nil_node + + # See `Node.type`. + # -- + # : () -> :nil_node + def self.type: () -> :nil_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of `&nil` inside method arguments. + # + # def a(&nil) + # ^^^^ + # end + class NoBlockParameterNode < Node + @keyword_loc: Location + + @operator_loc: Location + + # Initialize a new NoBlockParameterNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location operator_loc, Location keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location operator_loc, Location keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> NoBlockParameterNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?keyword_loc: Location) -> NoBlockParameterNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?keyword_loc: Location) -> NoBlockParameterNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :no_block_parameter_node + def type: () -> :no_block_parameter_node + + # See `Node.type`. + # -- + # : () -> :no_block_parameter_node + def self.type: () -> :no_block_parameter_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of `**nil` inside method arguments. + # + # def a(**nil) + # ^^^^^ + # end + class NoKeywordsParameterNode < Node + @keyword_loc: Location + + @operator_loc: Location + + # Initialize a new NoKeywordsParameterNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location operator_loc, Location keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location operator_loc, Location keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> NoKeywordsParameterNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?keyword_loc: Location) -> NoKeywordsParameterNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?keyword_loc: Location) -> NoKeywordsParameterNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :no_keywords_parameter_node + def type: () -> :no_keywords_parameter_node + + # See `Node.type`. + # -- + # : () -> :no_keywords_parameter_node + def self.type: () -> :no_keywords_parameter_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an implicit set of parameters through the use of numbered parameters within a block or lambda. + # + # -> { _1 + _2 } + # ^^^^^^^^^^^^^^ + class NumberedParametersNode < Node + @maximum: Integer + + # Initialize a new NumberedParametersNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Integer maximum) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Integer maximum) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> NumberedParametersNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?maximum: Integer) -> NumberedParametersNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?maximum: Integer) -> NumberedParametersNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :numbered_parameters_node + def type: () -> :numbered_parameters_node + + # See `Node.type`. + # -- + # : () -> :numbered_parameters_node + def self.type: () -> :numbered_parameters_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # maximum -> Integer + # + # Returns the `maximum` attribute. + # -- + # : () -> Integer + def maximum: () -> Integer + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents reading a numbered reference to a capture in the previous match. + # + # $1 + # ^^ + class NumberedReferenceReadNode < Node + @number: Integer + + # Initialize a new NumberedReferenceReadNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Integer number) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Integer number) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> NumberedReferenceReadNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?number: Integer) -> NumberedReferenceReadNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?number: Integer) -> NumberedReferenceReadNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :numbered_reference_read_node + def type: () -> :numbered_reference_read_node + + # See `Node.type`. + # -- + # : () -> :numbered_reference_read_node + def self.type: () -> :numbered_reference_read_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # number -> Integer + # + # The (1-indexed, from the left) number of the capture group. Numbered references that are too large result in this value being `0`. + # + # $1 # number `1` + # + # $5432 # number `5432` + # + # $4294967296 # number `0` + # -- + # : () -> Integer + def number: () -> Integer + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an optional keyword parameter to a method, block, or lambda definition. + # + # def a(b: 1) + # ^^^^ + # end + class OptionalKeywordParameterNode < Node + @value: Prism::node + + @name_loc: Location + + @name: Symbol + + # Initialize a new OptionalKeywordParameterNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> OptionalKeywordParameterNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node) -> OptionalKeywordParameterNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node) -> OptionalKeywordParameterNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :optional_keyword_parameter_node + def type: () -> :optional_keyword_parameter_node + + # See `Node.type`. + # -- + # : () -> :optional_keyword_parameter_node + def self.type: () -> :optional_keyword_parameter_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # a parameter name that has been repeated in the method signature + # -- + # : () -> bool + def repeated_parameter?: () -> bool + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an optional parameter to a method, block, or lambda definition. + # + # def a(b = 1) + # ^^^^^ + # end + class OptionalParameterNode < Node + @value: Prism::node + + @operator_loc: Location + + @name_loc: Location + + @name: Symbol + + # Initialize a new OptionalParameterNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> OptionalParameterNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> OptionalParameterNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> OptionalParameterNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :optional_parameter_node + def type: () -> :optional_parameter_node + + # See `Node.type`. + # -- + # : () -> :optional_parameter_node + def self.type: () -> :optional_parameter_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # a parameter name that has been repeated in the method signature + # -- + # : () -> bool + def repeated_parameter?: () -> bool + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # value -> Node + # + # Returns the `value` attribute. + # -- + # : () -> Prism::node + def value: () -> Prism::node + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `||` operator or the `or` keyword. + # + # left or right + # ^^^^^^^^^^^^^ + class OrNode < Node + @operator_loc: Location + + @right: Prism::node + + @left: Prism::node + + # Initialize a new OrNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node left, Prism::node right, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node left, Prism::node right, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> OrNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> OrNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node, ?right: Prism::node, ?operator_loc: Location) -> OrNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :or_node + def type: () -> :or_node + + # See `Node.type`. + # -- + # : () -> :or_node + def self.type: () -> :or_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # left -> Node + # + # Represents the left side of the expression. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # left or right + # ^^^^ + # + # 1 || 2 + # ^ + # -- + # : () -> Prism::node + def left: () -> Prism::node + + # :call-seq: + # right -> Node + # + # Represents the right side of the expression. + # + # left || right + # ^^^^^ + # + # 1 or 2 + # ^ + # -- + # : () -> Prism::node + def right: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `or` keyword or the `||` operator. + # + # left or right + # ^^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the list of parameters on a method, block, or lambda definition. + # + # def a(b, c, d) + # ^^^^^^^ + # end + class ParametersNode < Node + @block: (BlockParameterNode | NoBlockParameterNode)? + + @keyword_rest: (KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode)? + + @keywords: Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode] + + @posts: Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode | BlockParameterNode | NoBlockParameterNode] + + @rest: (RestParameterNode | ImplicitRestNode)? + + @optionals: Array[OptionalParameterNode] + + @requireds: Array[RequiredParameterNode | MultiTargetNode] + + # Initialize a new ParametersNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[RequiredParameterNode | MultiTargetNode] requireds, Array[OptionalParameterNode] optionals, (RestParameterNode | ImplicitRestNode)? rest, Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode | BlockParameterNode | NoBlockParameterNode] posts, Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode] keywords, (KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode)? keyword_rest, (BlockParameterNode | NoBlockParameterNode)? block) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[RequiredParameterNode | MultiTargetNode] requireds, Array[OptionalParameterNode] optionals, (RestParameterNode | ImplicitRestNode)? rest, Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode | BlockParameterNode | NoBlockParameterNode] posts, Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode] keywords, (KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode)? keyword_rest, (BlockParameterNode | NoBlockParameterNode)? block) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ParametersNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?requireds: Array[RequiredParameterNode | MultiTargetNode], ?optionals: Array[OptionalParameterNode], ?rest: (RestParameterNode | ImplicitRestNode)?, ?posts: Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode | BlockParameterNode | NoBlockParameterNode], ?keywords: Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode], ?keyword_rest: (KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode)?, ?block: (BlockParameterNode | NoBlockParameterNode)?) -> ParametersNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?requireds: Array[RequiredParameterNode | MultiTargetNode], ?optionals: Array[OptionalParameterNode], ?rest: (RestParameterNode | ImplicitRestNode)?, ?posts: Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode | BlockParameterNode | NoBlockParameterNode], ?keywords: Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode], ?keyword_rest: (KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode)?, ?block: (BlockParameterNode | NoBlockParameterNode)?) -> ParametersNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :parameters_node + def type: () -> :parameters_node + + # See `Node.type`. + # -- + # : () -> :parameters_node + def self.type: () -> :parameters_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # requireds -> Array[RequiredParameterNode | MultiTargetNode] + # + # Returns the `requireds` attribute. + # -- + # : () -> Array[RequiredParameterNode | MultiTargetNode] + def requireds: () -> Array[RequiredParameterNode | MultiTargetNode] + + # :call-seq: + # optionals -> Array[OptionalParameterNode] + # + # Returns the `optionals` attribute. + # -- + # : () -> Array[OptionalParameterNode] + def optionals: () -> Array[OptionalParameterNode] + + # :call-seq: + # rest -> RestParameterNode | ImplicitRestNode | nil + # + # Returns the `rest` attribute. + # -- + # : () -> (RestParameterNode | ImplicitRestNode)? + def rest: () -> (RestParameterNode | ImplicitRestNode)? + + # :call-seq: + # posts -> Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode | BlockParameterNode | NoBlockParameterNode] + # + # Returns the `posts` attribute. + # -- + # : () -> Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode | BlockParameterNode | NoBlockParameterNode] + def posts: () -> Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode | BlockParameterNode | NoBlockParameterNode] + + # :call-seq: + # keywords -> Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode] + # + # Returns the `keywords` attribute. + # -- + # : () -> Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode] + def keywords: () -> Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode] + + # :call-seq: + # keyword_rest -> KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode | nil + # + # Returns the `keyword_rest` attribute. + # -- + # : () -> (KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode)? + def keyword_rest: () -> (KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode)? + + # :call-seq: + # block -> BlockParameterNode | NoBlockParameterNode | nil + # + # Returns the `block` attribute. + # -- + # : () -> (BlockParameterNode | NoBlockParameterNode)? + def block: () -> (BlockParameterNode | NoBlockParameterNode)? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a parenthesized expression + # + # (10 + 34) + # ^^^^^^^^^ + class ParenthesesNode < Node + @closing_loc: Location + + @opening_loc: Location + + @body: Prism::node? + + # Initialize a new ParenthesesNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? body, Location opening_loc, Location closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? body, Location opening_loc, Location closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ParenthesesNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Prism::node?, ?opening_loc: Location, ?closing_loc: Location) -> ParenthesesNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Prism::node?, ?opening_loc: Location, ?closing_loc: Location) -> ParenthesesNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :parentheses_node + def type: () -> :parentheses_node + + # See `Node.type`. + # -- + # : () -> :parentheses_node + def self.type: () -> :parentheses_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # parentheses that contain multiple potentially void statements + # -- + # : () -> bool + def multiple_statements?: () -> bool + + # :call-seq: + # body -> Node | nil + # + # Returns the `body` attribute. + # -- + # : () -> Prism::node? + def body: () -> Prism::node? + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `^` operator for pinning an expression in a pattern matching expression. + # + # foo in ^(bar) + # ^^^^^^ + class PinnedExpressionNode < Node + @rparen_loc: Location + + @lparen_loc: Location + + @operator_loc: Location + + @expression: Prism::node + + # Initialize a new PinnedExpressionNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node expression, Location operator_loc, Location lparen_loc, Location rparen_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node expression, Location operator_loc, Location lparen_loc, Location rparen_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> PinnedExpressionNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?operator_loc: Location, ?lparen_loc: Location, ?rparen_loc: Location) -> PinnedExpressionNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?operator_loc: Location, ?lparen_loc: Location, ?rparen_loc: Location) -> PinnedExpressionNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :pinned_expression_node + def type: () -> :pinned_expression_node + + # See `Node.type`. + # -- + # : () -> :pinned_expression_node + def self.type: () -> :pinned_expression_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # expression -> Node + # + # The expression used in the pinned expression + # + # foo in ^(bar) + # ^^^ + # -- + # : () -> Prism::node + def expression: () -> Prism::node + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `^` operator + # + # foo in ^(bar) + # ^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # lparen_loc -> Location + # + # The Location of the opening parenthesis. + # + # foo in ^(bar) + # ^ + # -- + # : () -> Location + def lparen_loc: () -> Location + + # :category: Repository + # Save the lparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_lparen_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # rparen_loc -> Location + # + # The Location of the closing parenthesis. + # + # foo in ^(bar) + # ^ + # -- + # : () -> Location + def rparen_loc: () -> Location + + # :category: Repository + # Save the rparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_rparen_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # :call-seq: + # lparen -> String + # + # Slice the location of lparen_loc from the source. + # -- + # : () -> String + def lparen: () -> String + + # :call-seq: + # rparen -> String + # + # Slice the location of rparen_loc from the source. + # -- + # : () -> String + def rparen: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `^` operator for pinning a variable in a pattern matching expression. + # + # foo in ^bar + # ^^^^ + class PinnedVariableNode < Node + @operator_loc: Location + + @variable: LocalVariableReadNode | InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | ItLocalVariableReadNode | MissingNode + + # Initialize a new PinnedVariableNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, (LocalVariableReadNode | InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | ItLocalVariableReadNode | MissingNode) variable, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, LocalVariableReadNode | InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | ItLocalVariableReadNode | MissingNode variable, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> PinnedVariableNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?variable: (LocalVariableReadNode | InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | ItLocalVariableReadNode | MissingNode), ?operator_loc: Location) -> PinnedVariableNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?variable: LocalVariableReadNode | InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | ItLocalVariableReadNode | MissingNode, ?operator_loc: Location) -> PinnedVariableNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :pinned_variable_node + def type: () -> :pinned_variable_node + + # See `Node.type`. + # -- + # : () -> :pinned_variable_node + def self.type: () -> :pinned_variable_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # variable -> LocalVariableReadNode | InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | ItLocalVariableReadNode | MissingNode + # + # The variable used in the pinned expression + # + # foo in ^bar + # ^^^ + # -- + # : () -> (LocalVariableReadNode | InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | ItLocalVariableReadNode | MissingNode) + def variable: () -> (LocalVariableReadNode | InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode | ItLocalVariableReadNode | MissingNode) + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `^` operator + # + # foo in ^bar + # ^ + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `END` keyword. + # + # END { foo } + # ^^^^^^^^^^^ + class PostExecutionNode < Node + @closing_loc: Location + + @opening_loc: Location + + @keyword_loc: Location + + @statements: StatementsNode? + + # Initialize a new PostExecutionNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, StatementsNode? statements, Location keyword_loc, Location opening_loc, Location closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, StatementsNode? statements, Location keyword_loc, Location opening_loc, Location closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> PostExecutionNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?statements: StatementsNode?, ?keyword_loc: Location, ?opening_loc: Location, ?closing_loc: Location) -> PostExecutionNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?statements: StatementsNode?, ?keyword_loc: Location, ?opening_loc: Location, ?closing_loc: Location) -> PostExecutionNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :post_execution_node + def type: () -> :post_execution_node + + # See `Node.type`. + # -- + # : () -> :post_execution_node + def self.type: () -> :post_execution_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # statements -> StatementsNode | nil + # + # Returns the `statements` attribute. + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `BEGIN` keyword. + # + # BEGIN { foo } + # ^^^^^^^^^^^^^ + class PreExecutionNode < Node + @closing_loc: Location + + @opening_loc: Location + + @keyword_loc: Location + + @statements: StatementsNode? + + # Initialize a new PreExecutionNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, StatementsNode? statements, Location keyword_loc, Location opening_loc, Location closing_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, StatementsNode? statements, Location keyword_loc, Location opening_loc, Location closing_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> PreExecutionNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?statements: StatementsNode?, ?keyword_loc: Location, ?opening_loc: Location, ?closing_loc: Location) -> PreExecutionNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?statements: StatementsNode?, ?keyword_loc: Location, ?opening_loc: Location, ?closing_loc: Location) -> PreExecutionNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :pre_execution_node + def type: () -> :pre_execution_node + + # See `Node.type`. + # -- + # : () -> :pre_execution_node + def self.type: () -> :pre_execution_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # statements -> StatementsNode | nil + # + # Returns the `statements` attribute. + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # The top level node of any parse tree. + class ProgramNode < Node + @statements: StatementsNode + + @locals: Array[Symbol] + + # Initialize a new ProgramNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, StatementsNode statements) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, StatementsNode statements) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ProgramNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?statements: StatementsNode) -> ProgramNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?statements: StatementsNode) -> ProgramNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :program_node + def type: () -> :program_node + + # See `Node.type`. + # -- + # : () -> :program_node + def self.type: () -> :program_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # locals -> Array[Symbol] + # + # Returns the `locals` attribute. + # -- + # : () -> Array[Symbol] + def locals: () -> Array[Symbol] + + # :call-seq: + # statements -> StatementsNode + # + # Returns the `statements` attribute. + # -- + # : () -> StatementsNode + def statements: () -> StatementsNode + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `..` or `...` operators. + # + # 1..2 + # ^^^^ + # + # c if a =~ /left/ ... b =~ /right/ + # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + class RangeNode < Node + @operator_loc: Location + + @right: Prism::node? + + @left: Prism::node? + + # Initialize a new RangeNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node? left, Prism::node? right, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? left, Prism::node? right, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> RangeNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node?, ?right: Prism::node?, ?operator_loc: Location) -> RangeNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?left: Prism::node?, ?right: Prism::node?, ?operator_loc: Location) -> RangeNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :range_node + def type: () -> :range_node + + # See `Node.type`. + # -- + # : () -> :range_node + def self.type: () -> :range_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # ... operator + # -- + # : () -> bool + def exclude_end?: () -> bool + + # :call-seq: + # left -> Node | nil + # + # The left-hand side of the range, if present. It can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # 1... + # ^ + # + # hello...goodbye + # ^^^^^ + # -- + # : () -> Prism::node? + def left: () -> Prism::node? + + # :call-seq: + # right -> Node | nil + # + # The right-hand side of the range, if present. It can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # ..5 + # ^ + # + # 1...foo + # ^^^ + # If neither right-hand or left-hand side was included, this will be a MissingNode. + # -- + # : () -> Prism::node? + def right: () -> Prism::node? + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # The Location of the `..` or `...` operator. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a rational number literal. + # + # 1.0r + # ^^^^ + class RationalNode < Node + @denominator: Integer + + @numerator: Integer + + # Initialize a new RationalNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Integer numerator, Integer denominator) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Integer numerator, Integer denominator) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> RationalNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?numerator: Integer, ?denominator: Integer) -> RationalNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?numerator: Integer, ?denominator: Integer) -> RationalNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :rational_node + def type: () -> :rational_node + + # See `Node.type`. + # -- + # : () -> :rational_node + def self.type: () -> :rational_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # 0b prefix + # -- + # : () -> bool + def binary?: () -> bool + + # :category: Flags + # 0d or no prefix + # -- + # : () -> bool + def decimal?: () -> bool + + # :category: Flags + # 0o or 0 prefix + # -- + # : () -> bool + def octal?: () -> bool + + # :category: Flags + # 0x prefix + # -- + # : () -> bool + def hexadecimal?: () -> bool + + # :call-seq: + # numerator -> Integer + # + # The numerator of the rational number. + # + # 1.5r # numerator 3 + # -- + # : () -> Integer + def numerator: () -> Integer + + # :call-seq: + # denominator -> Integer + # + # The denominator of the rational number. + # + # 1.5r # denominator 2 + # -- + # : () -> Integer + def denominator: () -> Integer + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `redo` keyword. + # + # redo + # ^^^^ + class RedoNode < Node + # Initialize a new RedoNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> RedoNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> RedoNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> RedoNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :redo_node + def type: () -> :redo_node + + # See `Node.type`. + # -- + # : () -> :redo_node + def self.type: () -> :redo_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a regular expression literal with no interpolation. + # + # /foo/i + # ^^^^^^ + class RegularExpressionNode < Node + @unescaped: String + + @closing_loc: Location + + @content_loc: Location + + @opening_loc: Location + + # Initialize a new RegularExpressionNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Location content_loc, Location closing_loc, String unescaped) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Location content_loc, Location closing_loc, String unescaped) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> RegularExpressionNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> RegularExpressionNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> RegularExpressionNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :regular_expression_node + def type: () -> :regular_expression_node + + # See `Node.type`. + # -- + # : () -> :regular_expression_node + def self.type: () -> :regular_expression_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # i - ignores the case of characters when matching + # -- + # : () -> bool + def ignore_case?: () -> bool + + # :category: Flags + # x - ignores whitespace and allows comments in regular expressions + # -- + # : () -> bool + def extended?: () -> bool + + # :category: Flags + # m - allows $ to match the end of lines within strings + # -- + # : () -> bool + def multi_line?: () -> bool + + # :category: Flags + # o - only interpolates values into the regular expression once + # -- + # : () -> bool + def once?: () -> bool + + # :category: Flags + # e - forces the EUC-JP encoding + # -- + # : () -> bool + def euc_jp?: () -> bool + + # :category: Flags + # n - forces the ASCII-8BIT encoding + # -- + # : () -> bool + def ascii_8bit?: () -> bool + + # :category: Flags + # s - forces the Windows-31J encoding + # -- + # : () -> bool + def windows_31j?: () -> bool + + # :category: Flags + # u - forces the UTF-8 encoding + # -- + # : () -> bool + def utf_8?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to UTF-8 + # -- + # : () -> bool + def forced_utf8_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to binary + # -- + # : () -> bool + def forced_binary_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to US-ASCII + # -- + # : () -> bool + def forced_us_ascii_encoding?: () -> bool + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # content_loc -> Location + # + # Returns the Location represented by `content_loc`. + # -- + # : () -> Location + def content_loc: () -> Location + + # :category: Repository + # Save the content_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_content_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # unescaped -> String + # + # Returns the `unescaped` attribute. + # -- + # : () -> String + def unescaped: () -> String + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # content -> String + # + # Slice the location of content_loc from the source. + # -- + # : () -> String + def content: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a required keyword parameter to a method, block, or lambda definition. + # + # def a(b: ) + # ^^ + # end + class RequiredKeywordParameterNode < Node + @name_loc: Location + + @name: Symbol + + # Initialize a new RequiredKeywordParameterNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> RequiredKeywordParameterNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location) -> RequiredKeywordParameterNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location) -> RequiredKeywordParameterNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :required_keyword_parameter_node + def type: () -> :required_keyword_parameter_node + + # See `Node.type`. + # -- + # : () -> :required_keyword_parameter_node + def self.type: () -> :required_keyword_parameter_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # a parameter name that has been repeated in the method signature + # -- + # : () -> bool + def repeated_parameter?: () -> bool + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # :category: Locations + # :call-seq: + # name_loc -> Location + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location + def name_loc: () -> Location + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_name_loc: (_Repository repository) -> Relocation::Entry + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a required parameter to a method, block, or lambda definition. + # + # def a(b) + # ^ + # end + class RequiredParameterNode < Node + @name: Symbol + + # Initialize a new RequiredParameterNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol name) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> RequiredParameterNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> RequiredParameterNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> RequiredParameterNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :required_parameter_node + def type: () -> :required_parameter_node + + # See `Node.type`. + # -- + # : () -> :required_parameter_node + def self.type: () -> :required_parameter_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # a parameter name that has been repeated in the method signature + # -- + # : () -> bool + def repeated_parameter?: () -> bool + + # :call-seq: + # name -> Symbol + # + # Returns the `name` attribute. + # -- + # : () -> Symbol + def name: () -> Symbol + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an expression modified with a rescue. + # + # foo rescue nil + # ^^^^^^^^^^^^^^ + class RescueModifierNode < Node + @rescue_expression: Prism::node + + @keyword_loc: Location + + @expression: Prism::node + + # Initialize a new RescueModifierNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Prism::node expression, Location keyword_loc, Prism::node rescue_expression) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node expression, Location keyword_loc, Prism::node rescue_expression) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> RescueModifierNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?keyword_loc: Location, ?rescue_expression: Prism::node) -> RescueModifierNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?keyword_loc: Location, ?rescue_expression: Prism::node) -> RescueModifierNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :rescue_modifier_node + def type: () -> :rescue_modifier_node + + # See `Node.type`. + # -- + # : () -> :rescue_modifier_node + def self.type: () -> :rescue_modifier_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # expression -> Node + # + # Returns the `expression` attribute. + # -- + # : () -> Prism::node + def expression: () -> Prism::node + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # rescue_expression -> Node + # + # Returns the `rescue_expression` attribute. + # -- + # : () -> Prism::node + def rescue_expression: () -> Prism::node + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a rescue statement. + # + # begin + # rescue Foo, *splat, Bar => ex + # foo + # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + # end + # + # `Foo, *splat, Bar` are in the `exceptions` field. `ex` is in the `reference` field. + class RescueNode < Node + @subsequent: RescueNode? + + @statements: StatementsNode? + + @then_keyword_loc: Location? + + @reference: (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode)? + + @operator_loc: Location? + + @exceptions: Array[Prism::node] + + @keyword_loc: Location + + # Initialize a new RescueNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Array[Prism::node] exceptions, Location? operator_loc, (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode)? reference, Location? then_keyword_loc, StatementsNode? statements, RescueNode? subsequent) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Array[Prism::node] exceptions, Location? operator_loc, (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode)? reference, Location? then_keyword_loc, StatementsNode? statements, RescueNode? subsequent) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> RescueNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?exceptions: Array[Prism::node], ?operator_loc: Location?, ?reference: (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode)?, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?subsequent: RescueNode?) -> RescueNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?exceptions: Array[Prism::node], ?operator_loc: Location?, ?reference: (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode)?, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?subsequent: RescueNode?) -> RescueNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :rescue_node + def type: () -> :rescue_node + + # See `Node.type`. + # -- + # : () -> :rescue_node + def self.type: () -> :rescue_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # exceptions -> Array[Node] + # + # Returns the `exceptions` attribute. + # -- + # : () -> Array[Prism::node] + def exceptions: () -> Array[Prism::node] + + # :category: Locations + # :call-seq: + # operator_loc -> Location | nil + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location? + def operator_loc: () -> Location? + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_operator_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # reference -> LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode | nil + # + # Returns the `reference` attribute. + # -- + # : () -> (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode)? + def reference: () -> (LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | BackReferenceReadNode | NumberedReferenceReadNode | MissingNode)? + + # :category: Locations + # :call-seq: + # then_keyword_loc -> Location | nil + # + # Returns the Location represented by `then_keyword_loc`. + # -- + # : () -> Location? + def then_keyword_loc: () -> Location? + + # :category: Repository + # Save the then_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_then_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # statements -> StatementsNode | nil + # + # Returns the `statements` attribute. + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :call-seq: + # subsequent -> RescueNode | nil + # + # Returns the `subsequent` attribute. + # -- + # : () -> RescueNode? + def subsequent: () -> RescueNode? + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # :call-seq: + # operator -> String | nil + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String? + def operator: () -> String? + + # :call-seq: + # then_keyword -> String | nil + # + # Slice the location of then_keyword_loc from the source. + # -- + # : () -> String? + def then_keyword: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a rest parameter to a method, block, or lambda definition. + # + # def a(*b) + # ^^ + # end + class RestParameterNode < Node + @operator_loc: Location + + @name_loc: Location? + + @name: Symbol? + + # Initialize a new RestParameterNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Symbol? name, Location? name_loc, Location operator_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Symbol? name, Location? name_loc, Location operator_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> RestParameterNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> RestParameterNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> RestParameterNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :rest_parameter_node + def type: () -> :rest_parameter_node + + # See `Node.type`. + # -- + # : () -> :rest_parameter_node + def self.type: () -> :rest_parameter_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # a parameter name that has been repeated in the method signature + # -- + # : () -> bool + def repeated_parameter?: () -> bool + + # :call-seq: + # name -> Symbol | nil + # + # Returns the `name` attribute. + # -- + # : () -> Symbol? + def name: () -> Symbol? + + # :category: Locations + # :call-seq: + # name_loc -> Location | nil + # + # Returns the Location represented by `name_loc`. + # -- + # : () -> Location? + def name_loc: () -> Location? + + # :category: Repository + # Save the name_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_name_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `retry` keyword. + # + # retry + # ^^^^^ + class RetryNode < Node + # Initialize a new RetryNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> RetryNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> RetryNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> RetryNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :retry_node + def type: () -> :retry_node + + # See `Node.type`. + # -- + # : () -> :retry_node + def self.type: () -> :retry_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `return` keyword. + # + # return 1 + # ^^^^^^^^ + class ReturnNode < Node + @arguments: ArgumentsNode? + + @keyword_loc: Location + + # Initialize a new ReturnNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, ArgumentsNode? arguments) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, ArgumentsNode? arguments) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ReturnNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?arguments: ArgumentsNode?) -> ReturnNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?arguments: ArgumentsNode?) -> ReturnNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :return_node + def type: () -> :return_node + + # See `Node.type`. + # -- + # : () -> :return_node + def self.type: () -> :return_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # arguments -> ArgumentsNode | nil + # + # Returns the `arguments` attribute. + # -- + # : () -> ArgumentsNode? + def arguments: () -> ArgumentsNode? + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the `self` keyword. + # + # self + # ^^^^ + class SelfNode < Node + # Initialize a new SelfNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> SelfNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> SelfNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> SelfNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :self_node + def type: () -> :self_node + + # See `Node.type`. + # -- + # : () -> :self_node + def self.type: () -> :self_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # This node wraps a constant write to indicate that when the value is written, it should have its shareability state modified. + # + # # shareable_constant_value: literal + # C = { a: 1 } + # ^^^^^^^^^^^^ + class ShareableConstantNode < Node + @write: ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode + + # Initialize a new ShareableConstantNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, (ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode) write) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode write) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> ShareableConstantNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?write: (ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode)) -> ShareableConstantNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?write: ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode) -> ShareableConstantNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :shareable_constant_node + def type: () -> :shareable_constant_node + + # See `Node.type`. + # -- + # : () -> :shareable_constant_node + def self.type: () -> :shareable_constant_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # constant writes that should be modified with shareable constant value literal + # -- + # : () -> bool + def literal?: () -> bool + + # :category: Flags + # constant writes that should be modified with shareable constant value experimental everything + # -- + # : () -> bool + def experimental_everything?: () -> bool + + # :category: Flags + # constant writes that should be modified with shareable constant value experimental copy + # -- + # : () -> bool + def experimental_copy?: () -> bool + + # :call-seq: + # write -> ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode + # + # The constant write that should be modified with the shareability state. + # -- + # : () -> (ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode) + def write: () -> (ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode) + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a singleton class declaration involving the `class` keyword. + # + # class << self end + # ^^^^^^^^^^^^^^^^^ + class SingletonClassNode < Node + @end_keyword_loc: Location + + @body: (StatementsNode | BeginNode)? + + @expression: Prism::node + + @operator_loc: Location + + @class_keyword_loc: Location + + @locals: Array[Symbol] + + # Initialize a new SingletonClassNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, Location class_keyword_loc, Location operator_loc, Prism::node expression, (StatementsNode | BeginNode)? body, Location end_keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, Location class_keyword_loc, Location operator_loc, Prism::node expression, (StatementsNode | BeginNode)? body, Location end_keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> SingletonClassNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?class_keyword_loc: Location, ?operator_loc: Location, ?expression: Prism::node, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location) -> SingletonClassNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?class_keyword_loc: Location, ?operator_loc: Location, ?expression: Prism::node, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location) -> SingletonClassNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :singleton_class_node + def type: () -> :singleton_class_node + + # See `Node.type`. + # -- + # : () -> :singleton_class_node + def self.type: () -> :singleton_class_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # locals -> Array[Symbol] + # + # Returns the `locals` attribute. + # -- + # : () -> Array[Symbol] + def locals: () -> Array[Symbol] + + # :category: Locations + # :call-seq: + # class_keyword_loc -> Location + # + # Returns the Location represented by `class_keyword_loc`. + # -- + # : () -> Location + def class_keyword_loc: () -> Location + + # :category: Repository + # Save the class_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_class_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # expression -> Node + # + # Returns the `expression` attribute. + # -- + # : () -> Prism::node + def expression: () -> Prism::node + + # :call-seq: + # body -> StatementsNode | BeginNode | nil + # + # Returns the `body` attribute. + # -- + # : () -> (StatementsNode | BeginNode)? + def body: () -> (StatementsNode | BeginNode)? + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location + # + # Returns the Location represented by `end_keyword_loc`. + # -- + # : () -> Location + def end_keyword_loc: () -> Location + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # class_keyword -> String + # + # Slice the location of class_keyword_loc from the source. + # -- + # : () -> String + def class_keyword: () -> String + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # :call-seq: + # end_keyword -> String + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String + def end_keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `__ENCODING__` keyword. + # + # __ENCODING__ + # ^^^^^^^^^^^^ + class SourceEncodingNode < Node + # Initialize a new SourceEncodingNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> SourceEncodingNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> SourceEncodingNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> SourceEncodingNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :source_encoding_node + def type: () -> :source_encoding_node + + # See `Node.type`. + # -- + # : () -> :source_encoding_node + def self.type: () -> :source_encoding_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `__FILE__` keyword. + # + # __FILE__ + # ^^^^^^^^ + class SourceFileNode < Node + @filepath: String + + # Initialize a new SourceFileNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, String filepath) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, String filepath) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :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 + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?filepath: String) -> SourceFileNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :source_file_node + def type: () -> :source_file_node + + # See `Node.type`. + # -- + # : () -> :source_file_node + def self.type: () -> :source_file_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # internal bytes forced the encoding to UTF-8 + # -- + # : () -> bool + def forced_utf8_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to binary + # -- + # : () -> bool + def forced_binary_encoding?: () -> bool + + # :category: Flags + # frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal` + # -- + # : () -> bool + def frozen?: () -> bool + + # :category: Flags + # mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal` + # -- + # : () -> bool + def mutable?: () -> bool + + # :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 + def filepath: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `__LINE__` keyword. + # + # __LINE__ + # ^^^^^^^^ + class SourceLineNode < Node + # Initialize a new SourceLineNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> SourceLineNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> SourceLineNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> SourceLineNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :source_line_node + def type: () -> :source_line_node + + # See `Node.type`. + # -- + # : () -> :source_line_node + def self.type: () -> :source_line_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the splat operator. + # + # [*a] + # ^^ + class SplatNode < Node + @expression: Prism::node? + + @operator_loc: Location + + # Initialize a new SplatNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location operator_loc, Prism::node? expression) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location operator_loc, Prism::node? expression) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> SplatNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?expression: Prism::node?) -> SplatNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?expression: Prism::node?) -> SplatNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :splat_node + def type: () -> :splat_node + + # See `Node.type`. + # -- + # : () -> :splat_node + def self.type: () -> :splat_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # operator_loc -> Location + # + # Returns the Location represented by `operator_loc`. + # -- + # : () -> Location + def operator_loc: () -> Location + + # :category: Repository + # Save the operator_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_operator_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # expression -> Node | nil + # + # Returns the `expression` attribute. + # -- + # : () -> Prism::node? + def expression: () -> Prism::node? + + # :call-seq: + # operator -> String + # + # Slice the location of operator_loc from the source. + # -- + # : () -> String + def operator: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a set of statements contained within some scope. + # + # foo; bar; baz + # ^^^^^^^^^^^^^ + class StatementsNode < Node + @body: Array[Prism::node] + + # Initialize a new StatementsNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[Prism::node] body) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[Prism::node] body) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> StatementsNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Array[Prism::node]) -> StatementsNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?body: Array[Prism::node]) -> StatementsNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :statements_node + def type: () -> :statements_node + + # See `Node.type`. + # -- + # : () -> :statements_node + def self.type: () -> :statements_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # body -> Array[Node] + # + # Returns the `body` attribute. + # -- + # : () -> Array[Prism::node] + def body: () -> Array[Prism::node] + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a string literal, a string contained within a `%w` list, or plain string content within an interpolated string. + # + # "foo" + # ^^^^^ + # + # %w[foo] + # ^^^ + # + # "foo #{bar} baz" + # ^^^^ ^^^^ + class StringNode < Node + @unescaped: String + + @closing_loc: Location? + + @content_loc: Location + + @opening_loc: Location? + + # Initialize a new StringNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location? opening_loc, Location content_loc, Location? closing_loc, String unescaped) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location? opening_loc, Location content_loc, Location? closing_loc, String unescaped) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> StringNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?content_loc: Location, ?closing_loc: Location?, ?unescaped: String) -> StringNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?content_loc: Location, ?closing_loc: Location?, ?unescaped: String) -> StringNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :string_node + def type: () -> :string_node + + # See `Node.type`. + # -- + # : () -> :string_node + def self.type: () -> :string_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # internal bytes forced the encoding to UTF-8 + # -- + # : () -> bool + def forced_utf8_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to binary + # -- + # : () -> bool + def forced_binary_encoding?: () -> bool + + # :category: Flags + # frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal` + # -- + # : () -> bool + def frozen?: () -> bool + + # :category: Flags + # mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal` + # -- + # : () -> bool + def mutable?: () -> bool + + # :category: Locations + # :call-seq: + # opening_loc -> Location | nil + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location? + def opening_loc: () -> Location? + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_opening_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # content_loc -> Location + # + # Returns the Location represented by `content_loc`. + # -- + # : () -> Location + def content_loc: () -> Location + + # :category: Repository + # Save the content_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_content_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # unescaped -> String + # + # Returns the `unescaped` attribute. + # -- + # : () -> String + def unescaped: () -> String + + # :call-seq: + # opening -> String | nil + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String? + def opening: () -> String? + + # :call-seq: + # content -> String + # + # Slice the location of content_loc from the source. + # -- + # : () -> String + def content: () -> String + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `super` keyword with parentheses or arguments. + # + # super() + # ^^^^^^^ + # + # super foo, bar + # ^^^^^^^^^^^^^^ + # + # If no arguments are provided (except for a block), it would be a `ForwardingSuperNode` instead. + class SuperNode < Node + @block: (BlockNode | BlockArgumentNode)? + + @rparen_loc: Location? + + @arguments: ArgumentsNode? + + @lparen_loc: Location? + + @keyword_loc: Location + + # Initialize a new SuperNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Location? lparen_loc, ArgumentsNode? arguments, Location? rparen_loc, (BlockNode | BlockArgumentNode)? block) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Location? lparen_loc, ArgumentsNode? arguments, Location? rparen_loc, (BlockNode | BlockArgumentNode)? block) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> SuperNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?, ?block: (BlockNode | BlockArgumentNode)?) -> SuperNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?, ?block: (BlockNode | BlockArgumentNode)?) -> SuperNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :super_node + def type: () -> :super_node + + # See `Node.type`. + # -- + # : () -> :super_node + def self.type: () -> :super_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # lparen_loc -> Location | nil + # + # Returns the Location represented by `lparen_loc`. + # -- + # : () -> Location? + def lparen_loc: () -> Location? + + # :category: Repository + # Save the lparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_lparen_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # arguments -> ArgumentsNode | nil + # + # Can be only `nil` when there are empty parentheses, like `super()`. + # -- + # : () -> ArgumentsNode? + def arguments: () -> ArgumentsNode? + + # :category: Locations + # :call-seq: + # rparen_loc -> Location | nil + # + # Returns the Location represented by `rparen_loc`. + # -- + # : () -> Location? + def rparen_loc: () -> Location? + + # :category: Repository + # Save the rparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_rparen_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # block -> BlockNode | BlockArgumentNode | nil + # + # Returns the `block` attribute. + # -- + # : () -> (BlockNode | BlockArgumentNode)? + def block: () -> (BlockNode | BlockArgumentNode)? + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # :call-seq: + # lparen -> String | nil + # + # Slice the location of lparen_loc from the source. + # -- + # : () -> String? + def lparen: () -> String? + + # :call-seq: + # rparen -> String | nil + # + # Slice the location of rparen_loc from the source. + # -- + # : () -> String? + def rparen: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents a symbol literal or a symbol contained within a `%i` list. + # + # :foo + # ^^^^ + # + # %i[foo] + # ^^^ + class SymbolNode < Node + @unescaped: String + + @closing_loc: Location? + + @value_loc: Location? + + @opening_loc: Location? + + # Initialize a new SymbolNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location? opening_loc, Location? value_loc, Location? closing_loc, String unescaped) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location? opening_loc, Location? value_loc, Location? closing_loc, String unescaped) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> SymbolNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?value_loc: Location?, ?closing_loc: Location?, ?unescaped: String) -> SymbolNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?value_loc: Location?, ?closing_loc: Location?, ?unescaped: String) -> SymbolNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :symbol_node + def type: () -> :symbol_node + + # See `Node.type`. + # -- + # : () -> :symbol_node + def self.type: () -> :symbol_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # internal bytes forced the encoding to UTF-8 + # -- + # : () -> bool + def forced_utf8_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to binary + # -- + # : () -> bool + def forced_binary_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to US-ASCII + # -- + # : () -> bool + def forced_us_ascii_encoding?: () -> bool + + # :category: Locations + # :call-seq: + # opening_loc -> Location | nil + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location? + def opening_loc: () -> Location? + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_opening_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # value_loc -> Location | nil + # + # Returns the Location represented by `value_loc`. + # -- + # : () -> Location? + def value_loc: () -> Location? + + # :category: Repository + # Save the value_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_value_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # unescaped -> String + # + # Returns the `unescaped` attribute. + # -- + # : () -> String + def unescaped: () -> String + + # :call-seq: + # opening -> String | nil + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String? + def opening: () -> String? + + # :call-seq: + # value -> String | nil + # + # Slice the location of value_loc from the source. + # -- + # : () -> String? + def value: () -> String? + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the literal `true` keyword. + # + # true + # ^^^^ + class TrueNode < Node + # Initialize a new TrueNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, ) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> TrueNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> TrueNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer) -> TrueNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :true_node + def type: () -> :true_node + + # See `Node.type`. + # -- + # : () -> :true_node + def self.type: () -> :true_node + + # : () -> String + def inspect: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `undef` keyword. + # + # undef :foo, :bar, :baz + # ^^^^^^^^^^^^^^^^^^^^^^ + class UndefNode < Node + @keyword_loc: Location + + @names: Array[SymbolNode | InterpolatedSymbolNode] + + # Initialize a new UndefNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Array[SymbolNode | InterpolatedSymbolNode] names, Location keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Array[SymbolNode | InterpolatedSymbolNode] names, Location keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> UndefNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?names: Array[SymbolNode | InterpolatedSymbolNode], ?keyword_loc: Location) -> UndefNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?names: Array[SymbolNode | InterpolatedSymbolNode], ?keyword_loc: Location) -> UndefNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :undef_node + def type: () -> :undef_node + + # See `Node.type`. + # -- + # : () -> :undef_node + def self.type: () -> :undef_node + + # : () -> String + def inspect: () -> String + + # :call-seq: + # names -> Array[SymbolNode | InterpolatedSymbolNode] + # + # Returns the `names` attribute. + # -- + # : () -> Array[SymbolNode | InterpolatedSymbolNode] + def names: () -> Array[SymbolNode | InterpolatedSymbolNode] + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `unless` keyword, either in the block form or the modifier form. + # + # bar unless foo + # ^^^^^^^^^^^^^^ + # + # unless foo then bar end + # ^^^^^^^^^^^^^^^^^^^^^^^ + class UnlessNode < Node + @end_keyword_loc: Location? + + @else_clause: ElseNode? + + @statements: StatementsNode? + + @then_keyword_loc: Location? + + @predicate: Prism::node + + @keyword_loc: Location + + # Initialize a new UnlessNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Prism::node predicate, Location? then_keyword_loc, StatementsNode? statements, ElseNode? else_clause, Location? end_keyword_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Prism::node predicate, Location? then_keyword_loc, StatementsNode? statements, ElseNode? else_clause, Location? end_keyword_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> UnlessNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?else_clause: ElseNode?, ?end_keyword_loc: Location?) -> UnlessNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?else_clause: ElseNode?, ?end_keyword_loc: Location?) -> UnlessNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :unless_node + def type: () -> :unless_node + + # See `Node.type`. + # -- + # : () -> :unless_node + def self.type: () -> :unless_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # The Location of the `unless` keyword. + # + # unless cond then bar end + # ^^^^^^ + # + # bar unless cond + # ^^^^^^ + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # predicate -> Node + # + # The condition to be evaluated for the unless expression. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). + # + # unless cond then bar end + # ^^^^ + # + # bar unless cond + # ^^^^ + # -- + # : () -> Prism::node + def predicate: () -> Prism::node + + # :category: Locations + # :call-seq: + # then_keyword_loc -> Location | nil + # + # The Location of the `then` keyword, if present. + # + # unless cond then bar end + # ^^^^ + # -- + # : () -> Location? + def then_keyword_loc: () -> Location? + + # :category: Repository + # Save the then_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_then_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # statements -> StatementsNode | nil + # + # The body of statements that will executed if the unless condition is + # falsey. Will be `nil` if no body is provided. + # + # unless cond then bar end + # ^^^ + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :call-seq: + # else_clause -> ElseNode | nil + # + # The else clause of the unless expression, if present. + # + # unless cond then bar else baz end + # ^^^^^^^^ + # -- + # : () -> ElseNode? + def else_clause: () -> ElseNode? + + # :category: Locations + # :call-seq: + # end_keyword_loc -> Location | nil + # + # The Location of the `end` keyword, if present. + # + # unless cond then bar end + # ^^^ + # -- + # : () -> Location? + def end_keyword_loc: () -> Location? + + # :category: Repository + # Save the end_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_end_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # :call-seq: + # then_keyword -> String | nil + # + # Slice the location of then_keyword_loc from the source. + # -- + # : () -> String? + def then_keyword: () -> String? + + # :call-seq: + # end_keyword -> String | nil + # + # Slice the location of end_keyword_loc from the source. + # -- + # : () -> String? + def end_keyword: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `until` keyword, either in the block form or the modifier form. + # + # bar until foo + # ^^^^^^^^^^^^^ + # + # until foo do bar end + # ^^^^^^^^^^^^^^^^^^^^ + class UntilNode < Node + @statements: StatementsNode? + + @predicate: Prism::node + + @closing_loc: Location? + + @do_keyword_loc: Location? + + @keyword_loc: Location + + # Initialize a new UntilNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Location? do_keyword_loc, Location? closing_loc, Prism::node predicate, StatementsNode? statements) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Location? do_keyword_loc, Location? closing_loc, Prism::node predicate, StatementsNode? statements) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> UntilNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?do_keyword_loc: Location?, ?closing_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) -> UntilNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?do_keyword_loc: Location?, ?closing_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) -> UntilNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :until_node + def type: () -> :until_node + + # See `Node.type`. + # -- + # : () -> :until_node + def self.type: () -> :until_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # a loop after a begin statement, so the body is executed first before the condition + # -- + # : () -> bool + def begin_modifier?: () -> bool + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # do_keyword_loc -> Location | nil + # + # Returns the Location represented by `do_keyword_loc`. + # -- + # : () -> Location? + def do_keyword_loc: () -> Location? + + # :category: Repository + # Save the do_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_do_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # predicate -> Node + # + # Returns the `predicate` attribute. + # -- + # : () -> Prism::node + def predicate: () -> Prism::node + + # :call-seq: + # statements -> StatementsNode | nil + # + # Returns the `statements` attribute. + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # :call-seq: + # do_keyword -> String | nil + # + # Slice the location of do_keyword_loc from the source. + # -- + # : () -> String? + def do_keyword: () -> String? + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `when` keyword within a case statement. + # + # case true + # when true + # ^^^^^^^^^ + # end + class WhenNode < Node + @statements: StatementsNode? + + @then_keyword_loc: Location? + + @conditions: Array[Prism::node] + + @keyword_loc: Location + + # Initialize a new WhenNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Array[Prism::node] conditions, Location? then_keyword_loc, StatementsNode? statements) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Array[Prism::node] conditions, Location? then_keyword_loc, StatementsNode? statements) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> WhenNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?conditions: Array[Prism::node], ?then_keyword_loc: Location?, ?statements: StatementsNode?) -> WhenNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?conditions: Array[Prism::node], ?then_keyword_loc: Location?, ?statements: StatementsNode?) -> WhenNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :when_node + def type: () -> :when_node + + # See `Node.type`. + # -- + # : () -> :when_node + def self.type: () -> :when_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # conditions -> Array[Node] + # + # Returns the `conditions` attribute. + # -- + # : () -> Array[Prism::node] + def conditions: () -> Array[Prism::node] + + # :category: Locations + # :call-seq: + # then_keyword_loc -> Location | nil + # + # Returns the Location represented by `then_keyword_loc`. + # -- + # : () -> Location? + def then_keyword_loc: () -> Location? + + # :category: Repository + # Save the then_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_then_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # statements -> StatementsNode | nil + # + # Returns the `statements` attribute. + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # :call-seq: + # then_keyword -> String | nil + # + # Slice the location of then_keyword_loc from the source. + # -- + # : () -> String? + def then_keyword: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `while` keyword, either in the block form or the modifier form. + # + # bar while foo + # ^^^^^^^^^^^^^ + # + # while foo do bar end + # ^^^^^^^^^^^^^^^^^^^^ + class WhileNode < Node + @statements: StatementsNode? + + @predicate: Prism::node + + @closing_loc: Location? + + @do_keyword_loc: Location? + + @keyword_loc: Location + + # Initialize a new WhileNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Location? do_keyword_loc, Location? closing_loc, Prism::node predicate, StatementsNode? statements) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Location? do_keyword_loc, Location? closing_loc, Prism::node predicate, StatementsNode? statements) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> WhileNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?do_keyword_loc: Location?, ?closing_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) -> WhileNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?do_keyword_loc: Location?, ?closing_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) -> WhileNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :while_node + def type: () -> :while_node + + # See `Node.type`. + # -- + # : () -> :while_node + def self.type: () -> :while_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # a loop after a begin statement, so the body is executed first before the condition + # -- + # : () -> bool + def begin_modifier?: () -> bool + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # do_keyword_loc -> Location | nil + # + # Returns the Location represented by `do_keyword_loc`. + # -- + # : () -> Location? + def do_keyword_loc: () -> Location? + + # :category: Repository + # Save the do_keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_do_keyword_loc: (_Repository repository) -> Relocation::Entry? + + # :category: Locations + # :call-seq: + # closing_loc -> Location | nil + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location? + def closing_loc: () -> Location? + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_closing_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # predicate -> Node + # + # Returns the `predicate` attribute. + # -- + # : () -> Prism::node + def predicate: () -> Prism::node + + # :call-seq: + # statements -> StatementsNode | nil + # + # Returns the `statements` attribute. + # -- + # : () -> StatementsNode? + def statements: () -> StatementsNode? + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # :call-seq: + # do_keyword -> String | nil + # + # Slice the location of do_keyword_loc from the source. + # -- + # : () -> String? + def do_keyword: () -> String? + + # :call-seq: + # closing -> String | nil + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String? + def closing: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents an xstring literal with no interpolation. + # + # `foo` + # ^^^^^ + class XStringNode < Node + @unescaped: String + + @closing_loc: Location + + @content_loc: Location + + @opening_loc: Location + + # Initialize a new XStringNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Location content_loc, Location closing_loc, String unescaped) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, Location content_loc, Location closing_loc, String unescaped) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> XStringNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> XStringNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?content_loc: Location, ?closing_loc: Location, ?unescaped: String) -> XStringNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :x_string_node + def type: () -> :x_string_node + + # See `Node.type`. + # -- + # : () -> :x_string_node + def self.type: () -> :x_string_node + + # : () -> String + def inspect: () -> String + + # :category: Flags + # internal bytes forced the encoding to UTF-8 + # -- + # : () -> bool + def forced_utf8_encoding?: () -> bool + + # :category: Flags + # internal bytes forced the encoding to binary + # -- + # : () -> bool + def forced_binary_encoding?: () -> bool + + # :category: Locations + # :call-seq: + # opening_loc -> Location + # + # Returns the Location represented by `opening_loc`. + # -- + # : () -> Location + def opening_loc: () -> Location + + # :category: Repository + # Save the opening_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_opening_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # content_loc -> Location + # + # Returns the Location represented by `content_loc`. + # -- + # : () -> Location + def content_loc: () -> Location + + # :category: Repository + # Save the content_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_content_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # closing_loc -> Location + # + # Returns the Location represented by `closing_loc`. + # -- + # : () -> Location + def closing_loc: () -> Location + + # :category: Repository + # Save the closing_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_closing_loc: (_Repository repository) -> Relocation::Entry + + # :call-seq: + # unescaped -> String + # + # Returns the `unescaped` attribute. + # -- + # : () -> String + def unescaped: () -> String + + # :call-seq: + # opening -> String + # + # Slice the location of opening_loc from the source. + # -- + # : () -> String + def opening: () -> String + + # :call-seq: + # content -> String + # + # Slice the location of content_loc from the source. + # -- + # : () -> String + def content: () -> String + + # :call-seq: + # closing -> String + # + # Slice the location of closing_loc from the source. + # -- + # : () -> String + def closing: () -> String + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Represents the use of the `yield` keyword. + # + # yield 1 + # ^^^^^^^ + class YieldNode < Node + @rparen_loc: Location? + + @arguments: ArgumentsNode? + + @lparen_loc: Location? + + @keyword_loc: Location + + # Initialize a new YieldNode node. + # -- + # : (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Location? lparen_loc, ArgumentsNode? arguments, Location? rparen_loc) -> void + def initialize: (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Location? lparen_loc, ArgumentsNode? arguments, Location? rparen_loc) -> void + + # See Node.accept. + # -- + # : (_Visitor visitor) -> untyped + def accept: (_Visitor visitor) -> untyped + + # See Node.child_nodes. + # -- + # : () -> Array[node?] + def child_nodes: () -> Array[node?] + + # See Node.each_child_node. + # -- + # : () { (node) -> void } -> void + # : () -> Enumerator[node, void] + def each_child_node: () { (node) -> void } -> void + | () -> Enumerator[node, void] + + # See Node.compact_child_nodes. + # -- + # : () -> Array[node] + def compact_child_nodes: () -> Array[node] + + # See Node.comment_targets. + # -- + # : () -> Array[node | Location] + def comment_targets: () -> Array[node | Location] + + # :call-seq: + # copy(**fields) -> YieldNode + # + # Creates a copy of self with the given fields, using self as the template. + # -- + # : (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?) -> YieldNode + def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?) -> YieldNode + + alias deconstruct child_nodes + + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # See `Node#type`. + # -- + # : () -> :yield_node + def type: () -> :yield_node + + # See `Node.type`. + # -- + # : () -> :yield_node + def self.type: () -> :yield_node + + # : () -> String + def inspect: () -> String + + # :category: Locations + # :call-seq: + # keyword_loc -> Location + # + # Returns the Location represented by `keyword_loc`. + # -- + # : () -> Location + def keyword_loc: () -> Location + + # :category: Repository + # Save the keyword_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry + def save_keyword_loc: (_Repository repository) -> Relocation::Entry + + # :category: Locations + # :call-seq: + # lparen_loc -> Location | nil + # + # Returns the Location represented by `lparen_loc`. + # -- + # : () -> Location? + def lparen_loc: () -> Location? + + # :category: Repository + # Save the lparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_lparen_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # arguments -> ArgumentsNode | nil + # + # Returns the `arguments` attribute. + # -- + # : () -> ArgumentsNode? + def arguments: () -> ArgumentsNode? + + # :category: Locations + # :call-seq: + # rparen_loc -> Location | nil + # + # Returns the Location represented by `rparen_loc`. + # -- + # : () -> Location? + def rparen_loc: () -> Location? + + # :category: Repository + # Save the rparen_loc location using the given saved source so that + # it can be retrieved later. + # -- + # : (_Repository repository) -> Relocation::Entry? + def save_rparen_loc: (_Repository repository) -> Relocation::Entry? + + # :call-seq: + # keyword -> String + # + # Slice the location of keyword_loc from the source. + # -- + # : () -> String + def keyword: () -> String + + # :call-seq: + # lparen -> String | nil + # + # Slice the location of lparen_loc from the source. + # -- + # : () -> String? + def lparen: () -> String? + + # :call-seq: + # rparen -> String | nil + # + # Slice the location of rparen_loc from the source. + # -- + # : () -> String? + def rparen: () -> String? + + # : (untyped other) -> bool + def ===: (untyped other) -> bool + end + + # Flags for arguments nodes. + module ArgumentsNodeFlags + # if the arguments contain forwarding + CONTAINS_FORWARDING: untyped + + # if the arguments contain keywords + CONTAINS_KEYWORDS: untyped + + # if the arguments contain a keyword splat + CONTAINS_KEYWORD_SPLAT: untyped + + # if the arguments contain a splat + CONTAINS_SPLAT: untyped + + # if the arguments contain multiple splats + CONTAINS_MULTIPLE_SPLATS: untyped + end + + # Flags for array nodes. + module ArrayNodeFlags + # if array contains splat nodes + CONTAINS_SPLAT: untyped + end + + # Flags for call nodes. + module CallNodeFlags + # &. operator + SAFE_NAVIGATION: untyped + + # a call that could have been a local variable + VARIABLE_CALL: untyped + + # a call that is an attribute write, so the value being written should be returned + ATTRIBUTE_WRITE: untyped + + # a call that ignores method visibility + IGNORE_VISIBILITY: untyped + end + + # Flags for nodes that have unescaped content. + module EncodingFlags + # internal bytes forced the encoding to UTF-8 + FORCED_UTF8_ENCODING: untyped + + # internal bytes forced the encoding to binary + FORCED_BINARY_ENCODING: untyped + end + + # Flags for integer nodes that correspond to the base of the integer. + module IntegerBaseFlags + # 0b prefix + BINARY: untyped + + # 0d or no prefix + DECIMAL: untyped + + # 0o or 0 prefix + OCTAL: untyped + + # 0x prefix + HEXADECIMAL: untyped + end + + # Flags for interpolated string nodes that indicated mutability if they are also marked as literals. + module InterpolatedStringNodeFlags + # frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal`; only for adjacent string literals like `'a' 'b'` + FROZEN: untyped + + # mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal`; only for adjacent string literals like `'a' 'b'` + MUTABLE: untyped + end + + # Flags for keyword hash nodes. + module KeywordHashNodeFlags + # a keyword hash which only has `AssocNode` elements all with symbol keys, which means the elements can be treated as keyword arguments + SYMBOL_KEYS: untyped + end + + # Flags for while and until loop nodes. + module LoopFlags + # a loop after a begin statement, so the body is executed first before the condition + BEGIN_MODIFIER: untyped + end + + # Flags for parameter nodes. + module ParameterFlags + # a parameter name that has been repeated in the method signature + REPEATED_PARAMETER: untyped + end + + # Flags for parentheses nodes. + module ParenthesesNodeFlags + # parentheses that contain multiple potentially void statements + MULTIPLE_STATEMENTS: untyped + end + + # Flags for range and flip-flop nodes. + module RangeFlags + # ... operator + EXCLUDE_END: untyped + end + + # Flags for regular expression and match last line nodes. + module RegularExpressionFlags + # i - ignores the case of characters when matching + IGNORE_CASE: untyped + + # x - ignores whitespace and allows comments in regular expressions + EXTENDED: untyped + + # m - allows $ to match the end of lines within strings + MULTI_LINE: untyped + + # o - only interpolates values into the regular expression once + ONCE: untyped + + # e - forces the EUC-JP encoding + EUC_JP: untyped + + # n - forces the ASCII-8BIT encoding + ASCII_8BIT: untyped + + # s - forces the Windows-31J encoding + WINDOWS_31J: untyped + + # u - forces the UTF-8 encoding + UTF_8: untyped + + # internal bytes forced the encoding to UTF-8 + FORCED_UTF8_ENCODING: untyped + + # internal bytes forced the encoding to binary + FORCED_BINARY_ENCODING: untyped + + # internal bytes forced the encoding to US-ASCII + FORCED_US_ASCII_ENCODING: untyped + end + + # Flags for shareable constant nodes. + module ShareableConstantNodeFlags + # constant writes that should be modified with shareable constant value literal + LITERAL: untyped + + # constant writes that should be modified with shareable constant value experimental everything + EXPERIMENTAL_EVERYTHING: untyped + + # constant writes that should be modified with shareable constant value experimental copy + EXPERIMENTAL_COPY: untyped + end + + # Flags for string nodes. + module StringFlags + # internal bytes forced the encoding to UTF-8 + FORCED_UTF8_ENCODING: untyped + + # internal bytes forced the encoding to binary + FORCED_BINARY_ENCODING: untyped + + # frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal` + FROZEN: untyped + + # mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal` + MUTABLE: untyped + end + + # Flags for symbol nodes. + module SymbolFlags + # internal bytes forced the encoding to UTF-8 + FORCED_UTF8_ENCODING: untyped + + # internal bytes forced the encoding to binary + FORCED_BINARY_ENCODING: untyped + + # internal bytes forced the encoding to US-ASCII + FORCED_US_ASCII_ENCODING: untyped + end + + # The flags that are common to all nodes. + module NodeFlags + # A flag to indicate that the node is a candidate to emit a :line event + # through tracepoint when compiled. + NEWLINE: ::Integer + + # A flag to indicate that the value that the node represents is a value that + # can be determined at parse-time. + STATIC_LITERAL: ::Integer + end +end diff --git a/sig/generated/prism/node_ext.rbs b/sig/generated/prism/node_ext.rbs new file mode 100644 index 0000000000..273e591eb8 --- /dev/null +++ b/sig/generated/prism/node_ext.rbs @@ -0,0 +1,387 @@ +# Generated from lib/prism/node_ext.rb with RBS::Inline + +# -- +# Here we are reopening the prism module to provide methods on nodes that aren't +# templated and are meant as convenience methods. +# ++ +module Prism + class Node + # : (*String replacements) -> void + def deprecated: (*String replacements) -> void + end + + module RegularExpressionOptions + # Returns a numeric value that represents the flags that were used to create + # the regular expression. + # -- + # : (Integer flags) -> Integer + def self.options: (Integer flags) -> Integer + end + + class InterpolatedMatchLastLineNode < Node + # Returns a numeric value that represents the flags that were used to create + # the regular expression. + # -- + # : () -> Integer + def options: () -> Integer + end + + class InterpolatedRegularExpressionNode < Node + # Returns a numeric value that represents the flags that were used to create + # the regular expression. + # -- + # : () -> Integer + def options: () -> Integer + end + + class MatchLastLineNode < Node + # Returns a numeric value that represents the flags that were used to create + # the regular expression. + # -- + # : () -> Integer + def options: () -> Integer + end + + class RegularExpressionNode < Node + # Returns a numeric value that represents the flags that were used to create + # the regular expression. + # -- + # : () -> Integer + def options: () -> Integer + end + + module HeredocQuery + # Returns true if this node was represented as a heredoc in the source code. + # -- + # : (String? opening) -> bool? + def self.heredoc?: (String? opening) -> bool? + end + + class InterpolatedStringNode < Node + # Returns true if this node was represented as a heredoc in the source code. + # -- + # : () -> bool? + def heredoc?: () -> bool? + end + + class InterpolatedXStringNode < Node + # Returns true if this node was represented as a heredoc in the source code. + # -- + # : () -> bool? + def heredoc?: () -> bool? + end + + class StringNode < Node + # Returns true if this node was represented as a heredoc in the source code. + # -- + # : () -> bool? + def heredoc?: () -> bool? + + # Occasionally it's helpful to treat a string as if it were interpolated so + # that there's a consistent interface for working with strings. + # -- + # : () -> InterpolatedStringNode + def to_interpolated: () -> InterpolatedStringNode + end + + class XStringNode < Node + # Returns true if this node was represented as a heredoc in the source code. + # -- + # : () -> bool? + def heredoc?: () -> bool? + + # Occasionally it's helpful to treat a string as if it were interpolated so + # that there's a consistent interface for working with strings. + # -- + # : () -> InterpolatedXStringNode + def to_interpolated: () -> InterpolatedXStringNode + end + + class ImaginaryNode < Node + # Returns the value of the node as a Ruby Complex. + # -- + # : () -> Complex + def value: () -> Complex + end + + class RationalNode < Node + # Returns the value of the node as a Ruby Rational. + # -- + # : () -> Rational + def value: () -> Rational + + # Returns the value of the node as an IntegerNode or a FloatNode. This + # method is deprecated in favor of #value or #numerator/#denominator. + # -- + # : () -> (IntegerNode | FloatNode) + def numeric: () -> (IntegerNode | FloatNode) + end + + class ConstantReadNode < Node + # Returns the list of parts for the full name of this constant. + # For example: [:Foo] + # -- + # : () -> Array[Symbol] + def full_name_parts: () -> Array[Symbol] + + # Returns the full name of this constant. For example: "Foo" + # -- + # : () -> String + def full_name: () -> String + end + + class ConstantWriteNode < Node + # Returns the list of parts for the full name of this constant. + # For example: [:Foo] + # -- + # : () -> Array[Symbol] + def full_name_parts: () -> Array[Symbol] + + # Returns the full name of this constant. For example: "Foo" + # -- + # : () -> String + def full_name: () -> String + end + + class ConstantPathNode < Node + # An error class raised when dynamic parts are found while computing a + # constant path's full name. For example: + # Foo::Bar::Baz -> does not raise because all parts of the constant path are + # simple constants + # var::Bar::Baz -> raises because the first part of the constant path is a + # local variable + class DynamicPartsInConstantPathError < StandardError + end + + # An error class raised when missing nodes are found while computing a + # constant path's full name. For example: + # Foo:: -> raises because the constant path is missing the last part + class MissingNodesInConstantPathError < StandardError + end + + # Returns the list of parts for the full name of this constant path. + # For example: [:Foo, :Bar] + # -- + # : () -> Array[Symbol] + def full_name_parts: () -> Array[Symbol] + + # Returns the full name of this constant path. For example: "Foo::Bar" + # -- + # : () -> String + def full_name: () -> String + + # Previously, we had a child node on this class that contained either a + # constant read or a missing node. To not cause a breaking change, we + # continue to supply that API. + # -- + # : () -> (ConstantReadNode | MissingNode) + def child: () -> (ConstantReadNode | MissingNode) + end + + class ConstantPathTargetNode < Node + # Returns the list of parts for the full name of this constant path. + # For example: [:Foo, :Bar] + # -- + # : () -> Array[Symbol] + def full_name_parts: () -> Array[Symbol] + + # Returns the full name of this constant path. For example: "Foo::Bar" + # -- + # : () -> String + def full_name: () -> String + + # Previously, we had a child node on this class that contained either a + # constant read or a missing node. To not cause a breaking change, we + # continue to supply that API. + # -- + # : () -> (ConstantReadNode | MissingNode) + def child: () -> (ConstantReadNode | MissingNode) + end + + class ConstantTargetNode < Node + # Returns the list of parts for the full name of this constant. + # For example: [:Foo] + # -- + # : () -> Array[Symbol] + def full_name_parts: () -> Array[Symbol] + + # Returns the full name of this constant. For example: "Foo" + # -- + # : () -> String + def full_name: () -> String + end + + class ParametersNode < Node + # Mirrors the Method#parameters method. + # -- + # : () -> Array[[Symbol, Symbol] | [Symbol]] + def signature: () -> Array[[ Symbol, Symbol ] | [ Symbol ]] + end + + class CallNode < Node + # When a call node has the attribute_write flag set, it means that the call + # is using the attribute write syntax. This is either a method call to []= + # or a method call to a method that ends with =. Either way, the = sign is + # present in the source. + # + # Prism returns the message_loc _without_ the = sign attached, because there + # can be any amount of space between the message and the = sign. However, + # sometimes you want the location of the full message including the inner + # space and the = sign. This method provides that. + # -- + # : () -> Location? + def full_message_loc: () -> Location? + end + + class CallOperatorWriteNode < Node + # Returns the binary operator used to modify the receiver. This method is + # deprecated in favor of #binary_operator. + # -- + # : () -> Symbol + def operator: () -> Symbol + + # Returns the location of the binary operator used to modify the receiver. + # This method is deprecated in favor of #binary_operator_loc. + # -- + # : () -> Location + def operator_loc: () -> Location + end + + class ClassVariableOperatorWriteNode < Node + # Returns the binary operator used to modify the receiver. This method is + # deprecated in favor of #binary_operator. + # -- + # : () -> Symbol + def operator: () -> Symbol + + # Returns the location of the binary operator used to modify the receiver. + # This method is deprecated in favor of #binary_operator_loc. + # -- + # : () -> Location + def operator_loc: () -> Location + end + + class ConstantOperatorWriteNode < Node + # Returns the binary operator used to modify the receiver. This method is + # deprecated in favor of #binary_operator. + # -- + # : () -> Symbol + def operator: () -> Symbol + + # Returns the location of the binary operator used to modify the receiver. + # This method is deprecated in favor of #binary_operator_loc. + # -- + # : () -> Location + def operator_loc: () -> Location + end + + class ConstantPathOperatorWriteNode < Node + # Returns the binary operator used to modify the receiver. This method is + # deprecated in favor of #binary_operator. + # -- + # : () -> Symbol + def operator: () -> Symbol + + # Returns the location of the binary operator used to modify the receiver. + # This method is deprecated in favor of #binary_operator_loc. + # -- + # : () -> Location + def operator_loc: () -> Location + end + + class GlobalVariableOperatorWriteNode < Node + # Returns the binary operator used to modify the receiver. This method is + # deprecated in favor of #binary_operator. + # -- + # : () -> Symbol + def operator: () -> Symbol + + # Returns the location of the binary operator used to modify the receiver. + # This method is deprecated in favor of #binary_operator_loc. + # -- + # : () -> Location + def operator_loc: () -> Location + end + + class IndexOperatorWriteNode < Node + # Returns the binary operator used to modify the receiver. This method is + # deprecated in favor of #binary_operator. + # -- + # : () -> Symbol + def operator: () -> Symbol + + # Returns the location of the binary operator used to modify the receiver. + # This method is deprecated in favor of #binary_operator_loc. + # -- + # : () -> Location + def operator_loc: () -> Location + end + + class InstanceVariableOperatorWriteNode < Node + # Returns the binary operator used to modify the receiver. This method is + # deprecated in favor of #binary_operator. + # -- + # : () -> Symbol + def operator: () -> Symbol + + # Returns the location of the binary operator used to modify the receiver. + # This method is deprecated in favor of #binary_operator_loc. + # -- + # : () -> Location + def operator_loc: () -> Location + end + + class LocalVariableOperatorWriteNode < Node + # Returns the binary operator used to modify the receiver. This method is + # deprecated in favor of #binary_operator. + # -- + # : () -> Symbol + def operator: () -> Symbol + + # Returns the location of the binary operator used to modify the receiver. + # This method is deprecated in favor of #binary_operator_loc. + # -- + # : () -> Location + def operator_loc: () -> Location + end + + class CaseMatchNode < Node + # Returns the else clause of the case match node. This method is deprecated + # in favor of #else_clause. + # -- + # : () -> ElseNode? + def consequent: () -> ElseNode? + end + + class CaseNode < Node + # Returns the else clause of the case node. This method is deprecated in + # favor of #else_clause. + # -- + # : () -> ElseNode? + def consequent: () -> ElseNode? + end + + class IfNode < Node + # Returns the subsequent if/elsif/else clause of the if node. This method is + # deprecated in favor of #subsequent. + # -- + # : () -> (IfNode | ElseNode)? + def consequent: () -> (IfNode | ElseNode)? + end + + class RescueNode < Node + # Returns the subsequent rescue clause of the rescue node. This method is + # deprecated in favor of #subsequent. + # -- + # : () -> RescueNode? + def consequent: () -> RescueNode? + end + + class UnlessNode < Node + # Returns the else clause of the unless node. This method is deprecated in + # favor of #else_clause. + # -- + # : () -> ElseNode? + def consequent: () -> ElseNode? + end +end diff --git a/sig/generated/prism/parse_result.rbs b/sig/generated/prism/parse_result.rbs new file mode 100644 index 0000000000..96b1665d06 --- /dev/null +++ b/sig/generated/prism/parse_result.rbs @@ -0,0 +1,811 @@ +# Generated from lib/prism/parse_result.rb with RBS::Inline + +module Prism + # An internal interface for a cache that can be used to compute code + # units from byte offsets. + interface _CodeUnitsCache + def []: (Integer byte_offset) -> Integer + end + + # This represents a source of Ruby code that has been parsed. It is used in + # conjunction with locations to allow them to resolve line numbers and source + # ranges. + class Source + # Create a new source object with the given source code. This method should + # be used instead of `new` and it will return either a `Source` or a + # specialized and more performant `ASCIISource` if no multibyte characters + # are present in the source code. + # -- + # : (String source, ?Integer start_line, ?Array[Integer] offsets) -> Source + def self.for: (String source, ?Integer start_line, ?Array[Integer] offsets) -> Source + + # The source code that this source object represents. + attr_reader source: String + + # The line number where this source starts. + attr_reader start_line: Integer + + # The list of newline byte offsets in the source code. + attr_reader offsets: Array[Integer] + + # Create a new source object with the given source code. + # -- + # : (String source, ?Integer start_line, ?Array[Integer] offsets) -> void + def initialize: (String source, ?Integer start_line, ?Array[Integer] offsets) -> void + + # Replace the value of start_line with the given value. + # -- + # : (Integer start_line) -> void + def replace_start_line: (Integer start_line) -> void + + # Replace the value of offsets with the given value. + # -- + # : (Array[Integer] offsets) -> void + def replace_offsets: (Array[Integer] offsets) -> void + + # Returns the encoding of the source code, which is set by parameters to the + # parser or by the encoding magic comment. + # -- + # : () -> Encoding + def encoding: () -> Encoding + + # Returns the lines of the source code as an array of strings. + # -- + # : () -> Array[String] + def lines: () -> Array[String] + + # Perform a byteslice on the source code using the given byte offset and + # byte length. + # -- + # : (Integer byte_offset, Integer length) -> String + def slice: (Integer byte_offset, Integer length) -> String + + # Converts the line number and column in bytes to a byte offset. + # -- + # : (Integer line, Integer column) -> Integer + def byte_offset: (Integer line, Integer column) -> Integer + + # Binary search through the offsets to find the line number for the given + # byte offset. + # -- + # : (Integer byte_offset) -> Integer + def line: (Integer byte_offset) -> Integer + + # Return the byte offset of the start of the line corresponding to the given + # byte offset. + # -- + # : (Integer byte_offset) -> Integer + def line_start: (Integer byte_offset) -> Integer + + # Returns the byte offset of the end of the line corresponding to the given + # byte offset. + # -- + # : (Integer byte_offset) -> Integer + def line_end: (Integer byte_offset) -> Integer + + # Return the column in bytes for the given byte offset. + # -- + # : (Integer byte_offset) -> Integer + def column: (Integer byte_offset) -> Integer + + # Return the character offset for the given byte offset. + # -- + # : (Integer byte_offset) -> Integer + def character_offset: (Integer byte_offset) -> Integer + + # Return the column in characters for the given byte offset. + # -- + # : (Integer byte_offset) -> Integer + def character_column: (Integer byte_offset) -> Integer + + # Returns the offset from the start of the file for the given byte offset + # counting in code units for the given encoding. + # + # This method is tested with UTF-8, UTF-16, and UTF-32. If there is the + # concept of code units that differs from the number of characters in other + # encodings, it is not captured here. + # + # We purposefully replace invalid and undefined characters with replacement + # characters in this conversion. This happens for two reasons. First, it's + # possible that the given byte offset will not occur on a character + # boundary. Second, it's possible that the source code will contain a + # character that has no equivalent in the given encoding. + # -- + # : (Integer byte_offset, Encoding encoding) -> Integer + def code_units_offset: (Integer byte_offset, Encoding encoding) -> Integer + + # Generate a cache that targets a specific encoding for calculating code + # unit offsets. + # -- + # : (Encoding encoding) -> CodeUnitsCache + def code_units_cache: (Encoding encoding) -> CodeUnitsCache + + # Returns the column in code units for the given encoding for the + # given byte offset. + # -- + # : (Integer byte_offset, Encoding encoding) -> Integer + def code_units_column: (Integer byte_offset, Encoding encoding) -> Integer + + # Freeze this object and the objects it contains. + # -- + # : () -> void + def deep_freeze: () -> void + + private + + # Binary search through the offsets to find the line number for the given + # byte offset. + # -- + # : (Integer byte_offset) -> Integer + def find_line: (Integer byte_offset) -> Integer + end + + # A cache that can be used to quickly compute code unit offsets from byte + # offsets. It purposefully provides only a single #[] method to access the + # cache in order to minimize surface area. + # + # Note that there are some known issues here that may or may not be addressed + # in the future: + # + # * The first is that there are issues when the cache computes values that are + # not on character boundaries. This can result in subsequent computations + # being off by one or more code units. + # * The second is that this cache is currently unbounded. In theory we could + # introduce some kind of LRU cache to limit the number of entries, but this + # has not yet been implemented. + class CodeUnitsCache + class UTF16Counter + @source: String + + @encoding: Encoding + + # : (String source, Encoding encoding) -> void + def initialize: (String source, Encoding encoding) -> void + + # : (Integer byte_offset, Integer byte_length) -> Integer + def count: (Integer byte_offset, Integer byte_length) -> Integer + end + + class LengthCounter + @source: String + + @encoding: Encoding + + # : (String source, Encoding encoding) -> void + def initialize: (String source, Encoding encoding) -> void + + # : (Integer byte_offset, Integer byte_length) -> Integer + def count: (Integer byte_offset, Integer byte_length) -> Integer + end + + @source: String + + @counter: UTF16Counter | LengthCounter + + @cache: Hash[Integer, Integer] + + @offsets: Array[Integer] + + # Initialize a new cache with the given source and encoding. + # -- + # : (String source, Encoding encoding) -> void + def initialize: (String source, Encoding encoding) -> void + + # Retrieve the code units offset from the given byte offset. + # -- + # : (Integer byte_offset) -> Integer + def []: (Integer byte_offset) -> Integer + end + + # Specialized version of Prism::Source for source code that includes ASCII + # characters only. This class is used to apply performance optimizations that + # cannot be applied to sources that include multibyte characters. + # + # In the extremely rare case that a source includes multi-byte characters but + # is marked as binary because of a magic encoding comment and it cannot be + # eagerly converted to UTF-8, this class will be used as well. This is because + # at that point we will treat everything as single-byte characters. + class ASCIISource < Source + # Return the character offset for the given byte offset. + # -- + # : (Integer byte_offset) -> Integer + def character_offset: (Integer byte_offset) -> Integer + + # Return the column in characters for the given byte offset. + # -- + # : (Integer byte_offset) -> Integer + def character_column: (Integer byte_offset) -> Integer + + # Returns the offset from the start of the file for the given byte offset + # counting in code units for the given encoding. + # + # This method is tested with UTF-8, UTF-16, and UTF-32. If there is the + # concept of code units that differs from the number of characters in other + # encodings, it is not captured here. + # -- + # : (Integer byte_offset, Encoding encoding) -> Integer + def code_units_offset: (Integer byte_offset, Encoding encoding) -> Integer + + # Returns a cache that is the identity function in order to maintain the + # same interface. We can do this because code units are always equivalent to + # byte offsets for ASCII-only sources. + # -- + # : (Encoding encoding) -> _CodeUnitsCache + def code_units_cache: (Encoding encoding) -> _CodeUnitsCache + + # Specialized version of `code_units_column` that does not depend on + # `code_units_offset`, which is a more expensive operation. This is + # essentially the same as `Prism::Source#column`. + # -- + # : (Integer byte_offset, Encoding encoding) -> Integer + def code_units_column: (Integer byte_offset, Encoding encoding) -> Integer + end + + # This represents a location in the source. + class Location + # A Source object that is used to determine more information from the given + # offset and length. + attr_reader source: Source + + # The byte offset from the beginning of the source where this location + # starts. + attr_reader start_offset: Integer + + # The length of this location in bytes. + attr_reader length: Integer + + @trailing_comments: Array[Comment]? + + @leading_comments: Array[Comment]? + + # Create a new location object with the given source, start byte offset, and + # byte length. + # -- + # : (Source source, Integer start_offset, Integer length) -> void + def initialize: (Source source, Integer start_offset, Integer length) -> void + + # These are the comments that are associated with this location that exist + # before the start of this location. + # -- + # : () -> Array[Comment] + def leading_comments: () -> Array[Comment] + + # Attach a comment to the leading comments of this location. + # -- + # : (Comment comment) -> void + def leading_comment: (Comment comment) -> void + + # These are the comments that are associated with this location that exist + # after the end of this location. + # -- + # : () -> Array[Comment] + def trailing_comments: () -> Array[Comment] + + # Attach a comment to the trailing comments of this location. + # -- + # : (Comment comment) -> void + def trailing_comment: (Comment comment) -> void + + # Returns all comments that are associated with this location (both leading + # and trailing comments). + # -- + # : () -> Array[Comment] + def comments: () -> Array[Comment] + + # Create a new location object with the given options. + # -- + # : (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location + def copy: (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location + + # Returns a new location that is the result of chopping off the last byte. + # -- + # : () -> Location + def chop: () -> Location + + # Returns a string representation of this location. + # -- + # : () -> String + def inspect: () -> String + + # Returns all of the lines of the source code associated with this location. + # -- + # : () -> Array[String] + def source_lines: () -> Array[String] + + # The source code that this location represents. + # -- + # : () -> String + def slice: () -> String + + # The source code that this location represents starting from the beginning + # of the line that this location starts on to the end of the line that this + # location ends on. + # -- + # : () -> String + def slice_lines: () -> String + + # The character offset from the beginning of the source where this location + # starts. + # -- + # : () -> Integer + def start_character_offset: () -> Integer + + # The offset from the start of the file in code units of the given encoding. + # -- + # : (Encoding encoding) -> Integer + def start_code_units_offset: (Encoding encoding) -> Integer + + # The start offset from the start of the file in code units using the given + # cache to fetch or calculate the value. + # -- + # : (_CodeUnitsCache cache) -> Integer + def cached_start_code_units_offset: (_CodeUnitsCache cache) -> Integer + + # The byte offset from the beginning of the source where this location ends. + # -- + # : () -> Integer + def end_offset: () -> Integer + + # The character offset from the beginning of the source where this location + # ends. + # -- + # : () -> Integer + def end_character_offset: () -> Integer + + # The offset from the start of the file in code units of the given encoding. + # -- + # : (Encoding encoding) -> Integer + def end_code_units_offset: (Encoding encoding) -> Integer + + # The end offset from the start of the file in code units using the given + # cache to fetch or calculate the value. + # -- + # : (_CodeUnitsCache cache) -> Integer + def cached_end_code_units_offset: (_CodeUnitsCache cache) -> Integer + + # The line number where this location starts. + # -- + # : () -> Integer + def start_line: () -> Integer + + # The content of the line where this location starts before this location. + # -- + # : () -> String + def start_line_slice: () -> String + + # The line number where this location ends. + # -- + # : () -> Integer + def end_line: () -> Integer + + # The column in bytes where this location starts from the start of + # the line. + # -- + # : () -> Integer + def start_column: () -> Integer + + # The column in characters where this location ends from the start of + # the line. + # -- + # : () -> Integer + def start_character_column: () -> Integer + + # The column in code units of the given encoding where this location + # starts from the start of the line. + # -- + # : (?Encoding encoding) -> Integer + def start_code_units_column: (?Encoding encoding) -> Integer + + # The start column in code units using the given cache to fetch or calculate + # the value. + # -- + # : (_CodeUnitsCache cache) -> Integer + def cached_start_code_units_column: (_CodeUnitsCache cache) -> Integer + + # The column in bytes where this location ends from the start of the + # line. + # -- + # : () -> Integer + def end_column: () -> Integer + + # The column in characters where this location ends from the start of + # the line. + # -- + # : () -> Integer + def end_character_column: () -> Integer + + # The column in code units of the given encoding where this location + # ends from the start of the line. + # -- + # : (?Encoding encoding) -> Integer + def end_code_units_column: (?Encoding encoding) -> Integer + + # The end column in code units using the given cache to fetch or calculate + # the value. + # -- + # : (_CodeUnitsCache cache) -> Integer + def cached_end_code_units_column: (_CodeUnitsCache cache) -> Integer + + # Implement the hash pattern matching interface for Location. + # -- + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # Implement the pretty print interface for Location. + # -- + # : (PP q) -> void + def pretty_print: (PP q) -> void + + # Returns true if the given other location is equal to this location. + # -- + # : (untyped other) -> bool + def ==: (untyped other) -> bool + + # Returns a new location that stretches from this location to the given + # other location. Raises an error if this location is not before the other + # location or if they don't share the same source. + # -- + # : (Location other) -> Location + def join: (Location other) -> Location + + # Join this location with the first occurrence of the string in the source + # that occurs after this location on the same line, and return the new + # location. This will raise an error if the string does not exist. + # -- + # : (String string) -> Location + def adjoin: (String string) -> Location + end + + # This represents a comment that was encountered during parsing. It is the + # base class for all comment types. + class Comment + # The Location of this comment in the source. + attr_reader location: Location + + # Create a new comment object with the given location. + # -- + # : (Location location) -> void + def initialize: (Location location) -> void + + # Implement the hash pattern matching interface for Comment. + # -- + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # Returns the content of the comment by slicing it from the source code. + # -- + # : () -> String + def slice: () -> String + + # Returns true if this comment happens on the same line as other code and + # false if the comment is by itself. This can only be true for inline + # comments and should be false for block comments. + # -- + # : () -> bool + def trailing?: () -> bool + end + + # InlineComment objects are the most common. They correspond to comments in + # the source file like this one that start with #. + class InlineComment < Comment + # Returns true if this comment happens on the same line as other code and + # false if the comment is by itself. + # -- + # : () -> bool + def trailing?: () -> bool + + # Returns a string representation of this comment. + # -- + # : () -> String + def inspect: () -> String + end + + # EmbDocComment objects correspond to comments that are surrounded by =begin + # and =end. + class EmbDocComment < Comment + # Returns false. This can only be true for inline comments. + # -- + # : () -> bool + def trailing?: () -> bool + + # Returns a string representation of this comment. + # -- + # : () -> String + def inspect: () -> String + end + + # This represents a magic comment that was encountered during parsing. + class MagicComment + # A Location object representing the location of the key in the source. + attr_reader key_loc: Location + + # A Location object representing the location of the value in the source. + attr_reader value_loc: Location + + # Create a new magic comment object with the given key and value locations. + # -- + # : (Location key_loc, Location value_loc) -> void + def initialize: (Location key_loc, Location value_loc) -> void + + # Returns the key of the magic comment by slicing it from the source code. + # -- + # : () -> String + def key: () -> String + + # Returns the value of the magic comment by slicing it from the source code. + # -- + # : () -> String + def value: () -> String + + # Implement the hash pattern matching interface for MagicComment. + # -- + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # Returns a string representation of this magic comment. + # -- + # : () -> String + def inspect: () -> String + end + + # This represents an error that was encountered during parsing. + class ParseError + # The type of error. This is an _internal_ symbol that is used for + # communicating with translation layers. It is not meant to be public API. + attr_reader type: Symbol + + # The message associated with this error. + attr_reader message: String + + # A Location object representing the location of this error in the source. + attr_reader location: Location + + # The level of this error. + attr_reader level: Symbol + + # Create a new error object with the given message and location. + # -- + # : (Symbol type, String message, Location location, Symbol level) -> void + def initialize: (Symbol type, String message, Location location, Symbol level) -> void + + # Implement the hash pattern matching interface for ParseError. + # -- + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # Returns a string representation of this error. + # -- + # : () -> String + def inspect: () -> String + end + + # This represents a warning that was encountered during parsing. + class ParseWarning + # The type of warning. This is an _internal_ symbol that is used for + # communicating with translation layers. It is not meant to be public API. + attr_reader type: Symbol + + # The message associated with this warning. + attr_reader message: String + + # A Location object representing the location of this warning in the source. + attr_reader location: Location + + # The level of this warning. + attr_reader level: Symbol + + # Create a new warning object with the given message and location. + # -- + # : (Symbol type, String message, Location location, Symbol level) -> void + def initialize: (Symbol type, String message, Location location, Symbol level) -> void + + # Implement the hash pattern matching interface for ParseWarning. + # -- + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # Returns a string representation of this warning. + # -- + # : () -> String + def inspect: () -> String + end + + # This represents the result of a call to Prism.parse or Prism.parse_file. + # It contains the requested structure, any comments that were encounters, + # and any errors that were encountered. + class Result + # The list of comments that were encountered during parsing. + attr_reader comments: Array[Comment] + + # The list of magic comments that were encountered during parsing. + attr_reader magic_comments: Array[MagicComment] + + # An optional location that represents the location of the __END__ marker + # and the rest of the content of the file. This content is loaded into the + # DATA constant when the file being parsed is the main file being executed. + attr_reader data_loc: Location? + + # The list of errors that were generated during parsing. + attr_reader errors: Array[ParseError] + + # The list of warnings that were generated during parsing. + attr_reader warnings: Array[ParseWarning] + + # A Source instance that represents the source code that was parsed. + attr_reader source: Source + + # Create a new result object with the given values. + # -- + # : (Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void + def initialize: (Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void + + # Implement the hash pattern matching interface for Result. + # -- + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # Returns the encoding of the source code that was parsed. + # -- + # : () -> Encoding + def encoding: () -> Encoding + + # Returns true if there were no errors during parsing and false if there + # were. + # -- + # : () -> bool + def success?: () -> bool + + # Returns true if there were errors during parsing and false if there were + # not. + # -- + # : () -> bool + def failure?: () -> bool + + # Create a code units cache for the given encoding. + # -- + # : (Encoding encoding) -> _CodeUnitsCache + def code_units_cache: (Encoding encoding) -> _CodeUnitsCache + end + + # This is a result specific to the `parse` and `parse_file` methods. + class ParseResult < Result + # The syntax tree that was parsed from the source code. + attr_reader value: ProgramNode + + # Create a new parse result object with the given values. + # -- + # : (ProgramNode value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void + def initialize: (ProgramNode value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void + + # Implement the hash pattern matching interface for ParseResult. + # -- + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # Attach the list of comments to their respective locations in the tree. + # -- + # : () -> void + def attach_comments!: () -> void + + # Walk the tree and mark nodes that are on a new line, loosely emulating + # the behavior of CRuby's `:line` tracepoint event. + # -- + # : () -> void + def mark_newlines!: () -> void + + # Returns a string representation of the syntax tree with the errors + # displayed inline. + # -- + # : () -> String + def errors_format: () -> String + end + + # This is a result specific to the `lex` and `lex_file` methods. + class LexResult < Result + # The list of tokens that were parsed from the source code. + attr_reader value: Array[[ Token, Integer ]] + + # Create a new lex result object with the given values. + # -- + # : (Array[[Token, Integer]] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void + def initialize: (Array[[ Token, Integer ]] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void + + # Implement the hash pattern matching interface for LexResult. + # -- + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + end + + # This is a result specific to the `parse_lex` and `parse_lex_file` methods. + class ParseLexResult < Result + # A tuple of the syntax tree and the list of tokens that were parsed from + # the source code. + attr_reader value: [ ProgramNode, Array[[ Token, Integer ]] ] + + # Create a new parse lex result object with the given values. + # -- + # : ([ProgramNode, Array[[Token, Integer]]] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void + def initialize: ([ ProgramNode, Array[[ Token, Integer ]] ] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void + + # Implement the hash pattern matching interface for ParseLexResult. + # -- + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + end + + # This represents a token from the Ruby source. + class Token + # The Source object that represents the source this token came from. + attr_reader source: Source + + # The type of token that this token is. + attr_reader type: Symbol + + # A byteslice of the source that this token represents. + attr_reader value: String + + @location: Location | Integer + + # Create a new token object with the given type, value, and location. + # -- + # : (Source source, Symbol type, String value, Location | Integer location) -> void + def initialize: (Source source, Symbol type, String value, Location | Integer location) -> void + + # Implement the hash pattern matching interface for Token. + # -- + # : (Array[Symbol]? keys) -> Hash[Symbol, untyped] + def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] + + # A Location object representing the location of this token in the source. + # -- + # : () -> Location + def location: () -> Location + + # Implement the pretty print interface for Token. + # -- + # : (PP q) -> void + def pretty_print: (PP q) -> void + + # Returns true if the given other token is equal to this token. + # -- + # : (untyped other) -> bool + def ==: (untyped other) -> bool + + # Returns a string representation of this token. + # -- + # : () -> String + def inspect: () -> String + + # Freeze this object and the objects it contains. + # -- + # : () -> void + def deep_freeze: () -> void + end + + # This object is passed to the various Prism.* methods that accept the + # `scopes` option as an element of the list. It defines both the local + # variables visible at that scope as well as the forwarding parameters + # available at that scope. + class Scope + # The list of local variables that are defined in this scope. This should be + # defined as an array of symbols. + attr_reader locals: Array[Symbol] + + # The list of local variables that are forwarded to the next scope. This + # should by defined as an array of symbols containing the specific values of + # :*, :**, :&, or :"...". + attr_reader forwarding: Array[Symbol] + + # Create a new scope object with the given locals and forwarding. + # -- + # : (Array[Symbol] locals, Array[Symbol] forwarding) -> void + def initialize: (Array[Symbol] locals, Array[Symbol] forwarding) -> void + end + + # Create a new scope with the given locals and forwarding options that is + # suitable for passing into one of the Prism.* methods that accepts the + # `scopes` option. + # -- + # : (?locals: Array[Symbol], ?forwarding: Array[Symbol]) -> Scope + def self.scope: (?locals: Array[Symbol], ?forwarding: Array[Symbol]) -> Scope +end diff --git a/sig/generated/prism/parse_result/comments.rbs b/sig/generated/prism/parse_result/comments.rbs new file mode 100644 index 0000000000..1dc7ae974b --- /dev/null +++ b/sig/generated/prism/parse_result/comments.rbs @@ -0,0 +1,108 @@ +# Generated from lib/prism/parse_result/comments.rb with RBS::Inline + +module Prism + class ParseResult < Result + # When we've parsed the source, we have both the syntax tree and the list of + # comments that we found in the source. This class is responsible for + # walking the tree and finding the nearest location to attach each comment. + # + # It does this by first finding the nearest locations to each comment. + # Locations can either come from nodes directly or from location fields on + # nodes. For example, a `ClassNode` has an overall location encompassing the + # entire class, but it also has a location for the `class` keyword. + # + # Once the nearest locations are found, it determines which one to attach + # to. If it's a trailing comment (a comment on the same line as other source + # code), it will favor attaching to the nearest location that occurs before + # the comment. Otherwise it will favor attaching to the nearest location + # that is after the comment. + class Comments + # An internal interface for a target that comments can be attached + # to. This is either going to be a NodeTarget or a CommentTarget. + interface _CommentTarget + def start_offset: () -> Integer + + def end_offset: () -> Integer + + def encloses?: (Comment) -> bool + + def leading_comment: (Comment) -> void + + def trailing_comment: (Comment) -> void + end + + # A target for attaching comments that is based on a specific node's + # location. + class NodeTarget + # :nodoc: + attr_reader node: node + + # : (node node) -> void + def initialize: (node node) -> void + + # : () -> Integer + def start_offset: () -> Integer + + # : () -> Integer + def end_offset: () -> Integer + + # : (Comment comment) -> bool + def encloses?: (Comment comment) -> bool + + # : (Comment comment) -> void + def leading_comment: (Comment comment) -> void + + # : (Comment comment) -> void + def trailing_comment: (Comment comment) -> void + end + + # A target for attaching comments that is based on a location field on a + # node. For example, the `end` token of a ClassNode. + class LocationTarget + # :nodoc: + attr_reader location: Location + + # : (Location location) -> void + def initialize: (Location location) -> void + + # : () -> Integer + def start_offset: () -> Integer + + # : () -> Integer + def end_offset: () -> Integer + + # : (Comment comment) -> bool + def encloses?: (Comment comment) -> bool + + # : (Comment comment) -> void + def leading_comment: (Comment comment) -> void + + # : (Comment comment) -> void + def trailing_comment: (Comment comment) -> void + end + + # The parse result that we are attaching comments to. + attr_reader parse_result: ParseResult + + # Create a new Comments object that will attach comments to the given + # parse result. + # -- + # : (ParseResult parse_result) -> void + def initialize: (ParseResult parse_result) -> void + + # Attach the comments to their respective locations in the tree by + # mutating the parse result. + # -- + # : () -> void + def attach!: () -> void + + private + + # Responsible for finding the nearest targets to the given comment within + # the context of the given encapsulating node. + # -- + # : (node node, Comment comment) -> [_CommentTarget?, _CommentTarget?, _CommentTarget?] + def nearest_targets: (node node, Comment comment) -> [ _CommentTarget?, _CommentTarget?, _CommentTarget? ] + end + end +end diff --git a/sig/generated/prism/parse_result/errors.rbs b/sig/generated/prism/parse_result/errors.rbs new file mode 100644 index 0000000000..1b97d8a763 --- /dev/null +++ b/sig/generated/prism/parse_result/errors.rbs @@ -0,0 +1,22 @@ +# Generated from lib/prism/parse_result/errors.rb with RBS::Inline + +module Prism + class ParseResult < Result + # An object to represent the set of errors on a parse result. This object + # can be used to format the errors in a human-readable way. + class Errors + # The parse result that contains the errors. + attr_reader parse_result: ParseResult + + # Initialize a new set of errors from the given parse result. + # -- + # : (ParseResult parse_result) -> void + def initialize: (ParseResult parse_result) -> void + + # Formats the errors in a human-readable way and return them as a string. + # -- + # : () -> String + def format: () -> String + end + end +end diff --git a/sig/generated/prism/parse_result/newlines.rbs b/sig/generated/prism/parse_result/newlines.rbs new file mode 100644 index 0000000000..7037631712 --- /dev/null +++ b/sig/generated/prism/parse_result/newlines.rbs @@ -0,0 +1,129 @@ +# Generated from lib/prism/parse_result/newlines.rb with RBS::Inline + +module Prism + class ParseResult < Result + # The :line tracepoint event gets fired whenever the Ruby VM encounters an + # expression on a new line. The types of expressions that can trigger this + # event are: + # + # * if statements + # * unless statements + # * nodes that are children of statements lists + # + # In order to keep track of the newlines, we have a list of offsets that + # come back from the parser. We assign these offsets to the first nodes that + # we find in the tree that are on those lines. + # + # Note that the logic in this file should be kept in sync with the Java + # MarkNewlinesVisitor, since that visitor is responsible for marking the + # newlines for JRuby/TruffleRuby. + # + # This file is autoloaded only when `mark_newlines!` is called, so the + # re-opening of the various nodes in this file will only be performed in + # that case. We do that to avoid storing the extra `@newline` instance + # variable on every node if we don't need it. + class Newlines < Visitor + @lines: Array[bool] + + # Create a new Newlines visitor with the given newline offsets. + # -- + # : (Integer lines) -> void + def initialize: (Integer lines) -> void + + # Permit block nodes to mark newlines within themselves. + # -- + # : (BlockNode node) -> void + def visit_block_node: (BlockNode node) -> void + + # Permit lambda nodes to mark newlines within themselves. + # -- + # : (LambdaNode node) -> void + def visit_lambda_node: (LambdaNode node) -> void + + # Mark if nodes as newlines. + # -- + # : (IfNode node) -> void + def visit_if_node: (IfNode node) -> void + + # Mark unless nodes as newlines. + # -- + # : (UnlessNode node) -> void + def visit_unless_node: (UnlessNode node) -> void + + # Permit statements lists to mark newlines within themselves. + # -- + # : (StatementsNode node) -> void + def visit_statements_node: (StatementsNode node) -> void + end + end + + class Node + @newline_flag: bool + + # : () -> bool + def newline_flag?: () -> bool + + # : (Array[bool] lines) -> void + def newline_flag!: (Array[bool] lines) -> void + end + + class BeginNode < Node + # @rbs override + def newline_flag!: ... + end + + class ParenthesesNode < Node + # @rbs override + def newline_flag!: ... + end + + class IfNode < Node + # @rbs override + def newline_flag!: ... + end + + class UnlessNode < Node + # @rbs override + def newline_flag!: ... + end + + class UntilNode < Node + # @rbs override + def newline_flag!: ... + end + + class WhileNode < Node + # @rbs override + def newline_flag!: ... + end + + class RescueModifierNode < Node + # @rbs override + def newline_flag!: ... + end + + class InterpolatedMatchLastLineNode < Node + # @rbs override + def newline_flag!: ... + end + + class InterpolatedRegularExpressionNode < Node + # @rbs override + def newline_flag!: ... + end + + class InterpolatedStringNode < Node + # @rbs override + def newline_flag!: ... + end + + class InterpolatedSymbolNode < Node + # @rbs override + def newline_flag!: ... + end + + class InterpolatedXStringNode < Node + # @rbs override + def newline_flag!: ... + end +end diff --git a/sig/generated/prism/pattern.rbs b/sig/generated/prism/pattern.rbs new file mode 100644 index 0000000000..d427b0098b --- /dev/null +++ b/sig/generated/prism/pattern.rbs @@ -0,0 +1,156 @@ +# Generated from lib/prism/pattern.rb with RBS::Inline + +module Prism + # A pattern is an object that wraps a Ruby pattern matching expression. The + # expression would normally be passed to an `in` clause within a `case` + # expression or a rightward assignment expression. For example, in the + # following snippet: + # + # case node + # in ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]] + # end + # + # the pattern is the ConstantPathNode[...] expression. + # + # The pattern gets compiled into an object that responds to #call by running + # the #compile method. This method itself will run back through Prism to + # parse the expression into a tree, then walk the tree to generate the + # necessary callable objects. For example, if you wanted to compile the + # expression above into a callable, you would: + # + # callable = Prism::Pattern.new("ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]]").compile + # callable.call(node) + # + # The callable object returned by #compile is guaranteed to respond to #call + # with a single argument, which is the node to match against. It also is + # guaranteed to respond to #===, which means it itself can be used in a `case` + # expression, as in: + # + # case node + # when callable + # end + # + # If the query given to the initializer cannot be compiled into a valid + # matcher (either because of a syntax error or because it is using syntax we + # do not yet support) then a Prism::Pattern::CompilationError will be + # raised. + class Pattern + # Raised when the query given to a pattern is either invalid Ruby syntax or + # is using syntax that we don't yet support. + class CompilationError < StandardError + # Create a new CompilationError with the given representation of the node + # that caused the error. + # -- + # : (String repr) -> void + def initialize: (String repr) -> void + end + + # The query that this pattern was initialized with. + attr_reader query: String + + @compiled: Proc? + + # Create a new pattern with the given query. The query should be a string + # containing a Ruby pattern matching expression. + # -- + # : (String query) -> void + def initialize: (String query) -> void + + # Compile the query into a callable object that can be used to match against + # nodes. + # -- + # : () -> Proc + def compile: () -> Proc + + # Scan the given node and all of its children for nodes that match the + # pattern. If a block is given, it will be called with each node that + # matches the pattern. If no block is given, an enumerator will be returned + # that will yield each node that matches the pattern. + # -- + # : (node root) { (node) -> void } -> void + # : (node root) -> Enumerator[node, void] + def scan: (node root) { (node) -> void } -> void + | (node root) -> Enumerator[node, void] + + private + + # Shortcut for combining two procs into one that returns true if both return + # true. + # -- + # : (Proc left, Proc right) -> Proc + def combine_and: (Proc left, Proc right) -> Proc + + # Shortcut for combining two procs into one that returns true if either + # returns true. + # -- + # : (Proc left, Proc right) -> Proc + def combine_or: (Proc left, Proc right) -> Proc + + # Raise an error because the given node is not supported. Note purposefully + # not typing this method since it is a no return method that Steep does not + # understand. + # -- + # : (node node) -> bot + def compile_error: (node node) -> bot + + # in [foo, bar, baz] + # -- + # : (ArrayPatternNode node) -> Proc + def compile_array_pattern_node: (ArrayPatternNode node) -> Proc + + # in foo | bar + # -- + # : (AlternationPatternNode node) -> Proc + def compile_alternation_pattern_node: (AlternationPatternNode node) -> Proc + + # in Prism::ConstantReadNode + # -- + # : (ConstantPathNode node) -> Proc + def compile_constant_path_node: (ConstantPathNode node) -> Proc + + # in ConstantReadNode + # in String + # -- + # : (ConstantReadNode node) -> Proc + def compile_constant_read_node: (ConstantReadNode node) -> Proc + + # Compile a name associated with a constant. + # -- + # : ((ConstantPathNode | ConstantReadNode) node, Symbol name) -> Proc + def compile_constant_name: (ConstantPathNode | ConstantReadNode node, Symbol name) -> Proc + + # in InstanceVariableReadNode[name: Symbol] + # in { name: Symbol } + # -- + # : (HashPatternNode node) -> Proc + def compile_hash_pattern_node: (HashPatternNode node) -> Proc + + # in nil + # -- + # : (NilNode node) -> Proc + def compile_nil_node: (NilNode node) -> Proc + + # in /foo/ + # -- + # : (RegularExpressionNode node) -> Proc + def compile_regular_expression_node: (RegularExpressionNode node) -> Proc + + # in "" + # in "foo" + # -- + # : (StringNode node) -> Proc + def compile_string_node: (StringNode node) -> Proc + + # in :+ + # in :foo + # -- + # : (SymbolNode node) -> Proc + def compile_symbol_node: (SymbolNode node) -> Proc + + # Compile any kind of node. Dispatch out to the individual compilation + # methods based on the type of node. + # -- + # : (node node) -> Proc + def compile_node: (node node) -> Proc + end +end diff --git a/sig/generated/prism/reflection.rbs b/sig/generated/prism/reflection.rbs new file mode 100644 index 0000000000..8237da3a2e --- /dev/null +++ b/sig/generated/prism/reflection.rbs @@ -0,0 +1,101 @@ +# Generated from lib/prism/reflection.rb with RBS::Inline + +module Prism + # The Reflection module provides the ability to reflect on the structure of + # the syntax tree itself, as opposed to looking at a single syntax tree. This + # is useful in metaprogramming contexts. + module Reflection + # A field represents a single piece of data on a node. It is the base class + # for all other field types. + class Field + # The name of the field. + attr_reader name: Symbol + + # Initializes the field with the given name. + # -- + # : (Symbol name) -> void + def initialize: (Symbol name) -> void + end + + # A node field represents a single child node in the syntax tree. It + # resolves to a Prism::Node in Ruby. + class NodeField < Field + end + + # An optional node field represents a single child node in the syntax tree + # that may or may not be present. It resolves to either a Prism::Node or nil + # in Ruby. + class OptionalNodeField < Field + end + + # A node list field represents a list of child nodes in the syntax tree. It + # resolves to an array of Prism::Node instances in Ruby. + class NodeListField < Field + end + + # A constant field represents a constant value on a node. Effectively, it + # represents an identifier found within the source. It resolves to a symbol + # in Ruby. + class ConstantField < Field + end + + # An optional constant field represents a constant value on a node that may + # or may not be present. It resolves to either a symbol or nil in Ruby. + class OptionalConstantField < Field + end + + # A constant list field represents a list of constant values on a node. It + # resolves to an array of symbols in Ruby. + class ConstantListField < Field + end + + # A string field represents a string value on a node. It almost always + # represents the unescaped value of a string-like literal. It resolves to a + # string in Ruby. + class StringField < Field + end + + # A location field represents the location of some part of the node in the + # source code. For example, the location of a keyword or an operator. It + # resolves to a Prism::Location in Ruby. + class LocationField < Field + end + + # An optional location field represents the location of some part of the + # node in the source code that may or may not be present. It resolves to + # either a Prism::Location or nil in Ruby. + class OptionalLocationField < Field + end + + # An integer field represents an integer value. It is used to represent the + # value of an integer literal, the depth of local variables, and the number + # of a numbered reference. It resolves to an Integer in Ruby. + class IntegerField < Field + end + + # A float field represents a double-precision floating point value. It is + # used exclusively to represent the value of a floating point literal. It + # resolves to a Float in Ruby. + class FloatField < Field + end + + # A flags field represents a bitset of flags on a node. It resolves to an + # integer in Ruby. Note that the flags cannot be accessed directly on the + # node because the integer is kept private. Instead, the various flags in + # the bitset should be accessed through their query methods. + class FlagsField < Field + # The names of the flags in the bitset. + attr_reader flags: Array[Symbol] + + # Initializes the flags field with the given name and flags. + # -- + # : (Symbol name, Array[Symbol] flags) -> void + def initialize: (Symbol name, Array[Symbol] flags) -> void + end + + # Returns the fields for the given node. + # -- + # : (singleton(Node) node) -> Array[Field] + def self.fields_for: (singleton(Node) node) -> Array[Field] + end +end diff --git a/sig/generated/prism/relocation.rbs b/sig/generated/prism/relocation.rbs new file mode 100644 index 0000000000..35238609ca --- /dev/null +++ b/sig/generated/prism/relocation.rbs @@ -0,0 +1,502 @@ +# Generated from lib/prism/relocation.rb with RBS::Inline + +module Prism + # Prism parses deterministically for the same input. This provides a nice + # property that is exposed through the #node_id API on nodes. Effectively this + # means that for the same input, these values will remain consistent every + # time the source is parsed. This means we can reparse the source same with a + # #node_id value and find the exact same node again. + # + # The Relocation module provides an API around this property. It allows you to + # "save" nodes and locations using a minimal amount of memory (just the + # node_id and a field identifier) and then reify them later. + module Relocation + type entry_value = untyped + + type entry_values = Hash[Symbol, entry_value] + + interface _Value + def start_line: () -> Integer + + def end_line: () -> Integer + + def start_offset: () -> Integer + + def end_offset: () -> Integer + + def start_character_offset: () -> Integer + + def end_character_offset: () -> Integer + + def cached_start_code_units_offset: (_CodeUnitsCache cache) -> Integer + + def cached_end_code_units_offset: (_CodeUnitsCache cache) -> Integer + + def start_column: () -> Integer + + def end_column: () -> Integer + + def start_character_column: () -> Integer + + def end_character_column: () -> Integer + + def cached_start_code_units_column: (_CodeUnitsCache cache) -> Integer + + def cached_end_code_units_column: (_CodeUnitsCache cache) -> Integer + + def leading_comments: () -> Array[Comment] + + def trailing_comments: () -> Array[Comment] + end + + interface _Field + def fields: (_Value value) -> entry_values + end + + # An entry in a repository that will lazily reify its values when they are + # first accessed. + class Entry + # Raised if a value that could potentially be on an entry is missing + # because it was either not configured on the repository or it has not yet + # been fetched. + class MissingValueError < StandardError + end + + @values: Hash[Symbol, untyped]? + + @repository: Repository? + + # Initialize a new entry with the given repository. + # -- + # : (Repository repository) -> void + def initialize: (Repository repository) -> void + + # Fetch the filepath of the value. + # -- + # : () -> String + def filepath: () -> String + + # Fetch the start line of the value. + # -- + # : () -> Integer + def start_line: () -> Integer + + # Fetch the end line of the value. + # -- + # : () -> Integer + def end_line: () -> Integer + + # Fetch the start byte offset of the value. + # -- + # : () -> Integer + def start_offset: () -> Integer + + # Fetch the end byte offset of the value. + # -- + # : () -> Integer + def end_offset: () -> Integer + + # Fetch the start character offset of the value. + # -- + # : () -> Integer + def start_character_offset: () -> Integer + + # Fetch the end character offset of the value. + # -- + # : () -> Integer + def end_character_offset: () -> Integer + + # Fetch the start code units offset of the value, for the encoding that + # was configured on the repository. + # -- + # : () -> Integer + def start_code_units_offset: () -> Integer + + # Fetch the end code units offset of the value, for the encoding that was + # configured on the repository. + # -- + # : () -> Integer + def end_code_units_offset: () -> Integer + + # Fetch the start byte column of the value. + # -- + # : () -> Integer + def start_column: () -> Integer + + # Fetch the end byte column of the value. + # -- + # : () -> Integer + def end_column: () -> Integer + + # Fetch the start character column of the value. + # -- + # : () -> Integer + def start_character_column: () -> Integer + + # Fetch the end character column of the value. + # -- + # : () -> Integer + def end_character_column: () -> Integer + + # Fetch the start code units column of the value, for the encoding that + # was configured on the repository. + # -- + # : () -> Integer + def start_code_units_column: () -> Integer + + # Fetch the end code units column of the value, for the encoding that was + # configured on the repository. + # -- + # : () -> Integer + def end_code_units_column: () -> Integer + + # Fetch the leading comments of the value. + # -- + # : () -> Array[CommentsField::Comment] + def leading_comments: () -> Array[CommentsField::Comment] + + # Fetch the trailing comments of the value. + # -- + # : () -> Array[CommentsField::Comment] + def trailing_comments: () -> Array[CommentsField::Comment] + + # Fetch the leading and trailing comments of the value. + # -- + # : () -> Array[CommentsField::Comment] + def comments: () -> Array[CommentsField::Comment] + + # Reify the values on this entry with the given values. This is an + # internal-only API that is called from the repository when it is time to + # reify the values. + # -- + # : (entry_values values) -> void + def reify!: (entry_values values) -> void + + private + + # Fetch a value from the entry, raising an error if it is missing. + # -- + # : (Symbol name) -> entry_value + def fetch_value: (Symbol name) -> entry_value + + # Return the values from the repository, reifying them if necessary. + # -- + # : () -> entry_values + def values: () -> entry_values + end + + # Represents the source of a repository that will be reparsed. + class Source + # The value that will need to be reparsed. + attr_reader value: untyped + + # Initialize the source with the given value. + # -- + # : (untyped value) -> void + def initialize: (untyped value) -> void + + # Reparse the value and return the parse result. + # -- + # : () -> ParseResult + def result: () -> ParseResult + + # Create a code units cache for the given encoding. + # -- + # : (Encoding encoding) -> _CodeUnitsCache + def code_units_cache: (Encoding encoding) -> _CodeUnitsCache + end + + # A source that is represented by a file path. + class SourceFilepath < Source + # Reparse the file and return the parse result. + # -- + # : () -> ParseResult + def result: () -> ParseResult + end + + # A source that is represented by a string. + class SourceString < Source + # Reparse the string and return the parse result. + # -- + # : () -> ParseResult + def result: () -> ParseResult + end + + # A field that represents the file path. + class FilepathField + # The file path that this field represents. + attr_reader value: String + + # Initialize a new field with the given file path. + # -- + # : (String value) -> void + def initialize: (String value) -> void + + # Fetch the file path. + # -- + # : (_Value _value) -> entry_values + def fields: (_Value _value) -> entry_values + end + + # A field representing the start and end lines. + class LinesField + # Fetches the start and end line of a value. + # -- + # : (_Value value) -> entry_values + def fields: (_Value value) -> entry_values + end + + # A field representing the start and end byte offsets. + class OffsetsField + # Fetches the start and end byte offset of a value. + # -- + # : (_Value value) -> entry_values + def fields: (_Value value) -> entry_values + end + + # A field representing the start and end character offsets. + class CharacterOffsetsField + # Fetches the start and end character offset of a value. + # -- + # : (_Value value) -> entry_values + def fields: (_Value value) -> entry_values + end + + # A field representing the start and end code unit offsets. + class CodeUnitOffsetsField + # A pointer to the repository object that is used for lazily creating a + # code units cache. + attr_reader repository: Repository + + # The associated encoding for the code units. + attr_reader encoding: Encoding + + @cache: _CodeUnitsCache? + + # Initialize a new field with the associated repository and encoding. + # -- + # : (Repository repository, Encoding encoding) -> void + def initialize: (Repository repository, Encoding encoding) -> void + + # Fetches the start and end code units offset of a value for a particular + # encoding. + # -- + # : (_Value value) -> entry_values + def fields: (_Value value) -> entry_values + + private + + # Lazily create a code units cache for the associated encoding. + # -- + # : () -> _CodeUnitsCache + def cache: () -> _CodeUnitsCache + end + + # A field representing the start and end byte columns. + class ColumnsField + # Fetches the start and end byte column of a value. + # -- + # : (_Value value) -> entry_values + def fields: (_Value value) -> entry_values + end + + # A field representing the start and end character columns. + class CharacterColumnsField + # Fetches the start and end character column of a value. + # -- + # : (_Value value) -> entry_values + def fields: (_Value value) -> entry_values + end + + # A field representing the start and end code unit columns for a specific + # encoding. + class CodeUnitColumnsField + # The repository object that is used for lazily creating a code units + # cache. + attr_reader repository: Repository + + # The associated encoding for the code units. + attr_reader encoding: Encoding + + @cache: _CodeUnitsCache? + + # Initialize a new field with the associated repository and encoding. + # -- + # : (Repository repository, Encoding encoding) -> void + def initialize: (Repository repository, Encoding encoding) -> void + + # Fetches the start and end code units column of a value for a particular + # encoding. + # -- + # : (_Value value) -> entry_values + def fields: (_Value value) -> entry_values + + private + + # Lazily create a code units cache for the associated encoding. + # -- + # : () -> _CodeUnitsCache + def cache: () -> _CodeUnitsCache + end + + # An abstract field used as the parent class of the two comments fields. + class CommentsField + # An object that represents a slice of a comment. + class Comment + # The slice of the comment. + attr_reader slice: String + + # Initialize a new comment with the given slice. + # + # : (String slice) -> void + def initialize: (String slice) -> void + end + + private + + # Create comment objects from the given values. + # -- + # : (entry_value values) -> Array[Comment] + def comments: (entry_value values) -> Array[Comment] + end + + # A field representing the leading comments. + class LeadingCommentsField < CommentsField + # Fetches the leading comments of a value. + # -- + # : (_Value value) -> entry_values + def fields: (_Value value) -> entry_values + end + + # A field representing the trailing comments. + class TrailingCommentsField < CommentsField + # Fetches the trailing comments of a value. + # -- + # : (_Value value) -> entry_values + def fields: (_Value value) -> entry_values + end + + # A repository is a configured collection of fields and a set of entries + # that knows how to reparse a source and reify the values. + class Repository + # Raised when multiple fields of the same type are configured on the same + # repository. + class ConfigurationError < StandardError + end + + # The source associated with this repository. This will be either a + # SourceFilepath (the most common use case) or a SourceString. + attr_reader source: Source + + # The fields that have been configured on this repository. + attr_reader fields: Hash[Symbol, _Field] + + # The entries that have been saved on this repository. + attr_reader entries: Hash[Integer, Hash[Symbol, Entry]] + + # Initialize a new repository with the given source. + # -- + # : (Source source) -> void + def initialize: (Source source) -> void + + # Create a code units cache for the given encoding from the source. + # -- + # : (Encoding encoding) -> _CodeUnitsCache + def code_units_cache: (Encoding encoding) -> _CodeUnitsCache + + # Configure the filepath field for this repository and return self. + # -- + # : () -> self + def filepath: () -> self + + # Configure the lines field for this repository and return self. + # -- + # : () -> self + def lines: () -> self + + # Configure the offsets field for this repository and return self. + # -- + # : () -> self + def offsets: () -> self + + # Configure the character offsets field for this repository and return + # self. + # -- + # : () -> self + def character_offsets: () -> self + + # Configure the code unit offsets field for this repository for a specific + # encoding and return self. + # -- + # : (Encoding encoding) -> self + def code_unit_offsets: (Encoding encoding) -> self + + # Configure the columns field for this repository and return self. + # -- + # : () -> self + def columns: () -> self + + # Configure the character columns field for this repository and return + # self. + # -- + # : () -> self + def character_columns: () -> self + + # Configure the code unit columns field for this repository for a specific + # encoding and return self. + # -- + # : (Encoding encoding) -> self + def code_unit_columns: (Encoding encoding) -> self + + # Configure the leading comments field for this repository and return + # self. + # -- + # : () -> self + def leading_comments: () -> self + + # Configure the trailing comments field for this repository and return + # self. + # -- + # : () -> self + def trailing_comments: () -> self + + # Configure both the leading and trailing comment fields for this + # repository and return self. + # -- + # : () -> self + def comments: () -> self + + # This method is called from nodes and locations when they want to enter + # themselves into the repository. It it internal-only and meant to be + # called from the #save* APIs. + # -- + # : (Integer node_id, Symbol field_name) -> Entry + def enter: (Integer node_id, Symbol field_name) -> Entry + + # This method is called from the entries in the repository when they need + # to reify their values. It is internal-only and meant to be called from + # the various value APIs. + # -- + # : () -> void + def reify!: () -> void + + private + + # Append the given field to the repository and return the repository so + # that these calls can be chained. + # -- + # : (Symbol name, _Field) -> self + def field: (Symbol name, _Field) -> self + end + + # Create a new repository for the given filepath. + # -- + # : (String value) -> Repository + def self.filepath: (String value) -> Repository + + # Create a new repository for the given string. + # -- + # : (String value) -> Repository + def self.string: (String value) -> Repository + end +end diff --git a/sig/generated/prism/serialize.rbs b/sig/generated/prism/serialize.rbs new file mode 100644 index 0000000000..468f18dd56 --- /dev/null +++ b/sig/generated/prism/serialize.rbs @@ -0,0 +1,186 @@ +# Generated from lib/prism/serialize.rb with RBS::Inline + +module Prism + # A module responsible for deserializing parse results. + module Serialize + # The major version of prism that we are expecting to find in the serialized + # strings. + MAJOR_VERSION: ::Integer + + # The minor version of prism that we are expecting to find in the serialized + # strings. + MINOR_VERSION: ::Integer + + # The patch version of prism that we are expecting to find in the serialized + # strings. + PATCH_VERSION: ::Integer + + # Deserialize the dumped output from a request to parse or parse_file. + # + # The formatting of the source of this method is purposeful to illustrate + # the structure of the serialized data. + # -- + # : (String input, String serialized, bool freeze) -> ParseResult + def self.load_parse: (String input, String serialized, bool freeze) -> ParseResult + + # Deserialize the dumped output from a request to lex or lex_file. + # + # The formatting of the source of this method is purposeful to illustrate + # the structure of the serialized data. + # -- + # : (String input, String serialized, bool freeze) -> LexResult + def self.load_lex: (String input, String serialized, bool freeze) -> LexResult + + # Deserialize the dumped output from a request to parse_comments or + # parse_file_comments. + # + # The formatting of the source of this method is purposeful to illustrate + # the structure of the serialized data. + # -- + # : (String input, String serialized, bool freeze) -> Array[Comment] + def self.load_parse_comments: (String input, String serialized, bool freeze) -> Array[Comment] + + # Deserialize the dumped output from a request to parse_lex or + # parse_lex_file. + # + # The formatting of the source of this method is purposeful to illustrate + # the structure of the serialized data. + # -- + # : (String input, String serialized, bool freeze) -> ParseLexResult + def self.load_parse_lex: (String input, String serialized, bool freeze) -> ParseLexResult + + class ConstantPool + # :nodoc: + attr_reader size: Integer + + @input: String + + @serialized: String + + @base: Integer + + @pool: Array[Symbol?] + + # : (String input, String serialized, Integer base, Integer size) -> void + def initialize: (String input, String serialized, Integer base, Integer size) -> void + + # : (Integer index, Encoding encoding) -> Symbol + def get: (Integer index, Encoding encoding) -> Symbol + end + + FastStringIO: untyped + + class Loader + # :nodoc: + attr_reader input: String + + attr_reader io: StringIO + + attr_reader source: Source + + # : (Source source, String serialized) -> void + def initialize: (Source source, String serialized) -> void + + # : () -> bool + def eof?: () -> bool + + # : (ConstantPool constant_pool) -> void + def load_constant_pool: (ConstantPool constant_pool) -> void + + # : () -> void + def load_header: () -> void + + # : () -> Encoding + def load_encoding: () -> Encoding + + # : (bool freeze) -> Array[Integer] + def load_line_offsets: (bool freeze) -> Array[Integer] + + # : (bool freeze) -> Array[Comment] + def load_comments: (bool freeze) -> Array[Comment] + + # : (bool freeze) -> Array[MagicComment] + def load_magic_comments: (bool freeze) -> Array[MagicComment] + + DIAGNOSTIC_TYPES: Array[Symbol] + + # : () -> Symbol + def load_error_level: () -> Symbol + + # : (Encoding encoding, bool freeze) -> Array[ParseError] + def load_errors: (Encoding encoding, bool freeze) -> Array[ParseError] + + # : () -> Symbol + def load_warning_level: () -> Symbol + + # : (Encoding encoding, bool freeze) -> Array[ParseWarning] + def load_warnings: (Encoding encoding, bool freeze) -> Array[ParseWarning] + + # : () -> Array[[Token, Integer]] + def load_tokens: () -> Array[[ Token, Integer ]] + + # variable-length integer using https://en.wikipedia.org/wiki/LEB128 + # This is also what protobuf uses: https://protobuf.dev/programming-guides/encoding/#varints + # -- + # : () -> Integer + def load_varuint: () -> Integer + + # : () -> Integer + def load_varsint: () -> Integer + + # : () -> Integer + def load_integer: () -> Integer + + # : () -> Float + def load_double: () -> Float + + # : () -> Integer + def load_uint32: () -> Integer + + # : (ConstantPool constant_pool, Encoding encoding, bool freeze) -> node? + def load_optional_node: (ConstantPool constant_pool, Encoding encoding, bool freeze) -> node? + + # : (Encoding encoding) -> String + def load_embedded_string: (Encoding encoding) -> String + + # : (Encoding encoding) -> String + def load_string: (Encoding encoding) -> String + + # : (bool freeze) -> Location + def load_location_object: (bool freeze) -> Location + + # Load a location object from the serialized data. Note that we are lying + # about the signature a bit here, because we sometimes load it as a packed + # integer instead of an object. + # -- + # : (bool freeze) -> Location + def load_location: (bool freeze) -> Location + + # Load an optional location object from the serialized data if it is + # present. Note that we are lying about the signature a bit here, because + # we sometimes load it as a packed integer instead of an object. + # -- + # : (bool freeze) -> Location? + def load_optional_location: (bool freeze) -> Location? + + # : (bool freeze) -> Location? + def load_optional_location_object: (bool freeze) -> Location? + + # : (ConstantPool constant_pool, Encoding encoding) -> Symbol + def load_constant: (ConstantPool constant_pool, Encoding encoding) -> Symbol + + # : (ConstantPool constant_pool, Encoding encoding) -> Symbol? + def load_optional_constant: (ConstantPool constant_pool, Encoding encoding) -> Symbol? + + # : (ConstantPool constant_pool, Encoding encoding, bool freeze) -> node + def load_node: (ConstantPool constant_pool, Encoding encoding, bool freeze) -> node + + @load_node_lambdas: Array[Proc] + + def define_load_node_lambdas: () -> void + end + + # The token types that can be indexed by their enum values. + TOKEN_TYPES: Array[Symbol?] + end +end diff --git a/sig/generated/prism/string_query.rbs b/sig/generated/prism/string_query.rbs new file mode 100644 index 0000000000..de2183a731 --- /dev/null +++ b/sig/generated/prism/string_query.rbs @@ -0,0 +1,36 @@ +# Generated from lib/prism/string_query.rb with RBS::Inline + +module Prism + # Query methods that allow categorizing strings based on their context for + # where they could be valid in a Ruby syntax tree. + class StringQuery + def self.local?: (String string) -> bool + + def self.constant?: (String string) -> bool + + def self.method_name?: (String string) -> bool + + # The string that this query is wrapping. + attr_reader string: String + + # Initialize a new query with the given string. + # -- + # : (String string) -> void + def initialize: (String string) -> void + + # Whether or not this string is a valid local variable name. + # -- + # : () -> bool + def local?: () -> bool + + # Whether or not this string is a valid constant name. + # -- + # : () -> bool + def constant?: () -> bool + + # Whether or not this string is a valid method name. + # -- + # : () -> bool + def method_name?: () -> bool + end +end diff --git a/sig/generated/prism/translation.rbs b/sig/generated/prism/translation.rbs new file mode 100644 index 0000000000..09971a2971 --- /dev/null +++ b/sig/generated/prism/translation.rbs @@ -0,0 +1,8 @@ +# Generated from lib/prism/translation.rb with RBS::Inline + +module Prism + # This module is responsible for converting the prism syntax tree into other + # syntax trees. + module Translation + end +end diff --git a/sig/generated/prism/visitor.rbs b/sig/generated/prism/visitor.rbs new file mode 100644 index 0000000000..ec65adbb29 --- /dev/null +++ b/sig/generated/prism/visitor.rbs @@ -0,0 +1,1111 @@ +# Generated from lib/prism/visitor.rb with RBS::Inline + +module Prism + interface _Visitor + def visit_alias_global_variable_node: (AliasGlobalVariableNode) -> void + + def visit_alias_method_node: (AliasMethodNode) -> void + + def visit_alternation_pattern_node: (AlternationPatternNode) -> void + + def visit_and_node: (AndNode) -> void + + def visit_arguments_node: (ArgumentsNode) -> void + + def visit_array_node: (ArrayNode) -> void + + def visit_array_pattern_node: (ArrayPatternNode) -> void + + def visit_assoc_node: (AssocNode) -> void + + def visit_assoc_splat_node: (AssocSplatNode) -> void + + def visit_back_reference_read_node: (BackReferenceReadNode) -> void + + def visit_begin_node: (BeginNode) -> void + + def visit_block_argument_node: (BlockArgumentNode) -> void + + def visit_block_local_variable_node: (BlockLocalVariableNode) -> void + + def visit_block_node: (BlockNode) -> void + + def visit_block_parameter_node: (BlockParameterNode) -> void + + def visit_block_parameters_node: (BlockParametersNode) -> void + + def visit_break_node: (BreakNode) -> void + + def visit_call_and_write_node: (CallAndWriteNode) -> void + + def visit_call_node: (CallNode) -> void + + def visit_call_operator_write_node: (CallOperatorWriteNode) -> void + + def visit_call_or_write_node: (CallOrWriteNode) -> void + + def visit_call_target_node: (CallTargetNode) -> void + + def visit_capture_pattern_node: (CapturePatternNode) -> void + + def visit_case_match_node: (CaseMatchNode) -> void + + def visit_case_node: (CaseNode) -> void + + def visit_class_node: (ClassNode) -> void + + def visit_class_variable_and_write_node: (ClassVariableAndWriteNode) -> void + + def visit_class_variable_operator_write_node: (ClassVariableOperatorWriteNode) -> void + + def visit_class_variable_or_write_node: (ClassVariableOrWriteNode) -> void + + def visit_class_variable_read_node: (ClassVariableReadNode) -> void + + def visit_class_variable_target_node: (ClassVariableTargetNode) -> void + + def visit_class_variable_write_node: (ClassVariableWriteNode) -> void + + def visit_constant_and_write_node: (ConstantAndWriteNode) -> void + + def visit_constant_operator_write_node: (ConstantOperatorWriteNode) -> void + + def visit_constant_or_write_node: (ConstantOrWriteNode) -> void + + def visit_constant_path_and_write_node: (ConstantPathAndWriteNode) -> void + + def visit_constant_path_node: (ConstantPathNode) -> void + + def visit_constant_path_operator_write_node: (ConstantPathOperatorWriteNode) -> void + + def visit_constant_path_or_write_node: (ConstantPathOrWriteNode) -> void + + def visit_constant_path_target_node: (ConstantPathTargetNode) -> void + + def visit_constant_path_write_node: (ConstantPathWriteNode) -> void + + def visit_constant_read_node: (ConstantReadNode) -> void + + def visit_constant_target_node: (ConstantTargetNode) -> void + + def visit_constant_write_node: (ConstantWriteNode) -> void + + def visit_def_node: (DefNode) -> void + + def visit_defined_node: (DefinedNode) -> void + + def visit_else_node: (ElseNode) -> void + + def visit_embedded_statements_node: (EmbeddedStatementsNode) -> void + + def visit_embedded_variable_node: (EmbeddedVariableNode) -> void + + def visit_ensure_node: (EnsureNode) -> void + + def visit_false_node: (FalseNode) -> void + + def visit_find_pattern_node: (FindPatternNode) -> void + + def visit_flip_flop_node: (FlipFlopNode) -> void + + def visit_float_node: (FloatNode) -> void + + def visit_for_node: (ForNode) -> void + + def visit_forwarding_arguments_node: (ForwardingArgumentsNode) -> void + + def visit_forwarding_parameter_node: (ForwardingParameterNode) -> void + + def visit_forwarding_super_node: (ForwardingSuperNode) -> void + + def visit_global_variable_and_write_node: (GlobalVariableAndWriteNode) -> void + + def visit_global_variable_operator_write_node: (GlobalVariableOperatorWriteNode) -> void + + def visit_global_variable_or_write_node: (GlobalVariableOrWriteNode) -> void + + def visit_global_variable_read_node: (GlobalVariableReadNode) -> void + + def visit_global_variable_target_node: (GlobalVariableTargetNode) -> void + + def visit_global_variable_write_node: (GlobalVariableWriteNode) -> void + + def visit_hash_node: (HashNode) -> void + + def visit_hash_pattern_node: (HashPatternNode) -> void + + def visit_if_node: (IfNode) -> void + + def visit_imaginary_node: (ImaginaryNode) -> void + + def visit_implicit_node: (ImplicitNode) -> void + + def visit_implicit_rest_node: (ImplicitRestNode) -> void + + def visit_in_node: (InNode) -> void + + def visit_index_and_write_node: (IndexAndWriteNode) -> void + + def visit_index_operator_write_node: (IndexOperatorWriteNode) -> void + + def visit_index_or_write_node: (IndexOrWriteNode) -> void + + def visit_index_target_node: (IndexTargetNode) -> void + + def visit_instance_variable_and_write_node: (InstanceVariableAndWriteNode) -> void + + def visit_instance_variable_operator_write_node: (InstanceVariableOperatorWriteNode) -> void + + def visit_instance_variable_or_write_node: (InstanceVariableOrWriteNode) -> void + + def visit_instance_variable_read_node: (InstanceVariableReadNode) -> void + + def visit_instance_variable_target_node: (InstanceVariableTargetNode) -> void + + def visit_instance_variable_write_node: (InstanceVariableWriteNode) -> void + + def visit_integer_node: (IntegerNode) -> void + + def visit_interpolated_match_last_line_node: (InterpolatedMatchLastLineNode) -> void + + def visit_interpolated_regular_expression_node: (InterpolatedRegularExpressionNode) -> void + + def visit_interpolated_string_node: (InterpolatedStringNode) -> void + + def visit_interpolated_symbol_node: (InterpolatedSymbolNode) -> void + + def visit_interpolated_x_string_node: (InterpolatedXStringNode) -> void + + def visit_it_local_variable_read_node: (ItLocalVariableReadNode) -> void + + def visit_it_parameters_node: (ItParametersNode) -> void + + def visit_keyword_hash_node: (KeywordHashNode) -> void + + def visit_keyword_rest_parameter_node: (KeywordRestParameterNode) -> void + + def visit_lambda_node: (LambdaNode) -> void + + def visit_local_variable_and_write_node: (LocalVariableAndWriteNode) -> void + + def visit_local_variable_operator_write_node: (LocalVariableOperatorWriteNode) -> void + + def visit_local_variable_or_write_node: (LocalVariableOrWriteNode) -> void + + def visit_local_variable_read_node: (LocalVariableReadNode) -> void + + def visit_local_variable_target_node: (LocalVariableTargetNode) -> void + + def visit_local_variable_write_node: (LocalVariableWriteNode) -> void + + def visit_match_last_line_node: (MatchLastLineNode) -> void + + def visit_match_predicate_node: (MatchPredicateNode) -> void + + def visit_match_required_node: (MatchRequiredNode) -> void + + def visit_match_write_node: (MatchWriteNode) -> void + + def visit_missing_node: (MissingNode) -> void + + def visit_module_node: (ModuleNode) -> void + + def visit_multi_target_node: (MultiTargetNode) -> void + + def visit_multi_write_node: (MultiWriteNode) -> void + + def visit_next_node: (NextNode) -> void + + def visit_nil_node: (NilNode) -> void + + def visit_no_block_parameter_node: (NoBlockParameterNode) -> void + + def visit_no_keywords_parameter_node: (NoKeywordsParameterNode) -> void + + def visit_numbered_parameters_node: (NumberedParametersNode) -> void + + def visit_numbered_reference_read_node: (NumberedReferenceReadNode) -> void + + def visit_optional_keyword_parameter_node: (OptionalKeywordParameterNode) -> void + + def visit_optional_parameter_node: (OptionalParameterNode) -> void + + def visit_or_node: (OrNode) -> void + + def visit_parameters_node: (ParametersNode) -> void + + def visit_parentheses_node: (ParenthesesNode) -> void + + def visit_pinned_expression_node: (PinnedExpressionNode) -> void + + def visit_pinned_variable_node: (PinnedVariableNode) -> void + + def visit_post_execution_node: (PostExecutionNode) -> void + + def visit_pre_execution_node: (PreExecutionNode) -> void + + def visit_program_node: (ProgramNode) -> void + + def visit_range_node: (RangeNode) -> void + + def visit_rational_node: (RationalNode) -> void + + def visit_redo_node: (RedoNode) -> void + + def visit_regular_expression_node: (RegularExpressionNode) -> void + + def visit_required_keyword_parameter_node: (RequiredKeywordParameterNode) -> void + + def visit_required_parameter_node: (RequiredParameterNode) -> void + + def visit_rescue_modifier_node: (RescueModifierNode) -> void + + def visit_rescue_node: (RescueNode) -> void + + def visit_rest_parameter_node: (RestParameterNode) -> void + + def visit_retry_node: (RetryNode) -> void + + def visit_return_node: (ReturnNode) -> void + + def visit_self_node: (SelfNode) -> void + + def visit_shareable_constant_node: (ShareableConstantNode) -> void + + def visit_singleton_class_node: (SingletonClassNode) -> void + + def visit_source_encoding_node: (SourceEncodingNode) -> void + + def visit_source_file_node: (SourceFileNode) -> void + + def visit_source_line_node: (SourceLineNode) -> void + + def visit_splat_node: (SplatNode) -> void + + def visit_statements_node: (StatementsNode) -> void + + def visit_string_node: (StringNode) -> void + + def visit_super_node: (SuperNode) -> void + + def visit_symbol_node: (SymbolNode) -> void + + def visit_true_node: (TrueNode) -> void + + def visit_undef_node: (UndefNode) -> void + + def visit_unless_node: (UnlessNode) -> void + + def visit_until_node: (UntilNode) -> void + + def visit_when_node: (WhenNode) -> void + + def visit_while_node: (WhileNode) -> void + + def visit_x_string_node: (XStringNode) -> void + + def visit_yield_node: (YieldNode) -> void + end + + # A class that knows how to walk down the tree. None of the individual visit + # methods are implemented on this visitor, so it forces the consumer to + # implement each one that they need. For a default implementation that + # continues walking the tree, see the Visitor class. + class BasicVisitor + # Calls `accept` on the given node if it is not `nil`, which in turn should + # call back into this visitor by calling the appropriate `visit_*` method. + # -- + # : (node? node) -> void + def visit: (node? node) -> void + + # Visits each node in `nodes` by calling `accept` on each one. + # -- + # : (Array[node?] nodes) -> void + def visit_all: (Array[node?] nodes) -> void + + # Visits the child nodes of `node` by calling `accept` on each one. + # -- + # : (node node) -> void + def visit_child_nodes: (node node) -> void + end + + # A visitor is a class that provides a default implementation for every accept + # method defined on the nodes. This means it can walk a tree without the + # caller needing to define any special handling. This allows you to handle a + # subset of the tree, while still walking the whole tree. + # + # For example, to find all of the method calls that call the `foo` method, you + # could write: + # + # class FooCalls < Prism::Visitor + # def visit_call_node(node) + # if node.name == :foo + # # Do something with the node + # end + # + # # Call super so that the visitor continues walking the tree + # super + # end + # end + class Visitor < BasicVisitor + # Visit a AliasGlobalVariableNode node + # -- + # : (AliasGlobalVariableNode node) -> void + def visit_alias_global_variable_node: (AliasGlobalVariableNode node) -> void + + # Visit a AliasMethodNode node + # -- + # : (AliasMethodNode node) -> void + def visit_alias_method_node: (AliasMethodNode node) -> void + + # Visit a AlternationPatternNode node + # -- + # : (AlternationPatternNode node) -> void + def visit_alternation_pattern_node: (AlternationPatternNode node) -> void + + # Visit a AndNode node + # -- + # : (AndNode node) -> void + def visit_and_node: (AndNode node) -> void + + # Visit a ArgumentsNode node + # -- + # : (ArgumentsNode node) -> void + def visit_arguments_node: (ArgumentsNode node) -> void + + # Visit a ArrayNode node + # -- + # : (ArrayNode node) -> void + def visit_array_node: (ArrayNode node) -> void + + # Visit a ArrayPatternNode node + # -- + # : (ArrayPatternNode node) -> void + def visit_array_pattern_node: (ArrayPatternNode node) -> void + + # Visit a AssocNode node + # -- + # : (AssocNode node) -> void + def visit_assoc_node: (AssocNode node) -> void + + # Visit a AssocSplatNode node + # -- + # : (AssocSplatNode node) -> void + def visit_assoc_splat_node: (AssocSplatNode node) -> void + + # Visit a BackReferenceReadNode node + # -- + # : (BackReferenceReadNode node) -> void + def visit_back_reference_read_node: (BackReferenceReadNode node) -> void + + # Visit a BeginNode node + # -- + # : (BeginNode node) -> void + def visit_begin_node: (BeginNode node) -> void + + # Visit a BlockArgumentNode node + # -- + # : (BlockArgumentNode node) -> void + def visit_block_argument_node: (BlockArgumentNode node) -> void + + # Visit a BlockLocalVariableNode node + # -- + # : (BlockLocalVariableNode node) -> void + def visit_block_local_variable_node: (BlockLocalVariableNode node) -> void + + # Visit a BlockNode node + # -- + # : (BlockNode node) -> void + def visit_block_node: (BlockNode node) -> void + + # Visit a BlockParameterNode node + # -- + # : (BlockParameterNode node) -> void + def visit_block_parameter_node: (BlockParameterNode node) -> void + + # Visit a BlockParametersNode node + # -- + # : (BlockParametersNode node) -> void + def visit_block_parameters_node: (BlockParametersNode node) -> void + + # Visit a BreakNode node + # -- + # : (BreakNode node) -> void + def visit_break_node: (BreakNode node) -> void + + # Visit a CallAndWriteNode node + # -- + # : (CallAndWriteNode node) -> void + def visit_call_and_write_node: (CallAndWriteNode node) -> void + + # Visit a CallNode node + # -- + # : (CallNode node) -> void + def visit_call_node: (CallNode node) -> void + + # Visit a CallOperatorWriteNode node + # -- + # : (CallOperatorWriteNode node) -> void + def visit_call_operator_write_node: (CallOperatorWriteNode node) -> void + + # Visit a CallOrWriteNode node + # -- + # : (CallOrWriteNode node) -> void + def visit_call_or_write_node: (CallOrWriteNode node) -> void + + # Visit a CallTargetNode node + # -- + # : (CallTargetNode node) -> void + def visit_call_target_node: (CallTargetNode node) -> void + + # Visit a CapturePatternNode node + # -- + # : (CapturePatternNode node) -> void + def visit_capture_pattern_node: (CapturePatternNode node) -> void + + # Visit a CaseMatchNode node + # -- + # : (CaseMatchNode node) -> void + def visit_case_match_node: (CaseMatchNode node) -> void + + # Visit a CaseNode node + # -- + # : (CaseNode node) -> void + def visit_case_node: (CaseNode node) -> void + + # Visit a ClassNode node + # -- + # : (ClassNode node) -> void + def visit_class_node: (ClassNode node) -> void + + # Visit a ClassVariableAndWriteNode node + # -- + # : (ClassVariableAndWriteNode node) -> void + def visit_class_variable_and_write_node: (ClassVariableAndWriteNode node) -> void + + # Visit a ClassVariableOperatorWriteNode node + # -- + # : (ClassVariableOperatorWriteNode node) -> void + def visit_class_variable_operator_write_node: (ClassVariableOperatorWriteNode node) -> void + + # Visit a ClassVariableOrWriteNode node + # -- + # : (ClassVariableOrWriteNode node) -> void + def visit_class_variable_or_write_node: (ClassVariableOrWriteNode node) -> void + + # Visit a ClassVariableReadNode node + # -- + # : (ClassVariableReadNode node) -> void + def visit_class_variable_read_node: (ClassVariableReadNode node) -> void + + # Visit a ClassVariableTargetNode node + # -- + # : (ClassVariableTargetNode node) -> void + def visit_class_variable_target_node: (ClassVariableTargetNode node) -> void + + # Visit a ClassVariableWriteNode node + # -- + # : (ClassVariableWriteNode node) -> void + def visit_class_variable_write_node: (ClassVariableWriteNode node) -> void + + # Visit a ConstantAndWriteNode node + # -- + # : (ConstantAndWriteNode node) -> void + def visit_constant_and_write_node: (ConstantAndWriteNode node) -> void + + # Visit a ConstantOperatorWriteNode node + # -- + # : (ConstantOperatorWriteNode node) -> void + def visit_constant_operator_write_node: (ConstantOperatorWriteNode node) -> void + + # Visit a ConstantOrWriteNode node + # -- + # : (ConstantOrWriteNode node) -> void + def visit_constant_or_write_node: (ConstantOrWriteNode node) -> void + + # Visit a ConstantPathAndWriteNode node + # -- + # : (ConstantPathAndWriteNode node) -> void + def visit_constant_path_and_write_node: (ConstantPathAndWriteNode node) -> void + + # Visit a ConstantPathNode node + # -- + # : (ConstantPathNode node) -> void + def visit_constant_path_node: (ConstantPathNode node) -> void + + # Visit a ConstantPathOperatorWriteNode node + # -- + # : (ConstantPathOperatorWriteNode node) -> void + def visit_constant_path_operator_write_node: (ConstantPathOperatorWriteNode node) -> void + + # Visit a ConstantPathOrWriteNode node + # -- + # : (ConstantPathOrWriteNode node) -> void + def visit_constant_path_or_write_node: (ConstantPathOrWriteNode node) -> void + + # Visit a ConstantPathTargetNode node + # -- + # : (ConstantPathTargetNode node) -> void + def visit_constant_path_target_node: (ConstantPathTargetNode node) -> void + + # Visit a ConstantPathWriteNode node + # -- + # : (ConstantPathWriteNode node) -> void + def visit_constant_path_write_node: (ConstantPathWriteNode node) -> void + + # Visit a ConstantReadNode node + # -- + # : (ConstantReadNode node) -> void + def visit_constant_read_node: (ConstantReadNode node) -> void + + # Visit a ConstantTargetNode node + # -- + # : (ConstantTargetNode node) -> void + def visit_constant_target_node: (ConstantTargetNode node) -> void + + # Visit a ConstantWriteNode node + # -- + # : (ConstantWriteNode node) -> void + def visit_constant_write_node: (ConstantWriteNode node) -> void + + # Visit a DefNode node + # -- + # : (DefNode node) -> void + def visit_def_node: (DefNode node) -> void + + # Visit a DefinedNode node + # -- + # : (DefinedNode node) -> void + def visit_defined_node: (DefinedNode node) -> void + + # Visit a ElseNode node + # -- + # : (ElseNode node) -> void + def visit_else_node: (ElseNode node) -> void + + # Visit a EmbeddedStatementsNode node + # -- + # : (EmbeddedStatementsNode node) -> void + def visit_embedded_statements_node: (EmbeddedStatementsNode node) -> void + + # Visit a EmbeddedVariableNode node + # -- + # : (EmbeddedVariableNode node) -> void + def visit_embedded_variable_node: (EmbeddedVariableNode node) -> void + + # Visit a EnsureNode node + # -- + # : (EnsureNode node) -> void + def visit_ensure_node: (EnsureNode node) -> void + + # Visit a FalseNode node + # -- + # : (FalseNode node) -> void + def visit_false_node: (FalseNode node) -> void + + # Visit a FindPatternNode node + # -- + # : (FindPatternNode node) -> void + def visit_find_pattern_node: (FindPatternNode node) -> void + + # Visit a FlipFlopNode node + # -- + # : (FlipFlopNode node) -> void + def visit_flip_flop_node: (FlipFlopNode node) -> void + + # Visit a FloatNode node + # -- + # : (FloatNode node) -> void + def visit_float_node: (FloatNode node) -> void + + # Visit a ForNode node + # -- + # : (ForNode node) -> void + def visit_for_node: (ForNode node) -> void + + # Visit a ForwardingArgumentsNode node + # -- + # : (ForwardingArgumentsNode node) -> void + def visit_forwarding_arguments_node: (ForwardingArgumentsNode node) -> void + + # Visit a ForwardingParameterNode node + # -- + # : (ForwardingParameterNode node) -> void + def visit_forwarding_parameter_node: (ForwardingParameterNode node) -> void + + # Visit a ForwardingSuperNode node + # -- + # : (ForwardingSuperNode node) -> void + def visit_forwarding_super_node: (ForwardingSuperNode node) -> void + + # Visit a GlobalVariableAndWriteNode node + # -- + # : (GlobalVariableAndWriteNode node) -> void + def visit_global_variable_and_write_node: (GlobalVariableAndWriteNode node) -> void + + # Visit a GlobalVariableOperatorWriteNode node + # -- + # : (GlobalVariableOperatorWriteNode node) -> void + def visit_global_variable_operator_write_node: (GlobalVariableOperatorWriteNode node) -> void + + # Visit a GlobalVariableOrWriteNode node + # -- + # : (GlobalVariableOrWriteNode node) -> void + def visit_global_variable_or_write_node: (GlobalVariableOrWriteNode node) -> void + + # Visit a GlobalVariableReadNode node + # -- + # : (GlobalVariableReadNode node) -> void + def visit_global_variable_read_node: (GlobalVariableReadNode node) -> void + + # Visit a GlobalVariableTargetNode node + # -- + # : (GlobalVariableTargetNode node) -> void + def visit_global_variable_target_node: (GlobalVariableTargetNode node) -> void + + # Visit a GlobalVariableWriteNode node + # -- + # : (GlobalVariableWriteNode node) -> void + def visit_global_variable_write_node: (GlobalVariableWriteNode node) -> void + + # Visit a HashNode node + # -- + # : (HashNode node) -> void + def visit_hash_node: (HashNode node) -> void + + # Visit a HashPatternNode node + # -- + # : (HashPatternNode node) -> void + def visit_hash_pattern_node: (HashPatternNode node) -> void + + # Visit a IfNode node + # -- + # : (IfNode node) -> void + def visit_if_node: (IfNode node) -> void + + # Visit a ImaginaryNode node + # -- + # : (ImaginaryNode node) -> void + def visit_imaginary_node: (ImaginaryNode node) -> void + + # Visit a ImplicitNode node + # -- + # : (ImplicitNode node) -> void + def visit_implicit_node: (ImplicitNode node) -> void + + # Visit a ImplicitRestNode node + # -- + # : (ImplicitRestNode node) -> void + def visit_implicit_rest_node: (ImplicitRestNode node) -> void + + # Visit a InNode node + # -- + # : (InNode node) -> void + def visit_in_node: (InNode node) -> void + + # Visit a IndexAndWriteNode node + # -- + # : (IndexAndWriteNode node) -> void + def visit_index_and_write_node: (IndexAndWriteNode node) -> void + + # Visit a IndexOperatorWriteNode node + # -- + # : (IndexOperatorWriteNode node) -> void + def visit_index_operator_write_node: (IndexOperatorWriteNode node) -> void + + # Visit a IndexOrWriteNode node + # -- + # : (IndexOrWriteNode node) -> void + def visit_index_or_write_node: (IndexOrWriteNode node) -> void + + # Visit a IndexTargetNode node + # -- + # : (IndexTargetNode node) -> void + def visit_index_target_node: (IndexTargetNode node) -> void + + # Visit a InstanceVariableAndWriteNode node + # -- + # : (InstanceVariableAndWriteNode node) -> void + def visit_instance_variable_and_write_node: (InstanceVariableAndWriteNode node) -> void + + # Visit a InstanceVariableOperatorWriteNode node + # -- + # : (InstanceVariableOperatorWriteNode node) -> void + def visit_instance_variable_operator_write_node: (InstanceVariableOperatorWriteNode node) -> void + + # Visit a InstanceVariableOrWriteNode node + # -- + # : (InstanceVariableOrWriteNode node) -> void + def visit_instance_variable_or_write_node: (InstanceVariableOrWriteNode node) -> void + + # Visit a InstanceVariableReadNode node + # -- + # : (InstanceVariableReadNode node) -> void + def visit_instance_variable_read_node: (InstanceVariableReadNode node) -> void + + # Visit a InstanceVariableTargetNode node + # -- + # : (InstanceVariableTargetNode node) -> void + def visit_instance_variable_target_node: (InstanceVariableTargetNode node) -> void + + # Visit a InstanceVariableWriteNode node + # -- + # : (InstanceVariableWriteNode node) -> void + def visit_instance_variable_write_node: (InstanceVariableWriteNode node) -> void + + # Visit a IntegerNode node + # -- + # : (IntegerNode node) -> void + def visit_integer_node: (IntegerNode node) -> void + + # Visit a InterpolatedMatchLastLineNode node + # -- + # : (InterpolatedMatchLastLineNode node) -> void + def visit_interpolated_match_last_line_node: (InterpolatedMatchLastLineNode node) -> void + + # Visit a InterpolatedRegularExpressionNode node + # -- + # : (InterpolatedRegularExpressionNode node) -> void + def visit_interpolated_regular_expression_node: (InterpolatedRegularExpressionNode node) -> void + + # Visit a InterpolatedStringNode node + # -- + # : (InterpolatedStringNode node) -> void + def visit_interpolated_string_node: (InterpolatedStringNode node) -> void + + # Visit a InterpolatedSymbolNode node + # -- + # : (InterpolatedSymbolNode node) -> void + def visit_interpolated_symbol_node: (InterpolatedSymbolNode node) -> void + + # Visit a InterpolatedXStringNode node + # -- + # : (InterpolatedXStringNode node) -> void + def visit_interpolated_x_string_node: (InterpolatedXStringNode node) -> void + + # Visit a ItLocalVariableReadNode node + # -- + # : (ItLocalVariableReadNode node) -> void + def visit_it_local_variable_read_node: (ItLocalVariableReadNode node) -> void + + # Visit a ItParametersNode node + # -- + # : (ItParametersNode node) -> void + def visit_it_parameters_node: (ItParametersNode node) -> void + + # Visit a KeywordHashNode node + # -- + # : (KeywordHashNode node) -> void + def visit_keyword_hash_node: (KeywordHashNode node) -> void + + # Visit a KeywordRestParameterNode node + # -- + # : (KeywordRestParameterNode node) -> void + def visit_keyword_rest_parameter_node: (KeywordRestParameterNode node) -> void + + # Visit a LambdaNode node + # -- + # : (LambdaNode node) -> void + def visit_lambda_node: (LambdaNode node) -> void + + # Visit a LocalVariableAndWriteNode node + # -- + # : (LocalVariableAndWriteNode node) -> void + def visit_local_variable_and_write_node: (LocalVariableAndWriteNode node) -> void + + # Visit a LocalVariableOperatorWriteNode node + # -- + # : (LocalVariableOperatorWriteNode node) -> void + def visit_local_variable_operator_write_node: (LocalVariableOperatorWriteNode node) -> void + + # Visit a LocalVariableOrWriteNode node + # -- + # : (LocalVariableOrWriteNode node) -> void + def visit_local_variable_or_write_node: (LocalVariableOrWriteNode node) -> void + + # Visit a LocalVariableReadNode node + # -- + # : (LocalVariableReadNode node) -> void + def visit_local_variable_read_node: (LocalVariableReadNode node) -> void + + # Visit a LocalVariableTargetNode node + # -- + # : (LocalVariableTargetNode node) -> void + def visit_local_variable_target_node: (LocalVariableTargetNode node) -> void + + # Visit a LocalVariableWriteNode node + # -- + # : (LocalVariableWriteNode node) -> void + def visit_local_variable_write_node: (LocalVariableWriteNode node) -> void + + # Visit a MatchLastLineNode node + # -- + # : (MatchLastLineNode node) -> void + def visit_match_last_line_node: (MatchLastLineNode node) -> void + + # Visit a MatchPredicateNode node + # -- + # : (MatchPredicateNode node) -> void + def visit_match_predicate_node: (MatchPredicateNode node) -> void + + # Visit a MatchRequiredNode node + # -- + # : (MatchRequiredNode node) -> void + def visit_match_required_node: (MatchRequiredNode node) -> void + + # Visit a MatchWriteNode node + # -- + # : (MatchWriteNode node) -> void + def visit_match_write_node: (MatchWriteNode node) -> void + + # Visit a MissingNode node + # -- + # : (MissingNode node) -> void + def visit_missing_node: (MissingNode node) -> void + + # Visit a ModuleNode node + # -- + # : (ModuleNode node) -> void + def visit_module_node: (ModuleNode node) -> void + + # Visit a MultiTargetNode node + # -- + # : (MultiTargetNode node) -> void + def visit_multi_target_node: (MultiTargetNode node) -> void + + # Visit a MultiWriteNode node + # -- + # : (MultiWriteNode node) -> void + def visit_multi_write_node: (MultiWriteNode node) -> void + + # Visit a NextNode node + # -- + # : (NextNode node) -> void + def visit_next_node: (NextNode node) -> void + + # Visit a NilNode node + # -- + # : (NilNode node) -> void + def visit_nil_node: (NilNode node) -> void + + # Visit a NoBlockParameterNode node + # -- + # : (NoBlockParameterNode node) -> void + def visit_no_block_parameter_node: (NoBlockParameterNode node) -> void + + # Visit a NoKeywordsParameterNode node + # -- + # : (NoKeywordsParameterNode node) -> void + def visit_no_keywords_parameter_node: (NoKeywordsParameterNode node) -> void + + # Visit a NumberedParametersNode node + # -- + # : (NumberedParametersNode node) -> void + def visit_numbered_parameters_node: (NumberedParametersNode node) -> void + + # Visit a NumberedReferenceReadNode node + # -- + # : (NumberedReferenceReadNode node) -> void + def visit_numbered_reference_read_node: (NumberedReferenceReadNode node) -> void + + # Visit a OptionalKeywordParameterNode node + # -- + # : (OptionalKeywordParameterNode node) -> void + def visit_optional_keyword_parameter_node: (OptionalKeywordParameterNode node) -> void + + # Visit a OptionalParameterNode node + # -- + # : (OptionalParameterNode node) -> void + def visit_optional_parameter_node: (OptionalParameterNode node) -> void + + # Visit a OrNode node + # -- + # : (OrNode node) -> void + def visit_or_node: (OrNode node) -> void + + # Visit a ParametersNode node + # -- + # : (ParametersNode node) -> void + def visit_parameters_node: (ParametersNode node) -> void + + # Visit a ParenthesesNode node + # -- + # : (ParenthesesNode node) -> void + def visit_parentheses_node: (ParenthesesNode node) -> void + + # Visit a PinnedExpressionNode node + # -- + # : (PinnedExpressionNode node) -> void + def visit_pinned_expression_node: (PinnedExpressionNode node) -> void + + # Visit a PinnedVariableNode node + # -- + # : (PinnedVariableNode node) -> void + def visit_pinned_variable_node: (PinnedVariableNode node) -> void + + # Visit a PostExecutionNode node + # -- + # : (PostExecutionNode node) -> void + def visit_post_execution_node: (PostExecutionNode node) -> void + + # Visit a PreExecutionNode node + # -- + # : (PreExecutionNode node) -> void + def visit_pre_execution_node: (PreExecutionNode node) -> void + + # Visit a ProgramNode node + # -- + # : (ProgramNode node) -> void + def visit_program_node: (ProgramNode node) -> void + + # Visit a RangeNode node + # -- + # : (RangeNode node) -> void + def visit_range_node: (RangeNode node) -> void + + # Visit a RationalNode node + # -- + # : (RationalNode node) -> void + def visit_rational_node: (RationalNode node) -> void + + # Visit a RedoNode node + # -- + # : (RedoNode node) -> void + def visit_redo_node: (RedoNode node) -> void + + # Visit a RegularExpressionNode node + # -- + # : (RegularExpressionNode node) -> void + def visit_regular_expression_node: (RegularExpressionNode node) -> void + + # Visit a RequiredKeywordParameterNode node + # -- + # : (RequiredKeywordParameterNode node) -> void + def visit_required_keyword_parameter_node: (RequiredKeywordParameterNode node) -> void + + # Visit a RequiredParameterNode node + # -- + # : (RequiredParameterNode node) -> void + def visit_required_parameter_node: (RequiredParameterNode node) -> void + + # Visit a RescueModifierNode node + # -- + # : (RescueModifierNode node) -> void + def visit_rescue_modifier_node: (RescueModifierNode node) -> void + + # Visit a RescueNode node + # -- + # : (RescueNode node) -> void + def visit_rescue_node: (RescueNode node) -> void + + # Visit a RestParameterNode node + # -- + # : (RestParameterNode node) -> void + def visit_rest_parameter_node: (RestParameterNode node) -> void + + # Visit a RetryNode node + # -- + # : (RetryNode node) -> void + def visit_retry_node: (RetryNode node) -> void + + # Visit a ReturnNode node + # -- + # : (ReturnNode node) -> void + def visit_return_node: (ReturnNode node) -> void + + # Visit a SelfNode node + # -- + # : (SelfNode node) -> void + def visit_self_node: (SelfNode node) -> void + + # Visit a ShareableConstantNode node + # -- + # : (ShareableConstantNode node) -> void + def visit_shareable_constant_node: (ShareableConstantNode node) -> void + + # Visit a SingletonClassNode node + # -- + # : (SingletonClassNode node) -> void + def visit_singleton_class_node: (SingletonClassNode node) -> void + + # Visit a SourceEncodingNode node + # -- + # : (SourceEncodingNode node) -> void + def visit_source_encoding_node: (SourceEncodingNode node) -> void + + # Visit a SourceFileNode node + # -- + # : (SourceFileNode node) -> void + def visit_source_file_node: (SourceFileNode node) -> void + + # Visit a SourceLineNode node + # -- + # : (SourceLineNode node) -> void + def visit_source_line_node: (SourceLineNode node) -> void + + # Visit a SplatNode node + # -- + # : (SplatNode node) -> void + def visit_splat_node: (SplatNode node) -> void + + # Visit a StatementsNode node + # -- + # : (StatementsNode node) -> void + def visit_statements_node: (StatementsNode node) -> void + + # Visit a StringNode node + # -- + # : (StringNode node) -> void + def visit_string_node: (StringNode node) -> void + + # Visit a SuperNode node + # -- + # : (SuperNode node) -> void + def visit_super_node: (SuperNode node) -> void + + # Visit a SymbolNode node + # -- + # : (SymbolNode node) -> void + def visit_symbol_node: (SymbolNode node) -> void + + # Visit a TrueNode node + # -- + # : (TrueNode node) -> void + def visit_true_node: (TrueNode node) -> void + + # Visit a UndefNode node + # -- + # : (UndefNode node) -> void + def visit_undef_node: (UndefNode node) -> void + + # Visit a UnlessNode node + # -- + # : (UnlessNode node) -> void + def visit_unless_node: (UnlessNode node) -> void + + # Visit a UntilNode node + # -- + # : (UntilNode node) -> void + def visit_until_node: (UntilNode node) -> void + + # Visit a WhenNode node + # -- + # : (WhenNode node) -> void + def visit_when_node: (WhenNode node) -> void + + # Visit a WhileNode node + # -- + # : (WhileNode node) -> void + def visit_while_node: (WhileNode node) -> void + + # Visit a XStringNode node + # -- + # : (XStringNode node) -> void + def visit_x_string_node: (XStringNode node) -> void + + # Visit a YieldNode node + # -- + # : (YieldNode node) -> void + def visit_yield_node: (YieldNode node) -> void + end +end diff --git a/sig/prism/_private/node.rbs b/sig/prism/_private/node.rbs deleted file mode 100644 index b5918a7133..0000000000 --- a/sig/prism/_private/node.rbs +++ /dev/null @@ -1,8 +0,0 @@ -module Prism - class Node - @newline_flag: bool - - def newline_flag?: () -> bool - def newline_flag!: (Array[bool] lines) -> void - end -end diff --git a/sig/prism/_private/node_ext.rbs b/sig/prism/_private/node_ext.rbs deleted file mode 100644 index 82e08f4263..0000000000 --- a/sig/prism/_private/node_ext.rbs +++ /dev/null @@ -1,9 +0,0 @@ -module Prism - module RegularExpressionOptions: InterpolatedMatchLastLineNode, InterpolatedRegularExpressionNode, MatchLastLineNode, RegularExpressionNode - def options: () -> Integer - end - - module HeredocQuery: InterpolatedStringNode, InterpolatedXStringNode, StringNode, XStringNode - def heredoc?: () -> bool? - end -end diff --git a/sig/prism/_private/parse_result.rbs b/sig/prism/_private/parse_result.rbs deleted file mode 100644 index 380b6f9dd6..0000000000 --- a/sig/prism/_private/parse_result.rbs +++ /dev/null @@ -1,50 +0,0 @@ -module Prism - class Source - private - - def find_line: (Integer) -> Integer - end - - class CodeUnitsCache - class UTF16Counter - def initialize: (String source, Encoding encoding) -> void - def count: (Integer byte_offset, Integer byte_length) -> Integer - end - - class LengthCounter - def initialize: (String source, Encoding encoding) -> void - def count: (Integer byte_offset, Integer byte_length) -> Integer - end - end - - class Location - private - - def source!: () -> Source - end - - class ParseResult - def attach_comments!: () -> void - def mark_newlines!: () -> untyped - - class Errors - attr_reader parse_result: ParseResult - - def initialize: (ParseResult parse_result) -> void - def format: () -> String - end - - class Newlines < Visitor - @newline_marked: Array[bool] - - # Create a new Newlines visitor with the given newline offsets. - def initialize: (Array[bool] newline_marked) -> void - - def visit_block_node: (BlockNode node) -> void - def visit_lambda_node: (LambdaNode node) -> void - def visit_if_node: (IfNode node) -> void - def visit_unless_node: (UnlessNode node) -> void - def visit_statements_node: (StatementsNode node) -> void - end - end -end diff --git a/sig/prism/_private/pattern.rbs b/sig/prism/_private/pattern.rbs deleted file mode 100644 index 244206d15d..0000000000 --- a/sig/prism/_private/pattern.rbs +++ /dev/null @@ -1,26 +0,0 @@ -module Prism - class Pattern - class CompilationError < StandardError - def initialize: (String) -> void - end - - @compiled: Proc? - - private - - def combine_and: (Proc, Proc) -> Proc - def combine_or: (Proc, Proc) -> Proc - def compile_error: (Prism::node?) -> Proc - def compile_array_pattern_node: (ArrayPatternNode) -> Proc - def compile_alternation_pattern_node: (AlternationPatternNode) -> Proc - def compile_constant_path_node: (ConstantPathNode) -> Proc - def compile_constant_read_node: (ConstantReadNode) -> Proc - def compile_constant_name: (Prism::node, Symbol) -> Proc - def compile_hash_pattern_node: (HashPatternNode) -> Proc - def compile_nil_node: (NilNode) -> Proc - def compile_regular_expression_node: (RegularExpressionNode) -> Proc - def compile_string_node: (StringNode) -> Proc - def compile_symbol_node: (SymbolNode) -> Proc - def compile_node: (Prism::node?) -> Proc - end -end diff --git a/sig/prism/_private/relocation.rbs b/sig/prism/_private/relocation.rbs deleted file mode 100644 index fda123bb37..0000000000 --- a/sig/prism/_private/relocation.rbs +++ /dev/null @@ -1,12 +0,0 @@ -module Prism - module Relocation - class Entry - def reify!: (entry_values values) -> void - end - - class Repository - def enter: (Integer node_id, Symbol field_name) -> Entry - def reify!: () -> void - end - end -end diff --git a/sig/prism/_private/string_query.rbs b/sig/prism/_private/string_query.rbs deleted file mode 100644 index 47ea2ca1a0..0000000000 --- a/sig/prism/_private/string_query.rbs +++ /dev/null @@ -1,7 +0,0 @@ -module Prism - class StringQuery - def self.local?: (String string) -> bool - def self.constant?: (String string) -> bool - def self.method_name?: (String string) -> bool - end -end diff --git a/sig/prism/compiler.rbs b/sig/prism/compiler.rbs deleted file mode 100644 index 1afa7db74d..0000000000 --- a/sig/prism/compiler.rbs +++ /dev/null @@ -1,9 +0,0 @@ -module Prism - class Compiler - include _Visitor - - def visit: (Prism::node?) -> untyped - def visit_all: (Array[Prism::node?]) -> untyped - def visit_child_nodes: (Prism::node) -> void - end -end diff --git a/sig/prism/dispatcher.rbs b/sig/prism/dispatcher.rbs deleted file mode 100644 index f58b8661f3..0000000000 --- a/sig/prism/dispatcher.rbs +++ /dev/null @@ -1,19 +0,0 @@ -module Prism - class Dispatcher < Visitor - attr_reader listeners: Hash[Symbol, Array[untyped]] - - def initialize: () -> void - def register: (untyped, *Symbol) -> void - def register_public_methods: (untyped) -> void - def dispatch: (Prism::node) -> void - def dispatch_once: (Prism::node) -> void - - private def register_events: (untyped, Array[Symbol]) -> void - - class DispatchOnce < Visitor - attr_reader listeners: Hash[Symbol, Array[untyped]] - - def initialize: (Hash[Symbol, Array[untyped]]) -> void - end - end -end diff --git a/sig/prism/dot_visitor.rbs b/sig/prism/dot_visitor.rbs deleted file mode 100644 index 46b3dbf419..0000000000 --- a/sig/prism/dot_visitor.rbs +++ /dev/null @@ -1,6 +0,0 @@ -module Prism - class DotVisitor < Visitor - def initialize: () -> void - def to_dot: () -> String - end -end diff --git a/sig/prism/inspect_visitor.rbs b/sig/prism/inspect_visitor.rbs deleted file mode 100644 index 70fa878ac3..0000000000 --- a/sig/prism/inspect_visitor.rbs +++ /dev/null @@ -1,22 +0,0 @@ -module Prism - class InspectVisitor < Visitor - class Replace - attr_reader value: String - - def initialize: (String value) -> void - end - - attr_reader indent: String - attr_reader commands: Array[[String | node | Replace, String]] - - def initialize: (?String indent) -> void - def compose: () -> String - - def self.compose: (node node) -> String - - private - - def inspect_node: (String name, node node) -> String - def inspect_location: (Location? location) -> String - end -end diff --git a/sig/prism/lex_compat.rbs b/sig/prism/lex_compat.rbs deleted file mode 100644 index 5dc1f8764e..0000000000 --- a/sig/prism/lex_compat.rbs +++ /dev/null @@ -1,10 +0,0 @@ -module Prism - class LexCompat - class Result < Prism::Result - attr_reader value: Array[[[Integer, Integer], Symbol, String, untyped]] - - def initialize: (Array[[[Integer, Integer], Symbol, String, untyped]] value, Array[comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void - def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] - end - end -end diff --git a/sig/prism/node_ext.rbs b/sig/prism/node_ext.rbs deleted file mode 100644 index a187c1d246..0000000000 --- a/sig/prism/node_ext.rbs +++ /dev/null @@ -1,149 +0,0 @@ -module Prism - class Node - def deprecated: (*String replacements) -> void - end - - class InterpolatedMatchLastLineNode < Node - def options: () -> Integer - end - - class InterpolatedRegularExpressionNode < Node - def options: () -> Integer - end - - class MatchLastLineNode < Node - def options: () -> Integer - end - - class RegularExpressionNode < Node - def options: () -> Integer - end - - class InterpolatedStringNode < Node - def heredoc?: () -> bool - end - - class InterpolatedXStringNode < Node - def heredoc?: () -> bool - end - - class StringNode < Node - def heredoc?: () -> bool - def to_interpolated: () -> InterpolatedStringNode - end - - class XStringNode < Node - def heredoc?: () -> bool - def to_interpolated: () -> InterpolatedXStringNode - end - - class ImaginaryNode < Node - def value: () -> Complex - end - - class RationalNode < Node - def value: () -> Rational - def numeric: () -> (IntegerNode | FloatNode) - end - - class ConstantReadNode < Node - def full_name_parts: () -> Array[Symbol] - def full_name: () -> String - end - - class ConstantWriteNode < Node - def full_name_parts: () -> Array[Symbol] - def full_name: () -> String - end - - class ConstantPathNode < Node - class DynamicPartsInConstantPathError < StandardError - end - - class MissingNodesInConstantPathError < StandardError - end - - def full_name_parts: () -> Array[Symbol] - def full_name: () -> String - def child: () -> (ConstantReadNode | MissingNode) - end - - class ConstantPathTargetNode < Node - def full_name_parts: () -> Array[Symbol] - def full_name: () -> String - def child: () -> (ConstantReadNode | MissingNode) - end - - class ConstantTargetNode < Node - def full_name_parts: () -> Array[Symbol] - def full_name: () -> String - end - - class ParametersNode < Node - def signature: () -> Array[[Symbol, Symbol] | [Symbol]] - end - - class CallNode < Node - def full_message_loc: () -> Location? - end - - class CallOperatorWriteNode < Node - def operator: () -> Symbol - def operator_loc: () -> Location - end - - class ClassVariableOperatorWriteNode < Node - def operator: () -> Symbol - def operator_loc: () -> Location - end - - class ConstantOperatorWriteNode < Node - def operator: () -> Symbol - def operator_loc: () -> Location - end - - class ConstantPathOperatorWriteNode < Node - def operator: () -> Symbol - def operator_loc: () -> Location - end - - class GlobalVariableOperatorWriteNode < Node - def operator: () -> Symbol - def operator_loc: () -> Location - end - - class IndexOperatorWriteNode < Node - def operator: () -> Symbol - def operator_loc: () -> Location - end - - class InstanceVariableOperatorWriteNode < Node - def operator: () -> Symbol - def operator_loc: () -> Location - end - - class LocalVariableOperatorWriteNode < Node - def operator: () -> Symbol - def operator_loc: () -> Location - end - - class CaseMatchNode < Node - def consequent: () -> ElseNode? - end - - class CaseNode < Node - def consequent: () -> ElseNode? - end - - class IfNode < Node - def consequent: () -> (ElseNode | IfNode | nil) - end - - class RescueNode < Node - def consequent: () -> RescueNode? - end - - class UnlessNode < Node - def consequent: () -> ElseNode? - end -end diff --git a/sig/prism/parse_result.rbs b/sig/prism/parse_result.rbs deleted file mode 100644 index cbcf3fc2f8..0000000000 --- a/sig/prism/parse_result.rbs +++ /dev/null @@ -1,197 +0,0 @@ -module Prism - interface _CodeUnitsCache - def []: (Integer byte_offset) -> Integer - end - - class Source - attr_reader source: String - attr_reader start_line: Integer - attr_reader offsets: Array[Integer] - - def initialize: (String source, ?Integer start_line, ?Array[Integer] offsets) -> void - def replace_start_line: (Integer start_line) -> void - def replace_offsets: (Array[Integer] offsets) -> void - def encoding: () -> Encoding - def lines: () -> Array[String] - def slice: (Integer byte_offset, Integer length) -> String - def byte_offset: (Integer line, Integer column) -> Integer - def line: (Integer byte_offset) -> Integer - def line_start: (Integer byte_offset) -> Integer - def line_end: (Integer byte_offset) -> Integer - def line_offset: (Integer byte_offset) -> Integer - def column: (Integer byte_offset) -> Integer - def character_offset: (Integer byte_offset) -> Integer - def character_column: (Integer byte_offset) -> Integer - def code_units_offset: (Integer byte_offset, Encoding encoding) -> Integer - def code_units_cache: (Encoding encoding) -> _CodeUnitsCache - def code_units_column: (Integer byte_offset, Encoding encoding) -> Integer - def deep_freeze: () -> void - - def self.for: (String source) -> Source - end - - class CodeUnitsCache - def initialize: (String source, Encoding encoding) -> void - def []: (Integer byte_offset) -> Integer - end - - class ASCIISource < Source - def character_offset: (Integer byte_offset) -> Integer - def character_column: (Integer byte_offset) -> Integer - def code_units_offset: (Integer byte_offset, Encoding encoding) -> Integer - def code_units_cache: (Encoding encoding) -> _CodeUnitsCache - def code_units_column: (Integer byte_offset, Encoding encoding) -> Integer - end - - class Location - attr_reader source: Source - attr_reader start_offset: Integer - attr_reader length: Integer - - def initialize: (Source source, Integer start_offset, Integer length) -> void - def leading_comments: () -> Array[comment] - def leading_comment: (comment) -> void - def trailing_comments: () -> Array[comment] - def trailing_comment: (comment) -> void - def comments: () -> Array[comment] - def copy: (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location - def chop: () -> Location - def source_lines: () -> Array[String] - def slice: () -> String - def slice_lines: () -> String - def start_character_offset: () -> Integer - def start_code_units_offset: (Encoding encoding) -> Integer - def cached_start_code_units_offset: (_CodeUnitsCache cache) -> Integer - def end_offset: () -> Integer - def end_character_offset: () -> Integer - def end_code_units_offset: (Encoding encoding) -> Integer - def cached_end_code_units_offset: (_CodeUnitsCache cache) -> Integer - def start_line: () -> Integer - def start_line_slice: () -> String - def end_line: () -> Integer - def start_column: () -> Integer - def start_character_column: () -> Integer - def start_code_units_column: (Encoding encoding) -> Integer - def cached_start_code_units_column: (_CodeUnitsCache cache) -> Integer - def end_column: () -> Integer - def end_character_column: () -> Integer - def end_code_units_column: (Encoding encoding) -> Integer - def cached_end_code_units_column: (_CodeUnitsCache cache) -> Integer - def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] - def pretty_print: (untyped q) -> untyped - def join: (Location other) -> Location - def adjoin: (String string) -> Location - end - - class Comment - attr_reader location: Location - - def initialize: (Location location) -> void - def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] - def slice: () -> String - end - - interface _Comment - def trailing?: () -> bool - end - - type comment = Comment & _Comment - - class InlineComment < Comment - include _Comment - end - - class EmbDocComment < Comment - include _Comment - end - - class MagicComment - attr_reader key_loc: Location - attr_reader value_loc: Location - - def initialize: (Location key_loc, Location value_loc) -> void - - def key: () -> String - def value: () -> String - - def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] - end - - class ParseError - attr_reader type: Symbol - attr_reader message: String - attr_reader location: Location - attr_reader level: Symbol - - def initialize: (Symbol type, String message, Location location, Symbol level) -> void - def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] - end - - class ParseWarning - attr_reader type: Symbol - attr_reader message: String - attr_reader location: Location - attr_reader level: Symbol - - def initialize: (Symbol type, String message, Location location, Symbol level) -> void - def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] - end - - class Result - attr_reader comments: Array[comment] - attr_reader magic_comments: Array[MagicComment] - attr_reader data_loc: Location? - attr_reader errors: Array[ParseError] - attr_reader warnings: Array[ParseWarning] - attr_reader source: Source - - def initialize: (Array[comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void - def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] - def encoding: () -> Encoding - def success?: () -> bool - def failure?: () -> bool - def code_units_cache: (Encoding encoding) -> _CodeUnitsCache - end - - class ParseResult < Result - attr_reader value: ProgramNode - - def initialize: (ProgramNode value, Array[comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void - def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] - def errors_format: () -> String - end - - class LexResult < Result - attr_reader value: Array[[Token, Integer]] - - def initialize: (Array[[Token, Integer]] value, Array[comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void - def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] - end - - class ParseLexResult < Result - attr_reader value: [ProgramNode, Array[[Token, Integer]]] - - def initialize: ([ProgramNode, Array[[Token, Integer]]] value, Array[comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void - def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] - end - - class Token - attr_reader source: Source - attr_reader type: Symbol - attr_reader value: String - attr_reader location: Location - - def initialize: (Source source, Symbol type, String value, Location location) -> void - def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped] - def pretty_print: (untyped q) -> untyped - def ==: (untyped other) -> bool - def deep_freeze: () -> void - end - - class Scope - attr_reader locals: Array[Symbol] - attr_reader forwarding: Array[Symbol] - - def initialize: (Array[Symbol] locals, Array[Symbol] forwarding) -> void - end -end diff --git a/sig/prism/parse_result/comments.rbs b/sig/prism/parse_result/comments.rbs deleted file mode 100644 index 5b9e315063..0000000000 --- a/sig/prism/parse_result/comments.rbs +++ /dev/null @@ -1,38 +0,0 @@ -module Prism - class ParseResult < Result - class Comments - interface _Target - def start_offset: () -> Integer - def end_offset: () -> Integer - def encloses?: (comment) -> bool - def leading_comment: (comment) -> void - def trailing_comment: (comment) -> void - end - - class NodeTarget - include _Target - - attr_reader node: node - - def initialize: (node) -> void - end - - class LocationTarget - include _Target - - attr_reader location: Location - - def initialize: (Location location) -> void - end - - attr_reader parse_result: ParseResult - - def initialize: (ParseResult parse_result) -> void - def attach!: () -> void - - private - - def nearest_targets: (node, comment) -> [_Target?, _Target, _Target?] - end - end -end diff --git a/sig/prism/pattern.rbs b/sig/prism/pattern.rbs deleted file mode 100644 index a70293e18b..0000000000 --- a/sig/prism/pattern.rbs +++ /dev/null @@ -1,13 +0,0 @@ -module Prism - class Pattern - class CompilationError < StandardError - end - - attr_reader query: String - - def initialize: (String query) -> void - def compile: () -> Proc - def scan: (Prism::node root) { (Prism::node) -> void } -> void - | (Prism::node root) -> ::Enumerator[Prism::node, void] - end -end diff --git a/sig/prism/reflection.rbs b/sig/prism/reflection.rbs deleted file mode 100644 index 047ea32a50..0000000000 --- a/sig/prism/reflection.rbs +++ /dev/null @@ -1,50 +0,0 @@ -module Prism - module Reflection - class Field - attr_reader name: Symbol - - def initialize: (Symbol name) -> void - end - - class NodeField < Field - end - - class OptionalNodeField < Field - end - - class NodeListField < Field - end - - class ConstantField < Field - end - - class OptionalConstantField < Field - end - - class ConstantListField < Field - end - - class StringField < Field - end - - class LocationField < Field - end - - class OptionalLocationField < Field - end - - class IntegerField < Field - end - - class FloatField < Field - end - - class FlagsField < Field - attr_reader flags: Array[Symbol] - - def initialize: (Symbol name, Array[Symbol] flags) -> void - end - - def self.fields_for: (singleton(Node) node) -> Array[Field] - end -end diff --git a/sig/prism/relocation.rbs b/sig/prism/relocation.rbs deleted file mode 100644 index 7f5637d5fa..0000000000 --- a/sig/prism/relocation.rbs +++ /dev/null @@ -1,185 +0,0 @@ -module Prism - module Relocation - interface _Value - def start_line: () -> Integer - def end_line: () -> Integer - def start_offset: () -> Integer - def end_offset: () -> Integer - def start_character_offset: () -> Integer - def end_character_offset: () -> Integer - def cached_start_code_units_offset: (_CodeUnitsCache cache) -> Integer - def cached_end_code_units_offset: (_CodeUnitsCache cache) -> Integer - def start_column: () -> Integer - def end_column: () -> Integer - def start_character_column: () -> Integer - def end_character_column: () -> Integer - def cached_start_code_units_column: (_CodeUnitsCache cache) -> Integer - def cached_end_code_units_column: (_CodeUnitsCache cache) -> Integer - def leading_comments: () -> Array[Comment] - def trailing_comments: () -> Array[Comment] - end - - interface _Field - def fields: (_Value value) -> entry_values - end - - type entry_value = untyped - type entry_values = Hash[Symbol, entry_value] - - class Entry - class MissingValueError < StandardError - end - - def initialize: (Repository repository) -> void - - def filepath: () -> String - - def start_line: () -> Integer - def end_line: () -> Integer - - def start_offset: () -> Integer - def end_offset: () -> Integer - def start_character_offset: () -> Integer - def end_character_offset: () -> Integer - def start_code_units_offset: () -> Integer - def end_code_units_offset: () -> Integer - - def start_column: () -> Integer - def end_column: () -> Integer - def start_character_column: () -> Integer - def end_character_column: () -> Integer - def start_code_units_column: () -> Integer - def end_code_units_column: () -> Integer - - def leading_comments: () -> Array[CommentsField::Comment] - def trailing_comments: () -> Array[CommentsField::Comment] - def comments: () -> Array[CommentsField::Comment] - - private - - def fetch_value: (Symbol name) -> entry_value - def values: () -> entry_values - end - - class Source - attr_reader value: untyped - - def initialize: (untyped value) -> void - - def result: () -> ParseResult - def code_units_cache: (Encoding encoding) -> _CodeUnitsCache - end - - class SourceFilepath < Source - def result: () -> ParseResult - end - - class SourceString < Source - def result: () -> ParseResult - end - - class FilepathField - attr_reader value: String - - def initialize: (String value) -> void - - def fields: (_Value value) -> entry_values - end - - class LinesField - def fields: (_Value value) -> entry_values - end - - class OffsetsField - def fields: (_Value value) -> entry_values - end - - class CharacterOffsetsField - def fields: (_Value value) -> entry_values - end - - class CodeUnitOffsetsField - attr_reader repository: Repository - attr_reader encoding: Encoding - - def initialize: (Repository repository, Encoding encoding) -> void - def fields: (_Value value) -> entry_values - - private - - def cache: () -> _CodeUnitsCache - end - - class ColumnsField - def fields: (_Value value) -> entry_values - end - - class CharacterColumnsField - def fields: (_Value value) -> entry_values - end - - class CodeUnitColumnsField - attr_reader repository: Repository - attr_reader encoding: Encoding - - def initialize: (Repository repository, Encoding encoding) -> void - def fields: (_Value value) -> entry_values - - private - - def cache: () -> _CodeUnitsCache - end - - class CommentsField - class Comment - attr_reader slice: String - - def initialize: (String slice) -> void - end - - private - - def comments: (entry_value value) -> Array[Comment] - end - - class LeadingCommentsField < CommentsField - def fields: (_Value value) -> entry_values - end - - class TrailingCommentsField < CommentsField - def fields: (_Value value) -> entry_values - end - - class Repository - class ConfigurationError < StandardError - end - - attr_reader source: Source - attr_reader fields: Hash[Symbol, _Field] - attr_reader entries: Hash[Integer, Hash[Symbol, Entry]] - - def initialize: (Source source) -> void - - def code_units_cache: (Encoding encoding) -> _CodeUnitsCache - - def filepath: () -> self - def lines: () -> self - def offsets: () -> self - def character_offsets: () -> self - def code_unit_offsets: (Encoding encoding) -> self - def columns: () -> self - def character_columns: () -> self - def code_unit_columns: (Encoding encoding) -> self - def leading_comments: () -> self - def trailing_comments: () -> self - def comments: () -> self - - private - - def field: (Symbol name, _Field) -> self - end - - def self.filepath: (String value) -> Repository - def self.string: (String value) -> Repository - end -end diff --git a/sig/prism/serialize.rbs b/sig/prism/serialize.rbs deleted file mode 100644 index 71a7c5c1c9..0000000000 --- a/sig/prism/serialize.rbs +++ /dev/null @@ -1,8 +0,0 @@ -module Prism - module Serialize - def self.load_parse: (String, String, bool) -> ParseResult - def self.load_lex: (String, String, bool) -> LexResult - def self.load_parse_comments: (String, String, bool) -> Array[comment] - def self.load_parse_lex: (String, String, bool) -> ParseLexResult - end -end diff --git a/sig/prism/string_query.rbs b/sig/prism/string_query.rbs deleted file mode 100644 index 098746e552..0000000000 --- a/sig/prism/string_query.rbs +++ /dev/null @@ -1,11 +0,0 @@ -module Prism - class StringQuery - attr_reader string: String - - def initialize: (String string) -> void - - def local?: () -> bool - def constant?: () -> bool - def method_name?: () -> bool - end -end diff --git a/templates/lib/prism/compiler.rb.erb b/templates/lib/prism/compiler.rb.erb index 031557a221..13317cac04 100644 --- a/templates/lib/prism/compiler.rb.erb +++ b/templates/lib/prism/compiler.rb.erb @@ -1,3 +1,6 @@ +#-- +# rbs_inline: enabled + module Prism # A compiler is a visitor that returns the value of each node as it visits. # This is as opposed to a visitor which will only walk the tree. This can be @@ -18,22 +21,29 @@ module Prism # class Compiler < Visitor # Visit an individual node. + #-- + #: (node?) -> untyped def visit(node) # :nodoc: node&.accept(self) end # Visit a list of nodes. + #-- + #: (Array[node?]) -> untyped def visit_all(nodes) # :nodoc: nodes.map { |node| node&.accept(self) } end # Visit the child nodes of the given node. + #-- + #: (node) -> Array[untyped] def visit_child_nodes(node) # :nodoc: node.each_child_node.map { |node| node.accept(self) } end <%- nodes.each_with_index do |node, index| -%> <%= "\n" if index != 0 -%> + #: (<%= node.name %>) -> Array[untyped] def visit_<%= node.human %>(node) # :nodoc: node.each_child_node.map { |node| node.accept(self) } end diff --git a/templates/lib/prism/dispatcher.rb.erb b/templates/lib/prism/dispatcher.rb.erb index e4ca84db24..5991b0c904 100644 --- a/templates/lib/prism/dispatcher.rb.erb +++ b/templates/lib/prism/dispatcher.rb.erb @@ -1,3 +1,6 @@ +#-- +# rbs_inline: enabled + module Prism # The dispatcher class fires events for nodes that are found while walking an # AST to all registered listeners. It's useful for performing different types @@ -32,26 +35,35 @@ module Prism # dispatcher.dispatch_once(integer) # class Dispatcher < Visitor - # attr_reader listeners: Hash[Symbol, Array[Listener]] - attr_reader :listeners + # A hash mapping event names to arrays of listeners that should be notified + # when that event is fired. + attr_reader :listeners #: Hash[Symbol, Array[untyped]] # Initialize a new dispatcher. + #-- + #: () -> void def initialize @listeners = {} end # Register a listener for one or more events. + #-- + #: (untyped, *Symbol) -> void def register(listener, *events) register_events(listener, events) end # Register all public methods of a listener that match the pattern # `on__(enter|leave)`. + #-- + #: (untyped) -> void def register_public_methods(listener) register_events(listener, listener.public_methods(false).grep(/\Aon_.+_(?:enter|leave)\z/)) end # Register a listener for the given events. + #-- + #: (untyped, Array[Symbol]) -> void private def register_events(listener, events) # :nodoc: events.each { |event| (listeners[event] ||= []) << listener } end @@ -60,11 +72,14 @@ module Prism alias dispatch visit # Dispatches a single event for `node` to all registered listeners. + #-- + #: (node node) -> void def dispatch_once(node) node.accept(DispatchOnce.new(listeners)) end <%- nodes.each do |node| -%> + #: (<%= node.name %> node) -> void def visit_<%= node.human %>(node) # :nodoc: listeners[:on_<%= node.human %>_enter]&.each { |listener| listener.on_<%= node.human %>_enter(node) } super @@ -73,14 +88,17 @@ module Prism <%- end -%> class DispatchOnce < Visitor # :nodoc: - attr_reader :listeners + attr_reader :listeners #: Hash[Symbol, Array[untyped]] + #: (Hash[Symbol, Array[untyped]] listeners) -> void def initialize(listeners) @listeners = listeners end <%- nodes.each do |node| -%> # Dispatch enter and leave events for <%= node.name %> nodes. + #-- + #: (<%= node.name %> node) -> void def visit_<%= node.human %>(node) listeners[:on_<%= node.human %>_enter]&.each { |listener| listener.on_<%= node.human %>_enter(node) } listeners[:on_<%= node.human %>_leave]&.each { |listener| listener.on_<%= node.human %>_leave(node) } diff --git a/templates/lib/prism/dot_visitor.rb.erb b/templates/lib/prism/dot_visitor.rb.erb index 13c53af0d4..bdac9cfd3c 100644 --- a/templates/lib/prism/dot_visitor.rb.erb +++ b/templates/lib/prism/dot_visitor.rb.erb @@ -1,3 +1,6 @@ +#-- +# rbs_inline: enabled + require "cgi/escape" require "cgi/util" unless defined?(CGI::EscapeExt) @@ -6,14 +9,18 @@ module Prism # subtree into a graphviz dot graph. class DotVisitor < Visitor class Field # :nodoc: - attr_reader :name, :value, :port + attr_reader :name #: String + attr_reader :value #: String? + attr_reader :port #: bool + #: (String name, String? value, bool port) -> void def initialize(name, value, port) @name = name @value = value @port = port end + #: () -> String def to_dot if port "#{name}" @@ -24,17 +31,21 @@ module Prism end class Table # :nodoc: - attr_reader :name, :fields + attr_reader :name #: String + attr_reader :fields #: Array[Field] + #: (String name) -> void def initialize(name) @name = name @fields = [] end + #: (String name, ?String? value, ?port: bool) -> void def field(name, value = nil, port: false) fields << Field.new(name, value, port) end + #: () -> String def to_dot dot = <<~DOT @@ -50,26 +61,31 @@ module Prism end class Digraph # :nodoc: - attr_reader :nodes, :waypoints, :edges + attr_reader :nodes, :waypoints, :edges #: Array[String] + #: () -> void def initialize @nodes = [] @waypoints = [] @edges = [] end + #: (String value) -> void def node(value) nodes << value end + #: (String value) -> void def waypoint(value) waypoints << value end + #: (String value) -> void def edge(value) edges << value end + #: () -> String def to_dot <<~DOT digraph "Prism" { @@ -93,19 +109,24 @@ module Prism private_constant :Field, :Table, :Digraph # The digraph that is being built. - attr_reader :digraph + attr_reader :digraph #: Digraph # Initialize a new dot visitor. + #-- + #: () -> void def initialize @digraph = Digraph.new end # Convert this visitor into a graphviz dot graph string. + #-- + #: () -> String def to_dot digraph.to_dot end <%- nodes.each do |node| -%> + # (<%= node.name %>) -> void def visit_<%= node.human %>(node) # :nodoc: table = Table.new("<%= node.name %>") id = node_id(node) @@ -151,7 +172,7 @@ module Prism <%- end -%> <%- end -%> - digraph.nodes << <<~DOT + digraph.node(<<~DOT) #{id} [ label=<#{table.to_dot.gsub(/\n/, "\n ")}> ]; @@ -164,11 +185,15 @@ module Prism private # Generate a unique node ID for a node throughout the digraph. + #-- + #: (node) -> String def node_id(node) # :nodoc: "Node_#{node.object_id}" end # Inspect a location to display the start and end line and columns in bytes. + #-- + #: (Location) -> String def location_inspect(location) # :nodoc: "(#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column})" end @@ -176,6 +201,8 @@ module Prism # Inspect a node that has <%= flag.human %> flags to display the flags as a # comma-separated list. + #-- + #: (<%= nodes.filter_map { |node| node.name if node.flags == flag }.join(" | ") %> node) -> String def <%= flag.human %>_inspect(node) # :nodoc: flags = [] #: Array[String] <%- flag.values.each do |value| -%> diff --git a/templates/lib/prism/dsl.rb.erb b/templates/lib/prism/dsl.rb.erb index e16ebb7110..a75b8b253e 100644 --- a/templates/lib/prism/dsl.rb.erb +++ b/templates/lib/prism/dsl.rb.erb @@ -1,3 +1,6 @@ +#-- +# rbs_inline: enabled + module Prism # The DSL module provides a set of methods that can be used to create prism # nodes in a more concise manner. For example, instead of writing: @@ -56,17 +59,31 @@ module Prism extend self # Create a new Source object. + #-- + #: (String string) -> Source def source(string) Source.for(string) end # Create a new Location object. + #-- + #: (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location def location(source: default_source, start_offset: 0, length: 0) Location.new(source, start_offset, length) end <%- nodes.each do |node| -%> + <%- + params = [ + ["source", "Source"], + ["node_id", "Integer"], + ["location", "Location"], + ["flags", "Integer"] + ].concat(node.fields.map { |field| [field.name, field.rbs_class] }) + -%> # Create a new <%= node.name %> node. + #-- + #: (<%= params.map { |(name, type)| "?#{name}: #{type}" }.join(", ") %>) -> <%= node.name %> def <%= node.human %>(<%= ["source: default_source", "node_id: 0", "location: default_location", "flags: 0", *node.fields.map { |field| case field when Prism::Template::NodeField @@ -100,6 +117,8 @@ module Prism <%- flags.each do |flag| -%> # Retrieve the value of one of the <%= flag.name %> flags. + #-- + #: (Symbol name) -> Integer def <%= flag.human.chomp("s") %>(name) case name <%- flag.values.each do |value| -%> @@ -114,18 +133,24 @@ module Prism # The default source object that gets attached to nodes and locations if no # source is specified. + #-- + #: () -> Source def default_source Source.for("") end # The default location object that gets attached to nodes if no location is # specified, which uses the given source. + #-- + #: () -> Location def default_location Location.new(default_source, 0, 0) end # The default node that gets attached to nodes if no node is specified for a # required node field. + #-- + #: (Source source, Location location) -> node def default_node(source, location) MissingNode.new(source, -1, location, 0) end diff --git a/templates/lib/prism/inspect_visitor.rb.erb b/templates/lib/prism/inspect_visitor.rb.erb index 9a33cb8110..820f5ae75f 100644 --- a/templates/lib/prism/inspect_visitor.rb.erb +++ b/templates/lib/prism/inspect_visitor.rb.erb @@ -1,3 +1,6 @@ +#-- +# rbs_inline: enabled + module Prism # This visitor is responsible for composing the strings that get returned by # the various #inspect methods defined on each of the nodes. @@ -7,8 +10,9 @@ module Prism # when we hit an element in that list. In this case, we have a special # command that replaces the subsequent indent with the given value. class Replace # :nodoc: - attr_reader :value + attr_reader :value #: String + #: (String value) -> void def initialize(value) @value = value end @@ -17,18 +21,25 @@ module Prism private_constant :Replace # The current prefix string. - attr_reader :indent # :nodoc: + # :stopdoc: + attr_reader :indent #: String + # :startdoc: # The list of commands that we need to execute in order to compose the # final string. - attr_reader :commands # :nodoc: + #: stopdoc: + attr_reader :commands #: Array[[String | node | Replace, String]] + # :startdoc: + #: (?String indent) -> void def initialize(indent = +"") # :nodoc: @indent = indent @commands = [] end # Compose an inspect string for the given node. + #-- + #: (node node) -> String def self.compose(node) visitor = new node.accept(visitor) @@ -36,6 +47,8 @@ module Prism end # Compose the final string. + #-- + #: () -> String def compose # :nodoc: buffer = +"" replace = nil @@ -65,6 +78,7 @@ module Prism end <%- nodes.each do |node| -%> + #: (<%= node.name %> node) -> void def visit_<%= node.human %>(node) # :nodoc: commands << [inspect_node(<%= node.name.inspect %>, node), indent] <%- (fields = [node.flags || Prism::Template::Flags.empty, *node.fields]).each_with_index do |field, index| -%> @@ -112,12 +126,16 @@ module Prism private # Compose a header for the given node. + #-- + #: (String name, node node) -> String def inspect_node(name, node) # :nodoc: location = node.location "@ #{name} (location: (#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column}))\n" end # Compose a string representing the given inner location field. + #-- + #: (Location? location) -> String def inspect_location(location) # :nodoc: if location "(#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column}) = #{location.slice.inspect}" diff --git a/templates/lib/prism/mutation_compiler.rb.erb b/templates/lib/prism/mutation_compiler.rb.erb index b223860f2f..2d555048d2 100644 --- a/templates/lib/prism/mutation_compiler.rb.erb +++ b/templates/lib/prism/mutation_compiler.rb.erb @@ -1,3 +1,6 @@ +#-- +# rbs_inline: enabled + module Prism # This visitor walks through the tree and copies each node as it is being # visited. This is useful for consumers that want to mutate the tree, as you @@ -5,6 +8,7 @@ module Prism class MutationCompiler < Compiler <%- nodes.each_with_index do |node, index| -%> <%= "\n" if index != 0 -%> + #: (<%= node.name %>) -> node? def visit_<%= node.human %>(node) # :nodoc: <%- fields = node.fields.select { |field| [Prism::Template::NodeField, Prism::Template::OptionalNodeField, Prism::Template::NodeListField].include?(field.class) } -%> <%- if fields.any? -%> diff --git a/templates/lib/prism/node.rb.erb b/templates/lib/prism/node.rb.erb index 8c88529c66..2e42eeea13 100644 --- a/templates/lib/prism/node.rb.erb +++ b/templates/lib/prism/node.rb.erb @@ -1,26 +1,49 @@ -# :markup: markdown +#-- +# rbs_inline: enabled module Prism + # @rbs! + # interface _Repository + # def enter: (Integer node_id, Symbol field_name) -> Relocation::Entry + # end + # + # interface _Node + # def deconstruct: () -> Array[Prism::node?] + # def inspect: () -> String + # end + # + # type node = Node & _Node + # This represents a node in the tree. It is the parent class of all of the # various node types. class Node # A pointer to the source that this node was created from. - attr_reader :source # :nodoc: + # :stopdoc: + attr_reader :source #: Source private :source + # :startdoc: # A unique identifier for this node. This is used in a very specific # use case where you want to keep around a reference to a node without # having to keep around the syntax tree in memory. This unique identifier # will be consistent across multiple parses of the same source code. - attr_reader :node_id + attr_reader :node_id #: Integer + + # The location associated with this node. For lazily loading Location + # objects, we keep it as a packed integer until it is accessed. + # @rbs @location: Location | Integer # Save this node using a saved source so that it can be retrieved later. + #-- + #: (_Repository repository) -> Relocation::Entry def save(repository) repository.enter(node_id, :itself) end # A Location instance that represents the location of this node in the # source. + #-- + #: () -> Location def location location = @location return location if location.is_a?(Location) @@ -28,6 +51,8 @@ module Prism end # Save the location using a saved source so that it can be retrieved later. + #-- + #: (_Repository repository) -> Relocation::Entry def save_location(repository) repository.enter(node_id, :location) end @@ -38,22 +63,30 @@ module Prism # -------------------------------------------------------------------------- # Delegates to [`start_line`](rdoc-ref:Location#start_line) of the associated location object. + #-- + #: () -> Integer def start_line location.start_line end # Delegates to [`end_line`](rdoc-ref:Location#end_line) of the associated location object. + #-- + #: () -> Integer def end_line location.end_line end # Delegates to [`start_offset`](rdoc-ref:Location#start_offset) of the associated location object. + #-- + #: () -> Integer def start_offset location = @location location.is_a?(Location) ? location.start_offset : location >> 32 end # Delegates to [`end_offset`](rdoc-ref:Location#end_offset) of the associated location object. + #-- + #: () -> Integer def end_offset location = @location location.is_a?(Location) ? location.end_offset : ((location >> 32) + (location & 0xFFFFFFFF)) @@ -61,73 +94,99 @@ module Prism # Delegates to [`start_character_offset`](rdoc-ref:Location#start_character_offset) # of the associated location object. + #-- + #: () -> Integer def start_character_offset location.start_character_offset end # Delegates to [`end_character_offset`](rdoc-ref:Location#end_character_offset) # of the associated location object. + #-- + #: () -> Integer def end_character_offset location.end_character_offset end # Delegates to [`cached_start_code_units_offset`](rdoc-ref:Location#cached_start_code_units_offset) # of the associated location object. + #-- + #: (_CodeUnitsCache cache) -> Integer def cached_start_code_units_offset(cache) location.cached_start_code_units_offset(cache) end # Delegates to [`cached_end_code_units_offset`](rdoc-ref:Location#cached_end_code_units_offset) # of the associated location object. + #-- + #: (_CodeUnitsCache cache) -> Integer def cached_end_code_units_offset(cache) location.cached_end_code_units_offset(cache) end # Delegates to [`start_column`](rdoc-ref:Location#start_column) of the associated location object. + #-- + #: () -> Integer def start_column location.start_column end # Delegates to [`end_column`](rdoc-ref:Location#end_column) of the associated location object. + #-- + #: () -> Integer def end_column location.end_column end # Delegates to [`start_character_column`](rdoc-ref:Location#start_character_column) # of the associated location object. + #-- + #: () -> Integer def start_character_column location.start_character_column end # Delegates to [`end_character_column`](rdoc-ref:Location#end_character_column) # of the associated location object. + #-- + #: () -> Integer def end_character_column location.end_character_column end # Delegates to [`cached_start_code_units_column`](rdoc-ref:Location#cached_start_code_units_column) # of the associated location object. + #-- + #: (_CodeUnitsCache cache) -> Integer def cached_start_code_units_column(cache) location.cached_start_code_units_column(cache) end # Delegates to [`cached_end_code_units_column`](rdoc-ref:Location#cached_end_code_units_column) # of the associated location object. + #-- + #: (_CodeUnitsCache cache) -> Integer def cached_end_code_units_column(cache) location.cached_end_code_units_column(cache) end # Delegates to [`leading_comments`](rdoc-ref:Location#leading_comments) of the associated location object. + #-- + #: () -> Array[Comment] def leading_comments location.leading_comments end # Delegates to [`trailing_comments`](rdoc-ref:Location#trailing_comments) of the associated location object. + #-- + #: () -> Array[Comment] def trailing_comments location.trailing_comments end # Delegates to [`comments`](rdoc-ref:Location#comments) of the associated location object. + #-- + #: () -> Array[Comment] def comments location.comments end @@ -135,6 +194,8 @@ module Prism # :section: # Returns all of the lines of the source code associated with this node. + #-- + #: () -> Array[String] def source_lines location.source_lines end @@ -144,6 +205,8 @@ module Prism alias script_lines source_lines # Slice the location of the node from the source. + #-- + #: () -> String def slice location.slice end @@ -151,27 +214,37 @@ module Prism # Slice the location of the node from the source, starting at the beginning # of the line that the location starts on, ending at the end of the line # that the location ends on. + #-- + #: () -> String def slice_lines location.slice_lines end # An bitset of flags for this node. There are certain flags that are common # for all nodes, and then some nodes have specific flags. - attr_reader :flags # :nodoc: + # :stopdoc: + attr_reader :flags #: Integer protected :flags + # :startdoc: # Returns true if the node has the newline flag set. + #-- + #: () -> bool def newline? flags.anybits?(NodeFlags::NEWLINE) end # Returns true if the node has the static literal flag set. + #-- + #: () -> bool def static_literal? flags.anybits?(NodeFlags::STATIC_LITERAL) end # Similar to inspect, but respects the current level of indentation given by # the pretty print object. + #-- + #: (PP q) -> void def pretty_print(q) # :nodoc: q.seplist(inspect.chomp.each_line, -> { q.breakable }) do |line| q.text(line.chomp) @@ -180,6 +253,8 @@ module Prism end # Convert this node into a graphviz dot graph string. + #-- + #: () -> String def to_dot # @type self: node DotVisitor.new.tap { |visitor| accept(visitor) }.to_dot @@ -191,9 +266,11 @@ module Prism # # Important to note is that the column given to this method should be in # bytes, as opposed to characters or code units. + #-- + #: (Integer line, Integer column) -> Array[node] def tunnel(line, column) - queue = [self] #: Array[Prism::node] - result = [] #: Array[Prism::node] + queue = [self] #: Array[node] + result = [] #: Array[node] offset = source.byte_offset(line, column) while (node = queue.shift) @@ -215,9 +292,10 @@ module Prism # particular condition. # # node.breadth_first_search { |node| node.node_id == node_id } - # + #-- + #: () { (node) -> bool } -> node? def breadth_first_search(&block) - queue = [self] #: Array[Prism::node] + queue = [self] #: Array[node] while (node = queue.shift) return node if yield node @@ -233,7 +311,8 @@ module Prism # particular condition. # # node.breadth_first_search_all { |node| node.is_a?(Prism::CallNode) } - # + #-- + #: () { (node) -> bool } -> Array[node] def breadth_first_search_all(&block) queue = [self] #: Array[Prism::node] results = [] #: Array[Prism::node] @@ -250,6 +329,8 @@ module Prism # Returns a list of the fields that exist for this node class. Fields # describe the structure of the node. This kind of reflection is useful for # things like recursively visiting each node _and_ field in the tree. + #-- + #: () -> Array[Reflection::Field] def self.fields # This method should only be called on subclasses of Node, not Node # itself. @@ -265,12 +346,16 @@ module Prism # -------------------------------------------------------------------------- # Accepts a visitor and calls back into the specialized visit function. + #-- + #: (_Visitor visitor) -> untyped def accept(visitor) raise NoMethodError, "undefined method `accept' for #{inspect}" end # Returns an array of child nodes, including `nil`s in the place of optional # nodes that were not present. + #-- + #: () -> Array[node?] def child_nodes raise NoMethodError, "undefined method `child_nodes' for #{inspect}" end @@ -280,23 +365,32 @@ module Prism # With a block given, yields each child node. Without a block, returns # an enumerator that contains each child node. Excludes any `nil`s in # the place of optional nodes that were not present. + #-- + #: () { (node) -> void } -> void + #: () -> Enumerator[node, void] def each_child_node raise NoMethodError, "undefined method `each_child_node' for #{inspect}" end # Returns an array of child nodes, excluding any `nil`s in the place of # optional nodes that were not present. + #-- + #: () -> Array[node] def compact_child_nodes raise NoMethodError, "undefined method `compact_child_nodes' for #{inspect}" end # Returns an array of child nodes and locations that could potentially have # comments attached to them. + #-- + #: () -> Array[node | Location] def comment_targets raise NoMethodError, "undefined method `comment_targets' for #{inspect}" end # Returns a string representation of the node. + #-- + #: () -> String def inspect raise NoMethodError, "undefined method `inspect' for #{inspect}" end @@ -313,6 +407,8 @@ module Prism # it uses a single integer comparison, but also because if you're on CRuby # you can take advantage of the fact that case statements with all symbol # keys will use a jump table. + #-- + #: () -> Symbol def type raise NoMethodError, "undefined method `type' for #{inspect}" end @@ -321,6 +417,8 @@ module Prism # splitting on the type of the node without having to do a long === chain. # Note that like #type, it will still be slower than using == for a single # class, but should be faster in a case statement or an array comparison. + #-- + #: () -> Symbol def self.type raise NoMethodError, "undefined method `type' for #{inspect}" end @@ -331,7 +429,13 @@ module Prism #<%= line %> <%- end -%> class <%= node.name -%> < Node + <%- node.fields.each do |field| -%> + # @rbs @<%= field.name %>: <%= field.rbs_class %> + <%- end -%> + # Initialize a new <%= node.name %> node. + #-- + #: (Source source, Integer node_id, Location location, Integer flags, <%= node.fields.map { |field| "#{field.rbs_class} #{field.name}" }.join(", ") %>) -> void def initialize(<%= ["source", "node_id", "location", "flags", *node.fields.map(&:name)].join(", ") %>) @source = source @node_id = node_id @@ -357,11 +461,15 @@ module Prism # ---------------------------------------------------------------------------------- # See Node.accept. + #-- + #: (_Visitor visitor) -> untyped def accept(visitor) visitor.visit_<%= node.human %>(self) end # See Node.child_nodes. + #-- + #: () -> Array[node?] def child_nodes [<%= node.fields.map { |field| case field @@ -372,6 +480,9 @@ module Prism end # See Node.each_child_node. + #-- + #: () { (node) -> void } -> void + #: () -> Enumerator[node, void] def each_child_node return to_enum(:each_child_node) unless block_given? @@ -380,7 +491,7 @@ module Prism <%- when Prism::Template::NodeField -%> yield <%= field.name %> <%- when Prism::Template::OptionalNodeField -%> - yield <%= field.name %> if <%= field.name %> + if (<%= field.name %> = self.<%= field.name %>); yield <%= field.name %>; end <%- when Prism::Template::NodeListField -%> <%= field.name %>.each { |node| yield node } <%- end -%> @@ -388,6 +499,8 @@ module Prism end # See Node.compact_child_nodes. + #-- + #: () -> Array[node] def compact_child_nodes <%- if node.fields.any? { |field| field.is_a?(Prism::Template::OptionalNodeField) } -%> compact = [] #: Array[Prism::node] @@ -396,7 +509,7 @@ module Prism <%- when Prism::Template::NodeField -%> compact << <%= field.name %> <%- when Prism::Template::OptionalNodeField -%> - compact << <%= field.name %> if <%= field.name %> + if (<%= field.name %> = self.<%= field.name %>); compact << <%= field.name %>; end <%- when Prism::Template::NodeListField -%> compact.concat(<%= field.name %>) <%- end -%> @@ -413,6 +526,8 @@ module Prism end # See Node.comment_targets. + #-- + #: () -> Array[node | Location] def comment_targets [<%= node.fields.map { |field| case field @@ -426,26 +541,34 @@ module Prism # copy(**fields) -> <%= node.name %> # # Creates a copy of self with the given fields, using self as the template. + #-- + #: (?node_id: Integer, ?location: Location, ?flags: Integer, <%= node.fields.map { |field| "?#{field.name}: #{field.rbs_class}" }.join(", ") %>) -> <%= node.name %> def copy(<%= (["node_id", "location", "flags"] + node.fields.map(&:name)).map { |field| "#{field}: self.#{field}" }.join(", ") %>) <%= node.name %>.new(<%= ["source", "node_id", "location", "flags", *node.fields.map(&:name)].join(", ") %>) end alias deconstruct child_nodes + #: (Array[Symbol]? keys) -> Hash[Symbol, untyped] def deconstruct_keys(keys) # :nodoc: { <%= (["node_id: node_id", "location: location"] + node.fields.map { |field| "#{field.name}: #{field.name}" }).join(", ") %> } end # See `Node#type`. + #-- + #: () -> :<%= node.human %> def type :<%= node.human %> end # See `Node.type`. + #-- + #: () -> :<%= node.human %> def self.type :<%= node.human %> end + #: () -> String def inspect # :nodoc: InspectVisitor.compose(self) end @@ -456,6 +579,8 @@ module Prism <%- node_flags.values.each do |value| -%> # :category: Flags # <%= value.comment %> + #-- + #: () -> bool def <%= value.name.downcase %>? flags.anybits?(<%= node_flags.name %>::<%= value.name %>) end @@ -476,6 +601,8 @@ module Prism #<%= line %> <%- end -%> <%- end -%> + #-- + #: () -> Location def <%= field.name %> location = @<%= field.name %> return location if location.is_a?(Location) @@ -485,6 +612,8 @@ module Prism # :category: Repository # Save the <%= field.name %> location using the given saved source so that # it can be retrieved later. + #-- + #: (_Repository repository) -> Relocation::Entry def save_<%= field.name %>(repository) repository.enter(node_id, :<%= field.name %>) end @@ -501,6 +630,8 @@ module Prism #<%= line %> <%- end -%> <%- end -%> + #-- + #: () -> Location? def <%= field.name %> location = @<%= field.name %> case location @@ -516,6 +647,8 @@ module Prism # :category: Repository # Save the <%= field.name %> location using the given saved source so that # it can be retrieved later. + #-- + #: (_Repository repository) -> Relocation::Entry? def save_<%= field.name %>(repository) repository.enter(node_id, :<%= field.name %>) unless @<%= field.name %>.nil? end @@ -530,6 +663,8 @@ module Prism #<%= line %> <%- end -%> <%- end -%> + #-- + #: () -> <%= field.rbs_class %> def <%= field.name %> @<%= field.name %> end @@ -547,6 +682,8 @@ module Prism # <%= field.name.delete_suffix("_loc") %> -> String # # Slice the location of <%= field.name %> from the source. + #-- + #: () -> String def <%= field.name.delete_suffix("_loc") %> <%= field.name %>.slice end @@ -558,6 +695,8 @@ module Prism # <%= field.name.delete_suffix("_loc") %> -> String | nil # # Slice the location of <%= field.name %> from the source. + #-- + #: () -> String? def <%= field.name.delete_suffix("_loc") %> <%= field.name %>&.slice end @@ -566,6 +705,7 @@ module Prism <%- end -%> # :section: + #: (untyped other) -> bool def ===(other) # :nodoc: other.is_a?(<%= node.name %>)<%= " &&" if (fields = [*node.flags, *node.fields]).any? %> <%- fields.each_with_index do |field, index| -%> diff --git a/templates/lib/prism/reflection.rb.erb b/templates/lib/prism/reflection.rb.erb index 6c8b2f4d25..0012f120b2 100644 --- a/templates/lib/prism/reflection.rb.erb +++ b/templates/lib/prism/reflection.rb.erb @@ -1,3 +1,6 @@ +#-- +# rbs_inline: enabled + module Prism # The Reflection module provides the ability to reflect on the structure of # the syntax tree itself, as opposed to looking at a single syntax tree. This @@ -7,9 +10,11 @@ module Prism # for all other field types. class Field # The name of the field. - attr_reader :name + attr_reader :name #: Symbol # Initializes the field with the given name. + #-- + #: (Symbol name) -> void def initialize(name) @name = name end @@ -83,9 +88,11 @@ module Prism # the bitset should be accessed through their query methods. class FlagsField < Field # The names of the flags in the bitset. - attr_reader :flags + attr_reader :flags #: Array[Symbol] # Initializes the flags field with the given name and flags. + #-- + #: (Symbol name, Array[Symbol] flags) -> void def initialize(name, flags) super(name) @flags = flags @@ -93,6 +100,8 @@ module Prism end # Returns the fields for the given node. + #-- + #: (singleton(Node) node) -> Array[Field] def self.fields_for(node) case node.type <%- nodes.each do |node| -%> diff --git a/templates/lib/prism/serialize.rb.erb b/templates/lib/prism/serialize.rb.erb index 63ef07cb6e..433b520788 100644 --- a/templates/lib/prism/serialize.rb.erb +++ b/templates/lib/prism/serialize.rb.erb @@ -1,3 +1,6 @@ +#-- +# rbs_inline: enabled + require "stringio" require_relative "polyfill/unpack1" @@ -20,6 +23,8 @@ module Prism # # The formatting of the source of this method is purposeful to illustrate # the structure of the serialized data. + #-- + #: (String input, String serialized, bool freeze) -> ParseResult def self.load_parse(input, serialized, freeze) input = input.dup source = Source.for(input) @@ -43,7 +48,7 @@ module Prism constant_pool = ConstantPool.new(input, serialized, cpool_base, cpool_size) - node = loader.load_node(constant_pool, encoding, freeze) + node = loader.load_node(constant_pool, encoding, freeze) #: ProgramNode loader.load_constant_pool(constant_pool) raise unless loader.eof? @@ -73,6 +78,8 @@ module Prism # # The formatting of the source of this method is purposeful to illustrate # the structure of the serialized data. + #-- + #: (String input, String serialized, bool freeze) -> LexResult def self.load_lex(input, serialized, freeze) source = Source.for(input) loader = Loader.new(source, serialized) @@ -117,6 +124,8 @@ module Prism # # The formatting of the source of this method is purposeful to illustrate # the structure of the serialized data. + #-- + #: (String input, String serialized, bool freeze) -> Array[Comment] def self.load_parse_comments(input, serialized, freeze) source = Source.for(input) loader = Loader.new(source, serialized) @@ -139,6 +148,8 @@ module Prism # # The formatting of the source of this method is purposeful to illustrate # the structure of the serialized data. + #-- + #: (String input, String serialized, bool freeze) -> ParseLexResult def self.load_parse_lex(input, serialized, freeze) source = Source.for(input) loader = Loader.new(source, serialized) @@ -162,11 +173,11 @@ module Prism constant_pool = ConstantPool.new(input, serialized, cpool_base, cpool_size) - node = loader.load_node(constant_pool, encoding, freeze) + node = loader.load_node(constant_pool, encoding, freeze) #: ProgramNode loader.load_constant_pool(constant_pool) raise unless loader.eof? - value = [node, tokens] + value = [node, tokens] #: [ProgramNode, Array[[Token, Integer]]] result = ParseLexResult.new(value, comments, magic_comments, data_loc, errors, warnings, source) tokens.each do |token| @@ -189,8 +200,14 @@ module Prism end class ConstantPool # :nodoc: - attr_reader :size + attr_reader :size #: Integer + + # @rbs @input: String + # @rbs @serialized: String + # @rbs @base: Integer + # @rbs @pool: Array[Symbol?] + #: (String input, String serialized, Integer base, Integer size) -> void def initialize(input, serialized, base, size) @input = input @serialized = serialized @@ -199,17 +216,18 @@ module Prism @pool = Array.new(size, nil) end + #: (Integer index, Encoding encoding) -> Symbol def get(index, encoding) @pool[index] ||= begin offset = @base + index * 8 - start = @serialized.unpack1("L", offset: offset) - length = @serialized.unpack1("L", offset: offset + 4) + start = @serialized.unpack1("L", offset: offset) #: Integer + length = @serialized.unpack1("L", offset: offset + 4) #: Integer if start.nobits?(1 << 31) - @input.byteslice(start, length).force_encoding(encoding).to_sym + (@input.byteslice(start, length) or raise).force_encoding(encoding).to_sym else - @serialized.byteslice(start & ((1 << 31) - 1), length).force_encoding(encoding).to_sym + (@serialized.byteslice(start & ((1 << 31) - 1), length) or raise).force_encoding(encoding).to_sym end end end @@ -217,6 +235,7 @@ module Prism if RUBY_ENGINE == "truffleruby" # StringIO is synchronized and that adds a high overhead on TruffleRuby. + # @rbs skip class FastStringIO # :nodoc: attr_accessor :pos @@ -246,8 +265,11 @@ module Prism end class Loader # :nodoc: - attr_reader :input, :io, :source + attr_reader :input #: String + attr_reader :io #: StringIO + attr_reader :source #: Source + #: (Source source, String serialized) -> void def initialize(source, serialized) @input = source.source.dup raise unless serialized.encoding == Encoding::BINARY @@ -256,40 +278,46 @@ module Prism define_load_node_lambdas if RUBY_ENGINE != "ruby" end + #: () -> bool def eof? io.getbyte io.eof? end + #: (ConstantPool constant_pool) -> void def load_constant_pool(constant_pool) trailer = 0 constant_pool.size.times do |index| - start, length = io.read(8).unpack("L2") + start, length = (io.read(8) or raise).unpack("L2") #: [Integer, Integer] trailer += length if start.anybits?(1 << 31) end io.read(trailer) end + #: () -> void def load_header raise "Invalid serialization" if io.read(5) != "PRISM" - raise "Invalid serialization" if io.read(3).unpack("C3") != [MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION] + raise "Invalid serialization" if (io.read(3) or raise).unpack("C3") != [MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION] raise "Invalid serialization (location fields must be included but are not)" if io.getbyte != 0 end + #: () -> Encoding def load_encoding - encoding = Encoding.find(io.read(load_varuint)) + encoding = Encoding.find((io.read(load_varuint) or raise)) or raise @input = input.force_encoding(encoding).freeze encoding end + #: (bool freeze) -> Array[Integer] def load_line_offsets(freeze) offsets = Array.new(load_varuint) { load_varuint } offsets.freeze if freeze offsets end + #: (bool freeze) -> Array[Comment] def load_comments(freeze) comments = Array.new(load_varuint) do @@ -297,6 +325,7 @@ module Prism case load_varuint when 0 then InlineComment.new(load_location_object(freeze)) when 1 then EmbDocComment.new(load_location_object(freeze)) + else raise end comment.freeze if freeze @@ -307,6 +336,7 @@ module Prism comments end + #: (bool freeze) -> Array[MagicComment] def load_magic_comments(freeze) magic_comments = Array.new(load_varuint) do @@ -331,10 +361,11 @@ module Prism <%- warnings.each do |warning| -%> <%= warning.name.downcase.to_sym.inspect %>, <%- end -%> - ].freeze + ].freeze #: Array[Symbol] private_constant :DIAGNOSTIC_TYPES + #: () -> Symbol def load_error_level level = io.getbyte @@ -350,6 +381,7 @@ module Prism end end + #: (Encoding encoding, bool freeze) -> Array[ParseError] def load_errors(encoding, freeze) errors = Array.new(load_varuint) do @@ -369,6 +401,7 @@ module Prism errors end + #: () -> Symbol def load_warning_level level = io.getbyte @@ -382,6 +415,7 @@ module Prism end end + #: (Encoding encoding, bool freeze) -> Array[ParseWarning] def load_warnings(encoding, freeze) warnings = Array.new(load_varuint) do @@ -401,8 +435,9 @@ module Prism warnings end + #: () -> Array[[Token, Integer]] def load_tokens - tokens = [] + tokens = [] #: Array[[Token, Integer]] while (type = TOKEN_TYPES.fetch(load_varuint)) start = load_varuint @@ -420,25 +455,29 @@ module Prism # variable-length integer using https://en.wikipedia.org/wiki/LEB128 # This is also what protobuf uses: https://protobuf.dev/programming-guides/encoding/#varints + #-- + #: () -> Integer def load_varuint - n = io.getbyte + n = (io.getbyte or raise) if n < 128 n else n -= 128 shift = 0 - while (b = io.getbyte) >= 128 + while (b = (io.getbyte or raise)) >= 128 n += (b - 128) << (shift += 7) end n + (b << (shift + 7)) end end + #: () -> Integer def load_varsint n = load_varuint (n >> 1) ^ (-(n & 1)) end + #: () -> Integer def load_integer negative = io.getbyte != 0 length = load_varuint @@ -450,14 +489,17 @@ module Prism value end + #: () -> Float def load_double - io.read(8).unpack1("D") + (io.read(8) or raise).unpack1("D") #: Float end + #: () -> Integer def load_uint32 - io.read(4).unpack1("L") + (io.read(4) or raise).unpack1("L") #: Integer end + #: (ConstantPool constant_pool, Encoding encoding, bool freeze) -> node? def load_optional_node(constant_pool, encoding, freeze) if io.getbyte != 0 io.pos -= 1 @@ -465,14 +507,16 @@ module Prism end end + #: (Encoding encoding) -> String def load_embedded_string(encoding) - io.read(load_varuint).force_encoding(encoding).freeze + (io.read(load_varuint) or raise).force_encoding(encoding).freeze end + #: (Encoding encoding) -> String def load_string(encoding) case (type = io.getbyte) when 1 - input.byteslice(load_varuint, load_varuint).force_encoding(encoding).freeze + (input.byteslice(load_varuint, load_varuint) or raise).force_encoding(encoding).freeze when 2 load_embedded_string(encoding) else @@ -480,75 +524,116 @@ module Prism end end + #: (bool freeze) -> Location def load_location_object(freeze) location = Location.new(source, load_varuint, load_varuint) location.freeze if freeze location end + # Load a location object from the serialized data. Note that we are lying + # about the signature a bit here, because we sometimes load it as a packed + # integer instead of an object. + #-- + #: (bool freeze) -> Location def load_location(freeze) return load_location_object(freeze) if freeze - (load_varuint << 32) | load_varuint + (load_varuint << 32) | load_varuint #: Location end + # Load an optional location object from the serialized data if it is + # present. Note that we are lying about the signature a bit here, because + # we sometimes load it as a packed integer instead of an object. + #-- + #: (bool freeze) -> Location? def load_optional_location(freeze) load_location(freeze) if io.getbyte != 0 end + #: (bool freeze) -> Location? def load_optional_location_object(freeze) load_location_object(freeze) if io.getbyte != 0 end + #: (ConstantPool constant_pool, Encoding encoding) -> Symbol def load_constant(constant_pool, encoding) index = load_varuint constant_pool.get(index - 1, encoding) end + #: (ConstantPool constant_pool, Encoding encoding) -> Symbol? def load_optional_constant(constant_pool, encoding) index = load_varuint constant_pool.get(index - 1, encoding) if index != 0 end if RUBY_ENGINE == "ruby" + #: (ConstantPool constant_pool, Encoding encoding, bool freeze) -> node def load_node(constant_pool, encoding, freeze) type = io.getbyte node_id = load_varuint - location = load_location(freeze) - value = case type - <%- nodes.each_with_index do |node, index| -%> - when <%= index + 1 %> then - <%- if node.needs_serialized_length? -%> - load_uint32 - <%- end -%> - <%= node.name %>.new(<%= ["source", "node_id", "location", "load_varuint", *node.fields.map { |field| - case field - when Prism::Template::NodeField then "load_node(constant_pool, encoding, freeze)" - when Prism::Template::OptionalNodeField then "load_optional_node(constant_pool, encoding, freeze)" - when Prism::Template::StringField then "load_string(encoding)" - when Prism::Template::NodeListField then "Array.new(load_varuint) { load_node(constant_pool, encoding, freeze) }.tap { |nodes| nodes.freeze if freeze }" - when Prism::Template::ConstantField then "load_constant(constant_pool, encoding)" - when Prism::Template::OptionalConstantField then "load_optional_constant(constant_pool, encoding)" - when Prism::Template::ConstantListField then "Array.new(load_varuint) { load_constant(constant_pool, encoding) }.tap { |constants| constants.freeze if freeze }" - when Prism::Template::LocationField then "load_location(freeze)" - when Prism::Template::OptionalLocationField then "load_optional_location(freeze)" - when Prism::Template::UInt8Field then "io.getbyte" - when Prism::Template::UInt32Field then "load_varuint" - when Prism::Template::IntegerField then "load_integer" - when Prism::Template::DoubleField then "load_double" - else raise - end - }].join(", ") -%>) + location = load_location(freeze) #: Location + value = + case type + <%- nodes.each_with_index do |node, index| -%> + when <%= index + 1 %> + <%- if node.needs_serialized_length? -%> + load_uint32 + <%- end -%> + <%= node.name %>.new( + source, + node_id, + location, + load_varuint, + <%- node.fields.each do |field| -%> + <%- case field -%> + <%- when Prism::Template::NodeField -%> + load_node(constant_pool, encoding, freeze), #: <%= field.rbs_class %> + <%- when Prism::Template::OptionalNodeField -%> + load_optional_node(constant_pool, encoding, freeze), #: <%= field.rbs_class %> + <%- when Prism::Template::StringField -%> + load_string(encoding), + <%- when Prism::Template::NodeListField -%> + Array.new(load_varuint) do + load_node(constant_pool, encoding, freeze) #: <%= field.element_rbs_class %> + end.tap { |nodes| nodes.freeze if freeze }, + <%- when Prism::Template::ConstantField -%> + load_constant(constant_pool, encoding), + <%- when Prism::Template::OptionalConstantField -%> + load_optional_constant(constant_pool, encoding), + <%- when Prism::Template::ConstantListField -%> + Array.new(load_varuint) { load_constant(constant_pool, encoding) }.tap { |constants| constants.freeze if freeze }, + <%- when Prism::Template::LocationField -%> + load_location(freeze), + <%- when Prism::Template::OptionalLocationField -%> + load_optional_location(freeze), + <%- when Prism::Template::UInt8Field -%> + (io.getbyte or raise), + <%- when Prism::Template::UInt32Field -%> + load_varuint, + <%- when Prism::Template::IntegerField -%> + load_integer, + <%- when Prism::Template::DoubleField -%> + load_double, + <%- else raise -%> + <%- end -%> + <%- end -%> + ) <%- end -%> - end + else + raise "Unknown node type: #{type}" + end value.freeze if freeze value end else + # @rbs skip def load_node(constant_pool, encoding, freeze) - @load_node_lambdas[io.getbyte].call(constant_pool, encoding, freeze) + @load_node_lambdas[(io.getbyte or raise)].call(constant_pool, encoding, freeze) end + # @rbs skip def define_load_node_lambdas @load_node_lambdas = [ nil, @@ -559,24 +644,46 @@ module Prism <%- if node.needs_serialized_length? -%> load_uint32 <%- end -%> - value = <%= node.name %>.new(<%= ["source", "node_id", "location", "load_varuint", *node.fields.map { |field| - case field - when Prism::Template::NodeField then "load_node(constant_pool, encoding, freeze)" - when Prism::Template::OptionalNodeField then "load_optional_node(constant_pool, encoding, freeze)" - when Prism::Template::StringField then "load_string(encoding)" - when Prism::Template::NodeListField then "Array.new(load_varuint) { load_node(constant_pool, encoding, freeze) }" - when Prism::Template::ConstantField then "load_constant(constant_pool, encoding)" - when Prism::Template::OptionalConstantField then "load_optional_constant(constant_pool, encoding)" - when Prism::Template::ConstantListField then "Array.new(load_varuint) { load_constant(constant_pool, encoding) }" - when Prism::Template::LocationField then "load_location(freeze)" - when Prism::Template::OptionalLocationField then "load_optional_location(freeze)" - when Prism::Template::UInt8Field then "io.getbyte" - when Prism::Template::UInt32Field then "load_varuint" - when Prism::Template::IntegerField then "load_integer" - when Prism::Template::DoubleField then "load_double" - else raise - end - }].join(", ") -%>) + value = + <%= node.name %>.new( + source, + node_id, + location, + load_varuint, + <%- node.fields.map do |field| -%> + <%- case field -%> + <%- when Prism::Template::NodeField -%> + load_node(constant_pool, encoding, freeze), #: <%= field.rbs_class %> + <%- when Prism::Template::OptionalNodeField -%> + load_optional_node(constant_pool, encoding, freeze), #: <%= field.rbs_class %> + <%- when Prism::Template::StringField -%> + load_string(encoding), + <%- when Prism::Template::NodeListField -%> + Array.new(load_varuint) do + load_node(constant_pool, encoding, freeze) #: <%= field.element_rbs_class %> + end, + <%- when Prism::Template::ConstantField -%> + load_constant(constant_pool, encoding), + <%- when Prism::Template::OptionalConstantField -%> + load_optional_constant(constant_pool, encoding), + <%- when Prism::Template::ConstantListField -%> + Array.new(load_varuint) { load_constant(constant_pool, encoding) }, + <%- when Prism::Template::LocationField -%> + load_location(freeze), + <%- when Prism::Template::OptionalLocationField -%> + load_optional_location(freeze), + <%- when Prism::Template::UInt8Field -%> + (io.getbyte or raise), + <%- when Prism::Template::UInt32Field -%> + load_varuint, + <%- when Prism::Template::IntegerField -%> + load_integer, + <%- when Prism::Template::DoubleField -%> + load_double, + <%- else raise -%> + <%- end -%> + <%- end -%> + ) value.freeze if freeze value }, @@ -584,6 +691,10 @@ module Prism ] end end + + # @rbs! + # @load_node_lambdas: Array[Proc] + # def define_load_node_lambdas: () -> void end # The token types that can be indexed by their enum values. @@ -592,7 +703,7 @@ module Prism <%- tokens.each do |token| -%> <%= token.name.to_sym.inspect %>, <%- end -%> - ].freeze + ].freeze #: Array[Symbol?] private_constant :MAJOR_VERSION, :MINOR_VERSION, :PATCH_VERSION private_constant :ConstantPool, :FastStringIO, :Loader, :TOKEN_TYPES diff --git a/templates/lib/prism/visitor.rb.erb b/templates/lib/prism/visitor.rb.erb index 76f907724f..f23e87d99e 100644 --- a/templates/lib/prism/visitor.rb.erb +++ b/templates/lib/prism/visitor.rb.erb @@ -1,4 +1,14 @@ +#-- +# rbs_inline: enabled + module Prism + # @rbs! + # interface _Visitor + # <% nodes.each do |node| %> + # def visit_<%= node.human %>: (<%= node.name %>) -> void + # <% end %> + # end + # A class that knows how to walk down the tree. None of the individual visit # methods are implemented on this visitor, so it forces the consumer to # implement each one that they need. For a default implementation that @@ -6,18 +16,24 @@ module Prism class BasicVisitor # Calls `accept` on the given node if it is not `nil`, which in turn should # call back into this visitor by calling the appropriate `visit_*` method. + #-- + #: (node? node) -> void def visit(node) # @type self: _Visitor node&.accept(self) end # Visits each node in `nodes` by calling `accept` on each one. + #-- + #: (Array[node?] nodes) -> void def visit_all(nodes) # @type self: _Visitor nodes.each { |node| node&.accept(self) } end # Visits the child nodes of `node` by calling `accept` on each one. + #-- + #: (node node) -> void def visit_child_nodes(node) # @type self: _Visitor node.each_child_node { |node| node.accept(self) } @@ -47,6 +63,8 @@ module Prism <%- nodes.each_with_index do |node, index| -%> <%= "\n" if index != 0 -%> # Visit a <%= node.name %> node + #-- + #: (<%= node.name %> node) -> void def visit_<%= node.human %>(node) node.each_child_node { |node| node.accept(self) } end diff --git a/templates/sig/prism.rbs.erb b/templates/sig/prism.rbs.erb deleted file mode 100644 index ee35feccb8..0000000000 --- a/templates/sig/prism.rbs.erb +++ /dev/null @@ -1,92 +0,0 @@ -module Prism - BACKEND: :CEXT | :FFI - VERSION: String - - class CurrentVersionError < ArgumentError - def initialize: (String version) -> void - end - - # Methods taking a Ruby source code string: - <%- - { - parse: "ParseResult", - profile: "nil", - lex: "LexResult", - lex_compat: "LexCompat::Result", - parse_lex: "ParseLexResult", - dump: "String", - parse_comments: "Array[comment]", - parse_success?: "bool", - parse_failure?: "bool", - }.each do |method, return_type| - -%> - - def self.<%= method %>: ( - String source, - ?command_line: String, - ?encoding: Encoding | false, - ?filepath: String, - ?freeze: bool, - ?frozen_string_literal: bool, - ?line: Integer, - ?main_script: bool, - ?partial_script: bool, - ?scopes: Array[Array[Symbol]], - ?version: String - ) -> <%= return_type %> - <%- end -%> - - def self.load: ( - String source, - String serialized, - ?bool freeze - ) -> ParseResult - - # Methods taking a path to a Ruby file: - <%- - { - parse_file: "ParseResult", - profile_file: "nil", - lex_file: "LexResult", - parse_lex_file: "ParseLexResult", - dump_file: "String", - parse_file_comments: "Array[comment]", - parse_file_success?: "bool", - parse_file_failure?: "bool", - }.each do |method, return_type| - -%> - - def self.<%= method %>: ( - String filepath, - ?command_line: String, - ?encoding: Encoding | false, - ?freeze: bool, - ?frozen_string_literal: bool, - ?line: Integer, - ?main_script: bool, - ?partial_script: bool, - ?scopes: Array[Array[Symbol]], - ?version: String - ) -> <%= return_type %> - <%- end -%> - - interface _Stream - def gets: (?Integer integer) -> (String | nil) - end - - def self.parse_stream: ( - _Stream stream, - ?command_line: String, - ?encoding: Encoding | false, - ?filepath: String, - ?freeze: bool, - ?frozen_string_literal: bool, - ?line: Integer, - ?main_script: bool, - ?partial_script: bool, - ?scopes: Array[Array[Symbol]], - ?version: String - ) -> ParseResult - - def self.scope: (?locals: Array[Symbol], ?forwarding: Array[Symbol]) -> Scope -end diff --git a/templates/sig/prism/_private/dot_visitor.rbs.erb b/templates/sig/prism/_private/dot_visitor.rbs.erb deleted file mode 100644 index 4b380ecc97..0000000000 --- a/templates/sig/prism/_private/dot_visitor.rbs.erb +++ /dev/null @@ -1,45 +0,0 @@ -module Prism - class DotVisitor < Visitor - class Field - attr_reader name: String - attr_reader value: String? - attr_reader port: bool - - def initialize: (String name, String? value, bool port) -> void - def to_dot: () -> String - end - - class Table - attr_reader name: String - attr_reader fields: Array[Field] - - def initialize: (String name) -> void - def field: (String name, ?String? value, ?port: bool) -> void - def to_dot: () -> String - end - - class Digraph - attr_reader nodes: Array[String] - attr_reader waypoints: Array[String] - attr_reader edges: Array[String] - - def initialize: () -> void - def node: (String value) -> void - def waypoint: (String value) -> void - def edge: (String value) -> void - - def to_dot: () -> String - end - - attr_reader digraph: Digraph - - private - - def node_id: (Prism::node node) -> String - def location_inspect: (Location location) -> String - - <%- flags.each do |flag| -%> - def <%= flag.human %>_inspect: (<%= nodes.filter_map { |node| node.name if node.flags == flag }.join(" | ") %> node) -> String - <%- end -%> - end -end diff --git a/templates/sig/prism/dsl.rbs.erb b/templates/sig/prism/dsl.rbs.erb deleted file mode 100644 index 401467c0d8..0000000000 --- a/templates/sig/prism/dsl.rbs.erb +++ /dev/null @@ -1,31 +0,0 @@ -module Prism - module DSL - def source: (String string) -> Source - - def location: (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location - <%- nodes.each do |node| -%> - <%- - params = [ - ["source", "Source"], - ["node_id", "Integer"], - ["location", "Location"], - ["flags", "Integer"] - ].concat(node.fields.map { |field| [field.name, field.rbs_class] }) - -%> - - def <%= node.human %>: (<%= params.map { |(name, type)| "?#{name}: #{type}" }.join(", ") %>) -> <%= node.name %> - <%- end -%> - <%- flags.each do |flag| -%> - - def <%= flag.human.chomp("s") %>: (Symbol name) -> Integer - <%- end -%> - - private - - def default_source: () -> Source - - def default_location: () -> Location - - def default_node: (Source source, Location location) -> node - end -end diff --git a/templates/sig/prism/mutation_compiler.rbs.erb b/templates/sig/prism/mutation_compiler.rbs.erb deleted file mode 100644 index 303269ba49..0000000000 --- a/templates/sig/prism/mutation_compiler.rbs.erb +++ /dev/null @@ -1,7 +0,0 @@ -module Prism - class MutationCompiler < Compiler - <%- nodes.each do |node| -%> - def visit_<%= node.human %>: (<%= node.name %>) -> node? - <%- end -%> - end -end diff --git a/templates/sig/prism/node.rbs.erb b/templates/sig/prism/node.rbs.erb deleted file mode 100644 index 138edc11f4..0000000000 --- a/templates/sig/prism/node.rbs.erb +++ /dev/null @@ -1,136 +0,0 @@ -module Prism - class Node - attr_reader source: Source - attr_reader node_id: Integer - attr_reader location: Location - attr_reader flags: Integer - - def newline?: () -> bool - def static_literal?: () -> bool - - def accept: (_Visitor) -> void - def child_nodes: () -> Array[Prism::node?] - def comment_targets: () -> Array[Prism::node | Location] - def compact_child_nodes: () -> Array[Prism::node] - def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator[Prism::node] - def self.fields: () -> Array[Prism::Reflection::Field] - def type: () -> Symbol - def self.type: () -> Symbol - - def source_lines: () -> Array[String] - alias script_lines source_lines - def slice: () -> String - def slice_lines: () -> String - def pretty_print: (untyped q) -> untyped - def to_dot: () -> String - def tunnel: (Integer line, Integer column) -> Array[Prism::node] - def breadth_first_search: () { (Prism::node) -> bool } -> Prism::node? - alias find breadth_first_search - def breadth_first_search_all: () { (Prism::node) -> bool } -> Array[Prism::node] - alias find_all breadth_first_search_all - def newline!: (Array[untyped]) -> void - - def save: (_Repository repository) -> void - def save_location: (_Repository repository) -> void - - def leading_comments: () -> Array[comment] - def trailing_comments: () -> Array[comment] - def comments: () -> Array[comment] - - def start_offset: () -> Integer - def start_character_offset: () -> Integer - def start_code_units_offset: (Encoding encoding) -> Integer - def cached_start_code_units_offset: (_CodeUnitsCache cache) -> Integer - - def end_offset: () -> Integer - def end_character_offset: () -> Integer - def end_code_units_offset: (Encoding encoding) -> Integer - def cached_end_code_units_offset: (_CodeUnitsCache cache) -> Integer - - def start_line: () -> Integer - def end_line: () -> Integer - - def start_column: () -> Integer - def start_character_column: () -> Integer - def start_code_units_column: (Encoding encoding) -> Integer - def cached_start_code_units_column: (_CodeUnitsCache cache) -> Integer - - def end_column: () -> Integer - def end_character_column: () -> Integer - def end_code_units_column: (Encoding encoding) -> Integer - def cached_end_code_units_column: (_CodeUnitsCache cache) -> Integer - end - - # Methods implemented by every subclass of Node - interface _Node - def deconstruct: () -> Array[Prism::node?] - def inspect: () -> String - end - - type node = Node & _Node - - interface _Repository - def enter: (Integer node_id, Symbol field_name) -> void - end - - <%- nodes.each do |node| -%> - - <%- node.each_comment_line do |line| -%> - #<%= line %> - <%- end -%> - class <%= node.name -%> < Node - include _Node - <%- if (node_flags = node.flags) -%> - - <%- node_flags.values.each do |value| -%> - def <%= value.name.downcase %>?: () -> bool - <%- end -%> - <%- end -%> - - <%- node.fields.each do |field| -%> - attr_reader <%= field.name %>: <%= field.rbs_class %> - <%- end -%> - <%- if (locations = node.fields.select { |field| field.is_a?(Prism::Template::LocationField) || field.is_a?(Prism::Template::OptionalLocationField) }) -%> - - <%- locations.each do |field| -%> - def save_<%= field.name %>: (_Repository repository) -> void - <%- end -%> - <%- end -%> - - def initialize: (<%= ["Source source", "Integer node_id", "Location location", "Integer flags", *node.fields.map { |field| "#{field.rbs_class} #{field.name}" }].join(", ") %>) -> void - def copy: (<%= (["?node_id: Integer", "?location: Location", "?flags: Integer"] + node.fields.map { |field| "?#{field.name}: #{field.rbs_class}" }).join(", ") %>) -> <%= node.name %> - def deconstruct_keys: (Array[Symbol] keys) -> { <%= (["node_id: Integer", "location: Location"] + node.fields.map { |field| "#{field.name}: #{field.rbs_class}" }).join(", ") %> } - <%- node.fields.each do |field| -%> - <%- case field -%> - <%- when Prism::Template::LocationField -%> - <%- raise unless field.name.end_with?("_loc") -%> - <%- next if node.fields.any? { |other| other.name == field.name.delete_suffix("_loc") } -%> - def <%= field.name.delete_suffix("_loc") %>: () -> String - <%- when Prism::Template::OptionalLocationField -%> - <%- raise unless field.name.end_with?("_loc") -%> - <%- next if node.fields.any? { |other| other.name == field.name.delete_suffix("_loc") } -%> - def <%= field.name.delete_suffix("_loc") %>: () -> String? - <%- end -%> - <%- end -%> - def type: () -> :<%= node.human %> - | ... - def self.type: () -> :<%= node.human %> - end - <%- end -%> - <%- flags.each do |flag| -%> - - # <%= flag.comment %> - module <%= flag.name %> - <%- flag.values.each do |value| -%> - # <%= value.comment %> - <%= value.name %>: Integer - <%- end -%> - end - <%- end -%> - - # The flags that are common to all nodes. - module NodeFlags - NEWLINE: Integer - STATIC_LITERAL: Integer - end -end diff --git a/templates/sig/prism/visitor.rbs.erb b/templates/sig/prism/visitor.rbs.erb deleted file mode 100644 index 2e8de030f6..0000000000 --- a/templates/sig/prism/visitor.rbs.erb +++ /dev/null @@ -1,17 +0,0 @@ -module Prism - class BasicVisitor - def visit: (Prism::node?) -> void - def visit_all: (Array[Prism::node?]) -> void - def visit_child_nodes: (Prism::node) -> void - end - - interface _Visitor - <%- nodes.each do |node| -%> - def visit_<%= node.human %>: (<%= node.name %>) -> void - <%- end -%> - end - - class Visitor < BasicVisitor - include _Visitor - end -end diff --git a/templates/template.rb b/templates/template.rb index 65e6ed0381..e42d2dc57f 100755 --- a/templates/template.rb +++ b/templates/template.rb @@ -150,7 +150,7 @@ def rbs_class if specific_kind specific_kind elsif union_kind - union_kind.join(" | ") + "(#{union_kind.join(" | ")})" else "Prism::node" end @@ -192,7 +192,7 @@ def rbs_class if specific_kind "#{specific_kind}?" elsif union_kind - [*union_kind, "nil"].join(" | ") + "(#{union_kind.join(" | ")})?" else "Prism::node?" end @@ -230,16 +230,20 @@ def check_field_kind # This represents a field on a node that is a list of nodes. We pass them as # references and store them directly on the struct. class NodeListField < NodeKindField - def rbs_class + def element_rbs_class if specific_kind - "Array[#{specific_kind}]" + "#{specific_kind}" elsif union_kind - "Array[#{union_kind.join(" | ")}]" + "#{union_kind.join(" | ")}" else - "Array[Prism::node]" + "Prism::node" end end + def rbs_class + "Array[#{element_rbs_class}]" + end + def call_seq_type if specific_kind "Array[#{specific_kind}]" @@ -639,13 +643,6 @@ def render(name, write_to: nil) ++ =end - HEADING - when ".rbs" - <<~HEADING - # This file is generated by the templates/template.rb script and should not be - # modified manually. See #{filepath} - # if you are looking to modify the template - HEADING when ".rbi" <<~HEADING @@ -744,13 +741,7 @@ def locals "src/token_type.c", "rbi/prism/dsl.rbi", "rbi/prism/node.rbi", - "rbi/prism/visitor.rbi", - "sig/prism.rbs", - "sig/prism/dsl.rbs", - "sig/prism/mutation_compiler.rbs", - "sig/prism/node.rbs", - "sig/prism/visitor.rbs", - "sig/prism/_private/dot_visitor.rbs" + "rbi/prism/visitor.rbi" ] end end