< prev index next >

src/jdk.compiler/share/classes/com/sun/source/util/Trees.java

Print this page




  36 import javax.lang.model.type.DeclaredType;
  37 import javax.lang.model.type.ErrorType;
  38 import javax.lang.model.type.TypeMirror;
  39 import javax.tools.Diagnostic;
  40 import javax.tools.JavaCompiler.CompilationTask;
  41 
  42 import com.sun.source.tree.CatchTree;
  43 import com.sun.source.tree.ClassTree;
  44 import com.sun.source.tree.CompilationUnitTree;
  45 import com.sun.source.tree.MethodTree;
  46 import com.sun.source.tree.Scope;
  47 import com.sun.source.tree.Tree;
  48 
  49 /**
  50  * Bridges JSR 199, JSR 269, and the Tree API.
  51  *
  52  * @author Peter von der Ah&eacute;
  53  */
  54 public abstract class Trees {
  55     /**





  56      * Returns a Trees object for a given CompilationTask.
  57      * @param task the compilation task for which to get the Trees object
  58      * @throws IllegalArgumentException if the task does not support the Trees API.
  59      * @return the Trees object
  60      */
  61     public static Trees instance(CompilationTask task) {
  62         String taskClassName = task.getClass().getName();
  63         if (!taskClassName.equals("com.sun.tools.javac.api.JavacTaskImpl")
  64                 && !taskClassName.equals("com.sun.tools.javac.api.BasicJavacTask"))
  65             throw new IllegalArgumentException();
  66         return getJavacTrees(CompilationTask.class, task);
  67     }
  68 
  69     /**
  70      * Returns a Trees object for a given ProcessingEnvironment.
  71      * @param env the processing environment for which to get the Trees object
  72      * @throws IllegalArgumentException if the env does not support the Trees API.
  73      * @return the Trees object
  74      */
  75     public static Trees instance(ProcessingEnvironment env) {




  36 import javax.lang.model.type.DeclaredType;
  37 import javax.lang.model.type.ErrorType;
  38 import javax.lang.model.type.TypeMirror;
  39 import javax.tools.Diagnostic;
  40 import javax.tools.JavaCompiler.CompilationTask;
  41 
  42 import com.sun.source.tree.CatchTree;
  43 import com.sun.source.tree.ClassTree;
  44 import com.sun.source.tree.CompilationUnitTree;
  45 import com.sun.source.tree.MethodTree;
  46 import com.sun.source.tree.Scope;
  47 import com.sun.source.tree.Tree;
  48 
  49 /**
  50  * Bridges JSR 199, JSR 269, and the Tree API.
  51  *
  52  * @author Peter von der Ah&eacute;
  53  */
  54 public abstract class Trees {
  55     /**
  56      * Constructor for subclasses to call.
  57      */
  58     public Trees() {}
  59 
  60     /**
  61      * Returns a Trees object for a given CompilationTask.
  62      * @param task the compilation task for which to get the Trees object
  63      * @throws IllegalArgumentException if the task does not support the Trees API.
  64      * @return the Trees object
  65      */
  66     public static Trees instance(CompilationTask task) {
  67         String taskClassName = task.getClass().getName();
  68         if (!taskClassName.equals("com.sun.tools.javac.api.JavacTaskImpl")
  69                 && !taskClassName.equals("com.sun.tools.javac.api.BasicJavacTask"))
  70             throw new IllegalArgumentException();
  71         return getJavacTrees(CompilationTask.class, task);
  72     }
  73 
  74     /**
  75      * Returns a Trees object for a given ProcessingEnvironment.
  76      * @param env the processing environment for which to get the Trees object
  77      * @throws IllegalArgumentException if the env does not support the Trees API.
  78      * @return the Trees object
  79      */
  80     public static Trees instance(ProcessingEnvironment env) {


< prev index next >