{
-
- // internal bytes forced the encoding to UTF-8
- public static final short FORCED_UTF8_ENCODING = 1 << 0;
-
- // internal bytes forced the encoding to binary
- public static final short FORCED_BINARY_ENCODING = 1 << 1;
-
- // internal bytes forced the encoding to US-ASCII
- public static final short FORCED_US_ASCII_ENCODING = 1 << 2;
-
- public static boolean isForcedUtf8Encoding(short flags) {
- return (flags & FORCED_UTF8_ENCODING) != 0;
- }
-
- public static boolean isForcedBinaryEncoding(short flags) {
- return (flags & FORCED_BINARY_ENCODING) != 0;
- }
-
- public static boolean isForcedUsAsciiEncoding(short flags) {
- return (flags & FORCED_US_ASCII_ENCODING) != 0;
- }
-
- private final short flags;
-
- public SymbolFlags(short flags) {
- this.flags = flags;
- }
-
- @Override
- public int hashCode() {
- return flags;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof SymbolFlags)) {
- return false;
- }
-
- return flags == ((SymbolFlags) other).flags;
- }
-
- @Override
- public int compareTo(SymbolFlags other) {
- return flags - other.flags;
- }
-
- public boolean isForcedUtf8Encoding() {
- return (flags & FORCED_UTF8_ENCODING) != 0;
- }
-
- public boolean isForcedBinaryEncoding() {
- return (flags & FORCED_BINARY_ENCODING) != 0;
- }
-
- public boolean isForcedUsAsciiEncoding() {
- return (flags & FORCED_US_ASCII_ENCODING) != 0;
- }
-
- }
-
- /**
- *
- * Represents the use of the `alias` keyword to alias a global variable.
- *
- * alias $foo $bar
- * ^^^^^^^^^^^^^^^
- *
- */
- public static final class AliasGlobalVariableNode extends Node {
- /**
- *
- * Represents the new name of the global variable that can be used after aliasing. This can be either a global variable, a back reference, or a numbered reference.
- *
- * alias $foo $bar
- * ^^^^
- *
- */
- public final Node new_name;
- /**
- *
- * Represents the old name of the global variable that could be used before aliasing. This can be either a global variable, a back reference, or a numbered reference.
- *
- * alias $foo $bar
- * ^^^^
- *
- */
- public final Node old_name;
-
- public AliasGlobalVariableNode(Node new_name, Node old_name, int startOffset, int length) {
- super(startOffset, length);
- this.new_name = new_name;
- this.old_name = old_name;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.new_name.accept(visitor);
- this.old_name.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.new_name, this.old_name };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitAliasGlobalVariableNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("new_name: ");
- builder.append(this.new_name.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("old_name: ");
- builder.append(this.old_name.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `alias` keyword to alias a method.
- *
- * alias foo bar
- * ^^^^^^^^^^^^^
- *
- */
- public static final class AliasMethodNode extends Node {
- public final Node new_name;
- public final Node old_name;
-
- public AliasMethodNode(Node new_name, Node old_name, int startOffset, int length) {
- super(startOffset, length);
- this.new_name = new_name;
- this.old_name = old_name;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.new_name.accept(visitor);
- this.old_name.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.new_name, this.old_name };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitAliasMethodNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("new_name: ");
- builder.append(this.new_name.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("old_name: ");
- builder.append(this.old_name.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents an alternation pattern in pattern matching.
- *
- * foo => bar | baz
- * ^^^^^^^^^
- *
- */
- public static final class AlternationPatternNode extends Node {
- public final Node left;
- public final Node right;
-
- public AlternationPatternNode(Node left, Node right, int startOffset, int length) {
- super(startOffset, length);
- this.left = left;
- this.right = right;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.left.accept(visitor);
- this.right.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.left, this.right };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitAlternationPatternNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("left: ");
- builder.append(this.left.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("right: ");
- builder.append(this.right.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `&&` operator or the `and` keyword.
- *
- * left and right
- * ^^^^^^^^^^^^^^
- *
- */
- public static final class AndNode extends 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
- * ^
- *
- */
- public final Node left;
- /**
- *
- * Represents the right 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 && right
- * ^^^^^
- *
- * 1 and 2
- * ^
- *
- */
- public final Node right;
-
- public AndNode(Node left, Node right, int startOffset, int length) {
- super(startOffset, length);
- this.left = left;
- this.right = right;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.left.accept(visitor);
- this.right.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.left, this.right };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitAndNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("left: ");
- builder.append(this.left.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("right: ");
- builder.append(this.right.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a set of arguments to a method or a keyword.
- *
- * return foo, bar, baz
- * ^^^^^^^^^^^^^
- *
- */
- public static final class ArgumentsNode extends Node {
- public final short flags;
- public final Node[] arguments;
-
- public ArgumentsNode(short flags, Node[] arguments, int startOffset, int length) {
- super(startOffset, length);
- this.flags = flags;
- this.arguments = arguments;
- }
-
- public boolean isContainsKeywords() {
- return ArgumentsNodeFlags.isContainsKeywords(this.flags);
- }
-
- public boolean isContainsKeywordSplat() {
- return ArgumentsNodeFlags.isContainsKeywordSplat(this.flags);
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- for (Nodes.Node child : this.arguments) {
- child.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- ArrayList childNodes = new ArrayList<>();
- childNodes.addAll(Arrays.asList(this.arguments));
- return childNodes.toArray(EMPTY_ARRAY);
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitArgumentsNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- String nextNextIndent = nextIndent + " ";
- builder.append(nextIndent);
- builder.append("flags: ");
- builder.append(this.flags);
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("arguments: ");
- builder.append('\n');
- for (Node child : this.arguments) {
- builder.append(nextNextIndent).append(child.toString(nextNextIndent));
- }
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents an array literal. This can be a regular array using brackets or a special array using % like %w or %i.
- *
- * [1, 2, 3]
- * ^^^^^^^^^
- *
- */
- public static final class ArrayNode extends Node {
- public final short flags;
- /**
- *
- * 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.
- *
- */
- public final Node[] elements;
-
- public ArrayNode(short flags, Node[] elements, int startOffset, int length) {
- super(startOffset, length);
- this.flags = flags;
- this.elements = elements;
- }
-
- public boolean isContainsSplat() {
- return ArrayNodeFlags.isContainsSplat(this.flags);
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- for (Nodes.Node child : this.elements) {
- child.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- ArrayList childNodes = new ArrayList<>();
- childNodes.addAll(Arrays.asList(this.elements));
- return childNodes.toArray(EMPTY_ARRAY);
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitArrayNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- String nextNextIndent = nextIndent + " ";
- builder.append(nextIndent);
- builder.append("flags: ");
- builder.append(this.flags);
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("elements: ");
- builder.append('\n');
- for (Node child : this.elements) {
- builder.append(nextNextIndent).append(child.toString(nextNextIndent));
- }
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents an array pattern in pattern matching.
- *
- * foo in 1, 2
- * ^^^^^^^^^^^
- *
- * foo in [1, 2]
- * ^^^^^^^^^^^^^
- *
- * foo in *1
- * ^^^^^^^^^
- *
- * foo in Bar[]
- * ^^^^^^^^^^^^
- *
- * foo in Bar[1, 2, 3]
- * ^^^^^^^^^^^^^^^^^^^
- *
- */
- public static final class ArrayPatternNode extends Node {
- @Nullable
- public final Node constant;
- public final Node[] requireds;
- @Nullable
- public final Node rest;
- public final Node[] posts;
-
- public ArrayPatternNode(Node constant, Node[] requireds, Node rest, Node[] posts, int startOffset, int length) {
- super(startOffset, length);
- this.constant = constant;
- this.requireds = requireds;
- this.rest = rest;
- this.posts = posts;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.constant != null) {
- this.constant.accept(visitor);
- }
- for (Nodes.Node child : this.requireds) {
- child.accept(visitor);
- }
- if (this.rest != null) {
- this.rest.accept(visitor);
- }
- for (Nodes.Node child : this.posts) {
- child.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- ArrayList childNodes = new ArrayList<>();
- childNodes.add(this.constant);
- childNodes.addAll(Arrays.asList(this.requireds));
- childNodes.add(this.rest);
- childNodes.addAll(Arrays.asList(this.posts));
- return childNodes.toArray(EMPTY_ARRAY);
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitArrayPatternNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- String nextNextIndent = nextIndent + " ";
- builder.append(nextIndent);
- builder.append("constant: ");
- builder.append(this.constant == null ? "null\n" : this.constant.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("requireds: ");
- builder.append('\n');
- for (Node child : this.requireds) {
- builder.append(nextNextIndent).append(child.toString(nextNextIndent));
- }
- builder.append(nextIndent);
- builder.append("rest: ");
- builder.append(this.rest == null ? "null\n" : this.rest.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("posts: ");
- builder.append('\n');
- for (Node child : this.posts) {
- builder.append(nextNextIndent).append(child.toString(nextNextIndent));
- }
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a hash key/value pair.
- *
- * { a => b }
- * ^^^^^^
- *
- */
- public static final class AssocNode extends 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 }
- * ^^^^^^^^^^
- *
- */
- public final Node key;
- /**
- *
- * 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 }
- * ^
- *
- */
- public final Node value;
-
- public AssocNode(Node key, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.key = key;
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.key.accept(visitor);
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.key, this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitAssocNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("key: ");
- builder.append(this.key.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a splat in a hash literal.
- *
- * { **foo }
- * ^^^^^
- *
- */
- public static final class AssocSplatNode extends Node {
- /**
- *
- * The value to be splatted, if present. Will be missing when keyword rest argument forwarding is used.
- *
- * { **foo }
- * ^^^
- *
- */
- @Nullable
- public final Node value;
-
- public AssocSplatNode(Node value, int startOffset, int length) {
- super(startOffset, length);
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.value != null) {
- this.value.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitAssocSplatNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value == null ? "null\n" : this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents reading a reference to a field in the previous match.
- *
- * $'
- * ^^
- *
- */
- public static final class BackReferenceReadNode extends Node {
- /**
- *
- * The name of the back-reference variable, including the leading `$`.
- *
- * $& # name `:$&`
- *
- * $+ # name `:$+`
- *
- */
- public final org.jruby.RubySymbol name;
-
- public BackReferenceReadNode(org.jruby.RubySymbol name, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- }
-
- public Node[] childNodes() {
- return EMPTY_ARRAY;
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitBackReferenceReadNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a begin statement.
- *
- * begin
- * foo
- * end
- * ^^^^^
- *
- */
- public static final class BeginNode extends Node {
- @Nullable
- public final StatementsNode statements;
- @Nullable
- public final RescueNode rescue_clause;
- @Nullable
- public final ElseNode else_clause;
- @Nullable
- public final EnsureNode ensure_clause;
-
- public BeginNode(StatementsNode statements, RescueNode rescue_clause, ElseNode else_clause, EnsureNode ensure_clause, int startOffset, int length) {
- super(startOffset, length);
- this.statements = statements;
- this.rescue_clause = rescue_clause;
- this.else_clause = else_clause;
- this.ensure_clause = ensure_clause;
- }
-
- @Override
- public void setNewLineFlag(Source source, boolean[] newlineMarked) {
- // Never mark BeginNode with a newline flag, mark children instead
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.statements != null) {
- this.statements.accept(visitor);
- }
- if (this.rescue_clause != null) {
- this.rescue_clause.accept(visitor);
- }
- if (this.else_clause != null) {
- this.else_clause.accept(visitor);
- }
- if (this.ensure_clause != null) {
- this.ensure_clause.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.statements, this.rescue_clause, this.else_clause, this.ensure_clause };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitBeginNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("statements: ");
- builder.append(this.statements == null ? "null\n" : this.statements.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("rescue_clause: ");
- builder.append(this.rescue_clause == null ? "null\n" : this.rescue_clause.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("else_clause: ");
- builder.append(this.else_clause == null ? "null\n" : this.else_clause.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("ensure_clause: ");
- builder.append(this.ensure_clause == null ? "null\n" : this.ensure_clause.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents block method arguments.
- *
- * bar(&args)
- * ^^^^^^^^^^
- *
- */
- public static final class BlockArgumentNode extends Node {
- @Nullable
- public final Node expression;
-
- public BlockArgumentNode(Node expression, int startOffset, int length) {
- super(startOffset, length);
- this.expression = expression;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.expression != null) {
- this.expression.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.expression };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitBlockArgumentNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("expression: ");
- builder.append(this.expression == null ? "null\n" : this.expression.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a block local variable.
- *
- * a { |; b| }
- * ^
- *
- */
- public static final class BlockLocalVariableNode extends Node {
- public final short flags;
- public final org.jruby.RubySymbol name;
-
- public BlockLocalVariableNode(short flags, org.jruby.RubySymbol name, int startOffset, int length) {
- super(startOffset, length);
- this.flags = flags;
- this.name = name;
- }
-
- public boolean isRepeatedParameter() {
- return ParameterFlags.isRepeatedParameter(this.flags);
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- }
-
- public Node[] childNodes() {
- return EMPTY_ARRAY;
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitBlockLocalVariableNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("flags: ");
- builder.append(this.flags);
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a block of ruby code.
- *
- * [1, 2, 3].each { |i| puts x }
- * ^^^^^^^^^^^^^^
- *
- */
- public static final class BlockNode extends Node {
- public final org.jruby.RubySymbol[] locals;
- @Nullable
- public final Node parameters;
- @Nullable
- public final Node body;
-
- public BlockNode(org.jruby.RubySymbol[] locals, Node parameters, Node body, int startOffset, int length) {
- super(startOffset, length);
- this.locals = locals;
- this.parameters = parameters;
- this.body = body;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.parameters != null) {
- this.parameters.accept(visitor);
- }
- if (this.body != null) {
- this.body.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.parameters, this.body };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitBlockNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- String nextNextIndent = nextIndent + " ";
- builder.append(nextIndent);
- builder.append("locals: ");
- builder.append('\n');
- for (org.jruby.RubySymbol constant : this.locals) {
- builder.append(nextNextIndent).append('"').append(constant).append('"').append('\n');
- }
- builder.append(nextIndent);
- builder.append("parameters: ");
- builder.append(this.parameters == null ? "null\n" : this.parameters.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("body: ");
- builder.append(this.body == null ? "null\n" : this.body.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a block parameter to a method, block, or lambda definition.
- *
- * def a(&b)
- * ^^
- * end
- *
- */
- public static final class BlockParameterNode extends Node {
- public final short flags;
- @Nullable
- public final org.jruby.RubySymbol name;
-
- public BlockParameterNode(short flags, org.jruby.RubySymbol name, int startOffset, int length) {
- super(startOffset, length);
- this.flags = flags;
- this.name = name;
- }
-
- public boolean isRepeatedParameter() {
- return ParameterFlags.isRepeatedParameter(this.flags);
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- }
-
- public Node[] childNodes() {
- return EMPTY_ARRAY;
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitBlockParameterNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("flags: ");
- builder.append(this.flags);
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append(this.name == null ? "null" : "\"" + this.name + "\"");
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a block's parameters declaration.
- *
- * -> (a, b = 1; local) { }
- * ^^^^^^^^^^^^^^^^^
- *
- * foo do |a, b = 1; local|
- * ^^^^^^^^^^^^^^^^^
- * end
- *
- */
- public static final class BlockParametersNode extends Node {
- @Nullable
- public final ParametersNode parameters;
- public final BlockLocalVariableNode[] locals;
-
- public BlockParametersNode(ParametersNode parameters, BlockLocalVariableNode[] locals, int startOffset, int length) {
- super(startOffset, length);
- this.parameters = parameters;
- this.locals = locals;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.parameters != null) {
- this.parameters.accept(visitor);
- }
- for (Nodes.Node child : this.locals) {
- child.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- ArrayList childNodes = new ArrayList<>();
- childNodes.add(this.parameters);
- childNodes.addAll(Arrays.asList(this.locals));
- return childNodes.toArray(EMPTY_ARRAY);
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitBlockParametersNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- String nextNextIndent = nextIndent + " ";
- builder.append(nextIndent);
- builder.append("parameters: ");
- builder.append(this.parameters == null ? "null\n" : this.parameters.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("locals: ");
- builder.append('\n');
- for (Node child : this.locals) {
- builder.append(nextNextIndent).append(child.toString(nextNextIndent));
- }
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `break` keyword.
- *
- * break foo
- * ^^^^^^^^^
- *
- */
- public static final class BreakNode extends Node {
- /**
- *
- * 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
- * ^^^
- *
- */
- @Nullable
- public final ArgumentsNode arguments;
-
- public BreakNode(ArgumentsNode arguments, int startOffset, int length) {
- super(startOffset, length);
- this.arguments = arguments;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.arguments != null) {
- this.arguments.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.arguments };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitBreakNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("arguments: ");
- builder.append(this.arguments == null ? "null\n" : this.arguments.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `&&=` operator on a call.
- *
- * foo.bar &&= value
- * ^^^^^^^^^^^^^^^^^
- *
- */
- public static final class CallAndWriteNode extends Node {
- public final short flags;
- @Nullable
- public final Node receiver;
- public final org.jruby.RubySymbol read_name;
- public final org.jruby.RubySymbol write_name;
- public final Node value;
-
- public CallAndWriteNode(short flags, Node receiver, org.jruby.RubySymbol read_name, org.jruby.RubySymbol write_name, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.flags = flags;
- this.receiver = receiver;
- this.read_name = read_name;
- this.write_name = write_name;
- this.value = value;
- }
-
- public boolean isSafeNavigation() {
- return CallNodeFlags.isSafeNavigation(this.flags);
- }
-
- public boolean isVariableCall() {
- return CallNodeFlags.isVariableCall(this.flags);
- }
-
- public boolean isAttributeWrite() {
- return CallNodeFlags.isAttributeWrite(this.flags);
- }
-
- public boolean isIgnoreVisibility() {
- return CallNodeFlags.isIgnoreVisibility(this.flags);
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.receiver != null) {
- this.receiver.accept(visitor);
- }
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.receiver, this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitCallAndWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("flags: ");
- builder.append(this.flags);
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("receiver: ");
- builder.append(this.receiver == null ? "null\n" : this.receiver.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("read_name: ");
- builder.append('"').append(this.read_name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("write_name: ");
- builder.append('"').append(this.write_name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a method call, in all of the various forms that can take.
- *
- * foo
- * ^^^
- *
- * foo()
- * ^^^^^
- *
- * +foo
- * ^^^^
- *
- * foo + bar
- * ^^^^^^^^^
- *
- * foo.bar
- * ^^^^^^^
- *
- * foo&.bar
- * ^^^^^^^^
- *
- */
- public static final class CallNode extends Node {
- public final short flags;
- /**
- *
- * 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
- * ^^^
- *
- */
- @Nullable
- public final Node receiver;
- public final org.jruby.RubySymbol name;
- @Nullable
- public final ArgumentsNode arguments;
- @Nullable
- public final Node block;
-
- public CallNode(short flags, Node receiver, org.jruby.RubySymbol name, ArgumentsNode arguments, Node block, int startOffset, int length) {
- super(startOffset, length);
- this.flags = flags;
- this.receiver = receiver;
- this.name = name;
- this.arguments = arguments;
- this.block = block;
- }
-
- public boolean isSafeNavigation() {
- return CallNodeFlags.isSafeNavigation(this.flags);
- }
-
- public boolean isVariableCall() {
- return CallNodeFlags.isVariableCall(this.flags);
- }
-
- public boolean isAttributeWrite() {
- return CallNodeFlags.isAttributeWrite(this.flags);
- }
-
- public boolean isIgnoreVisibility() {
- return CallNodeFlags.isIgnoreVisibility(this.flags);
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.receiver != null) {
- this.receiver.accept(visitor);
- }
- if (this.arguments != null) {
- this.arguments.accept(visitor);
- }
- if (this.block != null) {
- this.block.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.receiver, this.arguments, this.block };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitCallNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("flags: ");
- builder.append(this.flags);
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("receiver: ");
- builder.append(this.receiver == null ? "null\n" : this.receiver.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("arguments: ");
- builder.append(this.arguments == null ? "null\n" : this.arguments.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("block: ");
- builder.append(this.block == null ? "null\n" : this.block.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of an assignment operator on a call.
- *
- * foo.bar += baz
- * ^^^^^^^^^^^^^^
- *
- */
- public static final class CallOperatorWriteNode extends Node {
- public final short flags;
- @Nullable
- public final Node receiver;
- public final org.jruby.RubySymbol read_name;
- public final org.jruby.RubySymbol write_name;
- public final org.jruby.RubySymbol binary_operator;
- public final Node value;
-
- public CallOperatorWriteNode(short flags, Node receiver, org.jruby.RubySymbol read_name, org.jruby.RubySymbol write_name, org.jruby.RubySymbol binary_operator, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.flags = flags;
- this.receiver = receiver;
- this.read_name = read_name;
- this.write_name = write_name;
- this.binary_operator = binary_operator;
- this.value = value;
- }
-
- public boolean isSafeNavigation() {
- return CallNodeFlags.isSafeNavigation(this.flags);
- }
-
- public boolean isVariableCall() {
- return CallNodeFlags.isVariableCall(this.flags);
- }
-
- public boolean isAttributeWrite() {
- return CallNodeFlags.isAttributeWrite(this.flags);
- }
-
- public boolean isIgnoreVisibility() {
- return CallNodeFlags.isIgnoreVisibility(this.flags);
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.receiver != null) {
- this.receiver.accept(visitor);
- }
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.receiver, this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitCallOperatorWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("flags: ");
- builder.append(this.flags);
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("receiver: ");
- builder.append(this.receiver == null ? "null\n" : this.receiver.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("read_name: ");
- builder.append('"').append(this.read_name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("write_name: ");
- builder.append('"').append(this.write_name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("binary_operator: ");
- builder.append('"').append(this.binary_operator).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `||=` operator on a call.
- *
- * foo.bar ||= value
- * ^^^^^^^^^^^^^^^^^
- *
- */
- public static final class CallOrWriteNode extends Node {
- public final short flags;
- @Nullable
- public final Node receiver;
- public final org.jruby.RubySymbol read_name;
- public final org.jruby.RubySymbol write_name;
- public final Node value;
-
- public CallOrWriteNode(short flags, Node receiver, org.jruby.RubySymbol read_name, org.jruby.RubySymbol write_name, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.flags = flags;
- this.receiver = receiver;
- this.read_name = read_name;
- this.write_name = write_name;
- this.value = value;
- }
-
- public boolean isSafeNavigation() {
- return CallNodeFlags.isSafeNavigation(this.flags);
- }
-
- public boolean isVariableCall() {
- return CallNodeFlags.isVariableCall(this.flags);
- }
-
- public boolean isAttributeWrite() {
- return CallNodeFlags.isAttributeWrite(this.flags);
- }
-
- public boolean isIgnoreVisibility() {
- return CallNodeFlags.isIgnoreVisibility(this.flags);
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.receiver != null) {
- this.receiver.accept(visitor);
- }
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.receiver, this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitCallOrWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("flags: ");
- builder.append(this.flags);
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("receiver: ");
- builder.append(this.receiver == null ? "null\n" : this.receiver.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("read_name: ");
- builder.append('"').append(this.read_name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("write_name: ");
- builder.append('"').append(this.write_name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents assigning to a method call.
- *
- * foo.bar, = 1
- * ^^^^^^^
- *
- * begin
- * rescue => foo.bar
- * ^^^^^^^
- * end
- *
- * for foo.bar in baz do end
- * ^^^^^^^
- *
- */
- public static final class CallTargetNode extends Node {
- public final short flags;
- public final Node receiver;
- public final org.jruby.RubySymbol name;
-
- public CallTargetNode(short flags, Node receiver, org.jruby.RubySymbol name, int startOffset, int length) {
- super(startOffset, length);
- this.flags = flags;
- this.receiver = receiver;
- this.name = name;
- }
-
- public boolean isSafeNavigation() {
- return CallNodeFlags.isSafeNavigation(this.flags);
- }
-
- public boolean isVariableCall() {
- return CallNodeFlags.isVariableCall(this.flags);
- }
-
- public boolean isAttributeWrite() {
- return CallNodeFlags.isAttributeWrite(this.flags);
- }
-
- public boolean isIgnoreVisibility() {
- return CallNodeFlags.isIgnoreVisibility(this.flags);
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.receiver.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.receiver };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitCallTargetNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("flags: ");
- builder.append(this.flags);
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("receiver: ");
- builder.append(this.receiver.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents assigning to a local variable in pattern matching.
- *
- * foo => [bar => baz]
- * ^^^^^^^^^^^^
- *
- */
- public static final class CapturePatternNode extends Node {
- public final Node value;
- public final Node target;
-
- public CapturePatternNode(Node value, Node target, int startOffset, int length) {
- super(startOffset, length);
- this.value = value;
- this.target = target;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.value.accept(visitor);
- this.target.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.value, this.target };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitCapturePatternNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("target: ");
- builder.append(this.target.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of a case statement for pattern matching.
- *
- * case true
- * in false
- * end
- * ^^^^^^^^^
- *
- */
- public static final class CaseMatchNode extends Node {
- @Nullable
- public final Node predicate;
- public final Node[] conditions;
- @Nullable
- public final ElseNode consequent;
-
- public CaseMatchNode(Node predicate, Node[] conditions, ElseNode consequent, int startOffset, int length) {
- super(startOffset, length);
- this.predicate = predicate;
- this.conditions = conditions;
- this.consequent = consequent;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.predicate != null) {
- this.predicate.accept(visitor);
- }
- for (Nodes.Node child : this.conditions) {
- child.accept(visitor);
- }
- if (this.consequent != null) {
- this.consequent.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- ArrayList childNodes = new ArrayList<>();
- childNodes.add(this.predicate);
- childNodes.addAll(Arrays.asList(this.conditions));
- childNodes.add(this.consequent);
- return childNodes.toArray(EMPTY_ARRAY);
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitCaseMatchNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- String nextNextIndent = nextIndent + " ";
- builder.append(nextIndent);
- builder.append("predicate: ");
- builder.append(this.predicate == null ? "null\n" : this.predicate.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("conditions: ");
- builder.append('\n');
- for (Node child : this.conditions) {
- builder.append(nextNextIndent).append(child.toString(nextNextIndent));
- }
- builder.append(nextIndent);
- builder.append("consequent: ");
- builder.append(this.consequent == null ? "null\n" : this.consequent.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of a case statement.
- *
- * case true
- * when false
- * end
- * ^^^^^^^^^^
- *
- */
- public static final class CaseNode extends Node {
- @Nullable
- public final Node predicate;
- public final Node[] conditions;
- @Nullable
- public final ElseNode consequent;
-
- public CaseNode(Node predicate, Node[] conditions, ElseNode consequent, int startOffset, int length) {
- super(startOffset, length);
- this.predicate = predicate;
- this.conditions = conditions;
- this.consequent = consequent;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.predicate != null) {
- this.predicate.accept(visitor);
- }
- for (Nodes.Node child : this.conditions) {
- child.accept(visitor);
- }
- if (this.consequent != null) {
- this.consequent.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- ArrayList childNodes = new ArrayList<>();
- childNodes.add(this.predicate);
- childNodes.addAll(Arrays.asList(this.conditions));
- childNodes.add(this.consequent);
- return childNodes.toArray(EMPTY_ARRAY);
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitCaseNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- String nextNextIndent = nextIndent + " ";
- builder.append(nextIndent);
- builder.append("predicate: ");
- builder.append(this.predicate == null ? "null\n" : this.predicate.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("conditions: ");
- builder.append('\n');
- for (Node child : this.conditions) {
- builder.append(nextNextIndent).append(child.toString(nextNextIndent));
- }
- builder.append(nextIndent);
- builder.append("consequent: ");
- builder.append(this.consequent == null ? "null\n" : this.consequent.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a class declaration involving the `class` keyword.
- *
- * class Foo end
- * ^^^^^^^^^^^^^
- *
- */
- public static final class ClassNode extends Node {
- public final org.jruby.RubySymbol[] locals;
- public final Node constant_path;
- @Nullable
- public final Node superclass;
- @Nullable
- public final Node body;
- public final org.jruby.RubySymbol name;
-
- public ClassNode(org.jruby.RubySymbol[] locals, Node constant_path, Node superclass, Node body, org.jruby.RubySymbol name, int startOffset, int length) {
- super(startOffset, length);
- this.locals = locals;
- this.constant_path = constant_path;
- this.superclass = superclass;
- this.body = body;
- this.name = name;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.constant_path.accept(visitor);
- if (this.superclass != null) {
- this.superclass.accept(visitor);
- }
- if (this.body != null) {
- this.body.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.constant_path, this.superclass, this.body };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitClassNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- String nextNextIndent = nextIndent + " ";
- builder.append(nextIndent);
- builder.append("locals: ");
- builder.append('\n');
- for (org.jruby.RubySymbol constant : this.locals) {
- builder.append(nextNextIndent).append('"').append(constant).append('"').append('\n');
- }
- builder.append(nextIndent);
- builder.append("constant_path: ");
- builder.append(this.constant_path.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("superclass: ");
- builder.append(this.superclass == null ? "null\n" : this.superclass.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("body: ");
- builder.append(this.body == null ? "null\n" : this.body.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `&&=` operator for assignment to a class variable.
- *
- * @@target &&= value
- * ^^^^^^^^^^^^^^^^^^
- *
- */
- public static final class ClassVariableAndWriteNode extends Node {
- public final org.jruby.RubySymbol name;
- public final Node value;
-
- public ClassVariableAndWriteNode(org.jruby.RubySymbol name, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitClassVariableAndWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents assigning to a class variable using an operator that isn't `=`.
- *
- * @@target += value
- * ^^^^^^^^^^^^^^^^^
- *
- */
- public static final class ClassVariableOperatorWriteNode extends Node {
- public final org.jruby.RubySymbol name;
- public final Node value;
- public final org.jruby.RubySymbol binary_operator;
-
- public ClassVariableOperatorWriteNode(org.jruby.RubySymbol name, Node value, org.jruby.RubySymbol binary_operator, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- this.value = value;
- this.binary_operator = binary_operator;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitClassVariableOperatorWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("binary_operator: ");
- builder.append('"').append(this.binary_operator).append('"');
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `||=` operator for assignment to a class variable.
- *
- * @@target ||= value
- * ^^^^^^^^^^^^^^^^^^
- *
- */
- public static final class ClassVariableOrWriteNode extends Node {
- public final org.jruby.RubySymbol name;
- public final Node value;
-
- public ClassVariableOrWriteNode(org.jruby.RubySymbol name, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitClassVariableOrWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents referencing a class variable.
- *
- * @@foo
- * ^^^^^
- *
- */
- public static final class ClassVariableReadNode extends Node {
- /**
- *
- * 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`
- *
- */
- public final org.jruby.RubySymbol name;
-
- public ClassVariableReadNode(org.jruby.RubySymbol name, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- }
-
- public Node[] childNodes() {
- return EMPTY_ARRAY;
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitClassVariableReadNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents writing to a class variable in a context that doesn't have an explicit value.
- *
- * @@foo, @@bar = baz
- * ^^^^^ ^^^^^
- *
- */
- public static final class ClassVariableTargetNode extends Node {
- public final org.jruby.RubySymbol name;
-
- public ClassVariableTargetNode(org.jruby.RubySymbol name, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- }
-
- public Node[] childNodes() {
- return EMPTY_ARRAY;
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitClassVariableTargetNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents writing to a class variable.
- *
- * @@foo = 1
- * ^^^^^^^^^
- *
- */
- public static final class ClassVariableWriteNode extends Node {
- /**
- *
- * 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`
- *
- */
- public final org.jruby.RubySymbol name;
- /**
- *
- * 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
- * ^^^
- *
- */
- public final Node value;
-
- public ClassVariableWriteNode(org.jruby.RubySymbol name, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitClassVariableWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `&&=` operator for assignment to a constant.
- *
- * Target &&= value
- * ^^^^^^^^^^^^^^^^
- *
- */
- public static final class ConstantAndWriteNode extends Node {
- public final org.jruby.RubySymbol name;
- public final Node value;
-
- public ConstantAndWriteNode(org.jruby.RubySymbol name, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantAndWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents assigning to a constant using an operator that isn't `=`.
- *
- * Target += value
- * ^^^^^^^^^^^^^^^
- *
- */
- public static final class ConstantOperatorWriteNode extends Node {
- public final org.jruby.RubySymbol name;
- public final Node value;
- public final org.jruby.RubySymbol binary_operator;
-
- public ConstantOperatorWriteNode(org.jruby.RubySymbol name, Node value, org.jruby.RubySymbol binary_operator, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- this.value = value;
- this.binary_operator = binary_operator;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantOperatorWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("binary_operator: ");
- builder.append('"').append(this.binary_operator).append('"');
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `||=` operator for assignment to a constant.
- *
- * Target ||= value
- * ^^^^^^^^^^^^^^^^
- *
- */
- public static final class ConstantOrWriteNode extends Node {
- public final org.jruby.RubySymbol name;
- public final Node value;
-
- public ConstantOrWriteNode(org.jruby.RubySymbol name, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantOrWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `&&=` operator for assignment to a constant path.
- *
- * Parent::Child &&= value
- * ^^^^^^^^^^^^^^^^^^^^^^^
- *
- */
- public static final class ConstantPathAndWriteNode extends Node {
- public final ConstantPathNode target;
- public final Node value;
-
- public ConstantPathAndWriteNode(ConstantPathNode target, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.target = target;
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.target.accept(visitor);
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.target, this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantPathAndWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("target: ");
- builder.append(this.target.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents accessing a constant through a path of `::` operators.
- *
- * Foo::Bar
- * ^^^^^^^^
- *
- */
- public static final class ConstantPathNode extends Node {
- /**
- *
- * 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
- * ^^^
- *
- */
- @Nullable
- public final Node parent;
- /**
- *
- * The name of the constant being accessed. This could be `nil` in the event of a syntax error.
- *
- */
- @Nullable
- public final org.jruby.RubySymbol name;
-
- public ConstantPathNode(Node parent, org.jruby.RubySymbol name, int startOffset, int length) {
- super(startOffset, length);
- this.parent = parent;
- this.name = name;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.parent != null) {
- this.parent.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.parent };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantPathNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("parent: ");
- builder.append(this.parent == null ? "null\n" : this.parent.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append(this.name == null ? "null" : "\"" + this.name + "\"");
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents assigning to a constant path using an operator that isn't `=`.
- *
- * Parent::Child += value
- * ^^^^^^^^^^^^^^^^^^^^^^
- *
- */
- public static final class ConstantPathOperatorWriteNode extends Node {
- public final ConstantPathNode target;
- public final Node value;
- public final org.jruby.RubySymbol binary_operator;
-
- public ConstantPathOperatorWriteNode(ConstantPathNode target, Node value, org.jruby.RubySymbol binary_operator, int startOffset, int length) {
- super(startOffset, length);
- this.target = target;
- this.value = value;
- this.binary_operator = binary_operator;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.target.accept(visitor);
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.target, this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantPathOperatorWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("target: ");
- builder.append(this.target.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("binary_operator: ");
- builder.append('"').append(this.binary_operator).append('"');
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `||=` operator for assignment to a constant path.
- *
- * Parent::Child ||= value
- * ^^^^^^^^^^^^^^^^^^^^^^^
- *
- */
- public static final class ConstantPathOrWriteNode extends Node {
- public final ConstantPathNode target;
- public final Node value;
-
- public ConstantPathOrWriteNode(ConstantPathNode target, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.target = target;
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.target.accept(visitor);
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.target, this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantPathOrWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("target: ");
- builder.append(this.target.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents writing to a constant path in a context that doesn't have an explicit value.
- *
- * Foo::Foo, Bar::Bar = baz
- * ^^^^^^^^ ^^^^^^^^
- *
- */
- public static final class ConstantPathTargetNode extends Node {
- @Nullable
- public final Node parent;
- @Nullable
- public final org.jruby.RubySymbol name;
-
- public ConstantPathTargetNode(Node parent, org.jruby.RubySymbol name, int startOffset, int length) {
- super(startOffset, length);
- this.parent = parent;
- this.name = name;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.parent != null) {
- this.parent.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.parent };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantPathTargetNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("parent: ");
- builder.append(this.parent == null ? "null\n" : this.parent.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append(this.name == null ? "null" : "\"" + this.name + "\"");
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents writing to a constant path.
- *
- * ::Foo = 1
- * ^^^^^^^^^
- *
- * Foo::Bar = 1
- * ^^^^^^^^^^^^
- *
- * ::Foo::Bar = 1
- * ^^^^^^^^^^^^^^
- *
- */
- public static final class ConstantPathWriteNode extends Node {
- /**
- *
- * A node representing the constant path being written to.
- *
- * Foo::Bar = 1
- * ^^^^^^^^
- *
- * ::Foo = :abc
- * ^^^^^
- *
- */
- public final ConstantPathNode target;
- /**
- *
- * 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
- * ^^^^
- *
- */
- public final Node value;
-
- public ConstantPathWriteNode(ConstantPathNode target, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.target = target;
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.target.accept(visitor);
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.target, this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantPathWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("target: ");
- builder.append(this.target.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents referencing a constant.
- *
- * Foo
- * ^^^
- *
- */
- public static final class ConstantReadNode extends Node {
- /**
- *
- * 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`
- *
- */
- public final org.jruby.RubySymbol name;
-
- public ConstantReadNode(org.jruby.RubySymbol name, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- }
-
- public Node[] childNodes() {
- return EMPTY_ARRAY;
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantReadNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents writing to a constant in a context that doesn't have an explicit value.
- *
- * Foo, Bar = baz
- * ^^^ ^^^
- *
- */
- public static final class ConstantTargetNode extends Node {
- public final org.jruby.RubySymbol name;
-
- public ConstantTargetNode(org.jruby.RubySymbol name, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- }
-
- public Node[] childNodes() {
- return EMPTY_ARRAY;
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantTargetNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents writing to a constant.
- *
- * Foo = 1
- * ^^^^^^^
- *
- */
- public static final class ConstantWriteNode extends Node {
- /**
- *
- * 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`
- *
- */
- public final org.jruby.RubySymbol name;
- /**
- *
- * 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
- * ^^^^^^^^^
- *
- */
- public final Node value;
-
- public ConstantWriteNode(org.jruby.RubySymbol name, Node value, int startOffset, int length) {
- super(startOffset, length);
- this.name = name;
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitConstantWriteNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a method definition.
- *
- * def method
- * end
- * ^^^^^^^^^^
- *
- */
- public static final class DefNode extends Node {
- public final int serializedLength;
- public final org.jruby.RubySymbol name;
- @Nullable
- public final Node receiver;
- @Nullable
- public final ParametersNode parameters;
- @Nullable
- public final Node body;
- public final org.jruby.RubySymbol[] locals;
-
- public DefNode(int serializedLength, org.jruby.RubySymbol name, Node receiver, ParametersNode parameters, Node body, org.jruby.RubySymbol[] locals, int startOffset, int length) {
- super(startOffset, length);
- this.serializedLength = serializedLength;
- this.name = name;
- this.receiver = receiver;
- this.parameters = parameters;
- this.body = body;
- this.locals = locals;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.receiver != null) {
- this.receiver.accept(visitor);
- }
- if (this.parameters != null) {
- this.parameters.accept(visitor);
- }
- if (this.body != null) {
- this.body.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.receiver, this.parameters, this.body };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitDefNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- String nextNextIndent = nextIndent + " ";
- builder.append(nextIndent);
- builder.append("name: ");
- builder.append('"').append(this.name).append('"');
- builder.append('\n');
- builder.append(nextIndent);
- builder.append("receiver: ");
- builder.append(this.receiver == null ? "null\n" : this.receiver.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("parameters: ");
- builder.append(this.parameters == null ? "null\n" : this.parameters.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("body: ");
- builder.append(this.body == null ? "null\n" : this.body.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("locals: ");
- builder.append('\n');
- for (org.jruby.RubySymbol constant : this.locals) {
- builder.append(nextNextIndent).append('"').append(constant).append('"').append('\n');
- }
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `defined?` keyword.
- *
- * defined?(a)
- * ^^^^^^^^^^^
- *
- */
- public static final class DefinedNode extends Node {
- public final Node value;
-
- public DefinedNode(Node value, int startOffset, int length) {
- super(startOffset, length);
- this.value = value;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.value.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.value };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitDefinedNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("value: ");
- builder.append(this.value.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents an `else` clause in a `case`, `if`, or `unless` statement.
- *
- * if a then b else c end
- * ^^^^^^^^^^
- *
- */
- public static final class ElseNode extends Node {
- @Nullable
- public final StatementsNode statements;
-
- public ElseNode(StatementsNode statements, int startOffset, int length) {
- super(startOffset, length);
- this.statements = statements;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.statements != null) {
- this.statements.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.statements };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitElseNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("statements: ");
- builder.append(this.statements == null ? "null\n" : this.statements.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents an interpolated set of statements.
- *
- * "foo #{bar}"
- * ^^^^^^
- *
- */
- public static final class EmbeddedStatementsNode extends Node {
- @Nullable
- public final StatementsNode statements;
-
- public EmbeddedStatementsNode(StatementsNode statements, int startOffset, int length) {
- super(startOffset, length);
- this.statements = statements;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.statements != null) {
- this.statements.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.statements };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitEmbeddedStatementsNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("statements: ");
- builder.append(this.statements == null ? "null\n" : this.statements.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents an interpolated variable.
- *
- * "foo #@bar"
- * ^^^^^
- *
- */
- public static final class EmbeddedVariableNode extends Node {
- public final Node variable;
-
- public EmbeddedVariableNode(Node variable, int startOffset, int length) {
- super(startOffset, length);
- this.variable = variable;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- this.variable.accept(visitor);
- }
-
- public Node[] childNodes() {
- return new Node[] { this.variable };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitEmbeddedVariableNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("variable: ");
- builder.append(this.variable.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents an `ensure` clause in a `begin` statement.
- *
- * begin
- * foo
- * ensure
- * ^^^^^^
- * bar
- * end
- *
- */
- public static final class EnsureNode extends Node {
- @Nullable
- public final StatementsNode statements;
-
- public EnsureNode(StatementsNode statements, int startOffset, int length) {
- super(startOffset, length);
- this.statements = statements;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.statements != null) {
- this.statements.accept(visitor);
- }
- }
-
- public Node[] childNodes() {
- return new Node[] { this.statements };
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitEnsureNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- builder.append(nextIndent);
- builder.append("statements: ");
- builder.append(this.statements == null ? "null\n" : this.statements.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the literal `false` keyword.
- *
- * false
- * ^^^^^
- *
- */
- public static final class FalseNode extends Node {
-
- public FalseNode(int startOffset, int length) {
- super(startOffset, length);
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- }
-
- public Node[] childNodes() {
- return EMPTY_ARRAY;
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitFalseNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents a find pattern in pattern matching.
- *
- * foo in *bar, baz, *qux
- * ^^^^^^^^^^^^^^^
- *
- * foo in [*bar, baz, *qux]
- * ^^^^^^^^^^^^^^^^^
- *
- * foo in Foo(*bar, baz, *qux)
- * ^^^^^^^^^^^^^^^^^^^^
- *
- */
- public static final class FindPatternNode extends Node {
- @Nullable
- public final Node constant;
- public final Node left;
- public final Node[] requireds;
- public final Node right;
-
- public FindPatternNode(Node constant, Node left, Node[] requireds, Node right, int startOffset, int length) {
- super(startOffset, length);
- this.constant = constant;
- this.left = left;
- this.requireds = requireds;
- this.right = right;
- }
-
- public void visitChildNodes(AbstractNodeVisitor visitor) {
- if (this.constant != null) {
- this.constant.accept(visitor);
- }
- this.left.accept(visitor);
- for (Nodes.Node child : this.requireds) {
- child.accept(visitor);
- }
- this.right.accept(visitor);
- }
-
- public Node[] childNodes() {
- ArrayList childNodes = new ArrayList<>();
- childNodes.add(this.constant);
- childNodes.add(this.left);
- childNodes.addAll(Arrays.asList(this.requireds));
- childNodes.add(this.right);
- return childNodes.toArray(EMPTY_ARRAY);
- }
-
- public T accept(AbstractNodeVisitor visitor) {
- return visitor.visitFindPatternNode(this);
- }
-
- @Override
- protected String toString(String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- if (hasNewLineFlag()) {
- builder.append("[Li]");
- }
- builder.append('\n');
- String nextIndent = indent + " ";
- String nextNextIndent = nextIndent + " ";
- builder.append(nextIndent);
- builder.append("constant: ");
- builder.append(this.constant == null ? "null\n" : this.constant.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("left: ");
- builder.append(this.left.toString(nextIndent));
- builder.append(nextIndent);
- builder.append("requireds: ");
- builder.append('\n');
- for (Node child : this.requireds) {
- builder.append(nextNextIndent).append(child.toString(nextNextIndent));
- }
- builder.append(nextIndent);
- builder.append("right: ");
- builder.append(this.right.toString(nextIndent));
- return builder.toString();
- }
- }
-
- /**
- *
- * Represents the use of the `..` or `...` operators to create flip flops.
- *
- * baz if foo .. bar
- * ^^^^^^^^^^
- *
- */
- public static final class FlipFlopNode extends Node {
- public final short flags;
- @Nullable
- public final Node left;
- @Nullable
- public final Node right;
-
- public FlipFlopNode(short flags, Node left, Node right, int startOffset, int length) {
- super(startOffset, length);
- this.flags = flags;
- this.left = left;
- this.right = right;
- }
-
- public boolean isExcludeEnd() {
- return RangeFlags.isExcludeEnd(this.flags);
- }
-
- public void visitChildNodes(AbstractNodeVisitor