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