google / google/google-java-format

Consistent formatting of multivariable try-with-resource blocks.

未關閉
#1,392 0 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Java
星號
6.2k
分支
937
平均合併
6 分鐘
30 天內合併 PR
3

描述

The current formatting of try-with-resource blocks that manage multiple variables is strange, as it results in inconsistent alignment and doesn't match how multiline parameters or code blocks are formatted.

Current output:
```java
try (var input = Files.newInputStream(Path.of("./input"));
var output = Files.newOutputStream(Path.of("./output")); ) {
output.write(input.read());
} catch (IOException _) {
}
```

How I think it should be formatted:
```java
try (
var input = Files.newInputStream(Path.of("./input"));
var output = Files.newOutputStream(Path.of("./output"));
) {
output.write(input.read());
} catch (IOException _) {
}
```

貢獻指南

開啟貢獻指南

研究方向

issue 中沒有指定檔案或測試。首先重現所示的 Java 輸入,並將目前的 formatter 輸出與所要求的多行 try-with-resources 版面配置進行比較;完成的標準是:在不變更無關格式的情況下,與多行參數或程式碼區塊保持一致的對齊。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
tooling
Issue 類型
功能
難度
3/5
預估耗時
1-2 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。