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

Formatter handles Java text blocks poorly

Open
#5,118 8 comments 0 reactions 1 assignee Claimed by @inuyasha82 View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 10h
Merged PRs (30d)
49

Description

Eclipse Version: 2026-03 (4.39.0)
Build id: 20260305-0817

Here's my code snippet:

```java
dependency(Supply, ScriptExecutor::new)
.name("VM-Runner.qemu-container-builder")
.required(resources(of(ApplicationTarFileType).using(Supply)))
.required(Path.of(
"src/org/jdrupes/vmoperator/runner/qemu/Containerfile.arch"))
.script(
"""
mkdir -p build/install/vm-runner.qemu && \
tar -C build/install/vm-runner.qemu -xf $1 && \
podman build --pull=always -t $2 \
-f src/org/jdrupes/vmoperator/runner/qemu/Containerfile.arch . && \
mkdir -p build/generated && \
touch build/generated/ContainerImage.tstamp
""")
.args(resources(of(ApplicationTarFileType).using(Supply)).limit(1)
.map(f -> f.path().toString()))
.args(name() + ":" + branch.replace('/', '-'))
.provideResources(of(new ResourceType() {}),
_ -> Stream.of(ContainerImage.of(buildDirectory()
.resolve("generated/ContainerImage.tstamp"))));

```

For some reason, the formatter insists (i.e. it re-formats if I change it) on inserting a line break between the opening parenthesis and the triple quotes and on indenting the text in the line after the triple quotes.

What I'd expect to see is something like this:

```java
.script("""
my text
""")
```

with the indentation of the text block content either indented by the configured indentation value or left "as-is".

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.