The attachment of the reflection artifact.
The attachment of the reflection artifact.
A method that should be called from every well-designed equals method that is open to be overridden in a subclass.
A method that should be called from every well-designed equals method that is open to be overridden in a subclass. See Programming in Scala, Chapter 28 for discussion and design.
the value being probed for possible equality
true if this instance can possibly equal that
, otherwise false
Can this tree carry attributes (i.
Can this tree carry attributes (i.e. symbols, types or positions)?
Typically the answer is yes, except for the EmptyTree
null object and
two special singletons: emptyValDef
and pendingSuperCall
.
The direct child trees of this tree.
The direct child trees of this tree. EmptyTrees are always omitted. Lists are flattened.
Apply pf' to each subtree on which the function is defined and collect the results.
Apply pf' to each subtree on which the function is defined and collect the results.
Like setType
, but if this is a previously empty TypeTree that
fact is remembered so that resetAllAttrs will snap back.
Like setType
, but if this is a previously empty TypeTree that
fact is remembered so that resetAllAttrs will snap back.
\@PP: Attempting to elaborate on the above, I find: If defineType is called on a TypeTree whose type field is null or NoType, this is recorded as "wasEmpty = true". That value is used in ResetAttrsTraverser, which nulls out the type field of TypeTrees for which wasEmpty is true, leaving the others alone.
resetAllAttrs is used in situations where some speculative
typing of a tree takes place, fails, and the tree needs to be
returned to its former state to try again. So according to me:
using defineType
instead of setType
is how you communicate
that the type being set does not depend on any previous state,
and therefore should be abandoned if the current line of type
inquiry doesn't work out.
Make a copy of this tree, keeping all attributes, except that all positions are focused (so nothing in this tree will be found when searching by position).
Make a copy of this tree, keeping all attributes, except that all positions are focused (so nothing in this tree will be found when searching by position).
Tests whether two trees are structurall equal.
Tests whether two trees are structurall equal.
Note that ==
on trees is reference equality.
Is there exists a part of this tree which satisfies predicate p
?
Is there exists a part of this tree which satisfies predicate p
?
Find all subtrees matching predicate p
.
Find all subtrees matching predicate p
. Same as withFilter
Returns optionally first tree (in a preorder traversal) which satisfies predicate p
,
or None if none exists.
Returns optionally first tree (in a preorder traversal) which satisfies predicate p
,
or None if none exists.
Do all parts of this tree satisfy predicate p
?
Do all parts of this tree satisfy predicate p
?
Apply f
to each subtree
Apply f
to each subtree
Extracts free term symbols from a tree that is reified or contains reified subtrees.
Extracts free term symbols from a tree that is reified or contains reified subtrees.
Extracts free type symbols from a tree that is reified or contains reified subtrees.
Extracts free type symbols from a tree that is reified or contains reified subtrees.
Does this tree represent a definition? (of a method, of a class, etc)
Does this tree represent a definition? (of a method, of a class, etc)
Is this tree one of the empty trees?
Is this tree one of the empty trees?
Empty trees are: the EmptyTree
null object, TypeTree
instances that don't carry a type
and the special emptyValDef
singleton.
In the compiler the isEmpty
check and the derived orElse
method are mostly used
as a check for a tree being a null object (EmptyTree
for term trees and empty TypeTree for type trees).
Unfortunately emptyValDef
is also considered to be isEmpty
, but this is deemed to be
a conceptual mistake pending a fix in https://issues.scala-lang.org/browse/SI-6762.
canHaveAttrs
The canonical way to test if a Tree represents a term.
The canonical way to test if a Tree represents a term.
The canonical way to test if a Tree represents a type.
The canonical way to test if a Tree represents a type.
Is this tree one of the empty trees?
Is this tree one of the empty trees?
isEmpty
Provides an alternate if tree is empty
Provides an alternate if tree is empty
The alternate tree
If this tree is non empty, this tree, otherwise alt
.
Position of the tree.
Position of the tree.
Sets the pos
of the tree.
Sets the pos
of the tree. Returns Unit
.
The size of this product.
The nth element of this product, 0-based.
The nth element of this product, 0-based. In other words, for a
product A(x1, ..., xk)
, returns x(n+1)
where 0 < n < k
.
the index of the element to return
the element n
elements after the first element
Update the attachment with the payload of the given class type T
removed.
Update the attachment with the payload of the given class type T
removed.
Returns the reflection artifact itself.
Sets the pos
of the tree.
Sets the pos
of the tree. Returns the tree itself.
Sets the symbol
of the tree.
Sets the symbol
of the tree. Returns the tree itself.
Sets the tpe
of the tree.
Sets the tpe
of the tree. Returns the tree itself.
Substitute symbols in to
for corresponding occurrences of references to
symbols from
in this type.
Substitute symbols in to
for corresponding occurrences of references to
symbols from
in this type.
Substitute given tree to
for occurrences of nodes that represent
C.this
, where C
referes to the given class clazz
.
Substitute given tree to
for occurrences of nodes that represent
C.this
, where C
referes to the given class clazz
.
Substitute types in to
for corresponding occurrences of references to
symbols from
in this tree.
Substitute types in to
for corresponding occurrences of references to
symbols from
in this tree.
Symbol of the tree.
Symbol of the tree.
For most trees symbol is null
. In SymTree
s,
it is overridden and implemented with a var, initialized to NoSymbol
.
Trees which are not SymTree
s but which carry symbols do so by
overriding def symbol
to forward it elsewhere. Examples:
Super(qual, _)
has qual
's symbol,Apply(fun, args)
has fun
's symbol,TypeApply(fun, args)
has fun
's symbol,AppliedTypeTree(tpt, args)
has tpt
's symbol,TypeTree(tpe)
has tpe
's typeSymbol
, if tpe != null
.
Sets the symbol
of the tree.
Sets the symbol
of the tree. Returns Unit
.
Type of the tree.
Type of the tree.
Upon creation most trees have their tpe
set to null
.
Types are typically assigned to trees during typechecking.
Some node factory methods set tpe
immediately after creation.
When the typechecker encounters a tree with a non-null tpe,
it will assume it to be correct and not check it again. This means one has
to be careful not to erase the tpe
field of subtrees.
Updates the attachment with the payload slot of T added/updated with the provided value.
Updates the attachment with the payload slot of T added/updated with the provided value. Replaces an existing payload of the same type, if exists. Returns the reflection artifact itself.
Find all subtrees matching predicate p
.
Find all subtrees matching predicate p
. Same as filter
Sets the tpe
of the tree.
Sets the tpe
of the tree. Returns Unit
.
(Since version 2.11.0) Use setType
Returns string formatted according to given format
string.
Returns string formatted according to given format
string.
Format strings are as for String.format
(@see java.lang.String.format).
An iterator over all the elements of this product.
An iterator over all the elements of this product.
in the default implementation, an Iterator[Any]
A string used in the toString
methods of derived classes.
A string used in the toString
methods of derived classes.
Implementations may override this method to prepend a string prefix
to the result of toString
methods.
in the default implementation, the empty string
Obtains string representation of a tree
Obtains string representation of a tree
The extended API of trees that's supported in macro context universes