google / google/google-java-format

Consistent formatting of multivariable try-with-resource blocks.

Offen
#1,392 0 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
6.2k
Forks
937
Ø Merge
6 Min.
Gemergte PRs (30 T.)
3

Beschreibung

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 _) {
}
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.