esprima-python icon indicating copy to clipboard operation
esprima-python copied to clipboard

Example in example folder doesnt work. no "generic_transform" function

Open SavSanta opened this issue 2 years ago • 7 comments

literal copy of transform_Object function into generic _transform function.

Since I never completed CompSci algo and data structures this may not be the right implementation but you have no issues tab to discuss further and it worked in my limited testing

SavSanta avatar Jun 11 '22 08:06 SavSanta

Are you able to change specific nodes using this method? Because for me it is changing all similar nodes to the same value.

jjboi8708 avatar Jul 04 '22 05:07 jjboi8708

I dont rememeber. Though i think that was the case [that it affected every node] as looking at some of my current code that i can see from here. I ended up using the visit_node and then made calls to some additional functions i created to match what i need from the nodes and actionate if it does match.

SavSanta avatar Jul 04 '22 16:07 SavSanta

So were you able to use the transform_Object function? Or did you use the visit_node function too to change the specific node within the tree? Also was it visit_generic because there isn't a function called visit_node.

jjboi8708 avatar Jul 04 '22 18:07 jjboi8708

No esprima based "transform" calls used. Made my own functions to verify and change what i needed and called out to them once they weree visited.

Also no it wasnt a function literally called visit_node. It it moreso visit_<node>. As in you replace the "node" portion with the Javascript node type you want the AST visitor to be concerned with as it visits the tree

SavSanta avatar Jul 04 '22 20:07 SavSanta

So you were able to transform, change or modify a specific node within your ast tree using the function you made?

jjboi8708 avatar Jul 04 '22 23:07 jjboi8708

I had specific matches needed in my filters. So It was more than one node....but essentially yes if they matched my filter I could change it. Cheers

SavSanta avatar Jul 05 '22 00:07 SavSanta

How did you change it using the visit_node functions because I am having trouble changing the nodes that I want to change?

jjboi8708 avatar Jul 05 '22 02:07 jjboi8708