eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

Code formatter: Suboptimal intent of method arguments

Open
#1,372 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
59
Forks
127
Avg merge
23h 30m
Merged PRs (30d)
35

Description

The String.formatted() method is not correctly intended for text blocks:
I want:
```
StringBuilder sql = new StringBuilder();
sql.append("""
INSERT INTO %s (%s) SELECT DISTINCT %s FROM %s
""".formatted(
"1",
"2",
"3",
"4"));
```
but I get
```
StringBuilder sql = new StringBuilder();
sql.append("""
INSERT INTO %s (%s) SELECT DISTINCT %s FROM %s
""".formatted(
"1",
"2",
"3",
"4"));
```
For regular strings the formatting is better. But I think it is wrong that the formatting does not add another indentation level.

Contributor guide

Open the contributing guide

Research direction

Reproduce the formatting shown for String.formatted() used with a Java text block, then compare it with the regular-string behavior described in the issue. Trace the code formatter entry point responsible for method arguments and establish whether text-block arguments should receive another indentation level. Done means the example formats with the requested indentation and existing formatter behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
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.