30 import java.util.List; 31 32 import javax.annotation.processing.ProcessingEnvironment; 33 import javax.lang.model.element.Element; 34 import javax.lang.model.element.PackageElement; 35 import javax.lang.model.type.TypeMirror; 36 import javax.tools.Diagnostic; 37 import javax.tools.FileObject; 38 import javax.tools.JavaCompiler.CompilationTask; 39 40 import com.sun.source.doctree.DocCommentTree; 41 import com.sun.source.doctree.DocTree; 42 43 /** 44 * Provides access to syntax trees for doc comments. 45 * 46 * @since 1.8 47 */ 48 public abstract class DocTrees extends Trees { 49 /** 50 * Returns a DocTrees object for a given CompilationTask. 51 * @param task the compilation task for which to get the Trees object 52 * @return the DocTrees object 53 * @throws IllegalArgumentException if the task does not support the Trees API. 54 */ 55 public static DocTrees instance(CompilationTask task) { 56 return (DocTrees) Trees.instance(task); 57 } 58 59 /** 60 * Returns a DocTrees object for a given ProcessingEnvironment. 61 * @param env the processing environment for which to get the Trees object 62 * @return the DocTrees object 63 * @throws IllegalArgumentException if the env does not support the Trees API. 64 */ 65 public static DocTrees instance(ProcessingEnvironment env) { 66 if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) 67 throw new IllegalArgumentException(); 68 return (DocTrees) getJavacTrees(ProcessingEnvironment.class, env); 69 } | 30 import java.util.List; 31 32 import javax.annotation.processing.ProcessingEnvironment; 33 import javax.lang.model.element.Element; 34 import javax.lang.model.element.PackageElement; 35 import javax.lang.model.type.TypeMirror; 36 import javax.tools.Diagnostic; 37 import javax.tools.FileObject; 38 import javax.tools.JavaCompiler.CompilationTask; 39 40 import com.sun.source.doctree.DocCommentTree; 41 import com.sun.source.doctree.DocTree; 42 43 /** 44 * Provides access to syntax trees for doc comments. 45 * 46 * @since 1.8 47 */ 48 public abstract class DocTrees extends Trees { 49 /** 50 * Constructor for subclasses to call. 51 */ 52 public DocTrees() {} 53 54 /** 55 * Returns a DocTrees object for a given CompilationTask. 56 * @param task the compilation task for which to get the Trees object 57 * @return the DocTrees object 58 * @throws IllegalArgumentException if the task does not support the Trees API. 59 */ 60 public static DocTrees instance(CompilationTask task) { 61 return (DocTrees) Trees.instance(task); 62 } 63 64 /** 65 * Returns a DocTrees object for a given ProcessingEnvironment. 66 * @param env the processing environment for which to get the Trees object 67 * @return the DocTrees object 68 * @throws IllegalArgumentException if the env does not support the Trees API. 69 */ 70 public static DocTrees instance(ProcessingEnvironment env) { 71 if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) 72 throw new IllegalArgumentException(); 73 return (DocTrees) getJavacTrees(ProcessingEnvironment.class, env); 74 } |