< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java

Print this page




  40 import java.util.*;
  41 import java.util.stream.Collectors;
  42 import java.util.stream.Stream;
  43 
  44 
  45 import com.sun.tools.javac.util.DefinedBy;
  46 import com.sun.tools.javac.util.DefinedBy.Api;
  47 import com.sun.tools.javac.util.StringUtils;
  48 
  49 /**
  50  * A processor which prints out elements.  Used to implement the
  51  * -Xprint option; the included visitor class is used to implement
  52  * Elements.printElements.
  53  *
  54  * <p><b>This is NOT part of any supported API.
  55  * If you write code that depends on this, you do so at your own risk.
  56  * This code and its internal interfaces are subject to change or
  57  * deletion without notice.</b>
  58  */
  59 @SupportedAnnotationTypes("*")
  60 @SupportedSourceVersion(SourceVersion.RELEASE_14)
  61 public class PrintingProcessor extends AbstractProcessor {
  62     PrintWriter writer;
  63 
  64     public PrintingProcessor() {
  65         super();
  66         writer = new PrintWriter(System.out);
  67     }
  68 
  69     public void setWriter(Writer w) {
  70         writer = new PrintWriter(w);
  71     }
  72 
  73     @Override @DefinedBy(Api.ANNOTATION_PROCESSING)
  74     public boolean process(Set<? extends TypeElement> tes,
  75                            RoundEnvironment renv) {
  76 
  77         for(Element element : renv.getRootElements()) {
  78             print(element);
  79         }
  80 




  40 import java.util.*;
  41 import java.util.stream.Collectors;
  42 import java.util.stream.Stream;
  43 
  44 
  45 import com.sun.tools.javac.util.DefinedBy;
  46 import com.sun.tools.javac.util.DefinedBy.Api;
  47 import com.sun.tools.javac.util.StringUtils;
  48 
  49 /**
  50  * A processor which prints out elements.  Used to implement the
  51  * -Xprint option; the included visitor class is used to implement
  52  * Elements.printElements.
  53  *
  54  * <p><b>This is NOT part of any supported API.
  55  * If you write code that depends on this, you do so at your own risk.
  56  * This code and its internal interfaces are subject to change or
  57  * deletion without notice.</b>
  58  */
  59 @SupportedAnnotationTypes("*")
  60 @SupportedSourceVersion(SourceVersion.RELEASE_15)
  61 public class PrintingProcessor extends AbstractProcessor {
  62     PrintWriter writer;
  63 
  64     public PrintingProcessor() {
  65         super();
  66         writer = new PrintWriter(System.out);
  67     }
  68 
  69     public void setWriter(Writer w) {
  70         writer = new PrintWriter(w);
  71     }
  72 
  73     @Override @DefinedBy(Api.ANNOTATION_PROCESSING)
  74     public boolean process(Set<? extends TypeElement> tes,
  75                            RoundEnvironment renv) {
  76 
  77         for(Element element : renv.getRootElements()) {
  78             print(element);
  79         }
  80 


< prev index next >