palantir / palantir/palantir-java-format

Two-column argument layout breaks with different AST shapes

Open
#204 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

We've hit an obscure edge case for the two-column argList logic, where it doesn't end up keeping the pairs together.
The logic tries to assert that N/2+1 rows have the same "kind" of tree in the AST.
However, the values in the example seem to be

  • Kind.PLUS (BinaryTree of + operations)
  • Kind.VARIABLE
  • Kind.METHOD_INVOCATION

https://github.com/palantir/palantir-java-format/blob/fc94362438d9450b2fefe29315e5ea687bd93215/palantir-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java#L3222-L3226

I honestly don't see much reason for this kind of heuristic (at least for values), so it might make sense to remove it.

Originally posted by @dansanduleac in https://github.com/palantir/conjure-verification/pull/311#discussion_r377215499

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 in JavaInputAstVisitor.java around lines 3222-3226 and trace the two-column argList handling that compares AST kinds. Reproduce the reported case with mixed PLUS, VARIABLE, and METHOD_INVOCATION values, then verify that the resulting pairs remain together. Done means the mixed AST shapes no longer trigger the layout failure, with formatter behavior checked for the reported case.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.