Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SavSanta
Copy link

@SavSanta SavSanta commented Jun 11, 2022

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

literal copy of transform_Object function into generic _transform function.
@jjboi8708
Copy link

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

@SavSanta
Copy link
Author

SavSanta commented Jul 4, 2022

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.

@jjboi8708
Copy link

jjboi8708 commented Jul 4, 2022

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.

@SavSanta
Copy link
Author

SavSanta commented Jul 4, 2022

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

@jjboi8708
Copy link

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

@SavSanta
Copy link
Author

SavSanta commented Jul 5, 2022

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

@jjboi8708
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants