public final class CopyState extends Object
Node.copy(CopyState).
The Soy AST is mostly a tree, but there are some back edges. Since the copying process is recursive and can be started from any node, there is no guarantee whether the back edges will be copied (this means that copying only a subtree may leave you with back edges pointing at the old tree, which is weird).
| Modifier and Type | Class and Description |
|---|---|
static interface |
CopyState.Listener<T>
A simple listener api that can be used to listen to changes to objects via the
updateRefs(T, T) api. |
| Constructor and Description |
|---|
CopyState() |
| Modifier and Type | Method and Description |
|---|---|
<T> void |
registerRefListener(T oldObject,
CopyState.Listener<T> listener)
Registers a listener to be invoked if the given object is ever updated via the
updateRefs(T, T) method. |
<T> void |
updateRefs(T oldObject,
T newObject)
Registers that the old object has been remapped to the new object.
|
public <T> void updateRefs(T oldObject,
T newObject)
This is useful for auxiliary AST datastructures which may contain back-edges in the AST.
When being copied, the auxiliary data structure is registered with this method then AST nodes
which have references to the old copy can register via registerRefListener(T, com.google.template.soy.basetree.CopyState.Listener<T>) so that
they can get a reference to the new copy as well.
public <T> void registerRefListener(T oldObject,
CopyState.Listener<T> listener)
updateRefs(T, T) method.
Note: the listener may be executed inline or not at all.