-
-
Notifications
You must be signed in to change notification settings - Fork 353
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
review: feat: CloneMaker can be used to listen on cloning process #1580
Conversation
Hi Pavel, On the implementation, it seems that CloneHelper is already the right abstraction for this, requiring some modification instead of adding a new class. About tests: it's good when tests come right at the first commit of a feature PR, because they enable the creader to quickly grasp the goal and usage. |
I agree, but I did new class because of backward compatibility and easier maintenance. The problem is that CloneHelper contains static So I see two ways WDYT? |
Although CloneHelper is public, it's not meant to be part of the API. It's OK if you redesign it in a non-backward compatible way. Yet, it's good to keep its name for sake of history and discoverability. |
766eaab
to
3489eb6
Compare
I refactored CloneHelper and removed CloneMaker. Working on test ... |
Is it correct that some elements of source AST are copied more times into target AST? It happens e.g. when CtExecutableReference, which points to constructor is sharing one CtTypeReference instance with two fields:
In such case origin AST shares CtTypeReference , while cloned instance has 2 clones of one source CtTypeReference. |
Is it correct that some elements of source AST are copied more times into target AST?
Yes. That's not an issue. In Spoon, the AST is meant to be a tree and not a lattice.
|
I added #1592 which tests that model is a tree and fixes few problems. This fix is needed before we can merge this one (part of the fix is here too in commit fix: Spoon AST is tree not a latice). |
786d387
to
ab25504
Compare
Revapi Analysis resultsOld API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-20171012.192256-75 New API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-SNAPSHOT Detected changes: 6. Change 1
Change 2
Change 3
Change 4
Change 5
Change 6
|
I am done. It is ready for merge |
…nto fea-clone-listener
Revapi Analysis resultsOld API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-20171012.192256-75 New API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-SNAPSHOT Detected changes: 6. Change 1
Change 2
Change 3
Change 4
Change 5
Change 6
|
Thanks for comments and merge fixing ... looks like I still do not understand how git works if I did not merged another branch well :-( |
This PR allows client to track, which clone source node is mapped to which clone target node.
One
CloneMaker
instance is used by cloning of one CtElement and all it's children.By overriding this CloneMaker and creating own instance for cloning, the client can listen on cloning process and client's implementation is called with each source and target cloned node.
Example:
@monperrus will you accept such feature into Spoon? If yes, I will make some test too.
What about name
CloneMaker
? Do you have better one?