Releases: jhipster/prettier-java
Releases Β· jhipster/prettier-java
2.6.5
2.6.4
2.6.0
Enhancements
- Support Java 21 preview feature: string templates (JEP 430) (#640 by @jtkiesel)
- Avoid breaking on certain method chains and arguments (Issue #626 closed by #632 by @jtkiesel)
Fixes
- Consistent break after equals (Issue #638 fixed by #641 by @jtkiesel)
- Properly break and indent lambda with comments (Issue #581 fixed by #604 by @jtkiesel)
- Do not fail on constructor and method receiver parameter (Issue #607 fixed by #642 by @jtkiesel)
- No break in single-block switch case (Issue #635 fixed by #636 by @jtkiesel)
- Non-block if/else statements are now kept on their own lines (Issue #631 fixed by #633 by @jtkiesel)
Misc
- Create documentation website (#628 by @jtkiesel) available at https://www.jhipster.tech/prettier-java
v2.5.0
Latest v2.5.0
Enhancements
- Supports Java 21 preview feature: unnamed patterns and variables (JEP 443) (#620 by @jtkiesel)
- New entrypoint lexAndParse to return both tokens and CST (#625 by @max-schaefer)
Fixes
Miscellaneous
v2.4.0
v2.3.1
v2.3.0
Latest v2.3.0
Enhancements
- Break long lines on type arguments (#584)
- Break and indent binary expression with cast properly (#587)
- Adjust indentation of multiline string (Issue #593 fixed with #596)
- Improves binary expression formatting (#594)
- Supports JLS annotation style (#586
Thanks to @jtkiesel for all of these contributions !
Fixes
- Fix browser compatibility issue when run in browser (Issue #597 fixed with #598)
Thanks to @magic-akari for the contribution
v2.2.0
Enhancements
- Upgrade prettier version to Prettier v3
v2.1.0
Latest v2.1.0
Enhancements
- Support for require-pragma option (Issue #573 closed with #574)
Thanks to @yannick-paz for the contribution !
// Input
/**
* @prettier
*/
public class Example { private int test=-1;}
// Output with require-pragma option activated
/**
* @prettier
*/
public class Example {
private int test = -1;
}
// Input
public class Example { private int test=-1;}
// Output with require-pragma option activated
public class Example { private int test=-1;}
Fixes
// Input
class Example {
void example() {
Object aParticularlyLongAndObnoxiousNameForIllustrativePurposes = new Object()
.someMethod();
Object[] aParticularlyLongAndObnoxiousNameForIllustrativePurposes2 = new Object[] {
new Object(),
new Object()
};
Object aParticularlyLongAndObnoxiousNameForIllustrativePurposes3 = SomeClass.someStaticMethod();
Object aParticularlyLongAndObnoxiousNameForIllustrativePurposes = someMethod()
.anotherMethod();
Object aParticularlyLongAndObnoxiousNameForIllustrativePurposes = anotherValue !=
null
? anotherValue
: new Object();
}
}
// Output
class Example {
void example() {
Object aParticularlyLongAndObnoxiousNameForIllustrativePurposes =
new Object().someMethod();
Object[] aParticularlyLongAndObnoxiousNameForIllustrativePurposes2 =
new Object[] { new Object(), new Object() };
Object aParticularlyLongAndObnoxiousNameForIllustrativePurposes3 =
SomeClass.someStaticMethod();
Object aParticularlyLongAndObnoxiousNameForIllustrativePurposes =
someMethod().anotherMethod();
Object aParticularlyLongAndObnoxiousNameForIllustrativePurposes =
anotherValue != null ? anotherValue : new Object();
}
}
v2.0.0
Breaking changes
- Drop support of Node.js 12
Enhancements
// Input
class T {
void test(Buyer other) {
return switch (other) {
case null -> true;
case Buyer b && this.bestPrice > b.bestPrice -> true;
case Buyer b && this.bestPrice > b.bestPrice -> {
return true;
}
case (Buyer b && this.bestPrice > b.bestPrice) -> true;
case Buyer b && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice -> true;
case Buyer b && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice -> {
return true;
}
case (Buyer b && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice) -> true;
case (Buyer b && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice && this.bestPrice > b.bestPrice) -> {
return true;
}
default -> false;
};
}
}
// Output
class T {
void test(Buyer other) {
return switch (other) {
case null -> true;
case Buyer b && this.bestPrice > b.bestPrice -> true;
case Buyer b && this.bestPrice > b.bestPrice -> {
return true;
}
case (Buyer b && this.bestPrice > b.bestPrice) -> true;
case Buyer b &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice -> true;
case Buyer b &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice -> {
return true;
}
case (
Buyer b &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice
) -> true;
case (
Buyer b &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice &&
this.bestPrice > b.bestPrice
) -> {
return true;
}
default -> false;
};
}
}
Fixes
public class Test {
public static final String REGEX = "^\s$";
}
- Fix unwanted space in "exports"-statement in module-info.java (Issue #550 closed with #551)
Thanks to @BjornJaspers for the fix
// Input
open module org.myorg.module {
requires some.required.module;
exports org.myorg.module.exportpackage1;
exports org.myorg.module.exportpackage2;
}
// Prettier 1.6.2
open module org.myorg.module {
requires some.required.module;
exports org.myorg.module.exportpackage1 ;
exports org.myorg.module.exportpackage2 ;
}
// Prettier 1.6.3
open module org.myorg.module {
requires some.required.module;
exports org.myorg.module.exportpackage1;
exports org.myorg.module.exportpackage2;
}