dnault / therapi-runtime-javadoc

Read Javadoc comments at run time.
Apache License 2.0
117 stars 19 forks source link

Support record classes in annotation processor #52

Closed xeals closed 2 years ago

xeals commented 2 years ago

Record classes are unmodifiable data class introduced in Java 16 and included in the recent LTS version Java 17. Since records are a new syntax for Java, they generate an ElementKind.RECORD AST element instead of ElementKind.CLASS and are not supported by the current visitor.

Javadoc for a record is the same as a regular class, except it may include @param fields referring to record components:

/**
 * Example class.
 *
 * @param a first component input
 * @param b second input
 */
public class Foo(boolean a, String b) {

  /** Alternate constructor */
  public Foo(boolean a) {
    this(a, null);
  }
}

General thoughts:

Depending on how an implementation might balance representation vs. intent:

dnault commented 2 years ago

The 0.13.0 release will add basic support for records. Record class docs will be retained, as well as docs for secondary constructors and other methods and fields defined in the record.

There will also be a new method ClassJavadoc.getRecordComponents() that returns any @param tags from the class docs.

I filed #60 for attaching docs to the canonical constructor and generated component accessors.

dnault commented 2 years ago

Version 0.13.0 with basic support for records is now live on Maven Central.