google / google/google-java-format

regression of issue #1008 on idea-plugin

Aberta
#1,271 0 comentários 0 reações 0 responsáveis Ver no GitHub
IntelliJ
Linguagem predominante
Java
Estrelas
6.2k
Forks
937
Merge médio
6min
PRs com merge (30d)
3

Descrição

Previously, when [Issue #1008](https://github.com/google/google-java-format/issues/1008) was reported, it was resolved.

However, with the recent update to the idea-plugin to version 1.27.0, this issue resurfaced.

This piece of code:

```java
switch (value) {
case 0 -> "it was 0";
case 1 -> "it was 1";
case 2 -> "it was 2";
case null, default -> "unexpected value";
};
```

Works fine with the CLI version of google-java-formatter, but will fail for the idea-plugin version of google-java-formatter.

The only solution is to revert the above switch pattern into
```java
case null -> "null value";
default -> "unexpected value";
```

A simple class to allow easy testing of this
```java
public class Test {
public static void main(String[] args) {
Object obj = null; // or some other object
String result = switch (obj) {
case null, default -> "handled";
};
System.out.println(result);
}
}
```
JDK Used: https://adoptium.net/en-GB/temurin/releases/?version=21

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Nenhum arquivo do repositório ou teste é nomeado. Comece reproduzindo o exemplo de switch do Java 21 com idea-plugin 1.27.0 e compare sua formatação com a da CLI; está concluído quando o plugin tratar `case null, default` de forma consistente com a CLI sem exigir o workaround.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
java
Domínio
tooling
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
45/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.