Trait

scala.tools.refactoring.transformation

Transformations

Related Doc: package transformation

Permalink

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
Visibility
  1. Public
  2. All

Type Members

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

    Permalink

Abstract Value Members

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

    Permalink

Concrete Value Members

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

    Permalink
  2. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ##(): Int

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

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

    Permalink

    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.

  6. final def asInstanceOf[T0]: T0

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

    Permalink
  8. def clone(): AnyRef

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

    Permalink

    Creates a transformation that always returns the value x.

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

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

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

    Permalink

    Always fails, independent of the input.

  13. def finalize(): Unit

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

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

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

    Permalink
  17. final def isInstanceOf[T0]: Boolean

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

    Permalink

    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.

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

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

    Permalink
  21. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. final def notifyAll(): Unit

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

    Permalink

    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.

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

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

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

    Permalink

    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

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

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

    Permalink

    Always succeeds and returns the input unchanged.

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

    Permalink
    Definition Classes
    AnyRef
  30. def toString(): String

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

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

    Permalink

    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) }

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

    Permalink
  34. final def wait(): Unit

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

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

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

    Permalink

    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.

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

    Permalink

    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