local_to_field
Promote a local variable in a method to an instance field with a dry-run preview. Apply changes safely using LSP coordinates; expected_symbol prevents stale edits.
Instructions
Promote a local variable inside a method to an instance field: the local becomes self. everywhere in the class. Point at the local variable's name (0-based LSP line/character, UTF-16 units). Defaults to a Dry Run preview; set apply=true to write. Supply expected_symbol when edits may have intervened since your LSP answer, so a stale Position fails safely. Locate the variable with your LSP first; this tool only changes code.
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": {
"file": "<file>",
"line": "<line>",
"character": "<character>"
},
"name": "local_to_field"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | ||
| line | Yes | ||
| root | No | ||
| apply | No | ||
| character | Yes | ||
| expected_symbol | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||