palantir / palantir/palantir-java-format

Wrapping enhancements for arguments

Open
#853 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
907
Forks
101
Avg merge
1d 3h
Merged PRs (30d)
19

Description

What happened?

Original code:

protected <T extends E> void findSubscriptions(
        @NonNull Object listener,
        TriConsumer<Class<T>, Subscribe, BiConsumer<Object, T>> consumer) {
}

After reformatting:

protected <T extends E> void findSubscriptions(
        @NonNull Object listener, TriConsumer<Class<T>, Subscribe, BiConsumer<Object, T>> consumer) {
}

What did you want to happen?

The original code is more readable in my opinion.
This essentially boils down to #834 except that it shouldn't be for just records, but every type of argument (constructor, method, ...) when the line becomes too long.

Optionally the stuff after the last argument can be on a new line:

protected <T extends E> void findSubscriptions(
        @NonNull Object listener,
        TriConsumer<Class<T>, Subscribe, BiConsumer<Object, T>> consumer
) {
    // which helps make the actual content easier to distinguish 
}

but I've rarely seen projects do this so I'm not including this in the request.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing this request with issue #834 and tracing the formatter’s existing handling of record and argument wrapping. Use the constructor and method examples in this issue to identify the relevant formatter entry points and tests, then verify that long argument lists wrap consistently while shorter ones retain their current layout.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.