Class CloneHelper

java.lang.Object
spoon.support.visitor.equals.CloneHelper

public class CloneHelper extends Object
CloneHelper is responsible for creating clones of CtElement AST nodes including the whole subtree. By default, the same instance of CloneHelper is used for whole clonning process. However, by subclassing this class and overriding method clone(CtElement), one can extend and/or modify the cloning behavior. For instance, one can listen to each call to clone and get each pair of `clone source` and `clone target`.
  • Field Details

  • Constructor Details

    • CloneHelper

      public CloneHelper()
  • Method Details

    • clone

      public <T extends CtElement> T clone(T element)
    • clone

      public <T extends CtElement> Collection<T> clone(Collection<T> elements)
    • clone

      public <T extends CtElement> List<T> clone(List<T> elements)
    • clone

      public <T extends CtElement> Set<T> clone(Set<T> elements)
      clones a Set of elements
      Type Parameters:
      T - the Set of elements to be cloned
      Returns:
      others Set of cloned elements
    • clone

      public <T extends CtElement> Map<String,​T> clone(Map<String,​T> elements)
    • addClone

      protected <T extends CtElement> void addClone(Collection<T> targetCollection, T element)
      clones an element and adds it's clone as value into targetCollection
      Parameters:
      targetCollection - - the collection which will receive a clone of element
      element - to be cloned element
    • addClone

      protected <T extends CtElement> void addClone(Map<String,​T> targetMap, String key, T value)
      clones a value and adds it's clone as value into targetMap under key
      Parameters:
      targetMap - - the Map which will receive a clone of value
      key - the target key, which has to be used to add cloned value into targetMap
      value - to be cloned element
    • tailor

      public void tailor(CtElement topLevelElement, CtElement topLevelClone)
      Is called by CloneVisitor at the end of the cloning for each element.