encapsulate_field
Creates getter and setter methods for a field and refactors all direct accesses to use them. Accepts file position and optional accessor names.
Instructions
Encapsulate a field: generate a getter/setter pair and rewrite all direct accesses (in this and other files) to go through them.
USAGE: Position on the field name; optionally name the accessors. OUTPUT: editsByFile with all required text edits; warnings from JDT's own condition checking. Edits are returned as text - apply them yourself.
IMPORTANT: Uses ZERO-BASED coordinates.
Requires load_project to be called first.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Path to source file containing the field | |
| line | Yes | Zero-based line number of the field declaration | |
| column | Yes | Zero-based column number (on the field name) | |
| getterName | No | Getter name (default: getX for field x) | |
| setterName | No | Setter name (default: setX for field x) |