google / google/google-java-format

regression of issue #1008 on idea-plugin

未关闭
#1,271 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
IntelliJ
主要语言
Java
星标
6.2k
派生
937
平均合并
6 分钟
30 天内合并 PR
3

描述

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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。