google / google/google-java-format

Block-like array initializers are not preserved

Offen
#572 3 Kommentare 0 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 [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html#s4.8.3-arrays) specifies that arrays may be formatted in a block-like fashion, however google-java-format clobbers this to one line per element.

For example, the following:

```
protected static final byte[] TEST_ARRAY =
new byte[] {
(byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0xFF, (byte) 0xFF
};
```
becomes
```
protected static final byte[] TEST_ARRAY =
new byte[] {
(byte) 0x31,
(byte) 0x32,
(byte) 0x33,
(byte) 0x34,
(byte) 0x35,
(byte) 0x36,
(byte) 0xFF,
(byte) 0xFF
};
```

For larger formatted constant definitions, formatting is essential to preserving understanding of the structure. It seems like preserving formatting should either be default behaviour, or an option.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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