// NOTE: This file is generated by the templates/template.rb script and should not // be modified manually. See /home/runner/work/herb/herb/templates/javascript/packages/core/src/nodes.ts.erb import { Location } from "./location.js" import { Token, SerializedToken } from "./token.js" import { HerbError } from "./errors.js" import { deserializePrismNode, inspectPrismSerialized } from "./prism/index.js" import type { PrismNode } from "./prism/index.js" import type { SerializedLocation } from "./location.js" import type { SerializedHerbError } from "./errors.js" import type { Visitor } from "./visitor.js" export type SerializedNodeType = string export interface SerializedNode { type: SerializedNodeType location: SerializedLocation errors: SerializedHerbError[] } export interface BaseNodeProps { type: NodeType location: Location errors: HerbError[] } export abstract class Node implements BaseNodeProps { readonly type: NodeType readonly location: Location readonly errors: HerbError[] source: string | null = null static from(node: SerializedNode): Node { return fromSerializedNode(node) } static get type(): NodeType { throw new Error("AST_NODE") } constructor(type: NodeType, location: Location, errors: HerbError[]) { this.type = type this.location = location this.errors = errors } setSource(source: string): void { this.source = source this.compactChildNodes().forEach(child => child.setSource(source)) } toJSON(): SerializedNode { return { type: this.type, location: this.location.toJSON(), errors: this.errors, } } inspect(): string { return this.treeInspect(0) } is(nodeClass: { new(...args: any[]): T; prototype: T, type: NodeType }): this is T { return this.type === nodeClass.type } isOfType(type: NodeType): this is T { return this.type === type } get isSingleLine(): boolean { return this.location.start.line === this.location.end.line } abstract treeInspect(indent?: number): string abstract recursiveErrors(): HerbError[] abstract accept(visitor: Visitor): void abstract childNodes(): (Node | null | undefined)[] abstract compactChildNodes(): Node[] protected inspectArray( array: (Node | HerbError)[] | null | undefined, prefix: string, ): string { if (!array) return "∅\n" if (array.length === 0) return "[]\n" let output = `(${array.length} item${array.length === 1 ? "" : "s"})\n` array.forEach((item, index) => { const isLast = index === array.length - 1 if (item instanceof Node || item instanceof HerbError) { output += this.inspectNode( item, prefix, isLast ? " " : "│ ", isLast, false, ) } else { const symbol = isLast ? "└── " : "├── " output += `${prefix}${symbol} ${item}\n` } }) output += `${prefix}\n` return output } protected inspectNode( node: Node | HerbError | undefined | null, prefix: string, prefix2: string = " ", last: boolean = true, trailingNewline: boolean = true, ): string { if (!node) return "∅\n" let output = trailingNewline ? "\n" : "" output += `${prefix}` output += last ? "└── " : "├── " output += node .treeInspect() .trimStart() .split("\n") .map((line, index) => index === 0 ? line.trimStart() : `${prefix}${prefix2}${line}`, ) .join("\n") .trimStart() output += `\n` return output } } export interface SerializedDocumentNode extends SerializedNode { type: "AST_DOCUMENT_NODE"; children: SerializedNode[]; // no-op for prism_context prism_node: number[] | null; } export interface DocumentNodeProps extends Omit { type: "AST_DOCUMENT_NODE"; children: Node[]; // no-op for prism_context prism_node: Uint8Array | null; } export class DocumentNode extends Node { declare readonly type: "AST_DOCUMENT_NODE"; readonly children: Node[]; // no-op for prism_context readonly prism_node: Uint8Array | null; static get type(): NodeType { return "AST_DOCUMENT_NODE" } static from(data: SerializedDocumentNode): DocumentNode { return new DocumentNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), children: (data.children || []).map(node => fromSerializedNode(node)), // no-op for prism_context prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, }) } constructor(props: DocumentNodeProps) { super(props.type, props.location, props.errors); this.children = props.children; // no-op for prism_context this.prism_node = props.prism_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitDocumentNode as ((node: DocumentNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedDocumentNode { return { ...super.toJSON(), type: "AST_DOCUMENT_NODE", children: this.children.map(node => node.toJSON()), // no-op for prism_context prism_node: this.prism_node ? Array.from(this.prism_node) : null, }; } treeInspect(): string { let output = ""; output += `@ DocumentNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; { const isLast = !this.prism_node; const symbol = isLast ? "└──" : "├──"; const childPrefix = isLast ? " " : "│ "; output += `${symbol} children: ${this.inspectArray(this.children, childPrefix)}`; } if (this.prism_node) { output += `└── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, " ") : `(${this.prism_node.length} bytes)`}\n`; } return output } } export interface SerializedLiteralNode extends SerializedNode { type: "AST_LITERAL_NODE"; content: string; } export interface LiteralNodeProps extends Omit { type: "AST_LITERAL_NODE"; content: string; } export class LiteralNode extends Node { declare readonly type: "AST_LITERAL_NODE"; readonly content: string; static get type(): NodeType { return "AST_LITERAL_NODE" } static from(data: SerializedLiteralNode): LiteralNode { return new LiteralNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), content: data.content, }) } constructor(props: LiteralNodeProps) { super(props.type, props.location, props.errors); this.content = props.content; } accept(visitor: Visitor): void { const visitMethod = visitor.visitLiteralNode as ((node: LiteralNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ].flat(); } toJSON(): SerializedLiteralNode { return { ...super.toJSON(), type: "AST_LITERAL_NODE", content: this.content, }; } treeInspect(): string { let output = ""; output += `@ LiteralNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `└── content: ${this.content ? JSON.stringify(this.content) : "∅"}\n`; return output } } export interface SerializedHTMLOpenTagNode extends SerializedNode { type: "AST_HTML_OPEN_TAG_NODE"; tag_opening: SerializedToken | null; tag_name: SerializedToken | null; tag_closing: SerializedToken | null; children: SerializedNode[]; is_void: boolean; } export interface HTMLOpenTagNodeProps extends Omit { type: "AST_HTML_OPEN_TAG_NODE"; tag_opening: Token | null; tag_name: Token | null; tag_closing: Token | null; children: Node[]; is_void: boolean; } export class HTMLOpenTagNode extends Node { declare readonly type: "AST_HTML_OPEN_TAG_NODE"; readonly tag_opening: Token | null; readonly tag_name: Token | null; readonly tag_closing: Token | null; readonly children: Node[]; readonly is_void: boolean; static get type(): NodeType { return "AST_HTML_OPEN_TAG_NODE" } static from(data: SerializedHTMLOpenTagNode): HTMLOpenTagNode { return new HTMLOpenTagNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, tag_name: data.tag_name ? Token.from(data.tag_name) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, children: (data.children || []).map(node => fromSerializedNode(node)), is_void: data.is_void, }) } constructor(props: HTMLOpenTagNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.tag_name = props.tag_name; this.tag_closing = props.tag_closing; this.children = props.children; this.is_void = props.is_void; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLOpenTagNode as ((node: HTMLOpenTagNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedHTMLOpenTagNode { return { ...super.toJSON(), type: "AST_HTML_OPEN_TAG_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, tag_name: this.tag_name ? this.tag_name.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, children: this.children.map(node => node.toJSON()), is_void: this.is_void, }; } treeInspect(): string { let output = ""; output += `@ HTMLOpenTagNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `├── children: ${this.inspectArray(this.children, "│ ")}`; output += `└── is_void: ${typeof this.is_void === 'boolean' ? String(this.is_void) : "∅"}\n`; return output } } export interface SerializedHTMLConditionalOpenTagNode extends SerializedNode { type: "AST_HTML_CONDITIONAL_OPEN_TAG_NODE"; conditional: SerializedERBIfNode | SerializedERBUnlessNode | null; tag_name: SerializedToken | null; is_void: boolean; } export interface HTMLConditionalOpenTagNodeProps extends Omit { type: "AST_HTML_CONDITIONAL_OPEN_TAG_NODE"; conditional: ERBIfNode | ERBUnlessNode | null; tag_name: Token | null; is_void: boolean; } export class HTMLConditionalOpenTagNode extends Node { declare readonly type: "AST_HTML_CONDITIONAL_OPEN_TAG_NODE"; readonly conditional: ERBIfNode | ERBUnlessNode | null; readonly tag_name: Token | null; readonly is_void: boolean; static get type(): NodeType { return "AST_HTML_CONDITIONAL_OPEN_TAG_NODE" } static from(data: SerializedHTMLConditionalOpenTagNode): HTMLConditionalOpenTagNode { return new HTMLConditionalOpenTagNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), conditional: data.conditional ? fromSerializedNode((data.conditional)) as ERBIfNode | ERBUnlessNode : null, tag_name: data.tag_name ? Token.from(data.tag_name) : null, is_void: data.is_void, }) } constructor(props: HTMLConditionalOpenTagNodeProps) { super(props.type, props.location, props.errors); this.conditional = props.conditional; this.tag_name = props.tag_name; this.is_void = props.is_void; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLConditionalOpenTagNode as ((node: HTMLConditionalOpenTagNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ this.conditional, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, this.conditional ? this.conditional.recursiveErrors() : [], ].flat(); } toJSON(): SerializedHTMLConditionalOpenTagNode { return { ...super.toJSON(), type: "AST_HTML_CONDITIONAL_OPEN_TAG_NODE", conditional: this.conditional ? this.conditional.toJSON() : null, tag_name: this.tag_name ? this.tag_name.toJSON() : null, is_void: this.is_void, }; } treeInspect(): string { let output = ""; output += `@ HTMLConditionalOpenTagNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── conditional: ${this.inspectNode(this.conditional, "│ ")}`; output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`; output += `└── is_void: ${typeof this.is_void === 'boolean' ? String(this.is_void) : "∅"}\n`; return output } } export interface SerializedHTMLCloseTagNode extends SerializedNode { type: "AST_HTML_CLOSE_TAG_NODE"; tag_opening: SerializedToken | null; tag_name: SerializedToken | null; children: SerializedNode[]; tag_closing: SerializedToken | null; } export interface HTMLCloseTagNodeProps extends Omit { type: "AST_HTML_CLOSE_TAG_NODE"; tag_opening: Token | null; tag_name: Token | null; children: any[]; tag_closing: Token | null; } export class HTMLCloseTagNode extends Node { declare readonly type: "AST_HTML_CLOSE_TAG_NODE"; readonly tag_opening: Token | null; readonly tag_name: Token | null; readonly children: Node[]; readonly tag_closing: Token | null; static get type(): NodeType { return "AST_HTML_CLOSE_TAG_NODE" } static from(data: SerializedHTMLCloseTagNode): HTMLCloseTagNode { return new HTMLCloseTagNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, tag_name: data.tag_name ? Token.from(data.tag_name) : null, children: (data.children || []).map(node => fromSerializedNode(node)), tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, }) } constructor(props: HTMLCloseTagNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.tag_name = props.tag_name; this.children = props.children; this.tag_closing = props.tag_closing; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLCloseTagNode as ((node: HTMLCloseTagNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedHTMLCloseTagNode { return { ...super.toJSON(), type: "AST_HTML_CLOSE_TAG_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, tag_name: this.tag_name ? this.tag_name.toJSON() : null, children: this.children.map(node => node.toJSON()), tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ HTMLCloseTagNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`; output += `├── children: ${this.inspectArray(this.children, "│ ")}`; output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; return output } } export interface SerializedHTMLOmittedCloseTagNode extends SerializedNode { type: "AST_HTML_OMITTED_CLOSE_TAG_NODE"; tag_name: SerializedToken | null; } export interface HTMLOmittedCloseTagNodeProps extends Omit { type: "AST_HTML_OMITTED_CLOSE_TAG_NODE"; tag_name: Token | null; } export class HTMLOmittedCloseTagNode extends Node { declare readonly type: "AST_HTML_OMITTED_CLOSE_TAG_NODE"; readonly tag_name: Token | null; static get type(): NodeType { return "AST_HTML_OMITTED_CLOSE_TAG_NODE" } static from(data: SerializedHTMLOmittedCloseTagNode): HTMLOmittedCloseTagNode { return new HTMLOmittedCloseTagNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_name: data.tag_name ? Token.from(data.tag_name) : null, }) } constructor(props: HTMLOmittedCloseTagNodeProps) { super(props.type, props.location, props.errors); this.tag_name = props.tag_name; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLOmittedCloseTagNode as ((node: HTMLOmittedCloseTagNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ].flat(); } toJSON(): SerializedHTMLOmittedCloseTagNode { return { ...super.toJSON(), type: "AST_HTML_OMITTED_CLOSE_TAG_NODE", tag_name: this.tag_name ? this.tag_name.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ HTMLOmittedCloseTagNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `└── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`; return output } } export interface SerializedHTMLVirtualCloseTagNode extends SerializedNode { type: "AST_HTML_VIRTUAL_CLOSE_TAG_NODE"; tag_name: SerializedToken | null; } export interface HTMLVirtualCloseTagNodeProps extends Omit { type: "AST_HTML_VIRTUAL_CLOSE_TAG_NODE"; tag_name: Token | null; } export class HTMLVirtualCloseTagNode extends Node { declare readonly type: "AST_HTML_VIRTUAL_CLOSE_TAG_NODE"; readonly tag_name: Token | null; static get type(): NodeType { return "AST_HTML_VIRTUAL_CLOSE_TAG_NODE" } static from(data: SerializedHTMLVirtualCloseTagNode): HTMLVirtualCloseTagNode { return new HTMLVirtualCloseTagNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_name: data.tag_name ? Token.from(data.tag_name) : null, }) } constructor(props: HTMLVirtualCloseTagNodeProps) { super(props.type, props.location, props.errors); this.tag_name = props.tag_name; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLVirtualCloseTagNode as ((node: HTMLVirtualCloseTagNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ].flat(); } toJSON(): SerializedHTMLVirtualCloseTagNode { return { ...super.toJSON(), type: "AST_HTML_VIRTUAL_CLOSE_TAG_NODE", tag_name: this.tag_name ? this.tag_name.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ HTMLVirtualCloseTagNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `└── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`; return output } } export interface SerializedHTMLElementNode extends SerializedNode { type: "AST_HTML_ELEMENT_NODE"; open_tag: SerializedHTMLOpenTagNode | SerializedHTMLConditionalOpenTagNode | SerializedERBOpenTagNode | null; tag_name: SerializedToken | null; body: SerializedNode[]; close_tag: SerializedHTMLCloseTagNode | SerializedHTMLOmittedCloseTagNode | SerializedHTMLVirtualCloseTagNode | SerializedERBEndNode | null; is_void: boolean; element_source: string; } export interface HTMLElementNodeProps extends Omit { type: "AST_HTML_ELEMENT_NODE"; open_tag: HTMLOpenTagNode | HTMLConditionalOpenTagNode | ERBOpenTagNode | null; tag_name: Token | null; body: Node[]; close_tag: HTMLCloseTagNode | HTMLOmittedCloseTagNode | HTMLVirtualCloseTagNode | ERBEndNode | null; is_void: boolean; element_source: string; } export class HTMLElementNode extends Node { declare readonly type: "AST_HTML_ELEMENT_NODE"; readonly open_tag: HTMLOpenTagNode | HTMLConditionalOpenTagNode | ERBOpenTagNode | null; readonly tag_name: Token | null; readonly body: Node[]; readonly close_tag: HTMLCloseTagNode | HTMLOmittedCloseTagNode | HTMLVirtualCloseTagNode | ERBEndNode | null; readonly is_void: boolean; readonly element_source: string; static get type(): NodeType { return "AST_HTML_ELEMENT_NODE" } static from(data: SerializedHTMLElementNode): HTMLElementNode { return new HTMLElementNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), open_tag: data.open_tag ? fromSerializedNode((data.open_tag)) as HTMLOpenTagNode | HTMLConditionalOpenTagNode | ERBOpenTagNode : null, tag_name: data.tag_name ? Token.from(data.tag_name) : null, body: (data.body || []).map(node => fromSerializedNode(node)), close_tag: data.close_tag ? fromSerializedNode((data.close_tag)) as HTMLCloseTagNode | HTMLOmittedCloseTagNode | HTMLVirtualCloseTagNode | ERBEndNode : null, is_void: data.is_void, element_source: data.element_source, }) } constructor(props: HTMLElementNodeProps) { super(props.type, props.location, props.errors); this.open_tag = props.open_tag; this.tag_name = props.tag_name; this.body = props.body; this.close_tag = props.close_tag; this.is_void = props.is_void; this.element_source = props.element_source; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLElementNode as ((node: HTMLElementNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ this.open_tag, ...this.body, this.close_tag, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, this.open_tag ? this.open_tag.recursiveErrors() : [], ...this.body.map(node => node.recursiveErrors()), this.close_tag ? this.close_tag.recursiveErrors() : [], ].flat(); } toJSON(): SerializedHTMLElementNode { return { ...super.toJSON(), type: "AST_HTML_ELEMENT_NODE", open_tag: this.open_tag ? this.open_tag.toJSON() : null, tag_name: this.tag_name ? this.tag_name.toJSON() : null, body: this.body.map(node => node.toJSON()), close_tag: this.close_tag ? this.close_tag.toJSON() : null, is_void: this.is_void, element_source: this.element_source, }; } treeInspect(): string { let output = ""; output += `@ HTMLElementNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── open_tag: ${this.inspectNode(this.open_tag, "│ ")}`; output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`; output += `├── body: ${this.inspectArray(this.body, "│ ")}`; output += `├── close_tag: ${this.inspectNode(this.close_tag, "│ ")}`; output += `├── is_void: ${typeof this.is_void === 'boolean' ? String(this.is_void) : "∅"}\n`; output += `└── element_source: ${this.element_source ? JSON.stringify(this.element_source) : "∅"}\n`; return output } } export interface SerializedHTMLConditionalElementNode extends SerializedNode { type: "AST_HTML_CONDITIONAL_ELEMENT_NODE"; condition: string; open_conditional: SerializedERBIfNode | SerializedERBUnlessNode | null; open_tag: SerializedHTMLOpenTagNode | null; body: SerializedNode[]; close_tag: SerializedHTMLCloseTagNode | SerializedHTMLOmittedCloseTagNode | null; close_conditional: SerializedERBIfNode | SerializedERBUnlessNode | null; tag_name: SerializedToken | null; element_source: string; } export interface HTMLConditionalElementNodeProps extends Omit { type: "AST_HTML_CONDITIONAL_ELEMENT_NODE"; condition: string; open_conditional: ERBIfNode | ERBUnlessNode | null; open_tag: HTMLOpenTagNode | null; body: Node[]; close_tag: HTMLCloseTagNode | HTMLOmittedCloseTagNode | null; close_conditional: ERBIfNode | ERBUnlessNode | null; tag_name: Token | null; element_source: string; } export class HTMLConditionalElementNode extends Node { declare readonly type: "AST_HTML_CONDITIONAL_ELEMENT_NODE"; readonly condition: string; readonly open_conditional: ERBIfNode | ERBUnlessNode | null; readonly open_tag: HTMLOpenTagNode | null; readonly body: Node[]; readonly close_tag: HTMLCloseTagNode | HTMLOmittedCloseTagNode | null; readonly close_conditional: ERBIfNode | ERBUnlessNode | null; readonly tag_name: Token | null; readonly element_source: string; static get type(): NodeType { return "AST_HTML_CONDITIONAL_ELEMENT_NODE" } static from(data: SerializedHTMLConditionalElementNode): HTMLConditionalElementNode { return new HTMLConditionalElementNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), condition: data.condition, open_conditional: data.open_conditional ? fromSerializedNode((data.open_conditional)) as ERBIfNode | ERBUnlessNode : null, open_tag: data.open_tag ? fromSerializedNode((data.open_tag)) as HTMLOpenTagNode : null, body: (data.body || []).map(node => fromSerializedNode(node)), close_tag: data.close_tag ? fromSerializedNode((data.close_tag)) as HTMLCloseTagNode | HTMLOmittedCloseTagNode : null, close_conditional: data.close_conditional ? fromSerializedNode((data.close_conditional)) as ERBIfNode | ERBUnlessNode : null, tag_name: data.tag_name ? Token.from(data.tag_name) : null, element_source: data.element_source, }) } constructor(props: HTMLConditionalElementNodeProps) { super(props.type, props.location, props.errors); this.condition = props.condition; this.open_conditional = props.open_conditional; this.open_tag = props.open_tag; this.body = props.body; this.close_tag = props.close_tag; this.close_conditional = props.close_conditional; this.tag_name = props.tag_name; this.element_source = props.element_source; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLConditionalElementNode as ((node: HTMLConditionalElementNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ this.open_conditional, this.open_tag, ...this.body, this.close_tag, this.close_conditional, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, this.open_conditional ? this.open_conditional.recursiveErrors() : [], this.open_tag ? this.open_tag.recursiveErrors() : [], ...this.body.map(node => node.recursiveErrors()), this.close_tag ? this.close_tag.recursiveErrors() : [], this.close_conditional ? this.close_conditional.recursiveErrors() : [], ].flat(); } toJSON(): SerializedHTMLConditionalElementNode { return { ...super.toJSON(), type: "AST_HTML_CONDITIONAL_ELEMENT_NODE", condition: this.condition, open_conditional: this.open_conditional ? this.open_conditional.toJSON() : null, open_tag: this.open_tag ? this.open_tag.toJSON() : null, body: this.body.map(node => node.toJSON()), close_tag: this.close_tag ? this.close_tag.toJSON() : null, close_conditional: this.close_conditional ? this.close_conditional.toJSON() : null, tag_name: this.tag_name ? this.tag_name.toJSON() : null, element_source: this.element_source, }; } treeInspect(): string { let output = ""; output += `@ HTMLConditionalElementNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── condition: ${this.condition ? JSON.stringify(this.condition) : "∅"}\n`; output += `├── open_conditional: ${this.inspectNode(this.open_conditional, "│ ")}`; output += `├── open_tag: ${this.inspectNode(this.open_tag, "│ ")}`; output += `├── body: ${this.inspectArray(this.body, "│ ")}`; output += `├── close_tag: ${this.inspectNode(this.close_tag, "│ ")}`; output += `├── close_conditional: ${this.inspectNode(this.close_conditional, "│ ")}`; output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`; output += `└── element_source: ${this.element_source ? JSON.stringify(this.element_source) : "∅"}\n`; return output } } export interface SerializedHTMLAttributeValueNode extends SerializedNode { type: "AST_HTML_ATTRIBUTE_VALUE_NODE"; open_quote: SerializedToken | null; children: SerializedNode[]; close_quote: SerializedToken | null; quoted: boolean; } export interface HTMLAttributeValueNodeProps extends Omit { type: "AST_HTML_ATTRIBUTE_VALUE_NODE"; open_quote: Token | null; children: Node[]; close_quote: Token | null; quoted: boolean; } export class HTMLAttributeValueNode extends Node { declare readonly type: "AST_HTML_ATTRIBUTE_VALUE_NODE"; readonly open_quote: Token | null; readonly children: Node[]; readonly close_quote: Token | null; readonly quoted: boolean; static get type(): NodeType { return "AST_HTML_ATTRIBUTE_VALUE_NODE" } static from(data: SerializedHTMLAttributeValueNode): HTMLAttributeValueNode { return new HTMLAttributeValueNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), open_quote: data.open_quote ? Token.from(data.open_quote) : null, children: (data.children || []).map(node => fromSerializedNode(node)), close_quote: data.close_quote ? Token.from(data.close_quote) : null, quoted: data.quoted, }) } constructor(props: HTMLAttributeValueNodeProps) { super(props.type, props.location, props.errors); this.open_quote = props.open_quote; this.children = props.children; this.close_quote = props.close_quote; this.quoted = props.quoted; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLAttributeValueNode as ((node: HTMLAttributeValueNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedHTMLAttributeValueNode { return { ...super.toJSON(), type: "AST_HTML_ATTRIBUTE_VALUE_NODE", open_quote: this.open_quote ? this.open_quote.toJSON() : null, children: this.children.map(node => node.toJSON()), close_quote: this.close_quote ? this.close_quote.toJSON() : null, quoted: this.quoted, }; } treeInspect(): string { let output = ""; output += `@ HTMLAttributeValueNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── open_quote: ${this.open_quote ? this.open_quote.treeInspect() : "∅"}\n`; output += `├── children: ${this.inspectArray(this.children, "│ ")}`; output += `├── close_quote: ${this.close_quote ? this.close_quote.treeInspect() : "∅"}\n`; output += `└── quoted: ${typeof this.quoted === 'boolean' ? String(this.quoted) : "∅"}\n`; return output } } export interface SerializedHTMLAttributeNameNode extends SerializedNode { type: "AST_HTML_ATTRIBUTE_NAME_NODE"; children: SerializedNode[]; } export interface HTMLAttributeNameNodeProps extends Omit { type: "AST_HTML_ATTRIBUTE_NAME_NODE"; children: any[]; } export class HTMLAttributeNameNode extends Node { declare readonly type: "AST_HTML_ATTRIBUTE_NAME_NODE"; readonly children: Node[]; static get type(): NodeType { return "AST_HTML_ATTRIBUTE_NAME_NODE" } static from(data: SerializedHTMLAttributeNameNode): HTMLAttributeNameNode { return new HTMLAttributeNameNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), children: (data.children || []).map(node => fromSerializedNode(node)), }) } constructor(props: HTMLAttributeNameNodeProps) { super(props.type, props.location, props.errors); this.children = props.children; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLAttributeNameNode as ((node: HTMLAttributeNameNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedHTMLAttributeNameNode { return { ...super.toJSON(), type: "AST_HTML_ATTRIBUTE_NAME_NODE", children: this.children.map(node => node.toJSON()), }; } treeInspect(): string { let output = ""; output += `@ HTMLAttributeNameNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `└── children: ${this.inspectArray(this.children, " ")}`; return output } } export interface SerializedHTMLAttributeNode extends SerializedNode { type: "AST_HTML_ATTRIBUTE_NODE"; name: SerializedHTMLAttributeNameNode | null; equals: SerializedToken | null; value: SerializedHTMLAttributeValueNode | null; } export interface HTMLAttributeNodeProps extends Omit { type: "AST_HTML_ATTRIBUTE_NODE"; name: HTMLAttributeNameNode | null; equals: Token | null; value: HTMLAttributeValueNode | null; } export class HTMLAttributeNode extends Node { declare readonly type: "AST_HTML_ATTRIBUTE_NODE"; readonly name: HTMLAttributeNameNode | null; readonly equals: Token | null; readonly value: HTMLAttributeValueNode | null; static get type(): NodeType { return "AST_HTML_ATTRIBUTE_NODE" } static from(data: SerializedHTMLAttributeNode): HTMLAttributeNode { return new HTMLAttributeNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), name: data.name ? fromSerializedNode((data.name)) as HTMLAttributeNameNode : null, equals: data.equals ? Token.from(data.equals) : null, value: data.value ? fromSerializedNode((data.value)) as HTMLAttributeValueNode : null, }) } constructor(props: HTMLAttributeNodeProps) { super(props.type, props.location, props.errors); this.name = props.name; this.equals = props.equals; this.value = props.value; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLAttributeNode as ((node: HTMLAttributeNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ this.name, this.value, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, this.name ? this.name.recursiveErrors() : [], this.value ? this.value.recursiveErrors() : [], ].flat(); } toJSON(): SerializedHTMLAttributeNode { return { ...super.toJSON(), type: "AST_HTML_ATTRIBUTE_NODE", name: this.name ? this.name.toJSON() : null, equals: this.equals ? this.equals.toJSON() : null, value: this.value ? this.value.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ HTMLAttributeNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── name: ${this.inspectNode(this.name, "│ ")}`; output += `├── equals: ${this.equals ? this.equals.treeInspect() : "∅"}\n`; output += `└── value: ${this.inspectNode(this.value, " ")}`; return output } } export interface SerializedRubyLiteralNode extends SerializedNode { type: "AST_RUBY_LITERAL_NODE"; content: string; } export interface RubyLiteralNodeProps extends Omit { type: "AST_RUBY_LITERAL_NODE"; content: string; } export class RubyLiteralNode extends Node { declare readonly type: "AST_RUBY_LITERAL_NODE"; readonly content: string; static get type(): NodeType { return "AST_RUBY_LITERAL_NODE" } static from(data: SerializedRubyLiteralNode): RubyLiteralNode { return new RubyLiteralNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), content: data.content, }) } constructor(props: RubyLiteralNodeProps) { super(props.type, props.location, props.errors); this.content = props.content; } accept(visitor: Visitor): void { const visitMethod = visitor.visitRubyLiteralNode as ((node: RubyLiteralNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ].flat(); } toJSON(): SerializedRubyLiteralNode { return { ...super.toJSON(), type: "AST_RUBY_LITERAL_NODE", content: this.content, }; } treeInspect(): string { let output = ""; output += `@ RubyLiteralNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `└── content: ${this.content ? JSON.stringify(this.content) : "∅"}\n`; return output } } export interface SerializedRubyHTMLAttributesSplatNode extends SerializedNode { type: "AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE"; content: string; prefix: string; } export interface RubyHTMLAttributesSplatNodeProps extends Omit { type: "AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE"; content: string; prefix: string; } export class RubyHTMLAttributesSplatNode extends Node { declare readonly type: "AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE"; readonly content: string; readonly prefix: string; static get type(): NodeType { return "AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE" } static from(data: SerializedRubyHTMLAttributesSplatNode): RubyHTMLAttributesSplatNode { return new RubyHTMLAttributesSplatNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), content: data.content, prefix: data.prefix, }) } constructor(props: RubyHTMLAttributesSplatNodeProps) { super(props.type, props.location, props.errors); this.content = props.content; this.prefix = props.prefix; } accept(visitor: Visitor): void { const visitMethod = visitor.visitRubyHTMLAttributesSplatNode as ((node: RubyHTMLAttributesSplatNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ].flat(); } toJSON(): SerializedRubyHTMLAttributesSplatNode { return { ...super.toJSON(), type: "AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE", content: this.content, prefix: this.prefix, }; } treeInspect(): string { let output = ""; output += `@ RubyHTMLAttributesSplatNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── content: ${this.content ? JSON.stringify(this.content) : "∅"}\n`; output += `└── prefix: ${this.prefix ? JSON.stringify(this.prefix) : "∅"}\n`; return output } } export interface SerializedERBOpenTagNode extends SerializedNode { type: "AST_ERB_OPEN_TAG_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; tag_name: SerializedToken | null; children: SerializedNode[]; } export interface ERBOpenTagNodeProps extends Omit { type: "AST_ERB_OPEN_TAG_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; tag_name: Token | null; children: Node[]; } export class ERBOpenTagNode extends Node { declare readonly type: "AST_ERB_OPEN_TAG_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly tag_name: Token | null; readonly children: Node[]; static get type(): NodeType { return "AST_ERB_OPEN_TAG_NODE" } static from(data: SerializedERBOpenTagNode): ERBOpenTagNode { return new ERBOpenTagNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, tag_name: data.tag_name ? Token.from(data.tag_name) : null, children: (data.children || []).map(node => fromSerializedNode(node)), }) } constructor(props: ERBOpenTagNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.tag_name = props.tag_name; this.children = props.children; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBOpenTagNode as ((node: ERBOpenTagNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedERBOpenTagNode { return { ...super.toJSON(), type: "AST_ERB_OPEN_TAG_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, tag_name: this.tag_name ? this.tag_name.toJSON() : null, children: this.children.map(node => node.toJSON()), }; } treeInspect(): string { let output = ""; output += `@ ERBOpenTagNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`; output += `└── children: ${this.inspectArray(this.children, " ")}`; return output } } export interface SerializedHTMLTextNode extends SerializedNode { type: "AST_HTML_TEXT_NODE"; content: string; } export interface HTMLTextNodeProps extends Omit { type: "AST_HTML_TEXT_NODE"; content: string; } export class HTMLTextNode extends Node { declare readonly type: "AST_HTML_TEXT_NODE"; readonly content: string; static get type(): NodeType { return "AST_HTML_TEXT_NODE" } static from(data: SerializedHTMLTextNode): HTMLTextNode { return new HTMLTextNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), content: data.content, }) } constructor(props: HTMLTextNodeProps) { super(props.type, props.location, props.errors); this.content = props.content; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLTextNode as ((node: HTMLTextNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ].flat(); } toJSON(): SerializedHTMLTextNode { return { ...super.toJSON(), type: "AST_HTML_TEXT_NODE", content: this.content, }; } treeInspect(): string { let output = ""; output += `@ HTMLTextNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `└── content: ${this.content ? JSON.stringify(this.content) : "∅"}\n`; return output } } export interface SerializedHTMLCommentNode extends SerializedNode { type: "AST_HTML_COMMENT_NODE"; comment_start: SerializedToken | null; children: SerializedNode[]; comment_end: SerializedToken | null; } export interface HTMLCommentNodeProps extends Omit { type: "AST_HTML_COMMENT_NODE"; comment_start: Token | null; children: Node[]; comment_end: Token | null; } export class HTMLCommentNode extends Node { declare readonly type: "AST_HTML_COMMENT_NODE"; readonly comment_start: Token | null; readonly children: Node[]; readonly comment_end: Token | null; static get type(): NodeType { return "AST_HTML_COMMENT_NODE" } static from(data: SerializedHTMLCommentNode): HTMLCommentNode { return new HTMLCommentNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), comment_start: data.comment_start ? Token.from(data.comment_start) : null, children: (data.children || []).map(node => fromSerializedNode(node)), comment_end: data.comment_end ? Token.from(data.comment_end) : null, }) } constructor(props: HTMLCommentNodeProps) { super(props.type, props.location, props.errors); this.comment_start = props.comment_start; this.children = props.children; this.comment_end = props.comment_end; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLCommentNode as ((node: HTMLCommentNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedHTMLCommentNode { return { ...super.toJSON(), type: "AST_HTML_COMMENT_NODE", comment_start: this.comment_start ? this.comment_start.toJSON() : null, children: this.children.map(node => node.toJSON()), comment_end: this.comment_end ? this.comment_end.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ HTMLCommentNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── comment_start: ${this.comment_start ? this.comment_start.treeInspect() : "∅"}\n`; output += `├── children: ${this.inspectArray(this.children, "│ ")}`; output += `└── comment_end: ${this.comment_end ? this.comment_end.treeInspect() : "∅"}\n`; return output } } export interface SerializedHTMLDoctypeNode extends SerializedNode { type: "AST_HTML_DOCTYPE_NODE"; tag_opening: SerializedToken | null; children: SerializedNode[]; tag_closing: SerializedToken | null; } export interface HTMLDoctypeNodeProps extends Omit { type: "AST_HTML_DOCTYPE_NODE"; tag_opening: Token | null; children: Node[]; tag_closing: Token | null; } export class HTMLDoctypeNode extends Node { declare readonly type: "AST_HTML_DOCTYPE_NODE"; readonly tag_opening: Token | null; readonly children: Node[]; readonly tag_closing: Token | null; static get type(): NodeType { return "AST_HTML_DOCTYPE_NODE" } static from(data: SerializedHTMLDoctypeNode): HTMLDoctypeNode { return new HTMLDoctypeNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, children: (data.children || []).map(node => fromSerializedNode(node)), tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, }) } constructor(props: HTMLDoctypeNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.children = props.children; this.tag_closing = props.tag_closing; } accept(visitor: Visitor): void { const visitMethod = visitor.visitHTMLDoctypeNode as ((node: HTMLDoctypeNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedHTMLDoctypeNode { return { ...super.toJSON(), type: "AST_HTML_DOCTYPE_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, children: this.children.map(node => node.toJSON()), tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ HTMLDoctypeNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── children: ${this.inspectArray(this.children, "│ ")}`; output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; return output } } export interface SerializedXMLDeclarationNode extends SerializedNode { type: "AST_XML_DECLARATION_NODE"; tag_opening: SerializedToken | null; children: SerializedNode[]; tag_closing: SerializedToken | null; } export interface XMLDeclarationNodeProps extends Omit { type: "AST_XML_DECLARATION_NODE"; tag_opening: Token | null; children: Node[]; tag_closing: Token | null; } export class XMLDeclarationNode extends Node { declare readonly type: "AST_XML_DECLARATION_NODE"; readonly tag_opening: Token | null; readonly children: Node[]; readonly tag_closing: Token | null; static get type(): NodeType { return "AST_XML_DECLARATION_NODE" } static from(data: SerializedXMLDeclarationNode): XMLDeclarationNode { return new XMLDeclarationNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, children: (data.children || []).map(node => fromSerializedNode(node)), tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, }) } constructor(props: XMLDeclarationNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.children = props.children; this.tag_closing = props.tag_closing; } accept(visitor: Visitor): void { const visitMethod = visitor.visitXMLDeclarationNode as ((node: XMLDeclarationNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedXMLDeclarationNode { return { ...super.toJSON(), type: "AST_XML_DECLARATION_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, children: this.children.map(node => node.toJSON()), tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ XMLDeclarationNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── children: ${this.inspectArray(this.children, "│ ")}`; output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; return output } } export interface SerializedCDATANode extends SerializedNode { type: "AST_CDATA_NODE"; tag_opening: SerializedToken | null; children: SerializedNode[]; tag_closing: SerializedToken | null; } export interface CDATANodeProps extends Omit { type: "AST_CDATA_NODE"; tag_opening: Token | null; children: Node[]; tag_closing: Token | null; } export class CDATANode extends Node { declare readonly type: "AST_CDATA_NODE"; readonly tag_opening: Token | null; readonly children: Node[]; readonly tag_closing: Token | null; static get type(): NodeType { return "AST_CDATA_NODE" } static from(data: SerializedCDATANode): CDATANode { return new CDATANode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, children: (data.children || []).map(node => fromSerializedNode(node)), tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, }) } constructor(props: CDATANodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.children = props.children; this.tag_closing = props.tag_closing; } accept(visitor: Visitor): void { const visitMethod = visitor.visitCDATANode as ((node: CDATANode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedCDATANode { return { ...super.toJSON(), type: "AST_CDATA_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, children: this.children.map(node => node.toJSON()), tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ CDATANode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── children: ${this.inspectArray(this.children, "│ ")}`; output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; return output } } export interface SerializedWhitespaceNode extends SerializedNode { type: "AST_WHITESPACE_NODE"; value: SerializedToken | null; } export interface WhitespaceNodeProps extends Omit { type: "AST_WHITESPACE_NODE"; value: Token | null; } export class WhitespaceNode extends Node { declare readonly type: "AST_WHITESPACE_NODE"; readonly value: Token | null; static get type(): NodeType { return "AST_WHITESPACE_NODE" } static from(data: SerializedWhitespaceNode): WhitespaceNode { return new WhitespaceNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), value: data.value ? Token.from(data.value) : null, }) } constructor(props: WhitespaceNodeProps) { super(props.type, props.location, props.errors); this.value = props.value; } accept(visitor: Visitor): void { const visitMethod = visitor.visitWhitespaceNode as ((node: WhitespaceNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ].flat(); } toJSON(): SerializedWhitespaceNode { return { ...super.toJSON(), type: "AST_WHITESPACE_NODE", value: this.value ? this.value.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ WhitespaceNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `└── value: ${this.value ? this.value.treeInspect() : "∅"}\n`; return output } } export interface SerializedERBContentNode extends SerializedNode { type: "AST_ERB_CONTENT_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; // no-op for analyzed_ruby parsed: boolean; valid: boolean; prism_node: number[] | null; } export interface ERBContentNodeProps extends Omit { type: "AST_ERB_CONTENT_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; // no-op for analyzed_ruby parsed: boolean; valid: boolean; prism_node: Uint8Array | null; } export class ERBContentNode extends Node { declare readonly type: "AST_ERB_CONTENT_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; // no-op for analyzed_ruby readonly parsed: boolean; readonly valid: boolean; readonly prism_node: Uint8Array | null; static get type(): NodeType { return "AST_ERB_CONTENT_NODE" } static from(data: SerializedERBContentNode): ERBContentNode { return new ERBContentNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, // no-op for analyzed_ruby parsed: data.parsed, valid: data.valid, prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, }) } constructor(props: ERBContentNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; // no-op for analyzed_ruby this.parsed = props.parsed; this.valid = props.valid; this.prism_node = props.prism_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBContentNode as ((node: ERBContentNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ].flat(); } toJSON(): SerializedERBContentNode { return { ...super.toJSON(), type: "AST_ERB_CONTENT_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, // no-op for analyzed_ruby parsed: this.parsed, valid: this.valid, prism_node: this.prism_node ? Array.from(this.prism_node) : null, }; } treeInspect(): string { let output = ""; output += `@ ERBContentNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `├── parsed: ${typeof this.parsed === 'boolean' ? String(this.parsed) : "∅"}\n`; { const isLast = !this.prism_node; const symbol = isLast ? "└──" : "├──"; output += `${symbol} valid: ${typeof this.valid === 'boolean' ? String(this.valid) : "∅"}\n`; } if (this.prism_node) { output += `└── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, " ") : `(${this.prism_node.length} bytes)`}\n`; } return output } } export interface SerializedERBEndNode extends SerializedNode { type: "AST_ERB_END_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; } export interface ERBEndNodeProps extends Omit { type: "AST_ERB_END_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; } export class ERBEndNode extends Node { declare readonly type: "AST_ERB_END_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; static get type(): NodeType { return "AST_ERB_END_NODE" } static from(data: SerializedERBEndNode): ERBEndNode { return new ERBEndNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, }) } constructor(props: ERBEndNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBEndNode as ((node: ERBEndNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ].flat(); } toJSON(): SerializedERBEndNode { return { ...super.toJSON(), type: "AST_ERB_END_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBEndNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; return output } } export interface SerializedERBElseNode extends SerializedNode { type: "AST_ERB_ELSE_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; statements: SerializedNode[]; } export interface ERBElseNodeProps extends Omit { type: "AST_ERB_ELSE_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; statements: Node[]; } export class ERBElseNode extends Node { declare readonly type: "AST_ERB_ELSE_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly statements: Node[]; static get type(): NodeType { return "AST_ERB_ELSE_NODE" } static from(data: SerializedERBElseNode): ERBElseNode { return new ERBElseNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, statements: (data.statements || []).map(node => fromSerializedNode(node)), }) } constructor(props: ERBElseNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.statements = props.statements; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBElseNode as ((node: ERBElseNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.statements, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.statements.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedERBElseNode { return { ...super.toJSON(), type: "AST_ERB_ELSE_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, statements: this.statements.map(node => node.toJSON()), }; } treeInspect(): string { let output = ""; output += `@ ERBElseNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `└── statements: ${this.inspectArray(this.statements, " ")}`; return output } } export interface SerializedERBIfNode extends SerializedNode { type: "AST_ERB_IF_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; then_keyword: SerializedLocation | null; prism_node: number[] | null; statements: SerializedNode[]; subsequent: SerializedERBIfNode | SerializedERBElseNode | null; end_node: SerializedERBEndNode | null; } export interface ERBIfNodeProps extends Omit { type: "AST_ERB_IF_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; then_keyword: Location | null; prism_node: Uint8Array | null; statements: Node[]; subsequent: ERBIfNode | ERBElseNode | null; end_node: ERBEndNode | null; } export class ERBIfNode extends Node { declare readonly type: "AST_ERB_IF_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly then_keyword: Location | null; readonly prism_node: Uint8Array | null; readonly statements: Node[]; readonly subsequent: ERBIfNode | ERBElseNode | null; readonly end_node: ERBEndNode | null; static get type(): NodeType { return "AST_ERB_IF_NODE" } static from(data: SerializedERBIfNode): ERBIfNode { return new ERBIfNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, then_keyword: data.then_keyword ? Location.from(data.then_keyword) : null, prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, statements: (data.statements || []).map(node => fromSerializedNode(node)), subsequent: data.subsequent ? fromSerializedNode((data.subsequent)) as ERBIfNode | ERBElseNode : null, end_node: data.end_node ? fromSerializedNode((data.end_node)) as ERBEndNode : null, }) } constructor(props: ERBIfNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.then_keyword = props.then_keyword; this.prism_node = props.prism_node; this.statements = props.statements; this.subsequent = props.subsequent; this.end_node = props.end_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBIfNode as ((node: ERBIfNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.statements, this.subsequent, this.end_node, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.statements.map(node => node.recursiveErrors()), this.subsequent ? this.subsequent.recursiveErrors() : [], this.end_node ? this.end_node.recursiveErrors() : [], ].flat(); } toJSON(): SerializedERBIfNode { return { ...super.toJSON(), type: "AST_ERB_IF_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, then_keyword: this.then_keyword ? this.then_keyword.toJSON() : null, prism_node: this.prism_node ? Array.from(this.prism_node) : null, statements: this.statements.map(node => node.toJSON()), subsequent: this.subsequent ? this.subsequent.toJSON() : null, end_node: this.end_node ? this.end_node.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBIfNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `├── then_keyword: ${this.then_keyword ? "(location: " + this.then_keyword.treeInspect() + ")" : "∅"}\n`; if (this.prism_node) { output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`; } output += `├── statements: ${this.inspectArray(this.statements, "│ ")}`; output += `├── subsequent: ${this.inspectNode(this.subsequent, "│ ")}`; output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`; return output } } export interface SerializedERBBlockNode extends SerializedNode { type: "AST_ERB_BLOCK_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; prism_node: number[] | null; body: SerializedNode[]; block_arguments: SerializedNode[]; rescue_clause: SerializedERBRescueNode | null; else_clause: SerializedERBElseNode | null; ensure_clause: SerializedERBEnsureNode | null; end_node: SerializedERBEndNode | null; } export interface ERBBlockNodeProps extends Omit { type: "AST_ERB_BLOCK_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; prism_node: Uint8Array | null; body: Node[]; block_arguments: any[]; rescue_clause: ERBRescueNode | null; else_clause: ERBElseNode | null; ensure_clause: ERBEnsureNode | null; end_node: ERBEndNode | null; } export class ERBBlockNode extends Node { declare readonly type: "AST_ERB_BLOCK_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly prism_node: Uint8Array | null; readonly body: Node[]; readonly block_arguments: Node[]; readonly rescue_clause: ERBRescueNode | null; readonly else_clause: ERBElseNode | null; readonly ensure_clause: ERBEnsureNode | null; readonly end_node: ERBEndNode | null; static get type(): NodeType { return "AST_ERB_BLOCK_NODE" } static from(data: SerializedERBBlockNode): ERBBlockNode { return new ERBBlockNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, body: (data.body || []).map(node => fromSerializedNode(node)), block_arguments: (data.block_arguments || []).map(node => fromSerializedNode(node)), rescue_clause: data.rescue_clause ? fromSerializedNode((data.rescue_clause)) as ERBRescueNode : null, else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) as ERBElseNode : null, ensure_clause: data.ensure_clause ? fromSerializedNode((data.ensure_clause)) as ERBEnsureNode : null, end_node: data.end_node ? fromSerializedNode((data.end_node)) as ERBEndNode : null, }) } constructor(props: ERBBlockNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.prism_node = props.prism_node; this.body = props.body; this.block_arguments = props.block_arguments; this.rescue_clause = props.rescue_clause; this.else_clause = props.else_clause; this.ensure_clause = props.ensure_clause; this.end_node = props.end_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBBlockNode as ((node: ERBBlockNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.body, ...this.block_arguments, this.rescue_clause, this.else_clause, this.ensure_clause, this.end_node, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.body.map(node => node.recursiveErrors()), ...this.block_arguments.map(node => node.recursiveErrors()), this.rescue_clause ? this.rescue_clause.recursiveErrors() : [], this.else_clause ? this.else_clause.recursiveErrors() : [], this.ensure_clause ? this.ensure_clause.recursiveErrors() : [], this.end_node ? this.end_node.recursiveErrors() : [], ].flat(); } toJSON(): SerializedERBBlockNode { return { ...super.toJSON(), type: "AST_ERB_BLOCK_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, prism_node: this.prism_node ? Array.from(this.prism_node) : null, body: this.body.map(node => node.toJSON()), block_arguments: this.block_arguments.map(node => node.toJSON()), rescue_clause: this.rescue_clause ? this.rescue_clause.toJSON() : null, else_clause: this.else_clause ? this.else_clause.toJSON() : null, ensure_clause: this.ensure_clause ? this.ensure_clause.toJSON() : null, end_node: this.end_node ? this.end_node.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBBlockNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; if (this.prism_node) { output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`; } output += `├── body: ${this.inspectArray(this.body, "│ ")}`; output += `├── block_arguments: ${this.inspectArray(this.block_arguments, "│ ")}`; output += `├── rescue_clause: ${this.inspectNode(this.rescue_clause, "│ ")}`; output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`; output += `├── ensure_clause: ${this.inspectNode(this.ensure_clause, "│ ")}`; output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`; return output } } export interface SerializedERBWhenNode extends SerializedNode { type: "AST_ERB_WHEN_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; then_keyword: SerializedLocation | null; statements: SerializedNode[]; } export interface ERBWhenNodeProps extends Omit { type: "AST_ERB_WHEN_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; then_keyword: Location | null; statements: Node[]; } export class ERBWhenNode extends Node { declare readonly type: "AST_ERB_WHEN_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly then_keyword: Location | null; readonly statements: Node[]; static get type(): NodeType { return "AST_ERB_WHEN_NODE" } static from(data: SerializedERBWhenNode): ERBWhenNode { return new ERBWhenNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, then_keyword: data.then_keyword ? Location.from(data.then_keyword) : null, statements: (data.statements || []).map(node => fromSerializedNode(node)), }) } constructor(props: ERBWhenNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.then_keyword = props.then_keyword; this.statements = props.statements; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBWhenNode as ((node: ERBWhenNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.statements, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.statements.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedERBWhenNode { return { ...super.toJSON(), type: "AST_ERB_WHEN_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, then_keyword: this.then_keyword ? this.then_keyword.toJSON() : null, statements: this.statements.map(node => node.toJSON()), }; } treeInspect(): string { let output = ""; output += `@ ERBWhenNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `├── then_keyword: ${this.then_keyword ? "(location: " + this.then_keyword.treeInspect() + ")" : "∅"}\n`; output += `└── statements: ${this.inspectArray(this.statements, " ")}`; return output } } export interface SerializedERBCaseNode extends SerializedNode { type: "AST_ERB_CASE_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; children: SerializedNode[]; prism_node: number[] | null; conditions: SerializedNode[]; else_clause: SerializedERBElseNode | null; end_node: SerializedERBEndNode | null; } export interface ERBCaseNodeProps extends Omit { type: "AST_ERB_CASE_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; children: Node[]; prism_node: Uint8Array | null; conditions: any[]; else_clause: ERBElseNode | null; end_node: ERBEndNode | null; } export class ERBCaseNode extends Node { declare readonly type: "AST_ERB_CASE_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly children: Node[]; readonly prism_node: Uint8Array | null; readonly conditions: Node[]; readonly else_clause: ERBElseNode | null; readonly end_node: ERBEndNode | null; static get type(): NodeType { return "AST_ERB_CASE_NODE" } static from(data: SerializedERBCaseNode): ERBCaseNode { return new ERBCaseNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, children: (data.children || []).map(node => fromSerializedNode(node)), prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, conditions: (data.conditions || []).map(node => fromSerializedNode(node)), else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) as ERBElseNode : null, end_node: data.end_node ? fromSerializedNode((data.end_node)) as ERBEndNode : null, }) } constructor(props: ERBCaseNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.children = props.children; this.prism_node = props.prism_node; this.conditions = props.conditions; this.else_clause = props.else_clause; this.end_node = props.end_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBCaseNode as ((node: ERBCaseNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ...this.conditions, this.else_clause, this.end_node, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ...this.conditions.map(node => node.recursiveErrors()), this.else_clause ? this.else_clause.recursiveErrors() : [], this.end_node ? this.end_node.recursiveErrors() : [], ].flat(); } toJSON(): SerializedERBCaseNode { return { ...super.toJSON(), type: "AST_ERB_CASE_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, children: this.children.map(node => node.toJSON()), prism_node: this.prism_node ? Array.from(this.prism_node) : null, conditions: this.conditions.map(node => node.toJSON()), else_clause: this.else_clause ? this.else_clause.toJSON() : null, end_node: this.end_node ? this.end_node.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBCaseNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `├── children: ${this.inspectArray(this.children, "│ ")}`; if (this.prism_node) { output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`; } output += `├── conditions: ${this.inspectArray(this.conditions, "│ ")}`; output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`; output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`; return output } } export interface SerializedERBCaseMatchNode extends SerializedNode { type: "AST_ERB_CASE_MATCH_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; children: SerializedNode[]; prism_node: number[] | null; conditions: SerializedNode[]; else_clause: SerializedERBElseNode | null; end_node: SerializedERBEndNode | null; } export interface ERBCaseMatchNodeProps extends Omit { type: "AST_ERB_CASE_MATCH_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; children: Node[]; prism_node: Uint8Array | null; conditions: any[]; else_clause: ERBElseNode | null; end_node: ERBEndNode | null; } export class ERBCaseMatchNode extends Node { declare readonly type: "AST_ERB_CASE_MATCH_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly children: Node[]; readonly prism_node: Uint8Array | null; readonly conditions: Node[]; readonly else_clause: ERBElseNode | null; readonly end_node: ERBEndNode | null; static get type(): NodeType { return "AST_ERB_CASE_MATCH_NODE" } static from(data: SerializedERBCaseMatchNode): ERBCaseMatchNode { return new ERBCaseMatchNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, children: (data.children || []).map(node => fromSerializedNode(node)), prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, conditions: (data.conditions || []).map(node => fromSerializedNode(node)), else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) as ERBElseNode : null, end_node: data.end_node ? fromSerializedNode((data.end_node)) as ERBEndNode : null, }) } constructor(props: ERBCaseMatchNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.children = props.children; this.prism_node = props.prism_node; this.conditions = props.conditions; this.else_clause = props.else_clause; this.end_node = props.end_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBCaseMatchNode as ((node: ERBCaseMatchNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.children, ...this.conditions, this.else_clause, this.end_node, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.children.map(node => node.recursiveErrors()), ...this.conditions.map(node => node.recursiveErrors()), this.else_clause ? this.else_clause.recursiveErrors() : [], this.end_node ? this.end_node.recursiveErrors() : [], ].flat(); } toJSON(): SerializedERBCaseMatchNode { return { ...super.toJSON(), type: "AST_ERB_CASE_MATCH_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, children: this.children.map(node => node.toJSON()), prism_node: this.prism_node ? Array.from(this.prism_node) : null, conditions: this.conditions.map(node => node.toJSON()), else_clause: this.else_clause ? this.else_clause.toJSON() : null, end_node: this.end_node ? this.end_node.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBCaseMatchNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `├── children: ${this.inspectArray(this.children, "│ ")}`; if (this.prism_node) { output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`; } output += `├── conditions: ${this.inspectArray(this.conditions, "│ ")}`; output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`; output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`; return output } } export interface SerializedERBWhileNode extends SerializedNode { type: "AST_ERB_WHILE_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; prism_node: number[] | null; statements: SerializedNode[]; end_node: SerializedERBEndNode | null; } export interface ERBWhileNodeProps extends Omit { type: "AST_ERB_WHILE_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; prism_node: Uint8Array | null; statements: Node[]; end_node: ERBEndNode | null; } export class ERBWhileNode extends Node { declare readonly type: "AST_ERB_WHILE_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly prism_node: Uint8Array | null; readonly statements: Node[]; readonly end_node: ERBEndNode | null; static get type(): NodeType { return "AST_ERB_WHILE_NODE" } static from(data: SerializedERBWhileNode): ERBWhileNode { return new ERBWhileNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, statements: (data.statements || []).map(node => fromSerializedNode(node)), end_node: data.end_node ? fromSerializedNode((data.end_node)) as ERBEndNode : null, }) } constructor(props: ERBWhileNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.prism_node = props.prism_node; this.statements = props.statements; this.end_node = props.end_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBWhileNode as ((node: ERBWhileNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.statements, this.end_node, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.statements.map(node => node.recursiveErrors()), this.end_node ? this.end_node.recursiveErrors() : [], ].flat(); } toJSON(): SerializedERBWhileNode { return { ...super.toJSON(), type: "AST_ERB_WHILE_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, prism_node: this.prism_node ? Array.from(this.prism_node) : null, statements: this.statements.map(node => node.toJSON()), end_node: this.end_node ? this.end_node.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBWhileNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; if (this.prism_node) { output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`; } output += `├── statements: ${this.inspectArray(this.statements, "│ ")}`; output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`; return output } } export interface SerializedERBUntilNode extends SerializedNode { type: "AST_ERB_UNTIL_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; prism_node: number[] | null; statements: SerializedNode[]; end_node: SerializedERBEndNode | null; } export interface ERBUntilNodeProps extends Omit { type: "AST_ERB_UNTIL_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; prism_node: Uint8Array | null; statements: Node[]; end_node: ERBEndNode | null; } export class ERBUntilNode extends Node { declare readonly type: "AST_ERB_UNTIL_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly prism_node: Uint8Array | null; readonly statements: Node[]; readonly end_node: ERBEndNode | null; static get type(): NodeType { return "AST_ERB_UNTIL_NODE" } static from(data: SerializedERBUntilNode): ERBUntilNode { return new ERBUntilNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, statements: (data.statements || []).map(node => fromSerializedNode(node)), end_node: data.end_node ? fromSerializedNode((data.end_node)) as ERBEndNode : null, }) } constructor(props: ERBUntilNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.prism_node = props.prism_node; this.statements = props.statements; this.end_node = props.end_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBUntilNode as ((node: ERBUntilNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.statements, this.end_node, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.statements.map(node => node.recursiveErrors()), this.end_node ? this.end_node.recursiveErrors() : [], ].flat(); } toJSON(): SerializedERBUntilNode { return { ...super.toJSON(), type: "AST_ERB_UNTIL_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, prism_node: this.prism_node ? Array.from(this.prism_node) : null, statements: this.statements.map(node => node.toJSON()), end_node: this.end_node ? this.end_node.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBUntilNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; if (this.prism_node) { output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`; } output += `├── statements: ${this.inspectArray(this.statements, "│ ")}`; output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`; return output } } export interface SerializedERBForNode extends SerializedNode { type: "AST_ERB_FOR_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; prism_node: number[] | null; statements: SerializedNode[]; end_node: SerializedERBEndNode | null; } export interface ERBForNodeProps extends Omit { type: "AST_ERB_FOR_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; prism_node: Uint8Array | null; statements: Node[]; end_node: ERBEndNode | null; } export class ERBForNode extends Node { declare readonly type: "AST_ERB_FOR_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly prism_node: Uint8Array | null; readonly statements: Node[]; readonly end_node: ERBEndNode | null; static get type(): NodeType { return "AST_ERB_FOR_NODE" } static from(data: SerializedERBForNode): ERBForNode { return new ERBForNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, statements: (data.statements || []).map(node => fromSerializedNode(node)), end_node: data.end_node ? fromSerializedNode((data.end_node)) as ERBEndNode : null, }) } constructor(props: ERBForNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.prism_node = props.prism_node; this.statements = props.statements; this.end_node = props.end_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBForNode as ((node: ERBForNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.statements, this.end_node, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.statements.map(node => node.recursiveErrors()), this.end_node ? this.end_node.recursiveErrors() : [], ].flat(); } toJSON(): SerializedERBForNode { return { ...super.toJSON(), type: "AST_ERB_FOR_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, prism_node: this.prism_node ? Array.from(this.prism_node) : null, statements: this.statements.map(node => node.toJSON()), end_node: this.end_node ? this.end_node.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBForNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; if (this.prism_node) { output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`; } output += `├── statements: ${this.inspectArray(this.statements, "│ ")}`; output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`; return output } } export interface SerializedERBRescueNode extends SerializedNode { type: "AST_ERB_RESCUE_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; statements: SerializedNode[]; subsequent: SerializedERBRescueNode | null; } export interface ERBRescueNodeProps extends Omit { type: "AST_ERB_RESCUE_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; statements: Node[]; subsequent: ERBRescueNode | null; } export class ERBRescueNode extends Node { declare readonly type: "AST_ERB_RESCUE_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly statements: Node[]; readonly subsequent: ERBRescueNode | null; static get type(): NodeType { return "AST_ERB_RESCUE_NODE" } static from(data: SerializedERBRescueNode): ERBRescueNode { return new ERBRescueNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, statements: (data.statements || []).map(node => fromSerializedNode(node)), subsequent: data.subsequent ? fromSerializedNode((data.subsequent)) as ERBRescueNode : null, }) } constructor(props: ERBRescueNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.statements = props.statements; this.subsequent = props.subsequent; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBRescueNode as ((node: ERBRescueNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.statements, this.subsequent, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.statements.map(node => node.recursiveErrors()), this.subsequent ? this.subsequent.recursiveErrors() : [], ].flat(); } toJSON(): SerializedERBRescueNode { return { ...super.toJSON(), type: "AST_ERB_RESCUE_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, statements: this.statements.map(node => node.toJSON()), subsequent: this.subsequent ? this.subsequent.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBRescueNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `├── statements: ${this.inspectArray(this.statements, "│ ")}`; output += `└── subsequent: ${this.inspectNode(this.subsequent, " ")}`; return output } } export interface SerializedERBEnsureNode extends SerializedNode { type: "AST_ERB_ENSURE_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; statements: SerializedNode[]; } export interface ERBEnsureNodeProps extends Omit { type: "AST_ERB_ENSURE_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; statements: Node[]; } export class ERBEnsureNode extends Node { declare readonly type: "AST_ERB_ENSURE_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly statements: Node[]; static get type(): NodeType { return "AST_ERB_ENSURE_NODE" } static from(data: SerializedERBEnsureNode): ERBEnsureNode { return new ERBEnsureNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, statements: (data.statements || []).map(node => fromSerializedNode(node)), }) } constructor(props: ERBEnsureNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.statements = props.statements; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBEnsureNode as ((node: ERBEnsureNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.statements, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.statements.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedERBEnsureNode { return { ...super.toJSON(), type: "AST_ERB_ENSURE_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, statements: this.statements.map(node => node.toJSON()), }; } treeInspect(): string { let output = ""; output += `@ ERBEnsureNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `└── statements: ${this.inspectArray(this.statements, " ")}`; return output } } export interface SerializedERBBeginNode extends SerializedNode { type: "AST_ERB_BEGIN_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; prism_node: number[] | null; statements: SerializedNode[]; rescue_clause: SerializedERBRescueNode | null; else_clause: SerializedERBElseNode | null; ensure_clause: SerializedERBEnsureNode | null; end_node: SerializedERBEndNode | null; } export interface ERBBeginNodeProps extends Omit { type: "AST_ERB_BEGIN_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; prism_node: Uint8Array | null; statements: Node[]; rescue_clause: ERBRescueNode | null; else_clause: ERBElseNode | null; ensure_clause: ERBEnsureNode | null; end_node: ERBEndNode | null; } export class ERBBeginNode extends Node { declare readonly type: "AST_ERB_BEGIN_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly prism_node: Uint8Array | null; readonly statements: Node[]; readonly rescue_clause: ERBRescueNode | null; readonly else_clause: ERBElseNode | null; readonly ensure_clause: ERBEnsureNode | null; readonly end_node: ERBEndNode | null; static get type(): NodeType { return "AST_ERB_BEGIN_NODE" } static from(data: SerializedERBBeginNode): ERBBeginNode { return new ERBBeginNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, statements: (data.statements || []).map(node => fromSerializedNode(node)), rescue_clause: data.rescue_clause ? fromSerializedNode((data.rescue_clause)) as ERBRescueNode : null, else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) as ERBElseNode : null, ensure_clause: data.ensure_clause ? fromSerializedNode((data.ensure_clause)) as ERBEnsureNode : null, end_node: data.end_node ? fromSerializedNode((data.end_node)) as ERBEndNode : null, }) } constructor(props: ERBBeginNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.prism_node = props.prism_node; this.statements = props.statements; this.rescue_clause = props.rescue_clause; this.else_clause = props.else_clause; this.ensure_clause = props.ensure_clause; this.end_node = props.end_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBBeginNode as ((node: ERBBeginNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.statements, this.rescue_clause, this.else_clause, this.ensure_clause, this.end_node, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.statements.map(node => node.recursiveErrors()), this.rescue_clause ? this.rescue_clause.recursiveErrors() : [], this.else_clause ? this.else_clause.recursiveErrors() : [], this.ensure_clause ? this.ensure_clause.recursiveErrors() : [], this.end_node ? this.end_node.recursiveErrors() : [], ].flat(); } toJSON(): SerializedERBBeginNode { return { ...super.toJSON(), type: "AST_ERB_BEGIN_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, prism_node: this.prism_node ? Array.from(this.prism_node) : null, statements: this.statements.map(node => node.toJSON()), rescue_clause: this.rescue_clause ? this.rescue_clause.toJSON() : null, else_clause: this.else_clause ? this.else_clause.toJSON() : null, ensure_clause: this.ensure_clause ? this.ensure_clause.toJSON() : null, end_node: this.end_node ? this.end_node.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBBeginNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; if (this.prism_node) { output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`; } output += `├── statements: ${this.inspectArray(this.statements, "│ ")}`; output += `├── rescue_clause: ${this.inspectNode(this.rescue_clause, "│ ")}`; output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`; output += `├── ensure_clause: ${this.inspectNode(this.ensure_clause, "│ ")}`; output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`; return output } } export interface SerializedERBUnlessNode extends SerializedNode { type: "AST_ERB_UNLESS_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; then_keyword: SerializedLocation | null; prism_node: number[] | null; statements: SerializedNode[]; else_clause: SerializedERBElseNode | null; end_node: SerializedERBEndNode | null; } export interface ERBUnlessNodeProps extends Omit { type: "AST_ERB_UNLESS_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; then_keyword: Location | null; prism_node: Uint8Array | null; statements: Node[]; else_clause: ERBElseNode | null; end_node: ERBEndNode | null; } export class ERBUnlessNode extends Node { declare readonly type: "AST_ERB_UNLESS_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly then_keyword: Location | null; readonly prism_node: Uint8Array | null; readonly statements: Node[]; readonly else_clause: ERBElseNode | null; readonly end_node: ERBEndNode | null; static get type(): NodeType { return "AST_ERB_UNLESS_NODE" } static from(data: SerializedERBUnlessNode): ERBUnlessNode { return new ERBUnlessNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, then_keyword: data.then_keyword ? Location.from(data.then_keyword) : null, prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, statements: (data.statements || []).map(node => fromSerializedNode(node)), else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) as ERBElseNode : null, end_node: data.end_node ? fromSerializedNode((data.end_node)) as ERBEndNode : null, }) } constructor(props: ERBUnlessNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.then_keyword = props.then_keyword; this.prism_node = props.prism_node; this.statements = props.statements; this.else_clause = props.else_clause; this.end_node = props.end_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBUnlessNode as ((node: ERBUnlessNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.statements, this.else_clause, this.end_node, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.statements.map(node => node.recursiveErrors()), this.else_clause ? this.else_clause.recursiveErrors() : [], this.end_node ? this.end_node.recursiveErrors() : [], ].flat(); } toJSON(): SerializedERBUnlessNode { return { ...super.toJSON(), type: "AST_ERB_UNLESS_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, then_keyword: this.then_keyword ? this.then_keyword.toJSON() : null, prism_node: this.prism_node ? Array.from(this.prism_node) : null, statements: this.statements.map(node => node.toJSON()), else_clause: this.else_clause ? this.else_clause.toJSON() : null, end_node: this.end_node ? this.end_node.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBUnlessNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `├── then_keyword: ${this.then_keyword ? "(location: " + this.then_keyword.treeInspect() + ")" : "∅"}\n`; if (this.prism_node) { output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`; } output += `├── statements: ${this.inspectArray(this.statements, "│ ")}`; output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`; output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`; return output } } export interface SerializedRubyRenderLocalNode extends SerializedNode { type: "AST_RUBY_RENDER_LOCAL_NODE"; name: SerializedToken | null; value: SerializedRubyLiteralNode | null; } export interface RubyRenderLocalNodeProps extends Omit { type: "AST_RUBY_RENDER_LOCAL_NODE"; name: Token | null; value: RubyLiteralNode | null; } export class RubyRenderLocalNode extends Node { declare readonly type: "AST_RUBY_RENDER_LOCAL_NODE"; readonly name: Token | null; readonly value: RubyLiteralNode | null; static get type(): NodeType { return "AST_RUBY_RENDER_LOCAL_NODE" } static from(data: SerializedRubyRenderLocalNode): RubyRenderLocalNode { return new RubyRenderLocalNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), name: data.name ? Token.from(data.name) : null, value: data.value ? fromSerializedNode((data.value)) as RubyLiteralNode : null, }) } constructor(props: RubyRenderLocalNodeProps) { super(props.type, props.location, props.errors); this.name = props.name; this.value = props.value; } accept(visitor: Visitor): void { const visitMethod = visitor.visitRubyRenderLocalNode as ((node: RubyRenderLocalNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ this.value, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, this.value ? this.value.recursiveErrors() : [], ].flat(); } toJSON(): SerializedRubyRenderLocalNode { return { ...super.toJSON(), type: "AST_RUBY_RENDER_LOCAL_NODE", name: this.name ? this.name.toJSON() : null, value: this.value ? this.value.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ RubyRenderLocalNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── name: ${this.name ? this.name.treeInspect() : "∅"}\n`; output += `└── value: ${this.inspectNode(this.value, " ")}`; return output } } export interface SerializedRubyRenderKeywordsNode extends SerializedNode { type: "AST_RUBY_RENDER_KEYWORDS_NODE"; partial: SerializedToken | null; template_path: SerializedToken | null; layout: SerializedToken | null; file: SerializedToken | null; inline_template: SerializedToken | null; body: SerializedToken | null; plain: SerializedToken | null; html: SerializedToken | null; renderable: SerializedToken | null; collection: SerializedToken | null; object: SerializedToken | null; as_name: SerializedToken | null; spacer_template: SerializedToken | null; formats: SerializedToken | null; variants: SerializedToken | null; handlers: SerializedToken | null; content_type: SerializedToken | null; locals: SerializedNode[]; } export interface RubyRenderKeywordsNodeProps extends Omit { type: "AST_RUBY_RENDER_KEYWORDS_NODE"; partial: Token | null; template_path: Token | null; layout: Token | null; file: Token | null; inline_template: Token | null; body: Token | null; plain: Token | null; html: Token | null; renderable: Token | null; collection: Token | null; object: Token | null; as_name: Token | null; spacer_template: Token | null; formats: Token | null; variants: Token | null; handlers: Token | null; content_type: Token | null; locals: any[]; } export class RubyRenderKeywordsNode extends Node { declare readonly type: "AST_RUBY_RENDER_KEYWORDS_NODE"; readonly partial: Token | null; readonly template_path: Token | null; readonly layout: Token | null; readonly file: Token | null; readonly inline_template: Token | null; readonly body: Token | null; readonly plain: Token | null; readonly html: Token | null; readonly renderable: Token | null; readonly collection: Token | null; readonly object: Token | null; readonly as_name: Token | null; readonly spacer_template: Token | null; readonly formats: Token | null; readonly variants: Token | null; readonly handlers: Token | null; readonly content_type: Token | null; readonly locals: Node[]; static get type(): NodeType { return "AST_RUBY_RENDER_KEYWORDS_NODE" } static from(data: SerializedRubyRenderKeywordsNode): RubyRenderKeywordsNode { return new RubyRenderKeywordsNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), partial: data.partial ? Token.from(data.partial) : null, template_path: data.template_path ? Token.from(data.template_path) : null, layout: data.layout ? Token.from(data.layout) : null, file: data.file ? Token.from(data.file) : null, inline_template: data.inline_template ? Token.from(data.inline_template) : null, body: data.body ? Token.from(data.body) : null, plain: data.plain ? Token.from(data.plain) : null, html: data.html ? Token.from(data.html) : null, renderable: data.renderable ? Token.from(data.renderable) : null, collection: data.collection ? Token.from(data.collection) : null, object: data.object ? Token.from(data.object) : null, as_name: data.as_name ? Token.from(data.as_name) : null, spacer_template: data.spacer_template ? Token.from(data.spacer_template) : null, formats: data.formats ? Token.from(data.formats) : null, variants: data.variants ? Token.from(data.variants) : null, handlers: data.handlers ? Token.from(data.handlers) : null, content_type: data.content_type ? Token.from(data.content_type) : null, locals: (data.locals || []).map(node => fromSerializedNode(node)), }) } constructor(props: RubyRenderKeywordsNodeProps) { super(props.type, props.location, props.errors); this.partial = props.partial; this.template_path = props.template_path; this.layout = props.layout; this.file = props.file; this.inline_template = props.inline_template; this.body = props.body; this.plain = props.plain; this.html = props.html; this.renderable = props.renderable; this.collection = props.collection; this.object = props.object; this.as_name = props.as_name; this.spacer_template = props.spacer_template; this.formats = props.formats; this.variants = props.variants; this.handlers = props.handlers; this.content_type = props.content_type; this.locals = props.locals; } accept(visitor: Visitor): void { const visitMethod = visitor.visitRubyRenderKeywordsNode as ((node: RubyRenderKeywordsNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.locals, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.locals.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedRubyRenderKeywordsNode { return { ...super.toJSON(), type: "AST_RUBY_RENDER_KEYWORDS_NODE", partial: this.partial ? this.partial.toJSON() : null, template_path: this.template_path ? this.template_path.toJSON() : null, layout: this.layout ? this.layout.toJSON() : null, file: this.file ? this.file.toJSON() : null, inline_template: this.inline_template ? this.inline_template.toJSON() : null, body: this.body ? this.body.toJSON() : null, plain: this.plain ? this.plain.toJSON() : null, html: this.html ? this.html.toJSON() : null, renderable: this.renderable ? this.renderable.toJSON() : null, collection: this.collection ? this.collection.toJSON() : null, object: this.object ? this.object.toJSON() : null, as_name: this.as_name ? this.as_name.toJSON() : null, spacer_template: this.spacer_template ? this.spacer_template.toJSON() : null, formats: this.formats ? this.formats.toJSON() : null, variants: this.variants ? this.variants.toJSON() : null, handlers: this.handlers ? this.handlers.toJSON() : null, content_type: this.content_type ? this.content_type.toJSON() : null, locals: this.locals.map(node => node.toJSON()), }; } treeInspect(): string { let output = ""; output += `@ RubyRenderKeywordsNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── partial: ${this.partial ? this.partial.treeInspect() : "∅"}\n`; output += `├── template_path: ${this.template_path ? this.template_path.treeInspect() : "∅"}\n`; output += `├── layout: ${this.layout ? this.layout.treeInspect() : "∅"}\n`; output += `├── file: ${this.file ? this.file.treeInspect() : "∅"}\n`; output += `├── inline_template: ${this.inline_template ? this.inline_template.treeInspect() : "∅"}\n`; output += `├── body: ${this.body ? this.body.treeInspect() : "∅"}\n`; output += `├── plain: ${this.plain ? this.plain.treeInspect() : "∅"}\n`; output += `├── html: ${this.html ? this.html.treeInspect() : "∅"}\n`; output += `├── renderable: ${this.renderable ? this.renderable.treeInspect() : "∅"}\n`; output += `├── collection: ${this.collection ? this.collection.treeInspect() : "∅"}\n`; output += `├── object: ${this.object ? this.object.treeInspect() : "∅"}\n`; output += `├── as_name: ${this.as_name ? this.as_name.treeInspect() : "∅"}\n`; output += `├── spacer_template: ${this.spacer_template ? this.spacer_template.treeInspect() : "∅"}\n`; output += `├── formats: ${this.formats ? this.formats.treeInspect() : "∅"}\n`; output += `├── variants: ${this.variants ? this.variants.treeInspect() : "∅"}\n`; output += `├── handlers: ${this.handlers ? this.handlers.treeInspect() : "∅"}\n`; output += `├── content_type: ${this.content_type ? this.content_type.treeInspect() : "∅"}\n`; output += `└── locals: ${this.inspectArray(this.locals, " ")}`; return output } } export interface SerializedERBRenderNode extends SerializedNode { type: "AST_ERB_RENDER_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; // no-op for analyzed_ruby prism_node: number[] | null; keywords: SerializedRubyRenderKeywordsNode | null; body: SerializedNode[]; block_arguments: SerializedNode[]; rescue_clause: SerializedERBRescueNode | null; else_clause: SerializedERBElseNode | null; ensure_clause: SerializedERBEnsureNode | null; end_node: SerializedERBEndNode | null; } export interface ERBRenderNodeProps extends Omit { type: "AST_ERB_RENDER_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; // no-op for analyzed_ruby prism_node: Uint8Array | null; keywords: RubyRenderKeywordsNode | null; body: Node[]; block_arguments: any[]; rescue_clause: ERBRescueNode | null; else_clause: ERBElseNode | null; ensure_clause: ERBEnsureNode | null; end_node: ERBEndNode | null; } export class ERBRenderNode extends Node { declare readonly type: "AST_ERB_RENDER_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; // no-op for analyzed_ruby readonly prism_node: Uint8Array | null; readonly keywords: RubyRenderKeywordsNode | null; readonly body: Node[]; readonly block_arguments: Node[]; readonly rescue_clause: ERBRescueNode | null; readonly else_clause: ERBElseNode | null; readonly ensure_clause: ERBEnsureNode | null; readonly end_node: ERBEndNode | null; static get type(): NodeType { return "AST_ERB_RENDER_NODE" } static from(data: SerializedERBRenderNode): ERBRenderNode { return new ERBRenderNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, // no-op for analyzed_ruby prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, keywords: data.keywords ? fromSerializedNode((data.keywords)) as RubyRenderKeywordsNode : null, body: (data.body || []).map(node => fromSerializedNode(node)), block_arguments: (data.block_arguments || []).map(node => fromSerializedNode(node)), rescue_clause: data.rescue_clause ? fromSerializedNode((data.rescue_clause)) as ERBRescueNode : null, else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) as ERBElseNode : null, ensure_clause: data.ensure_clause ? fromSerializedNode((data.ensure_clause)) as ERBEnsureNode : null, end_node: data.end_node ? fromSerializedNode((data.end_node)) as ERBEndNode : null, }) } constructor(props: ERBRenderNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; // no-op for analyzed_ruby this.prism_node = props.prism_node; this.keywords = props.keywords; this.body = props.body; this.block_arguments = props.block_arguments; this.rescue_clause = props.rescue_clause; this.else_clause = props.else_clause; this.ensure_clause = props.ensure_clause; this.end_node = props.end_node; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBRenderNode as ((node: ERBRenderNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ this.keywords, ...this.body, ...this.block_arguments, this.rescue_clause, this.else_clause, this.ensure_clause, this.end_node, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, this.keywords ? this.keywords.recursiveErrors() : [], ...this.body.map(node => node.recursiveErrors()), ...this.block_arguments.map(node => node.recursiveErrors()), this.rescue_clause ? this.rescue_clause.recursiveErrors() : [], this.else_clause ? this.else_clause.recursiveErrors() : [], this.ensure_clause ? this.ensure_clause.recursiveErrors() : [], this.end_node ? this.end_node.recursiveErrors() : [], ].flat(); } toJSON(): SerializedERBRenderNode { return { ...super.toJSON(), type: "AST_ERB_RENDER_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, // no-op for analyzed_ruby prism_node: this.prism_node ? Array.from(this.prism_node) : null, keywords: this.keywords ? this.keywords.toJSON() : null, body: this.body.map(node => node.toJSON()), block_arguments: this.block_arguments.map(node => node.toJSON()), rescue_clause: this.rescue_clause ? this.rescue_clause.toJSON() : null, else_clause: this.else_clause ? this.else_clause.toJSON() : null, ensure_clause: this.ensure_clause ? this.ensure_clause.toJSON() : null, end_node: this.end_node ? this.end_node.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBRenderNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; if (this.prism_node) { output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`; } output += `├── keywords: ${this.inspectNode(this.keywords, "│ ")}`; output += `├── body: ${this.inspectArray(this.body, "│ ")}`; output += `├── block_arguments: ${this.inspectArray(this.block_arguments, "│ ")}`; output += `├── rescue_clause: ${this.inspectNode(this.rescue_clause, "│ ")}`; output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`; output += `├── ensure_clause: ${this.inspectNode(this.ensure_clause, "│ ")}`; output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`; return output } } export interface SerializedRubyParameterNode extends SerializedNode { type: "AST_RUBY_PARAMETER_NODE"; name: SerializedToken | null; default_value: SerializedRubyLiteralNode | null; kind: string; required: boolean; } export interface RubyParameterNodeProps extends Omit { type: "AST_RUBY_PARAMETER_NODE"; name: Token | null; default_value: RubyLiteralNode | null; kind: string; required: boolean; } export class RubyParameterNode extends Node { declare readonly type: "AST_RUBY_PARAMETER_NODE"; readonly name: Token | null; readonly default_value: RubyLiteralNode | null; readonly kind: string; readonly required: boolean; static get type(): NodeType { return "AST_RUBY_PARAMETER_NODE" } static from(data: SerializedRubyParameterNode): RubyParameterNode { return new RubyParameterNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), name: data.name ? Token.from(data.name) : null, default_value: data.default_value ? fromSerializedNode((data.default_value)) as RubyLiteralNode : null, kind: data.kind, required: data.required, }) } constructor(props: RubyParameterNodeProps) { super(props.type, props.location, props.errors); this.name = props.name; this.default_value = props.default_value; this.kind = props.kind; this.required = props.required; } accept(visitor: Visitor): void { const visitMethod = visitor.visitRubyParameterNode as ((node: RubyParameterNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ this.default_value, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, this.default_value ? this.default_value.recursiveErrors() : [], ].flat(); } toJSON(): SerializedRubyParameterNode { return { ...super.toJSON(), type: "AST_RUBY_PARAMETER_NODE", name: this.name ? this.name.toJSON() : null, default_value: this.default_value ? this.default_value.toJSON() : null, kind: this.kind, required: this.required, }; } treeInspect(): string { let output = ""; output += `@ RubyParameterNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── name: ${this.name ? this.name.treeInspect() : "∅"}\n`; output += `├── default_value: ${this.inspectNode(this.default_value, "│ ")}`; output += `├── kind: ${this.kind ? JSON.stringify(this.kind) : "∅"}\n`; output += `└── required: ${typeof this.required === 'boolean' ? String(this.required) : "∅"}\n`; return output } } export interface SerializedERBStrictLocalsNode extends SerializedNode { type: "AST_ERB_STRICT_LOCALS_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; // no-op for analyzed_ruby prism_node: number[] | null; locals: SerializedNode[]; } export interface ERBStrictLocalsNodeProps extends Omit { type: "AST_ERB_STRICT_LOCALS_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; // no-op for analyzed_ruby prism_node: Uint8Array | null; locals: any[]; } export class ERBStrictLocalsNode extends Node { declare readonly type: "AST_ERB_STRICT_LOCALS_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; // no-op for analyzed_ruby readonly prism_node: Uint8Array | null; readonly locals: Node[]; static get type(): NodeType { return "AST_ERB_STRICT_LOCALS_NODE" } static from(data: SerializedERBStrictLocalsNode): ERBStrictLocalsNode { return new ERBStrictLocalsNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, // no-op for analyzed_ruby prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null, locals: (data.locals || []).map(node => fromSerializedNode(node)), }) } constructor(props: ERBStrictLocalsNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; // no-op for analyzed_ruby this.prism_node = props.prism_node; this.locals = props.locals; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBStrictLocalsNode as ((node: ERBStrictLocalsNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.locals, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } get prismNode(): PrismNode | null { if (!this.prism_node || !this.source) return null; return deserializePrismNode(this.prism_node, this.source); } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.locals.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedERBStrictLocalsNode { return { ...super.toJSON(), type: "AST_ERB_STRICT_LOCALS_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, // no-op for analyzed_ruby prism_node: this.prism_node ? Array.from(this.prism_node) : null, locals: this.locals.map(node => node.toJSON()), }; } treeInspect(): string { let output = ""; output += `@ ERBStrictLocalsNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; if (this.prism_node) { output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`; } output += `└── locals: ${this.inspectArray(this.locals, " ")}`; return output } } export interface SerializedERBYieldNode extends SerializedNode { type: "AST_ERB_YIELD_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; } export interface ERBYieldNodeProps extends Omit { type: "AST_ERB_YIELD_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; } export class ERBYieldNode extends Node { declare readonly type: "AST_ERB_YIELD_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; static get type(): NodeType { return "AST_ERB_YIELD_NODE" } static from(data: SerializedERBYieldNode): ERBYieldNode { return new ERBYieldNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, }) } constructor(props: ERBYieldNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBYieldNode as ((node: ERBYieldNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ].flat(); } toJSON(): SerializedERBYieldNode { return { ...super.toJSON(), type: "AST_ERB_YIELD_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, }; } treeInspect(): string { let output = ""; output += `@ ERBYieldNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; return output } } export interface SerializedERBInNode extends SerializedNode { type: "AST_ERB_IN_NODE"; tag_opening: SerializedToken | null; content: SerializedToken | null; tag_closing: SerializedToken | null; then_keyword: SerializedLocation | null; statements: SerializedNode[]; } export interface ERBInNodeProps extends Omit { type: "AST_ERB_IN_NODE"; tag_opening: Token | null; content: Token | null; tag_closing: Token | null; then_keyword: Location | null; statements: Node[]; } export class ERBInNode extends Node { declare readonly type: "AST_ERB_IN_NODE"; readonly tag_opening: Token | null; readonly content: Token | null; readonly tag_closing: Token | null; readonly then_keyword: Location | null; readonly statements: Node[]; static get type(): NodeType { return "AST_ERB_IN_NODE" } static from(data: SerializedERBInNode): ERBInNode { return new ERBInNode({ type: data.type, location: Location.from(data.location), errors: (data.errors || []).map(error => HerbError.from(error)), tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null, content: data.content ? Token.from(data.content) : null, tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null, then_keyword: data.then_keyword ? Location.from(data.then_keyword) : null, statements: (data.statements || []).map(node => fromSerializedNode(node)), }) } constructor(props: ERBInNodeProps) { super(props.type, props.location, props.errors); this.tag_opening = props.tag_opening; this.content = props.content; this.tag_closing = props.tag_closing; this.then_keyword = props.then_keyword; this.statements = props.statements; } accept(visitor: Visitor): void { const visitMethod = visitor.visitERBInNode as ((node: ERBInNode) => void) | undefined if (typeof visitMethod === "function") { visitMethod.call(visitor, this) } } childNodes(): (Node | null | undefined)[] { return [ ...this.statements, ]; } compactChildNodes(): Node[] { return this.childNodes().filter(node => node !== null && node !== undefined) } recursiveErrors(): HerbError[] { return [ ...this.errors, ...this.statements.map(node => node.recursiveErrors()), ].flat(); } toJSON(): SerializedERBInNode { return { ...super.toJSON(), type: "AST_ERB_IN_NODE", tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null, content: this.content ? this.content.toJSON() : null, tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null, then_keyword: this.then_keyword ? this.then_keyword.toJSON() : null, statements: this.statements.map(node => node.toJSON()), }; } treeInspect(): string { let output = ""; output += `@ ERBInNode ${this.location.treeInspectWithLabel()}\n`; output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`; output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`; output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`; output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`; output += `├── then_keyword: ${this.then_keyword ? "(location: " + this.then_keyword.treeInspect() + ")" : "∅"}\n`; output += `└── statements: ${this.inspectArray(this.statements, " ")}`; return output } } export type ConcreteNode = DocumentNode | LiteralNode | HTMLOpenTagNode | HTMLConditionalOpenTagNode | HTMLCloseTagNode | HTMLOmittedCloseTagNode | HTMLVirtualCloseTagNode | HTMLElementNode | HTMLConditionalElementNode | HTMLAttributeValueNode | HTMLAttributeNameNode | HTMLAttributeNode | RubyLiteralNode | RubyHTMLAttributesSplatNode | ERBOpenTagNode | HTMLTextNode | HTMLCommentNode | HTMLDoctypeNode | XMLDeclarationNode | CDATANode | WhitespaceNode | ERBContentNode | ERBEndNode | ERBElseNode | ERBIfNode | ERBBlockNode | ERBWhenNode | ERBCaseNode | ERBCaseMatchNode | ERBWhileNode | ERBUntilNode | ERBForNode | ERBRescueNode | ERBEnsureNode | ERBBeginNode | ERBUnlessNode | RubyRenderLocalNode | RubyRenderKeywordsNode | ERBRenderNode | RubyParameterNode | ERBStrictLocalsNode | ERBYieldNode | ERBInNode export function fromSerializedNode(node: SerializedDocumentNode): DocumentNode; export function fromSerializedNode(node: SerializedLiteralNode): LiteralNode; export function fromSerializedNode(node: SerializedHTMLOpenTagNode): HTMLOpenTagNode; export function fromSerializedNode(node: SerializedHTMLConditionalOpenTagNode): HTMLConditionalOpenTagNode; export function fromSerializedNode(node: SerializedHTMLCloseTagNode): HTMLCloseTagNode; export function fromSerializedNode(node: SerializedHTMLOmittedCloseTagNode): HTMLOmittedCloseTagNode; export function fromSerializedNode(node: SerializedHTMLVirtualCloseTagNode): HTMLVirtualCloseTagNode; export function fromSerializedNode(node: SerializedHTMLElementNode): HTMLElementNode; export function fromSerializedNode(node: SerializedHTMLConditionalElementNode): HTMLConditionalElementNode; export function fromSerializedNode(node: SerializedHTMLAttributeValueNode): HTMLAttributeValueNode; export function fromSerializedNode(node: SerializedHTMLAttributeNameNode): HTMLAttributeNameNode; export function fromSerializedNode(node: SerializedHTMLAttributeNode): HTMLAttributeNode; export function fromSerializedNode(node: SerializedRubyLiteralNode): RubyLiteralNode; export function fromSerializedNode(node: SerializedRubyHTMLAttributesSplatNode): RubyHTMLAttributesSplatNode; export function fromSerializedNode(node: SerializedERBOpenTagNode): ERBOpenTagNode; export function fromSerializedNode(node: SerializedHTMLTextNode): HTMLTextNode; export function fromSerializedNode(node: SerializedHTMLCommentNode): HTMLCommentNode; export function fromSerializedNode(node: SerializedHTMLDoctypeNode): HTMLDoctypeNode; export function fromSerializedNode(node: SerializedXMLDeclarationNode): XMLDeclarationNode; export function fromSerializedNode(node: SerializedCDATANode): CDATANode; export function fromSerializedNode(node: SerializedWhitespaceNode): WhitespaceNode; export function fromSerializedNode(node: SerializedERBContentNode): ERBContentNode; export function fromSerializedNode(node: SerializedERBEndNode): ERBEndNode; export function fromSerializedNode(node: SerializedERBElseNode): ERBElseNode; export function fromSerializedNode(node: SerializedERBIfNode): ERBIfNode; export function fromSerializedNode(node: SerializedERBBlockNode): ERBBlockNode; export function fromSerializedNode(node: SerializedERBWhenNode): ERBWhenNode; export function fromSerializedNode(node: SerializedERBCaseNode): ERBCaseNode; export function fromSerializedNode(node: SerializedERBCaseMatchNode): ERBCaseMatchNode; export function fromSerializedNode(node: SerializedERBWhileNode): ERBWhileNode; export function fromSerializedNode(node: SerializedERBUntilNode): ERBUntilNode; export function fromSerializedNode(node: SerializedERBForNode): ERBForNode; export function fromSerializedNode(node: SerializedERBRescueNode): ERBRescueNode; export function fromSerializedNode(node: SerializedERBEnsureNode): ERBEnsureNode; export function fromSerializedNode(node: SerializedERBBeginNode): ERBBeginNode; export function fromSerializedNode(node: SerializedERBUnlessNode): ERBUnlessNode; export function fromSerializedNode(node: SerializedRubyRenderLocalNode): RubyRenderLocalNode; export function fromSerializedNode(node: SerializedRubyRenderKeywordsNode): RubyRenderKeywordsNode; export function fromSerializedNode(node: SerializedERBRenderNode): ERBRenderNode; export function fromSerializedNode(node: SerializedRubyParameterNode): RubyParameterNode; export function fromSerializedNode(node: SerializedERBStrictLocalsNode): ERBStrictLocalsNode; export function fromSerializedNode(node: SerializedERBYieldNode): ERBYieldNode; export function fromSerializedNode(node: SerializedERBInNode): ERBInNode; export function fromSerializedNode(node: SerializedNode): Node; export function fromSerializedNode(node: SerializedNode): Node { switch (node.type) { case "AST_DOCUMENT_NODE": return DocumentNode.from(node as SerializedDocumentNode); case "AST_LITERAL_NODE": return LiteralNode.from(node as SerializedLiteralNode); case "AST_HTML_OPEN_TAG_NODE": return HTMLOpenTagNode.from(node as SerializedHTMLOpenTagNode); case "AST_HTML_CONDITIONAL_OPEN_TAG_NODE": return HTMLConditionalOpenTagNode.from(node as SerializedHTMLConditionalOpenTagNode); case "AST_HTML_CLOSE_TAG_NODE": return HTMLCloseTagNode.from(node as SerializedHTMLCloseTagNode); case "AST_HTML_OMITTED_CLOSE_TAG_NODE": return HTMLOmittedCloseTagNode.from(node as SerializedHTMLOmittedCloseTagNode); case "AST_HTML_VIRTUAL_CLOSE_TAG_NODE": return HTMLVirtualCloseTagNode.from(node as SerializedHTMLVirtualCloseTagNode); case "AST_HTML_ELEMENT_NODE": return HTMLElementNode.from(node as SerializedHTMLElementNode); case "AST_HTML_CONDITIONAL_ELEMENT_NODE": return HTMLConditionalElementNode.from(node as SerializedHTMLConditionalElementNode); case "AST_HTML_ATTRIBUTE_VALUE_NODE": return HTMLAttributeValueNode.from(node as SerializedHTMLAttributeValueNode); case "AST_HTML_ATTRIBUTE_NAME_NODE": return HTMLAttributeNameNode.from(node as SerializedHTMLAttributeNameNode); case "AST_HTML_ATTRIBUTE_NODE": return HTMLAttributeNode.from(node as SerializedHTMLAttributeNode); case "AST_RUBY_LITERAL_NODE": return RubyLiteralNode.from(node as SerializedRubyLiteralNode); case "AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE": return RubyHTMLAttributesSplatNode.from(node as SerializedRubyHTMLAttributesSplatNode); case "AST_ERB_OPEN_TAG_NODE": return ERBOpenTagNode.from(node as SerializedERBOpenTagNode); case "AST_HTML_TEXT_NODE": return HTMLTextNode.from(node as SerializedHTMLTextNode); case "AST_HTML_COMMENT_NODE": return HTMLCommentNode.from(node as SerializedHTMLCommentNode); case "AST_HTML_DOCTYPE_NODE": return HTMLDoctypeNode.from(node as SerializedHTMLDoctypeNode); case "AST_XML_DECLARATION_NODE": return XMLDeclarationNode.from(node as SerializedXMLDeclarationNode); case "AST_CDATA_NODE": return CDATANode.from(node as SerializedCDATANode); case "AST_WHITESPACE_NODE": return WhitespaceNode.from(node as SerializedWhitespaceNode); case "AST_ERB_CONTENT_NODE": return ERBContentNode.from(node as SerializedERBContentNode); case "AST_ERB_END_NODE": return ERBEndNode.from(node as SerializedERBEndNode); case "AST_ERB_ELSE_NODE": return ERBElseNode.from(node as SerializedERBElseNode); case "AST_ERB_IF_NODE": return ERBIfNode.from(node as SerializedERBIfNode); case "AST_ERB_BLOCK_NODE": return ERBBlockNode.from(node as SerializedERBBlockNode); case "AST_ERB_WHEN_NODE": return ERBWhenNode.from(node as SerializedERBWhenNode); case "AST_ERB_CASE_NODE": return ERBCaseNode.from(node as SerializedERBCaseNode); case "AST_ERB_CASE_MATCH_NODE": return ERBCaseMatchNode.from(node as SerializedERBCaseMatchNode); case "AST_ERB_WHILE_NODE": return ERBWhileNode.from(node as SerializedERBWhileNode); case "AST_ERB_UNTIL_NODE": return ERBUntilNode.from(node as SerializedERBUntilNode); case "AST_ERB_FOR_NODE": return ERBForNode.from(node as SerializedERBForNode); case "AST_ERB_RESCUE_NODE": return ERBRescueNode.from(node as SerializedERBRescueNode); case "AST_ERB_ENSURE_NODE": return ERBEnsureNode.from(node as SerializedERBEnsureNode); case "AST_ERB_BEGIN_NODE": return ERBBeginNode.from(node as SerializedERBBeginNode); case "AST_ERB_UNLESS_NODE": return ERBUnlessNode.from(node as SerializedERBUnlessNode); case "AST_RUBY_RENDER_LOCAL_NODE": return RubyRenderLocalNode.from(node as SerializedRubyRenderLocalNode); case "AST_RUBY_RENDER_KEYWORDS_NODE": return RubyRenderKeywordsNode.from(node as SerializedRubyRenderKeywordsNode); case "AST_ERB_RENDER_NODE": return ERBRenderNode.from(node as SerializedERBRenderNode); case "AST_RUBY_PARAMETER_NODE": return RubyParameterNode.from(node as SerializedRubyParameterNode); case "AST_ERB_STRICT_LOCALS_NODE": return ERBStrictLocalsNode.from(node as SerializedERBStrictLocalsNode); case "AST_ERB_YIELD_NODE": return ERBYieldNode.from(node as SerializedERBYieldNode); case "AST_ERB_IN_NODE": return ERBInNode.from(node as SerializedERBInNode); default: throw new Error(`Unknown node type: ${node.type}`); } } export type NodeType = | "AST_DOCUMENT_NODE" | "AST_LITERAL_NODE" | "AST_HTML_OPEN_TAG_NODE" | "AST_HTML_CONDITIONAL_OPEN_TAG_NODE" | "AST_HTML_CLOSE_TAG_NODE" | "AST_HTML_OMITTED_CLOSE_TAG_NODE" | "AST_HTML_VIRTUAL_CLOSE_TAG_NODE" | "AST_HTML_ELEMENT_NODE" | "AST_HTML_CONDITIONAL_ELEMENT_NODE" | "AST_HTML_ATTRIBUTE_VALUE_NODE" | "AST_HTML_ATTRIBUTE_NAME_NODE" | "AST_HTML_ATTRIBUTE_NODE" | "AST_RUBY_LITERAL_NODE" | "AST_RUBY_HTML_ATTRIBUTES_SPLAT_NODE" | "AST_ERB_OPEN_TAG_NODE" | "AST_HTML_TEXT_NODE" | "AST_HTML_COMMENT_NODE" | "AST_HTML_DOCTYPE_NODE" | "AST_XML_DECLARATION_NODE" | "AST_CDATA_NODE" | "AST_WHITESPACE_NODE" | "AST_ERB_CONTENT_NODE" | "AST_ERB_END_NODE" | "AST_ERB_ELSE_NODE" | "AST_ERB_IF_NODE" | "AST_ERB_BLOCK_NODE" | "AST_ERB_WHEN_NODE" | "AST_ERB_CASE_NODE" | "AST_ERB_CASE_MATCH_NODE" | "AST_ERB_WHILE_NODE" | "AST_ERB_UNTIL_NODE" | "AST_ERB_FOR_NODE" | "AST_ERB_RESCUE_NODE" | "AST_ERB_ENSURE_NODE" | "AST_ERB_BEGIN_NODE" | "AST_ERB_UNLESS_NODE" | "AST_RUBY_RENDER_LOCAL_NODE" | "AST_RUBY_RENDER_KEYWORDS_NODE" | "AST_ERB_RENDER_NODE" | "AST_RUBY_PARAMETER_NODE" | "AST_ERB_STRICT_LOCALS_NODE" | "AST_ERB_YIELD_NODE" | "AST_ERB_IN_NODE" export type ERBNodeType = Extract; export type ERBNode = | ERBOpenTagNode | ERBContentNode | ERBEndNode | ERBElseNode | ERBIfNode | ERBBlockNode | ERBWhenNode | ERBCaseNode | ERBCaseMatchNode | ERBWhileNode | ERBUntilNode | ERBForNode | ERBRescueNode | ERBEnsureNode | ERBBeginNode | ERBUnlessNode | ERBRenderNode | ERBStrictLocalsNode | ERBYieldNode | ERBInNode export const ERBNodeClasses = [ ERBOpenTagNode, ERBContentNode, ERBEndNode, ERBElseNode, ERBIfNode, ERBBlockNode, ERBWhenNode, ERBCaseNode, ERBCaseMatchNode, ERBWhileNode, ERBUntilNode, ERBForNode, ERBRescueNode, ERBEnsureNode, ERBBeginNode, ERBUnlessNode, ERBRenderNode, ERBStrictLocalsNode, ERBYieldNode, ERBInNode, ]