jhipster / prettier-java

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

fix: constructor and method receiver parameter #642

Closed jtkiesel closed 7 months ago

jtkiesel commented 7 months ago

What changed with this PR:

Fixes some issues with constructor receiver parameters, and added support for method receiver parameters.

Example

Input

class Currency {
  Currency(Currency this) {}

  Currency(Currency this, Currency other) {}

  Currency(@AnnotatedUsage Currency this, Currency other) {}

  Currency(@AnnotatedUsage Currency this, String aaaaaaaaaa, String bbbbbbbbbb) {}

  String getCode(Currency this) {}

  int compareTo(Currency this, Currency other) {}

  int compareTo(@AnnotatedUsage Currency this, Currency other) {}

  int compareTo(@AnnotatedUsage Currency this, String aaaaaaaaaa, String bbbbbbbbbb) {}

  class Inner {
    Inner(Currency Currency.this) {}

    String getCode(Currency Currency.this) {}
  }
}

Output

class Currency {

  Currency(Currency this) {}

  Currency(Currency this, Currency other) {}

  Currency(@AnnotatedUsage Currency this, Currency other) {}

  Currency(
    @AnnotatedUsage Currency this,
    String aaaaaaaaaa,
    String bbbbbbbbbb
  ) {}

  String getCode(Currency this) {}

  int compareTo(Currency this, Currency other) {}

  int compareTo(@AnnotatedUsage Currency this, Currency other) {}

  int compareTo(
    @AnnotatedUsage Currency this,
    String aaaaaaaaaa,
    String bbbbbbbbbb
  ) {}

  class Inner {

    Inner(Currency Currency.this) {}

    String getCode(Currency Currency.this) {}
  }
}

Relative issues or prs:

Closes #607