Compiler Tree API

com.sun.source.util
Class Trees

java.lang.Object
  extended by com.sun.source.util.Trees

public abstract class Trees
extends Object

Bridges JSR 199, JSR 269, and the Tree API.


Constructor Summary
Trees()
           
 
Method Summary
abstract  Element getElement(TreePath path)
          Gets the Element for the Tree node identified by a given TreePath.
abstract  TreePath getPath(CompilationUnitTree unit, Tree node)
          Gets the path to tree node within the specified compilation unit.
abstract  TreePath getPath(Element e)
          Gets the TreePath node for a given Element.
abstract  TreePath getPath(Element e, AnnotationMirror a)
          Gets the TreePath node for an AnnotationMirror on a given Element.
abstract  TreePath getPath(Element e, AnnotationMirror a, AnnotationValue v)
          Gets the TreePath node for an AnnotationValue for an AnnotationMirror on a given Element.
abstract  Scope getScope(TreePath path)
          Gets the Scope for the Tree node identified by a given TreePath.
abstract  SourcePositions getSourcePositions()
          Gets a utility object for obtaining source positions.
abstract  Tree getTree(Element element)
          Gets the Tree node for a given Element.
abstract  Tree getTree(Element e, AnnotationMirror a)
          Gets the Tree node for an AnnotationMirror on a given Element.
abstract  Tree getTree(Element e, AnnotationMirror a, AnnotationValue v)
          Gets the Tree node for an AnnotationValue for an AnnotationMirror on a given Element.
abstract  MethodTree getTree(ExecutableElement method)
          Gets the MethodTree node for a given ExecutableElement.
abstract  ClassTree getTree(TypeElement element)
          Gets the ClassTree node for a given TypeElement.
abstract  TypeMirror getTypeMirror(TreePath path)
          Gets the TypeMirror for the Tree node identified by a given TreePath.
static Trees instance(JavaCompiler.CompilationTask task)
          Gets a Trees object for a given CompilationTask.
static Trees instance(ProcessingEnvironment env)
          Gets a Trees object for a given CompilationTask.
abstract  boolean isAccessible(Scope scope, Element member, DeclaredType type)
          Checks whether the given element is accessible as a member of the given type in a given scope.
abstract  boolean isAccessible(Scope scope, TypeElement type)
          Checks whether a given type is accessible in a given scope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Trees

public Trees()
Method Detail

instance

public static Trees instance(JavaCompiler.CompilationTask task)
Gets a Trees object for a given CompilationTask.

Throws:
IllegalArgumentException - if the task does not support the Trees API.

instance

public static Trees instance(ProcessingEnvironment env)
Gets a Trees object for a given CompilationTask.

Throws:
IllegalArgumentException - if the env does not support the Trees API.

getSourcePositions

public abstract SourcePositions getSourcePositions()
Gets a utility object for obtaining source positions.


getTree

public abstract Tree getTree(Element element)
Gets the Tree node for a given Element. Returns null if the node can not be found.


getTree

public abstract ClassTree getTree(TypeElement element)
Gets the ClassTree node for a given TypeElement. Returns null if the node can not be found.


getTree

public abstract MethodTree getTree(ExecutableElement method)
Gets the MethodTree node for a given ExecutableElement. Returns null if the node can not be found.


getTree

public abstract Tree getTree(Element e,
                             AnnotationMirror a)
Gets the Tree node for an AnnotationMirror on a given Element. Returns null if the node can not be found.


getTree

public abstract Tree getTree(Element e,
                             AnnotationMirror a,
                             AnnotationValue v)
Gets the Tree node for an AnnotationValue for an AnnotationMirror on a given Element. Returns null if the node can not be found.


getPath

public abstract TreePath getPath(CompilationUnitTree unit,
                                 Tree node)
Gets the path to tree node within the specified compilation unit.


getPath

public abstract TreePath getPath(Element e)
Gets the TreePath node for a given Element. Returns null if the node can not be found.


getPath

public abstract TreePath getPath(Element e,
                                 AnnotationMirror a)
Gets the TreePath node for an AnnotationMirror on a given Element. Returns null if the node can not be found.


getPath

public abstract TreePath getPath(Element e,
                                 AnnotationMirror a,
                                 AnnotationValue v)
Gets the TreePath node for an AnnotationValue for an AnnotationMirror on a given Element. Returns null if the node can not be found.


getElement

public abstract Element getElement(TreePath path)
Gets the Element for the Tree node identified by a given TreePath. Returns null if the element is not available.

Throws:
IllegalArgumentException - is the TreePath does not identify a Tree node that might have an associated Element.

getTypeMirror

public abstract TypeMirror getTypeMirror(TreePath path)
Gets the TypeMirror for the Tree node identified by a given TreePath. Returns null if the TypeMirror is not available.

Throws:
IllegalArgumentException - is the TreePath does not identify a Tree node that might have an associated TypeMirror.

getScope

public abstract Scope getScope(TreePath path)
Gets the Scope for the Tree node identified by a given TreePath. Returns null if the Scope is not available.


isAccessible

public abstract boolean isAccessible(Scope scope,
                                     TypeElement type)
Checks whether a given type is accessible in a given scope.

Parameters:
scope - the scope to be checked
type - the type to be checked
Returns:
true if type is accessible

isAccessible

public abstract boolean isAccessible(Scope scope,
                                     Element member,
                                     DeclaredType type)
Checks whether the given element is accessible as a member of the given type in a given scope.

Parameters:
scope - the scope to be checked
member - the member to be checked
type - the type for which to check if the member is accessible
Returns:
true if member is accessible in type

Compiler Tree API

Submit a bug or feature
Copyright © 2005, 2015, Oracle and/or its affiliates. All rights reserved.