Skip to content
This repository was archived by the owner on Nov 6, 2019. It is now read-only.

Commit 334758c

Browse files
committed
Don't crash on unsupported node by default in visitNode, just report instead
1 parent c46473d commit 334758c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/ast/typescript/typeScriptAstUtils.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,18 @@ fun forEachChild(visitor: Visitor, node: Node) {
401401
})
402402
}
403403

404-
fun visitNode(visitor: Visitor, node: Node?): Unit {
404+
fun visitNode(visitor: Visitor, node: Node?) {
405405
if (node == null) return
406406

407+
try {
408+
visitNodeImpl(visitor, node)
409+
}
410+
catch (e: dynamic) {
411+
reportUnsupportedNode(node)
412+
}
413+
}
414+
415+
private fun visitNodeImpl(visitor: Visitor, node: Node) {
407416
when (node.kind as Any) {
408417
SyntaxKind.ModuleDeclaration -> visitor.visitModuleDeclaration(node.asDynamic())
409418

0 commit comments

Comments
 (0)