Finds and replaces AST patterns in source code.
Uses Sourceror for parsing, traversal, and source-level patching to preserve formatting of unchanged code.
Summary
Functions
Finds all occurrences of pattern in source.
Replaces all occurrences of pattern with replacement in source.
Types
@type match() :: %{ node: Macro.t(), range: Sourceror.Range.t(), captures: ExAST.Pattern.captures() }
Functions
Finds all occurrences of pattern in source.
Options
:inside— only match nodes nested within an ancestor matching this pattern:not_inside— reject nodes nested within an ancestor matching this pattern
Returns a list of matches with the matched node, its source range, and any captured values.
Replaces all occurrences of pattern with replacement in source.
Captures from the pattern are substituted into the replacement template.
Accepts the same :inside / :not_inside options as find_all/3.
Returns the modified source string.