jhipster / prettier-java

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

fix(printer): break and indent binary expression with cast properly #587

Closed jtkiesel closed 1 year ago

jtkiesel commented 1 year ago

What changed with this PR:

Assignments containing a binary expression beginning with a cast now break and indent the way Prettier JavaScript does.

Example

Input

public class Test {

  public static void main(String[] args) {
    if (oneLevelDeep) {
      if (twoLevelsDeep) {
        if (threeLevelsDeep) {
          int successfulCount = 0;
          int failureCount = 1;
          double availability = (double) successfulCount / (successfulCount + failureCount);
        }
      }
    }
  }
}

Output

public class Test {

  public static void main(String[] args) {
    if (oneLevelDeep) {
      if (twoLevelsDeep) {
        if (threeLevelsDeep) {
          int successfulCount = 0;
          int failureCount = 1;
          double availability =
            (double) successfulCount / (successfulCount + failureCount);
        }
      }
    }
  }
}

Relative issues or prs:

Fix #396