8000 fix: ensure parent pointers are correctly set for transformed nodes by ChouUn · Pull Request #1613 · TypeScriptToLua/TypeScriptToLua · GitHub
[go: up one dir, main page]

Skip to content

fix: ensure parent pointers are correctly set for transformed nodes #1613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension 8000

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/transformation/pre-transformers/using-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ export function usingTransformer(context: TransformationContext): ts.Transformer
if (hasUsings) {
// Recurse visitor into updated block to find further usings
const updatedBlock = ts.factory.updateBlock(node, newStatements);
const result = ts.visitEachChild(updatedBlock, visit, ctx);
const visitedBlock = ts.visitEachChild(updatedBlock, visit, ctx);

// Set all the synthetic node parents to something that makes sense
const parent: ts.Node[] = [updatedBlock];
const parent: ts.Node[] = [];
function setParent(node2: ts.Node): ts.Node {
ts.setParent(node2, parent[parent.length - 1]);
parent.push(node2);
ts.visitEachChild(node2, setParent, ctx);
parent.pop();
return node2;
}
ts.visitEachChild(updatedBlock, setParent, ctx);
ts.setParent(updatedBlock, node.parent);
parent.push(visitedBlock);
ts.visitEachChild(visitedBlock, setParent, ctx);
ts.setParent(visitedBlock, node.parent);

return result;
return visitedBlock;
}
}
return ts.visitEachChild(node, visit, ctx);
Expand Down
Loading
0