Closed rjbs closed 1 year ago
I use insert_before
+ remove
to achieve replacing element with a manually constructed one.
$elem->insert_before($new_elem);
$elem->remove;
Although I'm not sure if this breaks consistency of the PPI::Document
object in question, for the purpose of rewriting code, this seems to work.
At the very least, maybe the docs could indicate that replace
is aspirational. I had forgotten about this and it bit me again today.
Link to a PR which addresses this https://github.com/Perl-Critic/PPI/pull/254
Closed via #254
The method
$elem->replace($elem)
is documented but unimplemented. It would be very useful. Right now I'm using the undocumented, untested, unused__replace_child
method, and I feel awful about it.Please provide a means to do this legitimately.