google / google/google-java-format
Support JEP 512: Compact Source Files and Instance Main Methods
- Linguagem predominante
- Java
- Estrelas
- 6.2k
- Forks
- 937
- Merge médio
- 6min
- PRs com merge (30d)
- 3
Descrição
In https://github.com/enola-dev/enola/pull/974 for https://github.com/enola-dev/enola/issues/971 with https://github.com/enola-dev/enola/issues/970, I am using "Java's fancy modern main style", AKA the JEP 445 & 463 & 477 & 495 stuff:
* https://openjdk.org/jeps/445
* https://openjdk.org/jeps/463
* https://openjdk.org/jeps/477
* https://openjdk.org/jeps/495
So I have e.g. a `hello.java` which looks e.g. like this, which is actually valid (with `--enable-preview`) Java 21 syntax:
```java
import static java.lang.System.out;
void main() {
out.println("Hello World: " + dev.enola.common.Version.get());
}
```
`google-java-format` chokes on this with:
stderr: learn/jbang/hello.java:26:6: error: did not generate token "void"
void main() {
This is on v1.25.1, which is the 2nd most recent release today; looking at [the 1.25.2 Release Notes](https://github.com/google/google-java-format/releases), I have no reason to believe that this (just) got fixed there; ergo reporting this here.
Stating that `google-java-format` does not support `--enable-preview` would be valid. But from what little I figured (so far) this feature, contrary to e.g. those preview String Templates which then got removed again, this syntax appears to be here to stay, so probably should be supported, sooner or later.
Guia de contribuição
Direção de pesquisa
Comece reproduzindo a falha da v1.25.1 com o exemplo reportado learn/jbang/hello.java e analise os JEPs 445, 463, 477 e 495. Determine as alterações necessárias no formatter para arquivos-fonte compactos e métodos main de instância; em seguida, verifique se o exemplo é formatado com sucesso sem o erro “did not generate token”.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- java
- Domínio
- tooling
- Tipo de issue
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100