| Mutator | R Documentation |
Mutator
Mutator
Represents a single code mutation — a pattern to find and a replacement to
apply. Every mutator function (operator(), boolean_literal(), etc.)
returns an instance of this class.
fromThe token or operator to replace.
toThe replacement token or operator.
queryTree-sitter query used to locate candidate nodes.
match_fnOptional function(node_text) returning logical;
overrides the default node_text == from equality check.
replacement_fnOptional function(node_text) returning a string;
overrides the static to value as the replacement text.
mutate_fnOptional function(code) that fully replaces the
default mutation logic when set.
new()Create a new Mutator.
Mutator$new( from, to, query, match_fn = NULL, replacement_fn = NULL, mutate_fn = NULL )
fromToken to replace.
toReplacement token.
queryTree-sitter query string.
match_fnOptional custom match function.
replacement_fnOptional custom replacement function.
mutate_fnOptional function(code) that fully overrides the
default mutation logic.
mutate()Apply this mutator to a character vector of source lines.
Mutator$mutate(code)
codeCharacter vector of source lines.
A list of mutated code variants (one per match), or NULL if
the pattern was not found.
print()Print a short summary of the mutator.
Mutator$print()
clone()The objects of this class are cloneable with this method.
Mutator$clone(deep = FALSE)
deepWhether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.