Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions packages/typescript/src/api/node/node.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import {
getTokenPosOfNode,
type JSDoc,
ModifierFlags,
type Node,
type NodeArray,
type NodeBase,
type SourceFile,
SyntaxKind,
} from "../../ast/index.ts";
Expand Down Expand Up @@ -153,13 +155,13 @@ export class RemoteNodeList extends Array<RemoteNode> implements NodeArray<Remot
}
}

forEachNode<T>(visitNode: (node: RemoteNode) => T | undefined): T | undefined {
forEachNode<T>(visitNode: (node: Node) => T | undefined): T | undefined {
if (!this.length) return;
let next = this.index + 1;
while (next) {
const child = this.getOrCreateChildAtNodeIndex(next);
next = child.next;
const result = visitNode(child as RemoteNode);
const result = visitNode(child as Node);
if (result) return result;
}
}
Expand Down Expand Up @@ -222,7 +224,7 @@ export class RemoteNodeList extends Array<RemoteNode> implements NodeArray<Remot
}
}

export class RemoteNode extends RemoteNodeBase implements Node {
export class RemoteNode extends RemoteNodeBase implements NodeBase {
protected static NODE_LEN: number = NODE_LEN;
protected override get sourceFile(): SourceFileInfo {
return this._sourceFile;
Expand All @@ -244,7 +246,7 @@ export class RemoteNode extends RemoteNodeBase implements Node {
const child = this.getOrCreateChildAtNodeIndex(next);
if (child instanceof RemoteNodeList) {
if (visitList) {
const result = visitList(child);
const result = visitList(child as NodeArray<Node>);
if (result) {
return result;
}
Expand All @@ -257,7 +259,7 @@ export class RemoteNode extends RemoteNodeBase implements Node {
}
}
else if (child.kind !== SyntaxKind.JSDoc) {
const result = visitNode(child);
const result = visitNode(child as Node);
if (result) {
return result;
}
Expand All @@ -268,16 +270,16 @@ export class RemoteNode extends RemoteNodeBase implements Node {
}
}

get jsDoc(): readonly Node[] | undefined {
get jsDoc(): readonly JSDoc[] | undefined {
if (!this.hasChildren()) {
return undefined;
}
let result: Node[] | undefined;
let result: JSDoc[] | undefined;
let next = this.index + 1;
do {
const child = this.getOrCreateChildAtNodeIndex(next);
if (!(child instanceof RemoteNodeList) && child.kind === SyntaxKind.JSDoc) {
(result ??= []).push(child);
(result ??= []).push(child as unknown as JSDoc);
}
next = child.next;
}
Expand Down
Loading