< prev index next >

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

Print this page

        

*** 37,46 **** --- 37,48 ---- import java.io.PrintWriter; import java.io.Writer; import java.util.*; import java.util.stream.Collectors; + import java.util.stream.Stream; + import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.StringUtils;
*** 214,223 **** --- 216,235 ---- writer.print(" "); writer.print(e.getSimpleName()); printFormalTypeParameters(e, false); + if (kind == RECORD) { + // Print out state components + writer.print("("); + writer.print(e.getStateComponents() + .stream() + .map(stateDes -> stateDes.asType().toString() + " " + stateDes.getSimpleName()) + .collect(Collectors.joining(", "))); + writer.print(")"); + } + // Print superclass information if informative if (kind == CLASS) { TypeMirror supertype = e.getSuperclass(); if (supertype.getKind() != TypeKind.NONE) { TypeElement e2 = (TypeElement)
*** 226,235 **** --- 238,248 ---- writer.print(" extends " + supertype); } } printInterfaces(e); + printPermittedSubtypes(e); } writer.println(" {"); indentation++; if (kind == ENUM) {
*** 253,263 **** } for(Element element : enclosedElements) this.visit(element); } else { ! for(Element element : e.getEnclosedElements()) this.visit(element); } indentation--; indent(); --- 266,282 ---- } for(Element element : enclosedElements) this.visit(element); } else { ! for(Element element : ! (kind != RECORD ? ! e.getEnclosedElements() : ! e.getEnclosedElements() ! .stream() ! .filter(elt -> elementUtils.getOrigin(elt) == Elements.Origin.EXPLICIT ) ! .collect(Collectors.toList()) ) ) this.visit(element); } indentation--; indent();
*** 446,455 **** --- 465,478 ---- case ENUM: modifiers.remove(Modifier.FINAL); modifiers.remove(Modifier.ABSTRACT); break; + case RECORD: + modifiers.remove(Modifier.FINAL); + break; + case METHOD: case FIELD: Element enclosingElement = e.getEnclosingElement(); if (enclosingElement != null && enclosingElement.getKind().isInterface()) {
*** 570,579 **** --- 593,613 ---- .collect(Collectors.joining(", "))); } } } + private void printPermittedSubtypes(TypeElement e) { + List<? extends TypeMirror> subtypes = e.getPermittedSubtypes(); + if (!subtypes.isEmpty()) { // could remove this check with more complicated joining call + writer.print(" permits "); + writer.print(subtypes + .stream() + .map(subtype -> subtype.toString()) + .collect(Collectors.joining(", "))); + } + } + private void printThrows(ExecutableElement e) { List<? extends TypeMirror> thrownTypes = e.getThrownTypes(); final int size = thrownTypes.size(); if (size != 0) { writer.print(" throws");
< prev index next >