Class that implements the children and withNewChildren methods using reflection when implementing
TreeNode with a case class or case object.
Applies the given partial function starting from the leaves of this tree.
Applies the given partial function starting from the leafs of this tree.
Applies the given partial function starting from the leafs of this tree.
This is a stack-safe version of BottomUp.
Applies the given partial function starting from the leaves of this tree.
Applies the given partial function starting from the leaves of this tree. An additional context is being recursively passed from the leftmost child to its siblings and eventually to its parent.
Represents a finished transformation during off-stack transformations.
Common parent of BottomUpStackSafe and TopDownStackSafe
Applies the given partial function starting from the root of this tree.
Applies the given partial function starting from the root of this tree.
Note the applied rule cannot insert new parent nodes.
Applies the given partial function starting from the root of this tree.
Applies the given partial function starting from the root of this tree.
This is a stack-safe version of TopDown.
,Note the applied rule cannot insert new parent nodes.
Applies the given transformation starting from the leaves of this tree.
Represents a child transformation operation during off-stack transformations.
Represents a node transformation operation during off-stack transformations.
Applies the given transformation starting from the leaves of this tree.
Applies the given transformation starting from the leaves of this tree.
This is a stack-safe version of Transform.
This is the base-class for stack-safe tree transformations.
This is the basic tree node class.
This is the basic tree node class. Usually it makes more sense to use AbstractTreeNode, which uses reflection
to generate the children and withNewChildren field/method. Our benchmarks show that manually implementing
them can result in a speedup of a factor of ~3 for tree rewrites, so in performance critical places it might
make sense to extend TreeNode instead.
This class uses array operations instead of Scala collections, both for improved performance as well as to save stack frames during recursion, which allows it to operate on trees that are several thousand nodes high.
Common trait of all classes that represent tree operations for off-stack transformations.
Caches an instance of the copy method per case class type.
Class that implements the
childrenandwithNewChildrenmethods using reflection when implementingTreeNodewith a case class or case object.This class caches values that are expensive to recompute.
The constructor can also contain NonEmptyLists, Lists, and Options that contain children. This works as long as there the assignment of children in
withNewChildrento the different constructor parameters can be inferred.Inferred assignment of new children is done as follows:
newChildrento a constructor parameter that is a childOptionof a child: Assign some next child innewChildrenif the child type matches the element type of the Option, assign None otherwise.Listof children: Assign children fromnewChildrento the list until the type of a child does not match the element type of the list.It is possible to override the defaults and use custom
children/withNewChildrenimplementations.