Interactive

object Interactive

High-level API to get information out of typed trees, designed to be used by IDEs.

See also

InteractiveDriver to get typed trees from code.

class Object
trait Matchable
class Any

Type members

Classlikes

object Include

Value members

Concrete methods

def contextOfPath(path: List[Tree])(using Context): Context
def contextOfStat(stats: List[Tree], stat: Tree, exprOwner: Symbol, ctx: Context): Context

The first tree in the path that is a definition.

The first tree in the path that is a definition.

The source symbols that are the closest to path.

The source symbols that are the closest to path.

If this path ends in an import, then this returns all the symbols that are imported by this import statement.

Value Params
path

The path to the tree whose symbols to extract.

Returns

The source symbols that are the closest to path.

See also

sourceSymbol

The closest enclosing tree with a symbol containing position pos, or the EmptyTree.

The closest enclosing tree with a symbol containing position pos, or the EmptyTree.

def enclosingTree(path: List[Tree])(using Context): Tree

The closes enclosing tree with a symbol, or the EmptyTree.

The closes enclosing tree with a symbol, or the EmptyTree.

The type of the closest enclosing tree with a type containing position pos.

The type of the closest enclosing tree with a type containing position pos.

Find the definitions of the symbol at the end of path. In the case of an import node, all imported symbols will be considered.

Find the definitions of the symbol at the end of path. In the case of an import node, all imported symbols will be considered.

Value Params
driver

The driver responsible for path.

path

The path to the symbol for which we want the definitions.

Returns

The definitions for the symbol at the end of path.

def findDefinitions(symbols: List[Symbol], driver: InteractiveDriver, includeOverridden: Boolean, includeExternal: Boolean): List[SourceTree]

Find the definitions of symbols.

Find the definitions of symbols.

Value Params
driver

The driver responsible for the given symbols.

includeExternal

If true, also look for definitions on the classpath.

includeOverridden

If true, also include the symbols overridden by any of symbols.

symbols

The list of symbols for which to find a definition.

Returns

The definitions for the symbols in symbols, and if includeOverridden is set, the definitions for the symbols that they override.

def findTreesMatching(trees: List[SourceTree], includes: Set, symbol: Symbol, predicate: NameTree => Boolean)(using Context): List[SourceTree]

Find trees that match symbol in trees.

Find trees that match symbol in trees.

Value Params
includes

Whether to include references, definitions, etc.

predicate

An additional predicate that the trees must match.

symbol

The symbol for which we want to find references.

trees

The trees to inspect.

Return a predicate function that determines whether a given NameTree is an implementation of sym.

Return a predicate function that determines whether a given NameTree is an implementation of sym.

Value Params
sym

The symbol whose implementations to find.

Returns

A function that determines whether a NameTree is an implementation of sym.

Does this tree define a symbol ?

Does this tree define a symbol ?

def isRenamed(tree: NameTree)(using Context): Boolean

Is this tree using a renaming introduced by an import statement or an alias for this?

Is this tree using a renaming introduced by an import statement or an alias for this?

Value Params
tree

The tree to inspect

Returns

True, if this tree's name is different than its symbol's name, indicating that it uses a renaming introduced by an import statement or an alias for this.

def localize(symbol: Symbol, sourceDriver: InteractiveDriver, targetDriver: InteractiveDriver): Symbol

Given sym, originating from sourceDriver, find its representation in targetDriver.

Given sym, originating from sourceDriver, find its representation in targetDriver.

Value Params
sourceDriver

The driver from which symbol originates.

symbol

The symbol to expression in the new driver.

targetDriver

The driver in which we want to get a representation of symbol.

Returns

A representation of symbol in targetDriver.

def matchSymbol(tree: Tree, sym: Symbol, include: Set)(using Context): Boolean

Check if tree matches sym. This is the case if the symbol defined by tree equals sym, or the source symbol of tree equals sym, or include is overridden, and tree is overridden by sym, or include is overriding, and tree overrides sym.

Check if tree matches sym. This is the case if the symbol defined by tree equals sym, or the source symbol of tree equals sym, or include is overridden, and tree is overridden by sym, or include is overriding, and tree overrides sym.

def namedTrees(trees: List[SourceTree], include: Set, sym: Symbol)(using Context): List[SourceTree]

Find named trees with a non-empty position whose symbol match sym in trees.

Find named trees with a non-empty position whose symbol match sym in trees.

Note that nothing will be found for symbols not defined in source code, use sourceSymbol to get a symbol related to sym that is defined in source code.

def namedTrees(trees: List[SourceTree], include: Set, treePredicate: NameTree => Boolean)(using Context): List[SourceTree]

Find named trees with a non-empty position satisfying treePredicate in trees.

Find named trees with a non-empty position satisfying treePredicate in trees.

Value Params
include

Whether to include references, definitions, etc.

treePredicate

An additional predicate that the trees must match.

trees

The trees to inspect.

Returns

The trees with a non-empty position satisfying treePredicate.

def pathTo(trees: List[SourceTree], pos: SourcePosition)(using Context): List[Tree]

The reverse path to the node that closest encloses position pos, or Nil if no such path exists. If a non-empty path is returned it starts with the tree closest enclosing pos and ends with an element of trees.

The reverse path to the node that closest encloses position pos, or Nil if no such path exists. If a non-empty path is returned it starts with the tree closest enclosing pos and ends with an element of trees.

def pathTo(tree: Tree, span: Span)(using Context): List[Tree]
def sameName(n0: Name, n1: Name): Boolean

Are the two names the same?

Are the two names the same?