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

Applying actions on ast #131

Open
quentinLeDilavrec opened this issue Aug 20, 2020 · 7 comments
Open

Applying actions on ast #131

quentinLeDilavrec opened this issue Aug 20, 2020 · 7 comments

Comments

@quentinLeDilavrec
Copy link

Hi,

Is there a standard/convenient way of applying a subset of found actions?
I want to apply them on the left spoon ast to evaluate different intermediary version of an evolved code.

Thanks for your help!

@martinezmatias
Copy link
Contributor

Hi @quentinLeDilavrec

In the current version, that feature is not implemented.
It'd be really cool to have it!!
Regards
Matias

@martinezmatias
Copy link
Contributor

Hi @quentinLeDilavrec
BTW, it would not be so hard to implement it.
As I am quite busy next weeks, if you agree, I can help/guide you to implement it.
WDYT?
Cheers
Matias

@monperrus
Copy link
Contributor

monperrus commented Aug 20, 2020 via email

@quentinLeDilavrec
Copy link
Author

Thanks @martinezmatias I will make sure to ask you if I have problems with the implementation.
Cool @monperrus, I will try it, I was searching for such project, but did not find it !
It would be useful to put a link on http://spoon.gforge.inria.fr/ecosystem.html or fork it from https://github.com/SpoonLabs ;0

For now, I am having difficulties with nested operations, such as updates inside moves,
but I did not find explicit rules for this nesting (Update is the only one that can't be nested?).

#67 is also a good start but I think that the example does not work because
op.getSrcNode().replace(op. getDstNode()); op does not update the srcNode of its children.
But I don't know exactly how to solve it.

Regards,
Quentin

@martinezmatias
Copy link
Contributor

Hi @quentinLeDilavrec

Update is the only one that can't be nested?

Yes. That's right.

op.getSrcNode().replace(op. getDstNode()); op does not update the srcNode of its children.But I don't know exactly how to solve it.

I'll check it.

Regards
Matias

@monperrus
Copy link
Contributor

It would be useful to put a link on http://spoon.gforge.inria.fr/ecosystem.html

Great idea :) Would you make a PR on ecosystem.md?

@quentinLeDilavrec
Copy link
Author

quentinLeDilavrec commented Aug 21, 2020

It would be useful to put a link on http://spoon.gforge.inria.fr/ecosystem.html

Great idea :) Would you make a PR on ecosystem.md?

Yeah, I will do it.

But even tho it's a great project, I did not find many things that I could reuse from spork :,(
It seems that the logic to merge ASTs I buried under a third party merge library and some elements' wrapper to make it work efficiently (no deep equality, and not directly mutating the ast but picking the wrapped pieces that won the merge battle :/).

In my case, my best shot would be to implement a way to just mutate the ast without too much boilerplate,
only applying one op at a time and also being able to undo op individually.

  • It would allow me to cycle though the different intermediate state of the code (using a gray code and maybe grouping some op prior to cycling to reduce the combinatorial explosion).
  • And avoid cloning the whole ast.
  • But it makes the handling of things like references and parents a nightmare :b)

Moreover, I cannot consider operations individually, thus I would need to make a wrapper able to update other wrappers to avoid unwanted application of other operations.
Wrapping Operations also avoid changing their original behavior.
This wrapper should be resistant to applications of its parents operations.
It would mutate the ast and other operation with an apply() and unapply() method.

Some examples, given a delete inside a move,
a) if we make a swap to apply the move, the delete should become an insert and be immediately applied.
then when we decide to apply the delete we can do it easily.
b) otherwise if we first apply the delete when we apply the move just need to swap
but to then undo the delete we should insert the deleted node in the swapped ast :/.

@martinezmatias It sounds ok? Oo

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

No branches or pull requests

3 participants