FileDocCategorySizeDatePackage
Trees.javaAPI DocJava SE 6 API6050Tue Jun 10 00:23:26 BST 2008com.sun.source.util

Trees

public abstract class Trees extends Object
Bridges JSR 199, JSR 269, and the Tree API.
author
Peter von der Ahé

Fields Summary
Constructors Summary
Methods Summary
public abstract javax.lang.model.element.ElementgetElement(com.sun.source.util.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.

private static com.sun.source.util.TreesgetJavacTrees(java.lang.Class argType, java.lang.Object arg)

        try {
            ClassLoader cl = arg.getClass().getClassLoader();
            Class<?> c = Class.forName("com.sun.tools.javac.api.JavacTrees", false, cl);
            argType = Class.forName(argType.getName(), false, cl);
            Method m = c.getMethod("instance", new Class[] { argType });
            return (Trees) m.invoke(null, new Object[] { arg });
        } catch (Throwable e) {
            throw new AssertionError(e);
        }
    
public abstract com.sun.source.util.TreePathgetPath(com.sun.source.tree.CompilationUnitTree unit, com.sun.source.tree.Tree node)
Gets the path to tree node within the specified compilation unit.

public abstract com.sun.source.util.TreePathgetPath(javax.lang.model.element.Element e)
Gets the TreePath node for a given Element. Returns null if the node can not be found.

public abstract com.sun.source.util.TreePathgetPath(javax.lang.model.element.Element e, javax.lang.model.element.AnnotationMirror a)
Gets the TreePath node for an AnnotationMirror on a given Element. Returns null if the node can not be found.

public abstract com.sun.source.util.TreePathgetPath(javax.lang.model.element.Element e, javax.lang.model.element.AnnotationMirror a, javax.lang.model.element.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.

public abstract com.sun.source.tree.ScopegetScope(com.sun.source.util.TreePath path)
Gets the Scope for the Tree node identified by a given TreePath. Returns null if the Scope is not available.

public abstract com.sun.source.util.SourcePositionsgetSourcePositions()
Gets a utility object for obtaining source positions.

public abstract com.sun.source.tree.TreegetTree(javax.lang.model.element.Element element)
Gets the Tree node for a given Element. Returns null if the node can not be found.

public abstract com.sun.source.tree.ClassTreegetTree(javax.lang.model.element.TypeElement element)
Gets the ClassTree node for a given TypeElement. Returns null if the node can not be found.

public abstract com.sun.source.tree.MethodTreegetTree(javax.lang.model.element.ExecutableElement method)
Gets the MethodTree node for a given ExecutableElement. Returns null if the node can not be found.

public abstract com.sun.source.tree.TreegetTree(javax.lang.model.element.Element e, javax.lang.model.element.AnnotationMirror a)
Gets the Tree node for an AnnotationMirror on a given Element. Returns null if the node can not be found.

public abstract com.sun.source.tree.TreegetTree(javax.lang.model.element.Element e, javax.lang.model.element.AnnotationMirror a, javax.lang.model.element.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.

public abstract javax.lang.model.type.TypeMirrorgetTypeMirror(com.sun.source.util.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.

public static com.sun.source.util.Treesinstance(javax.tools.JavaCompiler.CompilationTask task)
Gets a Trees object for a given CompilationTask.

throws
IllegalArgumentException if the task does not support the Trees API.

        if (!task.getClass().getName().equals("com.sun.tools.javac.api.JavacTaskImpl"))
            throw new IllegalArgumentException();
        return getJavacTrees(CompilationTask.class, task);
    
public static com.sun.source.util.Treesinstance(javax.annotation.processing.ProcessingEnvironment env)
Gets a Trees object for a given CompilationTask.

throws
IllegalArgumentException if the env does not support the Trees API.

        if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment"))
            throw new IllegalArgumentException();
        return getJavacTrees(ProcessingEnvironment.class, env);
    
public abstract booleanisAccessible(com.sun.source.tree.Scope scope, javax.lang.model.element.TypeElement type)
Checks whether a given type is accessible in a given scope.

param
scope the scope to be checked
param
type the type to be checked
return
true if {@code type} is accessible

public abstract booleanisAccessible(com.sun.source.tree.Scope scope, javax.lang.model.element.Element member, javax.lang.model.type.DeclaredType type)
Checks whether the given element is accessible as a member of the given type in a given scope.

param
scope the scope to be checked
param
member the member to be checked
param
type the type for which to check if the member is accessible
return
true if {@code member} is accessible in {@code type}