jhipster / prettier-java

Prettier Java Plugin
http://www.jhipster.tech/prettier-java/
Apache License 2.0
1.06k stars 103 forks source link

fix: align with JDK 22 spec #666

Closed jtkiesel closed 3 weeks ago

jtkiesel commented 2 months ago

What changed with this PR:

Aligns the parser more closely with the JDK 22 spec, most notably fixing some rules that weren't properly supporting unnamed variables.

Example

Input

public sealed interface SadPanda {

  default String cry() {
    return switch(this) {
      case A _, B _, C _ -> "A lot";
    };
  }

  record A() implements SadPanda {}
  record B() implements SadPanda {}
  record C() implements SadPanda {}
}

Output

public sealed interface SadPanda {
  default String cry() {
    return switch (this) {
      case A _, B _, C _ -> "A lot";
    };
  }

  record A() implements SadPanda {}

  record B() implements SadPanda {}

  record C() implements SadPanda {}
}

Relative issues or prs:

Closes #665