redhat-developer / redhat-developer/vscode-java

Add formatter options to format multiple parameters with new lines

Open
#2,483 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

formatter preferences question
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

I'd like my code to be formatted with new lines for annotation, constructor or method call or declaration with multiple parameters.

For instance:

@Parameter(
    in = ParameterIn.PATH,
    name = "resourceName",
    description = "Resource Name",
    required = true,
    example = "1",
    schema = @Schema(type = SchemaType.STRING, minLength = 1)
)

Current formatter makes a one-liner like this:

@Parameter(in = ParameterIn.PATH, name = "resourceName", description = "Resource Name", required = true, example = "1", schema = @Schema(type = SchemaType.STRING, minLength = 1))

So the formatter should insert new line after the opening brace and comma and before the closing brace.

Environment
  • Operating System: MacOs Monterey 12.3
  • JDK version: openjdk version "11.0.15" 2022-04-19
  • Visual Studio Code version: 1.67.2
  • Java extension version: v1.6.0
Steps To Reproduce
  1. Add annotation with multiple parameters
  2. Format the code
  3. In my current formatter version it should compact it to one line
Current Result
@Parameter(in = ParameterIn.PATH, name = "resourceName", description = "Resource Name", required = true, example = "1", schema = @Schema(type = SchemaType.STRING, minLength = 1))
Expected Result
@Parameter(
    in = ParameterIn.PATH,
    name = "resourceName",
    description = "Resource Name",
    required = true,
    example = "1",
    schema = @Schema(type = SchemaType.STRING, minLength = 1)
)

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

Reproduce the formatter behavior with the annotation example and inspect the formatter entry point and its existing option handling. The work is complete when configurable formatting places parameters on separate lines after the opening delimiter and commas, before the closing delimiter, with the expected indentation.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.