eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Record formatting bug for blank lines before/after
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 49
Description
If I have the following Java code:
```java
public class Example {
/** Some documentation. */
private static int b = 10;
/**
* Constructor for the Example class.
*/
public Example(String s) {
this(1, s);
}
}
public record Example(int a, String s) {
/** Some documentation. */
private static int b = 10;
/**
* Constructor for the Example record.
*/
public Example(String s) {
this(1, s);
}
}
```
Then, using these settings:

It gets turned into:
```java
// Turn on the edit mode and paste or type your code here
public class Example {
/** Some documentation. */
private static int b = 10;
/**
* Constructor for the Example class.
*/
public Example(String s) {
this(1, s);
}
}
public record Example(int a, String s) {
/** Some documentation. */
private static int b = 10;
/**
* Constructor for the Example record.
*/
public Example(String s) {
this(1, s);
}
}
```
This is inconsistent between classes and records. Also, in the record, there should not be any blank line before the `b` field declaration, while there should be a blank line after it.
Contributor guide
Research direction
Reproduce the formatter behavior using the Java class and record examples in the issue with the settings shown in its image. Compare blank-line handling around the field and constructor documentation in both declarations. Done means class and record formatting are consistent, with no blank line before the field and one after it in the record.
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
- 35/100