scala.tools.refactoring.transformation

Transformations

trait Transformations extends AnyRef

Transformations is the basis for all refactoring transformations.

A transformation is a Function from X ⇒ Option[X], and can be combined with other transformations in two ways: andThen - which applies the second transformation only if the first one was successful, i.e. returned Some(_). orElse - which is applied only when the first transformation returned None.

Xs are typically instances of global.Tree, but this is not enforced. Once a transformations is assembled, it has to be applied to a tree and its children. The function all applies a transformation to the children of a tree. In the case of the trees, the tree has to apply the transformation to all children and return one single tree.

Additional functions are provided that apply a transformation top-down or bottom-up.

Self Type
Transformations with CompilerAccess
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Transformations
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. abstract class Transformation[X, Y] extends (X) ⇒ Option[Y]

Abstract Value Members

  1. abstract def traverse(x: nsc.Global.Tree, f: (nsc.Global.Tree) ⇒ nsc.Global.Tree): nsc.Global.Tree

Concrete Value Members

  1. def ![X](t: ⇒ (Transformations.this)#T[X, X]): (Transformations.this)#Transformation[X, X]

  2. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  3. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  4. final def ##(): Int

    Definition Classes
    AnyRef → Any
  5. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  6. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  7. def allChildren(t: ⇒ (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]): (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]

    Applies a transformation to all subtrees of a tree T, returning a new tree,typically of the same kind as T.

    Applies a transformation to all subtrees of a tree T, returning a new tree,typically of the same kind as T.

    If the transformation fails on one child, abort and fail the whole application.

  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def bottomup(t: ⇒ (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]): (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]

  10. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def constant(y: nsc.Global.Tree): (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]

    Creates a transformation that always returns the value x.

  12. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  14. def fail[X]: (Transformations.this)#T[X, X]

    Always fails, independent of the input.

  15. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  17. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  18. def id[X]: (Transformations.this)#T[X, X]

  19. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  20. def matchingChildren(t: (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]): (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]

    Applies a transformation to all subtrees of a tree T, returning a new tree,typically of the same kind as T.

    Applies a transformation to all subtrees of a tree T, returning a new tree,typically of the same kind as T.

    If the transformation fails on one child, apply the identity transformation id and don't fail, unlike allChildren.

  21. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  22. def not[X](t: ⇒ (Transformations.this)#T[X, X]): (Transformations.this)#Transformation[X, X]

  23. final def notify(): Unit

    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  25. def once[X <: AnyRef](t: (Transformations.this)#T[X, X]): (Transformations.this)#T[X, X]

    Do a transformation until it succeeded once, then just fail.

    Do a transformation until it succeeded once, then just fail.

    Note that because of the statefulness of once, you need to make sure that it isn't accidentally passed as a by-name parameter to another transformation and instantiated multiple times.

  26. def postorder(t: ⇒ (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]): (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]

  27. def predicate[X](f: (X) ⇒ Boolean): (Transformations.this)#T[X, X]

  28. def predicate[X](f: PartialFunction[X, Boolean]): (Transformations.this)#T[X, X]

    We often want to use transformations as predicates, which execute the next transformations if the result is true.

    We often want to use transformations as predicates, which execute the next transformations if the result is true. For example:

    val tree_with_range_pos = filter[Tree] { case t: Tree => t.pos.isRange }

    We can then use the predicate like this: tree_with_range_pos andThen do_something_with_the_tree orElse nothing

  29. def preorder(t: ⇒ (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]): (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]

  30. def succeed[X]: (Transformations.this)#T[X, X]

    Always succeeds and returns the input unchanged.

  31. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  32. def toString(): String

    Definition Classes
    AnyRef → Any
  33. def topdown(t: ⇒ (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]): (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]

  34. def transformation[X, Y](f: PartialFunction[X, Y]): (Transformations.this)#T[X, Y]

    Construct a transformation from a partial function; this is the most commonly used way to create new transformations, for example like:

    Construct a transformation from a partial function; this is the most commonly used way to create new transformations, for example like:

    val reverse_all_class_members = transformation[Tree, Tree] { case t: Template => t.copy(body = t.body.reverse) }

  35. def traverseAndTransformAll(t: ⇒ (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]): (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]

  36. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. def (t: ⇒ (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]): (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]

    Applies a transformation bottom-up, that is, it applies the transformation to the children of the tree first and then to their parent.

    Applies a transformation bottom-up, that is, it applies the transformation to the children of the tree first and then to their parent. The consequence is that the parent "sees" its transformed children.

  40. def (t: ⇒ (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]): (Transformations.this)#T[nsc.Global.Tree, nsc.Global.Tree]

    Applies a transformation top-down, that is, it applies the transformation to the tree T and then passes the transformed T to all children.

    Applies a transformation top-down, that is, it applies the transformation to the tree T and then passes the transformed T to all children. The consequence is that the children "see" their new parent.

Inherited from AnyRef

Inherited from Any

Ungrouped