Skip to content

Conversation

@joshwanf
Copy link
Collaborator

Formats .java files on save using google-java-format

@joshwanf joshwanf requested a review from prestoncabe as a code owner January 22, 2026 20:59
@prestoncabe
Copy link
Collaborator

Hey @joshwanf, what is the reasoning for using the google formatter instead of the redhat one? I am accustomed to the redhat vs code extension and see that it is much more widely used... but also have very little knowledge of java "best practices".

@joshwanf
Copy link
Collaborator Author

I'm mainly looking for a formatter/format spec that can break up long function definitions. For instance, the following block formats everything inside @APIResponse() in one long line.

I read that it's possible to load a XML definition file, but I don't have any local definitions loaded into my editor. If you have one that you normally use, I'm happy to use that.

Default Red Hat formatter:

    @APIResponses({
            @APIResponse(responseCode = "200", description = "Get all screeners for a user.", content = @Content(schema = @Schema(type = SchemaType.ARRAY, implementation = Screener.class))),
            @APIResponse(responseCode = "401", description = "Unauthorized user request.", content = @Content(schema = @Schema(type = SchemaType.ARRAY, implementation = Screener.class)))
    })

Ideally I would like a format spec that breaks the block into multiple lines (maybe even break the @Content):

  @APIResponses({
    @APIResponse(
        responseCode = "200",
        description = "Get all screeners for a user.",
        content =
            @Content(schema = @Schema(type = SchemaType.ARRAY, implementation = Screener.class))),
    @APIResponse(
        responseCode = "401",
        description = "Unauthorized user request.",
        content =
            @Content(schema = @Schema(type = SchemaType.ARRAY, implementation = Screener.class)))
  })

@joshwanf
Copy link
Collaborator Author

I seem to have found a solution using the Red Hat extension! Please hold for a future commit

@joshwanf joshwanf marked this pull request as draft January 23, 2026 21:02
@joshwanf joshwanf changed the title use google-java-format to format .java files Add .java formatter definitions Jan 24, 2026
@joshwanf joshwanf marked this pull request as ready for review January 24, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants