Class AstTransformer


  • @PublicApi
    public class AstTransformer
    extends java.lang.Object
    Allows for an easy way to "manipulate" the immutable Ast by changing specific nodes and getting back a new Ast containing the changed nodes while everything else is the same.
    • Constructor Detail

      • AstTransformer

        public AstTransformer()
    • Method Detail

      • transform

        public Node transform​(Node root,
                              NodeVisitor nodeVisitor)
        Transforms the input tree using the Visitor Pattern.
        Parameters:
        root - the root node of the input tree.
        nodeVisitor - the visitor which will transform the input tree.
        Returns:
        the transformed tree.
      • transform

        public Node transform​(Node root,
                              NodeVisitor nodeVisitor,
                              java.util.Map<java.lang.Class<?>,​java.lang.Object> rootVars)
        Transforms the input tree using the Visitor Pattern.
        Parameters:
        root - the root node of the input tree.
        nodeVisitor - the visitor which will transform the input tree.
        rootVars - a context argument to pass information into the nodeVisitor. Pass a contextual object to your visitor by adding it to this map such that such that the key is the class of the object, and the value is the object itself. The object can be retrieved within the visitor by calling context.getVarFromParents().
        Returns:
        the transformed tree.
      • transformParallel

        public Node transformParallel​(Node root,
                                      NodeVisitor nodeVisitor,
                                      java.util.concurrent.ForkJoinPool forkJoinPool)