Skip to content

Commit cd378b4

Browse files
committed
Remove getOrSetNodeChildren
1 parent 2c02eeb commit cd378b4

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/compiler/factory/nodeChildren.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,12 @@ export function getNodeChildren(node: Node): Node[] | undefined {
88
}
99

1010
/** @internal */
11-
export function setNodeChildren(node: Node, children: Node[]) {
11+
export function setNodeChildren(node: Node, children: Node[]): Node[] {
1212
nodeChildren.set(node, children);
13+
return children;
1314
}
1415

1516
/** @internal */
1617
export function unsetNodeChildren(node: Node) {
1718
nodeChildren.delete(node);
1819
}
19-
20-
/** @internal */
21-
export function getOrSetNodeChildren(node: Node, fn: () => Node[]): Node[] {
22-
let children = getNodeChildren(node);
23-
if (children === undefined) {
24-
setNodeChildren(node, children = fn());
25-
}
26-
return children;
27-
}

src/services/services.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ import {
106106
getNameFromPropertyName,
107107
getNewLineCharacter,
108108
getNewLineOrDefaultFromHost,
109+
getNodeChildren,
109110
getNonAssignedNameOfDeclaration,
110111
getNormalizedAbsolutePath,
111112
getObjectFlags,
112-
getOrSetNodeChildren,
113113
getQuotePreference,
114114
getScriptKind,
115115
getSetExternalModuleIndicator,
@@ -438,7 +438,7 @@ class NodeObject<TKind extends SyntaxKind> implements Node {
438438

439439
public getChildren(sourceFile?: SourceFileLike): Node[] {
440440
this.assertHasRealPosition("Node without a real position cannot be scanned and thus has no token nodes - use forEachChild and collect the result if that's fine");
441-
return getOrSetNodeChildren(this, () => createChildren(this, sourceFile));
441+
return getNodeChildren(this) ?? setNodeChildren(this, createChildren(this, sourceFile));
442442
}
443443

444444
public getFirstToken(sourceFile?: SourceFileLike): Node | undefined {

0 commit comments

Comments
 (0)