Skip to content

Cleanup pass: drop empty annotation parentheses #217

Open

Description

@abashev

Upstream: google/google-java-format#1504
Kind: idea | Priority: low

google-java-format#1504 (merged 2026-10-29, copybara export) extends the --cleanup AST pass introduced in google-java-format#1492 so that @Anno() becomes @Anno. Comments inside the parentheses are kept, and a space is inserted when the annotation is directly followed by an identifier.

Why it matters: it is one more non-whitespace rewrite that users of google-java-format will get by default, and it belongs with our existing cleanup tickets (brace insertion, redundant semicolons, unified cleanup pipeline). We have no cleanup pass beyond RemoveUnusedImports, so this is only worth doing if we adopt that pass at all.

Before (upstream behaviour before the change; I believe ours does not touch annotation parentheses but did not run it):

class T {
  `@Anno`() int x;
  `@Anno`()int y;
}

After (with the change, from the upstream description):

class T {
  `@Anno` int x;
  `@Anno` int y;
}

Affected files in our repo:

  • open-java-format/src/main/java/com/palantir/javaformat/java/RemoveUnusedImports.java (only existing non-whitespace pass)
  • open-java-format/src/main/java/com/palantir/javaformat/java/Formatter.java (where a pass would be wired in)

Suggested action: watch. Decide together with the other cleanup tickets; if a cleanup pass is added, this is a cheap rule.


Filed from an upstream-watch ticket after manual review.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions