eclipse-jdt / eclipse-jdt/eclipse.jdt.core

[formatting] Add line wrapping setting for placing each right brace/parenthesis on a single line

Open
#807 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 10h
Merged PRs (30d)
49

Description

It should be possible to place each right brace and parenthesis on a single line if the max line width is exceeded. For example:

`public class Parentheses extends ClassLoader {

/**
* @param list
*
* @return sorted list
*/
public List sort(List list) {
Collections.sort(
list,
new Comparator() {
@Override
public int compare(final String e1, final String e2) {
return e1.compareTo(e2) * -1;
}
}
);
return list;
}
}
`

Instead of:

`public class Parentheses extends ClassLoader {

/**
* @param list
*
* @return sorted list
*/
public List sort(List list) {
Collections.sort(list, new Comparator() {
@Override
public int compare(final String e1, final String e2) {
return e1.compareTo(e2) * -1;
}
}); // each of this should be placed on a single line as above!
return list;
}
}
`

This would make the assignment of the corresponding right and left brace/parenthesis pairs much easier and therefore enhance the readability of the code.

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by locating the Java formatter's line-wrapping settings and their tests, then trace how closing braces and parentheses are emitted when the maximum line width is exceeded. Done means a setting produces the shown one-delimiter-per-line formatting without changing behavior when the width is not exceeded.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.