Provide templating support for adding a parameter to a Java method

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

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
devtools

Research direction

Start by reading CoordinateBuilder.MethodDeclaration::replaceParameters and the surrounding Java templating and coordinate APIs. Determine how a JavaCoordinates.MethodDeclaration::addParameter operation can accept a position, including first, last, or a 0-based index; done means callers can add a parameter at the requested position without replacing the existing list.

Written by the indexing model from the issue text.

Description

enhancement

Currently the only manipulation available for templatizing changes to the parameters of Java method declarations is the CoordinateBuilder.MethodDeclaration::replaceParameters method, which is unsuitable for cases where an additional parameter needs to be added at a specified position to a list of existing ones.

A JavaCoordinates.MethodDeclaration::addParameter (or something equivalent) would be ideal for this use case, with some ability to specify the position of the new parameter (e.g. a 0-based index together with symbolic last/first values).

Dominant language
Java
Stars
3.7k
Forks
571
Avg merge
13h 12m
Merged PRs (30d)
261

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.

More from openrewrite/rewrite

All issues in openrewrite/rewrite

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.