ashlr__edit_structural
AST-aware rename across files. Handles Unicode identifiers, cross-file rename with shadowing guard, extract-function with return-value detection. TypeScript/TSX/JS/JSX only.
ashlr__edit_structural performs AST-aware symbol renames and function extractions. Unlike ashlr__edit (text search/replace), it understands scope and shadowing — a rename of foo only touches occurrences that resolve to the same binding.
Use cases
- Rename a function, variable, or type across all files in a project
- Rename Unicode identifiers (
café,π, CJK characters) correctly - Extract a code block into a new function, auto-detecting return values
- Dry-run a rename to preview all affected sites before applying
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
operation | "rename" | "rename-cross-file" | "extract-function" | no | Operation to perform (default: 'rename' for back-compat) |
path | string | no | Absolute or cwd-relative file path (rename, extract-function) |
rootDir | string | no | Root directory to search (rename-cross-file) |
name | string | no | Current identifier name to rename (rename, rename-cross-file) |
newName | string | yes | New symbol name. |
kind | "value" | "type" | no | 'value' (default) | 'type'; for rename operations |
dryRun | boolean | no | If true, return the planned edits without writing (default false) |
force | boolean | no | Bypass shadowing + collision guards for rename (default false) |
include | string[] | no | Glob patterns to include (rename-cross-file, default: **/*.{ts,tsx,js,jsx}) |
exclude | string[] | no | Glob patterns to exclude (rename-cross-file) |
anchorFile | string | no | Disambiguate when name appears in multiple files (rename-cross-file). |
maxFiles | number | no | Hard cap on candidate files for cross-file rename (default 200). Beyond this the rename is truncated and a warning is emitted. |
start | number | no | Byte offset start of range to extract (extract-function) |
end | number | no | Byte offset end of range to extract (extract-function) |
For function extraction, use extract mode (see tool schema for full args).
Supported languages
.ts, .tsx, .js, .jsx. Other languages fall back to ashlr__search_replace_regex.
Example
Returns a preview of all affected sites. Remove dryRun to apply.
Related
ashlr__edit— text search/replace (no AST)ashlr__multi_edit— batch edits across filesashlr__search_replace_regex— regex rename for non-TS languages- Capabilities matrix