encapsulate_field
Generate getter and setter for a Java field and automatically rewrite all direct accesses across files to use them. Requires project loaded first.
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, by the place each names (file, then position; those naming one place in JDT's order, those naming none last). 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 |
|---|---|---|---|
| line | Yes | Zero-based line number of the field declaration | |
| column | Yes | Zero-based column number (on the field name) | |
| filePath | Yes | Path to source file containing the field | |
| getterName | No | Getter name (default: getX for field x) | |
| setterName | No | Setter name (default: setX for field x) |