Replace the first sequence of elements with another sequence.
Replace the first sequence of elements with another sequence.
Represent an import selector as a tree, including both names as trees.
Represent an import selector as a tree, including both names as trees.
Import selectors are not trees, but we can provide an extractor that converts the ImportSelectors into our own ImportSelectorTrees.
Import selectors are not trees, but we can provide an extractor that converts the ImportSelectors into our own ImportSelectorTrees.
Represent a modifier as a tree, including its position.
Represent a modifier as a tree, including its position.
Represent a Name as a tree, including its position.
Represent a Name as a tree, including its position.
The PlainText "tree" provides a hook into the source code generation.
The PlainText "tree" provides a hook into the source code generation.
When a PlainText tree occurs during source code generation, its print
method is called with the current AbstractPrinter#PrintingContext. The
result is inserted into the generated source code.
For some use cases (blank line, raw and indented string) implementations
already exist in the PlainText
object.
Note that PlainText trees should never be allowed to escape the Scala refactoring library, so be careful when using compiler utilities to transform trees.
PrintingContext is passed around with all the print methods and contains the context or environment for the current printing.
PrintingContext is passed around with all the print methods and contains the context or environment for the current printing.
Representation of self type annotations: self: A with B => ^^^^^^^^^^^^^^
Representation of self type annotations: self: A with B => ^^^^^^^^^^^^^^
The call to the super constructor in a class: class A(i: Int) extends B(i) ^^^^
The call to the super constructor in a class: class A(i: Int) extends B(i) ^^^^
Use TraversalTracing for debugging and PlainTraversals for production
Use TraversalTracing for debugging and PlainTraversals for production
A traverser that also traverses a TypeTree's original type.
A traverser that also traverses a TypeTree's original type.
A traverser that creates fake trees for various type trees so they can be treated as if they were regular trees.
A traverser that creates fake trees for various type trees so they can be treated as if they were regular trees.
Add some methods to Tree that make it easier to compare Trees by position and to extract the position of a tree's name, which is tricky for Selects.
Add some methods to Tree that make it easier to compare Trees by position and to extract the position of a tree's name, which is tricky for Selects.
A SourceLayoutTree can be used to insert arbitrary text into the code, for example, blank lines.
A SourceLayoutTree can be used to insert arbitrary text into the code, for example, blank lines.
(Since version 0.5.0) Use PlainText objects and its components
Extracts information from ApplyNodes
Extracts information from ApplyNodes
The main feature of this extractor is that reverses the desugarings the compiler performs for named arguments by creating scala.tools.refactoring.common.EnrichedTrees.NamedArgument instances as necessary. Apart from that, this object is meant to mimic the regular scala.reflect.api.Trees.ApplyExtractor.
Unify the children of a Block tree and sort them in the same order they appear in the source code.
Unify the children of a Block tree and sort them in the same order they appear in the source code.
Also reshapes some trees: multiple assignments are removed and named argument trees are created.
Note that this extractor is needed primarily for tree printing. The rename refactoring for example, that doesn't use tree printing, would work with
object BlockExtractor { def unapply(t: Block) = { Some(t.expr :: t.stats) } }
as well.
Extract the modifiers with their position from a Modifiers object.
Extract the modifiers with their position from a Modifiers object.
Provides a finer-grained extractor for Template that distinguishes between class constructor parameters, early definitions, parents, self type annotation and the real body.
Provides a finer-grained extractor for Template that distinguishes between class constructor parameters, early definitions, parents, self type annotation and the real body.
Copy of scala.reflect.internal.Trees.ValOrDefDef of 2.11 to support 2.10.
Copy of scala.reflect.internal.Trees.ValOrDefDef of 2.11 to support 2.10.
When extracting source code from the file via a tree's position, it depends on the tree type whether we can use the position's start or point.
When extracting source code from the file via a tree's position, it depends on the tree type whether we can use the position's start or point.
The tree that will be replaced.
The position to adapt. This does not have to be the position of t.
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.
Returns the (symbol) ancestors of the tree excluding the ROOT in descending order. Also filters the symbols for package objects!
Converts a tree containing Idents and Selects to a .
separated string.
Converts a tree containing Idents and Selects to a .
separated string.
Returns a fully loaded and typed Tree instance for the given SourceFile.
Returns a fully loaded and typed Tree instance for the given SourceFile.
Returns all children that have a representation in the source code.
Returns all children that have a representation in the source code. This includes Name and Modifier trees and excludes everything that has no Position or is an EmptyTree.
Creates a transformation that always returns the value x.
Creates a transformation that always returns the value x.
Creates a list of TextChanges from a list of trees, regenerating only those trees that have changed.
Creates a list of TextChanges from a list of trees, regenerating only those trees that have changed.
Creates a fragment from a tree, regenerating only those trees that have changed.
Creates a fragment from a tree, regenerating only those trees that have changed.
Creates a string from a tree, regenerating all trees.
Creates a string from a tree, regenerating all trees.
If the sourceFile parameter is passed, it will be used to figure out what kinds of newline separators we should generate. If None is passed, '\n' is used.
The characters that are used to indent changed code.
The characters that are used to indent changed code.
Trees that reach the end of the file don't seem to have the correct end position, except if there's a newline at the end.
Trees that reach the end of the file don't seem to have the correct end position, except if there's a newline at the end.
Takes a name and wraps it in if the name corresponds to a Scala keyword.
Takes a name and wraps it in if the name corresponds to a Scala keyword.
Always fails, independent of the input.
Always fails, independent of the input.
Starting from a root tree, returns all children that have changed.
Starting from a root tree, returns all children that have changed. The format of the result is a tuple of a top-level tree, a position of the range that should be replaced and a set of all trees that changed in the context of that top-level tree, including the top-level tree.
Finds the "best" package for adding imports, together with the imports it already contains
Finds the "best" package for adding imports, together with the imports it already contains
The best package for imports means the innermost package where imports are still visible to all trees that might potentially need them. For example, given
package a.b.c package d package e package e1 { object E1 } package e2 { object E2 }
this function returns the package a.b.c.d.e
.
Finds a tree by its position, can be used to find the original tree from a transformed tree.
Finds a tree by its position, can be used to find the original tree from a transformed tree.
If multiple trees are candidates, then take the last one, because it is likely more specific.
Searches for a Symbol of a name in the type members of a tree.
Searches for a Symbol of a name in the type members of a tree.
This is mainly used for ImportSelectors, which don't carry any symbol information with them.
The expr of an Import tree.
The name of an ImportSelector of the import.
Returns whether the tree is considered empty.
Returns whether the tree is considered empty.
Prior to Scala 2.10.1 it was sufficient to check Tree#isEmpty, but now we also need to check if the tree is equal to emptyValDef.
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
.
Creates a function call fun
on the selector and passes a function with
a single parameter param
and the body body
.
Creates a function call fun
on the selector and passes a function with
a single parameter param
and the body body
.
Example:
someExpr becomes someExpr fun (param => body)
Creates a function call fun
on the selector and passes a function with
no parameter and the body body
.
Creates a function call fun
on the selector and passes a function with
no parameter and the body body
.
Example:
someExpr becomes someExpr fun (body)
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.
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
Creates a list of changes from a list of (potentially changed) trees.
Creates a list of changes from a list of (potentially changed) trees.
A list of changes that can be applied to the source file.
The characters that surround an import with multiple import selectors inside the braces:
The characters that surround an import with multiple import selectors inside the braces:
import a.{*name*}
Always succeeds and returns the input unchanged.
Always succeeds and returns the input unchanged.
Returns the most specific package declaration in the compilation
unit. For example, given the following declaration:
package a
package b
class C
it returns b
. If there are further nested packages, they are ignored:
package a
class C
package b
returns a
.
Creates changes by applying several transformations to the root tree of an abstract file.
Creates changes by applying several transformations to the root tree of an abstract file. Each transformation creates a new root tree that is used as input of the next transformation.
Creates changes by applying a transformation to the root tree of an abstract file.
Creates changes by applying a transformation to the root tree of an abstract file.
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) }
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.
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.
(Since version 0.5.0) Use PlainText objects and its components
Extracts members (vals, vars and defs) from a trait/class/object into a new trait.