extract_method
Extract selected code into a new method with automatically inferred parameters and return type for refactoring Java code.
Instructions
Extract a code block into a new method.
USAGE: Select code range, provide method name OUTPUT: Text edits for method declaration and call site
The tool analyzes the selected code to:
Determine which variables become parameters
Determine return type based on variables modified
Generate appropriate method signature
IMPORTANT: Uses ZERO-BASED coordinates.
Requires load_project to be called first.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"filePath": "<filePath>",
"startLine": "<startLine>",
"startColumn": "<startColumn>",
"endLine": "<endLine>",
"endColumn": "<endColumn>",
"methodName": "<methodName>"
},
"name": "extract_method"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endLine | Yes | Zero-based end line of code to extract | |
| filePath | Yes | Path to source file | |
| endColumn | Yes | Zero-based end column | |
| startLine | Yes | Zero-based start line of code to extract | |
| methodName | Yes | Name for the new method | |
| startColumn | Yes | Zero-based start column |