-
Notifications
You must be signed in to change notification settings - Fork 1
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
Need a way to prepend a node with another node #32
Comments
Note that this is not specific to MemberExpressions (
and so son.
These are plain objects, so they can't have methods. Perhaps you mean
If it returns a new node, what parent pointers would be adjusted? To what? That said, returning the new node would still be useful, otherwise it's nontrivial to get it from the user's pov. |
Ok, having a general one makes more sense, will do!
Yes this is what I meant 😅
I also like prepend the best; we can change our minds and I can rename as I'm working on the PR. Related to your next point, we could also name it something like
Good idea was planning on this already!
If it returns the new combined node, then the parent pointers of ...
const combinedNode = ...some calculations...;
parents.set(object, combinedNode, {force: true});
parents.set(property, combinedNode, {force: true});
... |
I think But that's what worries me, that it's non-obvious whether the order should be
That’s not enough, you also need to set |
Also, if we use |
object
to an existing MemberExpression
Can you elaborate more on what you mean by using transform here? |
It seems natural for the implementation to involve |
If you were implementing this, how would you involve transform in your implementation? Asking because I made a super quick (and currently incorrect due to the parents stuff) attempt at it in #33 and didn't see anywhere where using transform would be useful |
Just for clarification, should |
To properly make the transformation it also needs to modify the child pointers of the parent node so I'm not sure how useful this would be if it didn't mutate. |
Ok thanks, this makes sense. I'm clear on mutation of parent/child pointers. Should this function work the same as On one hand, doing it the same as |
I think it's convenient to return the new node so we don't have to find it again, but it should definitely adjust all the pointers needed. |
Sounds good! Will have a PR ready by this afternoon 👍
|
As mentioned in Mavo #1003, we will need a general way to expand MemberExpressions by prepending, and maybe also appending.
Prepending would look something like:
Should this function return void or return the new node without modifying the original? Or should it modify the original and return it? I'm not sure off the top of my head which would be most useful
Would having an append function be useful as well?
The text was updated successfully, but these errors were encountered: