jhipster / prettier-java

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

Support unnamed class compilation unit #615

Closed clementdessoude closed 7 months ago

clementdessoude commented 8 months ago

What changed with this PR:

Example

// Input
import com.toto.titi.Test;
import com.toto.titi.Toast;

class TestClass { static String greetings() { return "Hello world!"; } }
interface TestInterface { default String greetings() { return "Hello world!"; } }

;
String greeting() { return "Hello, World!"; }

void main() {
  System.out.println(Test.greeting());
}

// Output
import com.toto.titi.Test;
import com.toto.titi.Toast;

class TestClass {

  static String greetings() {
    return "Hello world!";
  }
}

interface TestInterface {
  default String greetings() {
    return "Hello world!";
  }
}

String greeting() {
  return "Hello, World!";
}

void main() {
  System.out.println(Test.greeting());
}

Relative issues or prs:

Closes: #614