You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are we able to get append/prepend API for inserting calls in function bodies? Currently the append/prepend API only works for the tree body.
Example:
functiontest(){foo('test');}
Fails: c.body.node[0].body.append('bar();').
So I looked for workarounds. I tried to manually push this new call into the body array via c.body.node[0].body.body.push('bar();'). But doing so fails because bar(); is a string and not an esprima object. A possible solution is to expose AST-query nodes modules so we can do the above. Or add documentation that the body array requires an esprima object.
I can code this change, just need vision.
The text was updated successfully, but these errors were encountered:
Hey, can you clarify what you're doing and what is the result you'd expect? Also, when you say something fail, it'd help to have the error trace you're seeing.
A PR is welcomed, looks like you'd just need to make the body node append and prepend function more flexible.
Are we able to get append/prepend API for inserting calls in function bodies? Currently the append/prepend API only works for the tree body.
Example:
Fails:
c.body.node[0].body.append('bar();')
.So I looked for workarounds. I tried to manually push this new call into the body array via
c.body.node[0].body.body.push('bar();')
. But doing so fails becausebar();
is a string and not an esprima object. A possible solution is to expose AST-query nodes modules so we can do the above. Or add documentation that the body array requires an esprima object.I can code this change, just need vision.
The text was updated successfully, but these errors were encountered: