google / google/google-java-format

regression of issue #1008 on idea-plugin

オープン
#1,271 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
IntelliJ
主要言語
Java
スター
6.2k
フォーク
937
平均マージ
6分
マージ済み PR(30日)
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 を短くまとめたダイジェスト。