[clang-format] Wrongly formats a Java line that contains `record` keyword
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
With code style for braces on a new line, disabling clang-format or removing the `record` keyword helps:
```
// clang-format off
private record PathEntry(CountryItem item, boolean myMapsMode, int topPosition, int topOffset)
{
@Override
public String toString()
{
return item.id + " (" + item.name + "), " + "myMapsMode: " + myMapsMode + ", topPosition: "
+ topPosition + ", topOffset: " + topOffset;
}
}
// clang-format on
```
Otherwise, it formats like this:
```
private record PathEntry(CountryItem item, boolean myMapsMode, int topPosition, int topOffset) {
@Override
public String toString()
{
return item.id + " (" + item.name + "), " + "myMapsMode: " + myMapsMode + ", topPosition: "
+ topPosition + ", topOffset: " + topOffset;
}
}
```
Contributor guide
Research direction
Start by running clang-format on the Java snippet in the issue with braces configured on a new line, then compare the output with the expected formatting shown. Trace the handling of Java record declarations and add a regression test demonstrating that the brace style is preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100