I am using javaparser to construct an AST from Java source code. Is there a way to safely copy AST nodes?
For example, if I want to duplicate a BinaryExpr to insert somewhere else in the tree, is there a built-in way to copy the node?
I am using javaparser to construct an AST from Java source code. Is there a way to safely copy AST nodes?
For example, if I want to duplicate a BinaryExpr to insert somewhere else in the tree, is there a built-in way to copy the node?
You may want to use the CloneVisitor (https://github.com/javaparser/javaparser/blob/master/javaparser-core/src/main/java/com/github/javaparser/ast/visitor/CloneVisitor.java)
Maybe we should make it more obvious, I will open an issue at (https://github.com/javaparser/javaparser/issues/147)
Disclaimer: I am a JavaParser contributor