encapsulate_field
Encapsulate a class attribute into getter/setter methods, rewriting reads to the getter and writes to the setter across the project, with a dry-run preview.
Instructions
Encapsulate a class attribute behind getter/setter methods, rewriting reads to the getter and writes to the setter across the project. Point at the attribute name (0-based LSP line/character, UTF-16 units), exactly as your LSP returns it. getter_name and setter_name override the default get_/set_ names. Defaults to a Dry Run preview; set apply=true to write. Accesses that cannot be proven to be this attribute are reported as uncertain_occurrences, never silently rewritten. Supply expected_symbol when edits may have intervened since your LSP answer. Locate the attribute 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": "encapsulate_field"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | ||
| line | Yes | ||
| root | No | ||
| apply | No | ||
| character | Yes | ||
| getter_name | No | ||
| setter_name | No | ||
| expected_symbol | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||