You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior: Unchanged. The only difference between the two elements is the comment above the first one, which shouldn't force its chain to break.
A block comment before a chain argument is also moved onto the last call, so it ends up describing the wrong part of the expression:
Expected behavior: Both inputs unchanged, as in Prettier JS. A comment that ends before the chain's first token should print ahead of the whole chain and shouldn't count as a comment inside it.
We've patched prettier-java locally to print such comments ahead of the chain and leave them out of the "chain has a comment" check.
Would it be helpful for me to open a PR? Looks like #1057 was closed without getting merged.
Activity
2is10 commentedon Oct 19, 2026
I was about to file this same issue, but luckily found this one.
I noticed it also happens in 2.11.0 when a comment precedes a chain that is a call argument:
Input:
Output:
...or when the comment precedes an array element, which is common in data providers:
Input:
Output:
Expected behavior: Unchanged. The only difference between the two elements is the comment above the first one, which shouldn't force its chain to break.
A block comment before a chain argument is also moved onto the last call, so it ends up describing the wrong part of the expression:
Input:
Output:
Expected behavior: Both inputs unchanged, as in Prettier JS. A comment that ends before the chain's first token should print ahead of the whole chain and shouldn't count as a comment inside it.
We've patched prettier-java locally to print such comments ahead of the chain and leave them out of the "chain has a comment" check.
Would it be helpful for me to open a PR? Looks like #1057 was closed without getting merged.
jtkiesel commentedon Oct 19, 2026
I think some/all of these might be resolved by #1109, but I will check later today.