Skip to content

Commit e2a1a78

Browse files
committed
reuse the fixupParentReferences function
1 parent d41ac8a commit e2a1a78

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/compiler/parser.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -444,19 +444,7 @@ namespace ts {
444444
if (result && result.jsDocComment) {
445445
// because the jsDocComment was parsed out of the source file, it might
446446
// not be covered by the fixupParentReferences.
447-
let parentNode: Node = result.jsDocComment;
448-
forEachChild(result.jsDocComment, visitNode);
449-
450-
function visitNode(n: Node): void {
451-
if (n.parent === undefined) {
452-
n.parent = parentNode;
453-
454-
const saveParent = parentNode;
455-
parentNode = n;
456-
forEachChild(n, visitNode);
457-
parentNode = saveParent;
458-
}
459-
}
447+
Parser.fixupParentReferences(result.jsDocComment);
460448
}
461449

462450
return result;
@@ -671,14 +659,14 @@ namespace ts {
671659
return node;
672660
}
673661

674-
export function fixupParentReferences(sourceFile: Node) {
662+
export function fixupParentReferences(rootNode: Node) {
675663
// normally parent references are set during binding. However, for clients that only need
676664
// a syntax tree, and no semantic features, then the binding process is an unnecessary
677665
// overhead. This functions allows us to set all the parents, without all the expense of
678666
// binding.
679667

680-
let parent: Node = sourceFile;
681-
forEachChild(sourceFile, visitNode);
668+
let parent: Node = rootNode;
669+
forEachChild(rootNode, visitNode);
682670
return;
683671

684672
function visitNode(n: Node): void {

0 commit comments

Comments
 (0)