jhipster / jhipster/prettier-java

Linebreaks in generics

Aperta
#526 13 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
1.2k
Fork
120
Merge medio
1g 14h
PR unite (30g)
27

Descrizione

In testing an upgrade to 1.6.1, we're sometimes seeing line breaks introduced into generics. Seems like this is probably a result of #512. I can see this being useful in pathological cases with extremely long generic type lists, but the issue is that we run prettier with a pretty aggressive line length limit, so we end up seeing split generics even in relatively straight-forward code samples. And it's pretty jarring when you first see it, because as far as I know, splitting generics like this isn't an idiomatic way to format Java (at least I haven't seen it in the wild before).

I tested the prettier-java upgrade on ~1,500 of our internal GitHub repos, and it definitely seemed like, in most cases, this generic splitting was hurting the code readability more than it helped. But curious to get your thoughts on how attached you are to this feature.

**Prettier-Java 1.6.1**

```sh
# Options (if any):
```

**Input:**

```java
public abstract class GenericWblGeneratorWithLongName {

public static PagedResult appendCustomOffsets(
Arg arg1,
Arg arg2
) {
// implementation
}
}
```

**Output:**

```java
public abstract class GenericWblGeneratorWithLongName<
OBJECT_TYPE, RECORD_TYPE
> {

public static <
RECORD, OFFSET
> PagedResult appendCustomOffsets(Arg arg1, Arg arg2) {
// implementation
}
}
```

**Expected behavior:**

```java
public abstract class GenericWblGeneratorWithLongName {

public static PagedResult appendCustomOffsets(
Arg arg1,
Arg arg2
) {
// implementation
}
}
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by reproducing the supplied Java input with the formatter and compare its output with the expected behavior. Trace the formatting path for class and method generic type parameters, then add a regression test for the examples; done means generic lists stay on one line while the existing argument wrapping remains unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.