Skip to content

Releases: jhipster/prettier-java

v1.1.1

25 May 06:38
Compare
Choose a tag to compare

Fixes

  • Fix parsing records inside class declarations
    and records with simplified constructors
    (#470)

Miscallenous

v1.1.0

19 May 07:26
Compare
Choose a tag to compare

Enhancements

  • Supports of Records (#460)
// Input
public record Pet(
    @NotNull String name, int age, String... others, Object @Nullable... errorMessageArgs
  ) {
  public Pet {
    if (age < 0) {
      throw new IllegalArgumentException("Age cannot be negative");
    }

    if (name == null || name.isBlank()) {
      throw new IllegalArgumentException("Name cannot be blank");
    }
  }

  public void test() {}
}

// Output
public record Pet(
  @NotNull String name, int age, String... others, Object @Nullable... errorMessageArgs
) {
  public Pet {
    if (age < 0) {
      throw new IllegalArgumentException("Age cannot be negative");
    }

    if (name == null || name.isBlank()) {
      throw new IllegalArgumentException("Name cannot be blank");
    }
  }

  public void test() {}
}

v1.0.2

14 Mar 22:04
Compare
Choose a tag to compare

v1.0.2

Fixes

  • Keep space between annotation and type identifiers in unannClassType expressions (#455)
// Input
class T {
  SomeClass.@Valid SomeInnerClass someInnerClass = someClass.getInteractions().get(0);

  void process(
    Map.@NonNull Entry<String, SkeletonConfiguration> entry,
    @NonNull Map<String, Object> context
  ) {}
}

// Prettier 1.0.1
class T {
  SomeClass.@ValidSomeInnerClass someInnerClass = someClass
    .getInteractions()
    .get(0);

  void process(
    Map.@NonNullEntry<String, SkeletonConfiguration> entry,
    @NonNull Map<String, Object> context
  ) {}
}

// Prettier 1.0.2
class T {

  SomeClass.@Valid SomeInnerClass someInnerClass = someClass
    .getInteractions()
    .get(0);

  void process(
    Map.@NonNull Entry<String, SkeletonConfiguration> entry,
    @NonNull Map<String, Object> context
  ) {}
}
  • Fix inconsistent indentation between chained method on method and new object (#456)
// Input
class T {
  public void method() {
    new Foo(stuff, thing, "auaaaaaaaaa some very long stuff", "some more").bar(10);
    foo(stuff, thing, "some very longuuuuuuuuuuuuuu stuff", "some more").bar(10);
  }
}

// Prettier 1.0.1
class T {
  public void method() {
    new Foo(stuff, thing, "auaaaaaaaaa some very long stuff", "some more")
    .bar(10);
    foo(stuff, thing, "some very longuuuuuuuuuuuuuu stuff", "some more")
      .bar(10);
  }
}

// Prettier 1.0.2
class T {

  public void method() {
    new Foo(stuff, thing, "auaaaaaaaaa some very long stuff", "some more")
      .bar(10);
    foo(stuff, thing, "some very longuuuuuuuuuuuuuu stuff", "some more")
      .bar(10);
  }
}
  • Fix unstable formatting for method invocations with only comments (#457)
// Input
class T {
  public void method() {
    Arrays.asList(// a
                  // b
                  // c
                  // d
    );
  }
}

// Prettier 1.0.1
class T {
  public void method() {
    Arrays.asList(// b // a
    // c
    // d
    );
  }
}

// Prettier 1.0.2
class T {

  public void method() {
    Arrays.asList( // a
      // b
      // c
      // d
    );
  }
}

Miscellaneous

  • Update lodash dependency to 4.17.21 (#458)

v1.0.1

28 Nov 09:17
Compare
Choose a tag to compare

v1.0.1

Fixes

  • Correct spaces emplacement in multi-value switch expression case label (#440)
// Input

public class Test {

  public void test(TestEnum testEnum) {
    switch (testEnum) {
      case FOO -> System.out.println("Foo!");
      case BAR, BAZ -> System.out.println("Not Foo!");
    }
  }
}

// Prettier 1.0.0

public class Test {

  public void test(TestEnum testEnum) {
    switch (testEnum) {
      case FOO -> System.out.println("Foo!");
      case BAR ,BAZ -> System.out.println("Not Foo!");
    }
  }
}

// Prettier 1.0.1

public class Test {

  public void test(TestEnum testEnum) {
    switch (testEnum) {
      case FOO -> System.out.println("Foo!");
      case BAR, BAZ -> System.out.println("Not Foo!");
    }
  }
}

Miscellaneous

  • Update prettier dependency to 2.2.1

v1.0.0

21 Nov 10:22
Compare
Choose a tag to compare

Enhancements

  • Support of Java 15 ! 🚀

  • Support of Text blocks

  • Support of new switch rules and yield statements

  • Improve throws rendering (From @jhaber: #384)

// Input

void throwException7(String string1, String string2, String string3, String string4) throws RuntimeException {
  throw new RuntimeException();
}

// Prettier 0.8.3

void throwException7(
  String string1,
  String string2,
  String string3,
  String string4
)
  throws RuntimeException {
  throw new RuntimeException();
}

// Prettier 1.0.0

void throwException7(
  String string1,
  String string2,
  String string3,
  String string4
) throws RuntimeException {
  throw new RuntimeException();
}

Fixes

  • Parsing of unannPrimitiveType in primary (#421)

Miscellaneous

  • Update dependencies

v0.8.3

12 Oct 07:03
Compare
Choose a tag to compare
v0.8.3

v0.8.2

12 Oct 06:40
Compare
Choose a tag to compare
v0.8.2

v0.8.1

30 Aug 18:34
Compare
Choose a tag to compare

Changelog v0.8.1

Enhancements

  • Generated a type definition for the Java parser (#422)

Fixes

  • Wrong indent in some chained methods invocation (#404)
// Input
class Indent {

  void indetMethod() {
    assertThat(
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa
    );

    assertThat(
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa
      )
      .isEqualTo();

    assertThat(
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa
      )
      .isEqualTo()
      .anotherInvocation(
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa
      );

    myInstanceObject
      .assertThat(
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa
      )
      .isEqualTo();


  }
}
// Output
class Indent {

  void indetMethod() {
    assertThat(
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa
    );

    assertThat(
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa
    )
      .isEqualTo();

    assertThat(
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
      useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa
    )
      .isEqualTo()
      .anotherInvocation(
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa,
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa
      );

    myInstanceObject
      .assertThat(
        useraaaaaaaaaaojzapjzpozjapjzpoajzpozaaaaaaaaaaaMapperlaaaaaaaaaaaaaaaaaaaaaaaa
      )
      .isEqualTo();
  }
}
  • Parsing of unannPrimitiveType in primary (#421)
// Throws in Prettier 0.8.0
double[][]::new

// Prettier 0.9.0
double[][]::new

v0.8.0

11 May 17:11
Compare
Choose a tag to compare

Changelog - v0.8.0

Enhancements

  • Possibility to run the Prettier Java package on every entrypoint defined in the following list (#395):
    [
      "variableInitializerList",
      "block",
      "blockStatements",
      "blockStatement",
      "localVariableDeclarationStatement",
      "localVariableDeclaration",
      "localVariableType",
      "statement",
      "statementWithoutTrailingSubstatement",
      "emptyStatement",
      "labeledStatement",
      "expressionStatement",
      "statementExpression",
      "ifStatement",
      "assertStatement",
      "switchStatement",
      "switchBlock",
      "switchCase",
      "switchLabel",
      "enumConstantName",
      "whileStatement",
      "doStatement",
      "forStatement",
      "basicForStatement",
      "forInit",
      "forUpdate",
      "statementExpressionList",
      "enhancedForStatement",
      "breakStatement",
      "continueStatement",
      "returnStatement",
      "throwStatement",
      "synchronizedStatement",
      "tryStatement",
      "catches",
      "catchClause",
      "catchFormalParameter",
      "catchType",
      "finally",
      "tryWithResourcesStatement",
      "resourceSpecification",
      "resourceList",
      "resource",
      "resourceInit",
      "variableAccess",
      "isBasicForStatement",
      "isLocalVariableDeclaration",
      "classDeclaration",
      "normalClassDeclaration",
      "classModifier",
      "typeParameters",
      "typeParameterList",
      "superclass",
      "superinterfaces",
      "interfaceTypeList",
      "classBody",
      "classBodyDeclaration",
      "classMemberDeclaration",
      "fieldDeclaration",
      "fieldModifier",
      "variableDeclaratorList",
      "variableDeclarator",
      "variableDeclaratorId",
      "variableInitializer",
      "unannType",
      "unannPrimitiveType",
      "unannReferenceType",
      "unannClassOrInterfaceType",
      "unannClassType",
      "unannInterfaceType",
      "unannTypeVariable",
      "methodDeclaration",
      "methodModifier",
      "methodHeader",
      "result",
      "methodDeclarator",
      "receiverParameter",
      "formalParameterList",
      "formalParameter",
      "variableParaRegularParameter",
      "variableArityParameter",
      "variableModifier",
      "throws",
      "exceptionTypeList",
      "exceptionType",
      "methodBody",
      "instanceInitializer",
      "staticInitializer",
      "constructorDeclaration",
      "constructorModifier",
      "constructorDeclarator",
      "simpleTypeName",
      "constructorBody",
      "explicitConstructorInvocation",
      "unqualifiedExplicitConstructorInvocation",
      "qualifiedExplicitConstructorInvocation",
      "enumDeclaration",
      "enumBody",
      "enumConstantList",
      "enumConstant",
      "enumConstantModifier",
      "enumBodyDeclarations",
      "isClassDeclaration",
      "identifyClassBodyDeclarationType",
      "isDims",
      "constantExpression",
      "expression",
      "lambdaExpression",
      "lambdaParameters",
      "lambdaParametersWithBraces",
      "lambdaParameterList",
      "inferredLambdaParameterList",
      "explicitLambdaParameterList",
      "lambdaParameter",
      "regularLambdaParameter",
      "lambdaParameterType",
      "lambdaBody",
      "ternaryExpression",
      "binaryExpression",
      "unaryExpression",
      "unaryExpressionNotPlusMinus",
      "primary",
      "primaryPrefix",
      "primarySuffix",
      "fqnOrRefType",
      "fqnOrRefTypePartRest",
      "fqnOrRefTypePartCommon",
      "fqnOrRefTypePartFirst",
      "parenthesisExpression",
      "castExpression",
      "primitiveCastExpression",
      "referenceTypeCastExpression",
      "newExpression",
      "unqualifiedClassInstanceCreationExpression",
      "classOrInterfaceTypeToInstantiate",
      "typeArgumentsOrDiamond",
      "diamond",
      "methodInvocationSuffix",
      "argumentList",
      "arrayCreationExpression",
      "arrayCreationDefaultInitSuffix",
      "arrayCreationExplicitInitSuffix",
      "dimExprs",
      "dimExpr",
      "classLiteralSuffix",
      "arrayAccessSuffix",
      "methodReferenceSuffix",
      "identifyNewExpressionType",
      "isLambdaExpression",
      "isCastExpression",
      "isPrimitiveCastExpression",
      "isReferenceTypeCastExpression",
      "isRefTypeInMethodRef",
      "interfaceDeclaration",
      "normalInterfaceDeclaration",
      "interfaceModifier",
      "extendsInterfaces",
      "interfaceBody",
      "interfaceMemberDeclaration",
      "constantDeclaration",
      "constantModifier",
      "interfaceMethodDeclaration",
      "interfaceMethodModifier",
      "annotationTypeDeclaration",
      "annotationTypeBody",
      "annotationTypeMemberDeclaration",
      "annotationTypeElementDeclaration",
      "annotationTypeElementModifier",
      "defaultValue",
      "annotation",
      "elementValuePairList",
      "elementValuePair",
      "elementValue",
      "elementValueArrayInitializer",
      "elementValueList",
      "identifyInterfaceBodyDeclarationType",
      "identifyAnnotationBodyDeclarationType",
      "isSimpleElementValueAnnotation",
      "literal",
      "integerLiteral",
      "floatingPointLiteral",
      "booleanLiteral",
      "moduleName",
      "packageName",
      "typeName",
      "expressionName",
      "methodName",
      "packageOrTypeName",
      "ambiguousName",
      "compilationUnit",
      "ordinaryCompilationUnit",
      "modularCompilationUnit",
      "packageDeclaration",
      "packageModifier",
      "importDeclaration",
      "typeDeclaration",
      "moduleDeclaration",
      "moduleDirective",
      "requiresModuleDirective",
      "exportsModuleDirective",
      "opensModuleDirective",
      "usesModuleDirective",
      "providesModuleDirective",
      "requiresModifier",
      "isModuleCompilationUnit",
      "primitiveType",
      "numericType",
      "integralType",
      "floatingPointType",
      "referenceType",
      "classOrInterfaceType",
      "classType",
      "interfaceType",
      "typeVariable",
      "dims",
      "typeParameter",
      "typeParameterModifier",
      "typeBound",
      "additionalBound",
      "typeArguments",
      "typeArgumentList",
      "typeArgument",
      "wildcard",
      "wildcardBounds"
    ]

Fixes

Re-Writer

  • Fix formatting of empty enums to not insert commas when trailing-comma is enabled #385)
    // Input
    public enum Enum {
    }
    
    // Prettier v0.7.1
    public enum Enum {
      ,
    }
    
    // Prettier v0.8.0
    public enum Enum {}
  • Fix formatting of enum with comments #385)

Miscellaneous

  • Update prettier dependency to 2.0.5 (#379) & (#400)
  • Binary artefacts creation for each release (#399)
  • Document Maven plugin (#394)

v0.7.1

01 Mar 19:14
Compare
Choose a tag to compare

Latest v0.7.1

Fixes

Re-Writer

  • Fix stable formatting for fields and methods with annotations (#369)

Miscellaneous