google / google/google-java-format

regression of issue #1008 on idea-plugin

Abierto
#1,271 0 comentarios 0 reacciones 0 asignados Ver en GitHub
IntelliJ
Lenguaje dominante
Java
Estrellas
6.2k
Forks
937
Merge medio
6 min
PR fusionados (30 d)
3

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.