apply_quick_fix
Applies a named quick fix (e.g., add import, surround with try-catch) to a Java source file to resolve code issues.
Instructions
Apply a fix by ID.
USAGE: apply_quick_fix(filePath="...", fixId="add_import:java.util.List") OUTPUT: Text edits to apply the fix
Fix ID formats:
add_import:{fullyQualifiedName} - Add an import statement
remove_import:{index} - Remove import at index
add_throws:{exceptionType} - Add throws declaration to method
surround_try_catch:{exceptionType} - Wrap statement in try-catch
IMPORTANT: Uses ZERO-BASED line numbers.
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>",
"fixId": "<fixId>"
},
"name": "apply_quick_fix"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| line | No | Zero-based line number (required for some fixes like add_throws) | |
| fixId | Yes | The fix ID from get_quick_fixes (e.g., 'add_import:java.util.List') | |
| filePath | Yes | Path to source file |