gritql
gritql copied to clipboard
Cannot rewrite empty field nodes
Currently, if a field is null we can't rewrite/insert into it (because we don't have an associated range for a field that wasn't found).
Workaround
Rewrite the entire parent node that contained the null field.
Example
engine marzano(0.1)
language python
pattern test_func($name, $parameters, $return_type, $body) {
function_definition($name, $parameters, $return_type, $body) as $function where {
$name <: r"test_.*",
}
}
pattern test_class($name, $superclasses, $body) {
class_definition($name, $superclasses, $body) as $cls where {
$superclasses <: contains `TestCase`,
}
}
test_func($return_type) as $function where {
$function <: within test_class(),
$return_type => `None`
}