Skip to main content
Glama

change_method_signature

Change a Java method's name, parameters, or return type and get edits for the declaration plus every call site, override, and related reference.

Instructions

Change method signature (parameters, return type, or name) and update all call sites.

Returns text edits for the method declaration and every place that must change. The caller should apply these edits to perform the change.

USAGE: Position on method declaration, provide changes OUTPUT: Edits for the declarations and every place updated

The method changes together with every method it overrides, every method that overrides it and every method a subtype inherits together with it, as rename_symbol renames them: one declaration edit each, each keeping its own parameter names and unchanged parameter types, and every call of any of them. A method related to a method of a class file is refused, naming that method: it cannot change. A place JDT's search reports but cannot confirm as a call, where a type or name does not resolve, is never rewritten: potentialMatches lists every one, to review by hand. An element of an annotation type is refused: it has no parameters; rename it with rename_symbol.

Every place JDT's change-signature refactoring updates is updated: calls, including the arguments of enum constants; Javadoc references (#method(Type) and Type#method(Type) links); a single static import of the method, renamed, or followed by an import of the new name when a member it names keeps the old name; the parameters of each lambda expression implementing the method; and, when a constructor without parameters is given some, its implicit super() calls: super(...) is added to each constructor of a direct subclass that calls it implicitly, and a constructor calling super(...) to each direct subclass that declares none. A call nested in another changed place, such as a chained call, changes within that place's edit.

Each edit replaces a span (type replace, with oldText and newText, or oldSignature and newSignature for a declaration, isDeclaration true) or inserts text (type insert, with line, column, offset and newText). A file's edits come in this order: declarations, the other places the search reports, in source order, lambda expressions, implicit super() calls, static imports.

PARAMETER OPERATIONS:

  • Add new parameter with default value for existing calls

  • Remove parameter (will remove from calls)

  • Rename parameter: give it its new name and, as oldName, the name it has now. Each declaration and lambda expression that names it so takes the new name in its parameter list and every reference to it in its body, a declaration's @param tag naming it too, and a Javadoc reference naming it takes the new name; calls keep their arguments. A declaration or lambda expression that names it otherwise keeps its own name. An oldName that names no parameter of the method is INVALID_PARAMETER.

  • Reorder parameters (specify all parameters in new order)

A renamed parameter's @param tag and references follow its declaration's or lambda expression's edit, in source order. The edits of the lambda expressions come in source order, file by file, as the other places do.

Every declaration keeps each kept parameter's modifiers and annotations as written. A changed type replaces only the type: the parameter is varargs when the new type ends in ..., and dimensions written after its name are dropped, as JDT does.

Refused as JDT refuses them (INVALID_PARAMETER 'newParameters', with JDT's messages): a blank parameter name or one that is no Java identifier; two parameters of one name; a name the change gives that a method changed with it already gives one of its parameters, naming that method; and a rename that changes what a name refers to: a renamed reference a local variable would capture (in the body, an anonymous class or a lambda expression), or a reference to a field or another variable the renamed parameter would capture. Each collision names the declaration it lies in and its place, as the file is now.

Compile errors that follow from the requested change (a changed return or parameter type breaking a caller, a removed parameter still used) do not refuse it. introducedProblems lists every compile error the applied edits introduce in each file the change edits or reports a place in, and JDT's note for each removed parameter a body still uses, at its first use, also where the code compiles because a field of that name captures it. Each entry gives filePath, line and column, as the file is now, and message, which names the method, field, initializer or type the error lies in ("a lambda expression in" it when it lies in one; an anonymous class by its number, as in Outer$1). Entries come by file, then line and column, then message. introducedProblems is present only when it has an entry.

warnings lists JDT's warnings on the new parameter names, in the order of the parameters, then one for each file holding a method reference that cannot be updated, in the order of methodReferences.

IMPORTANT: Uses ZERO-BASED coordinates.

potentialMatches, present only when there are any, holds the places JDT's search reports as possible matches but cannot confirm, because a type or name there does not resolve (a missing dependency or a compile error): count is their exact number, and locations lists them, as many as the results it stands beside may list. They are never counted or listed as results.

Requires load_project to be called first.

Input Schema

NameRequiredDescriptionDefault
lineYesZero-based line number of method declaration
columnYesZero-based column number
newNameNoNew method name (optional, omit to keep current)
filePathYesPath to source file containing the method
newParametersNoNew parameter list. Each item: {name, type, oldName?, defaultValue?}. Order matters.
newReturnTypeNoNew return type (optional, omit to keep current)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.5.3
    • changedInput schema / properties / newParameters / description
      Previous value: -"New parameter list. Each item: {name, type, defaultValue?}. Order matters."New value: +"New parameter list. Each item: {name, type, oldName?, defaultValue?}. Order matters."
    • addedInput schema / properties / newParameters / items / properties / oldName
      Added value: +{
      +  "description": "The parameter's current name, when it is renamed to name",
      +  "type": "string"
      +}
  2. Addedv1.3.4
  3. Removedv1.3.3
  4. First observedv1.2.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and does so exhaustively: it discloses what gets rewritten (calls, Javadoc links, lambda parameters, implicit super() calls, static imports), how refusals surface (INVALID_PARAMETER with JDT messages), that compile errors do not refuse but appear in introducedProblems/warnings, that potentialMatches holds unconfirmed places, edit ordering, and ZERO-BASED coordinates. This is far richer than typical behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose, USAGE, and OUTPUT are correctly front-loaded, which helps orientation. However the body is extraordinarily long with dense, sometimes convoluted prose (e.g., the multi-clause override/inheritance sentence), and the sheer size makes it harder to scan than a complex refactoring tool strictly requires.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, yet the description fully explains the return shape (text edits with replace/insert types, isDeclaration, oldText/newText, line/column/offset, per-file ordering) and the auxiliary result fields. For a 6-parameter mutation tool, nothing an agent needs to call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% (baseline 3), but the dedicated 'PARAMETER OPERATIONS' section adds real meaning beyond the schema: how to add a parameter with a defaultValue, remove one, rename via oldName (including how references and @param tags follow), and reorder, plus the INVALID_PARAMETER conditions. That exceeds what the schema's field descriptions convey.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource+scope: 'Change method signature (parameters, return type, or name) and update all call sites.' It distinguishes itself from the sibling rename_symbol (which it explicitly routes annotation-type elements to), so an agent can tell them apart without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The 'USAGE: Position on method declaration, provide changes' line plus the prerequisite 'Requires load_project to be called first' give clear invocation context, and it names rename_symbol as the alternative for annotation-type elements. It stops short of a full when/when-not contrast against refactoring siblings like extract_method or inline_method.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.