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 81 // Just print the elements, nothing more to do. 82 return true; 83 } 84 85 void print(Element element) { 86 new PrintingElementVisitor(writer, processingEnv.getElementUtils()). 87 visit(element).flush(); 88 } 89 90 /** 91 * Used for the -Xprint option and called by Elements.printElements 92 */ 93 @SuppressWarnings("removal") 94 public static class PrintingElementVisitor 95 extends SimpleElementVisitor14<PrintingElementVisitor, Boolean> { 96 int indentation; // Indentation level; 97 final PrintWriter writer; 98 final Elements elementUtils; 99 100 public PrintingElementVisitor(Writer w, Elements elementUtils) { 101 super(); 102 this.writer = new PrintWriter(w); 103 this.elementUtils = elementUtils; 104 indentation = 0; 105 } 106 107 @Override @DefinedBy(Api.LANGUAGE_MODEL) 108 protected PrintingElementVisitor defaultAction(Element e, Boolean newLine) { 109 if (newLine != null && newLine) 110 writer.println(); 111 printDocComment(e); 112 printModifiers(e); 113 return this; 114 } 115 116 @Override @DefinedBy(Api.LANGUAGE_MODEL) 117 @SuppressWarnings("removal") 118 public PrintingElementVisitor visitRecordComponent(RecordComponentElement e, Boolean p) { 119 // Do nothing; printing of component information done by 120 // printing the record type itself 121 return this; 122 } 123 124 @Override @DefinedBy(Api.LANGUAGE_MODEL) 125 public PrintingElementVisitor visitExecutable(ExecutableElement e, Boolean p) { 126 ElementKind kind = e.getKind(); 127 128 if (kind != STATIC_INIT && 129 kind != INSTANCE_INIT) { 130 Element enclosing = e.getEnclosingElement(); 131 132 // Don't print out the constructor of an anonymous class 133 if (kind == CONSTRUCTOR && 134 enclosing != null && 135 NestingKind.ANONYMOUS == 136 // Use an anonymous class to determine anonymity! 137 (new SimpleElementVisitor14<NestingKind, Void>() { | 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 81 // Just print the elements, nothing more to do. 82 return true; 83 } 84 85 void print(Element element) { 86 new PrintingElementVisitor(writer, processingEnv.getElementUtils()). 87 visit(element).flush(); 88 } 89 90 /** 91 * Used for the -Xprint option and called by Elements.printElements 92 */ 93 @SuppressWarnings("preview") 94 public static class PrintingElementVisitor 95 extends SimpleElementVisitor14<PrintingElementVisitor, Boolean> { 96 int indentation; // Indentation level; 97 final PrintWriter writer; 98 final Elements elementUtils; 99 100 public PrintingElementVisitor(Writer w, Elements elementUtils) { 101 super(); 102 this.writer = new PrintWriter(w); 103 this.elementUtils = elementUtils; 104 indentation = 0; 105 } 106 107 @Override @DefinedBy(Api.LANGUAGE_MODEL) 108 protected PrintingElementVisitor defaultAction(Element e, Boolean newLine) { 109 if (newLine != null && newLine) 110 writer.println(); 111 printDocComment(e); 112 printModifiers(e); 113 return this; 114 } 115 116 @Override @DefinedBy(Api.LANGUAGE_MODEL) 117 @SuppressWarnings("preview") 118 public PrintingElementVisitor visitRecordComponent(RecordComponentElement e, Boolean p) { 119 // Do nothing; printing of component information done by 120 // printing the record type itself 121 return this; 122 } 123 124 @Override @DefinedBy(Api.LANGUAGE_MODEL) 125 public PrintingElementVisitor visitExecutable(ExecutableElement e, Boolean p) { 126 ElementKind kind = e.getKind(); 127 128 if (kind != STATIC_INIT && 129 kind != INSTANCE_INIT) { 130 Element enclosing = e.getEnclosingElement(); 131 132 // Don't print out the constructor of an anonymous class 133 if (kind == CONSTRUCTOR && 134 enclosing != null && 135 NestingKind.ANONYMOUS == 136 // Use an anonymous class to determine anonymity! 137 (new SimpleElementVisitor14<NestingKind, Void>() { |