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

feat(model): Model change listener #1417

Merged
merged 40 commits into from
Jun 27, 2017

Conversation

tdurieux
Copy link
Collaborator

@tdurieux tdurieux commented Jun 23, 2017

Close #1168

@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@tdurieux tdurieux force-pushed the model_change_listener branch from 70857da to 2c7c72d Compare June 23, 2017 12:16
public CtCommentImpl() {
}

protected CtCommentImpl(CommentType type) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need it for CtJavaDocImpl

@monperrus
Copy link
Collaborator

rename spoon.diff in spoon.experimental.modelobs
put ChangeFactory in spoon.experimental.modelobs
add spoon.experimental.package-info.java:

this is unstable code, subject to potential complete redesign, not only in snapshots but also in releases. you can use this code but you'll probably be impacted upon future changes. 

move addArgument to separate PR

@monperrus
Copy link
Collaborator

split ChangeFactory into ChangeFactory (empty on*) and ListeningChangeFactory

@tdurieux tdurieux force-pushed the model_change_listener branch from a9b4b9f to 20ca0b6 Compare June 23, 2017 13:05
@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@tdurieux tdurieux force-pushed the model_change_listener branch from ade61b0 to dd6daa6 Compare June 23, 2017 13:58
@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@tdurieux
Copy link
Collaborator Author

Done for me.

@pvojtechovsky Do you see something to improve?

@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 23, 2017
@pvojtechovsky
Copy link
Collaborator

Nice code! I would not do it better. It is OK for me. Sometime I would prefer more comments ;-)

I like that it is by default disabled and that it adds no overhead if it is not needed.
I like Contexts and Actions and fast and low level FineModelChangeListener and higher level ActionBasedChangeListener.

Here are some topics for further discussion:

  • Why FineModelChangeListener is not an interface?
  • The CtExecutable#setParameters(List<CtParameter<?>> parameters) calls listener deleteAll and then add ... I can imagine some use cases where firing event about remove and add on the same element might be a problem (the element (e.g. parameter) will be marked dirty even if it was not really touched). What about another FineModelChangeListener method onListSet, which might internally call deleteAll and add, but implementor have a chance to detect what elements were really removed/added by listening on onListSet. Or we might use new UpdateMultipleAction, where value would be a kind of Collection.
  • All the collections returned by any model getter should be readonly in future. So clients are forced to use appropriate modification methods.

The topics above might be discussed/solved later - after this big PR is merged.

Anyway thank You for this effort!

@monperrus
Copy link
Collaborator

We're almost done :-)

  • remove addArgument in interface/impl
  • undo change in return type of removeType, removeArgument

@INRIA INRIA deleted a comment from spoon-bot Jun 26, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 26, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 26, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 26, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 26, 2017
@INRIA INRIA deleted a comment from spoon-bot Jun 26, 2017
@tdurieux tdurieux force-pushed the model_change_listener branch from f219f44 to d5cf834 Compare June 27, 2017 13:24
@spoon-bot
Copy link
Collaborator

Revapi Analysis results

Old API: fr.inria.gforge.spoon:spoon-core:jar:5.8.0-20170627.123204-68

New API: fr.inria.gforge.spoon:spoon-core:jar:5.8.0-SNAPSHOT

Detected changes: 2.

Change 1

Name Element
Old none
New method spoon.experimental.modelobs.FineModelChangeListener spoon.compiler.Environment::getModelChangeListener()
Code java.method.addedToInterface
Description Method was added to an interface.
Breaking binary: non_breaking

Change 2

Name Element
Old none
New method void spoon.compiler.Environment::setModelChangeListener(spoon.experimental.modelobs.FineModelChangeListener)
Code java.method.addedToInterface
Description Method was added to an interface.
Breaking binary: non_breaking

@tdurieux
Copy link
Collaborator Author

Done for me

@monperrus monperrus merged commit c89c285 into INRIA:master Jun 27, 2017
@monperrus
Copy link
Collaborator

Thanks @GerardPaligot for the intial work on this. Kudos @tdurieux for the heavyweight rebase and design improvements.

@pvojtechovsky
Copy link
Collaborator

Thanks @everybody for that great feature!

@INRIA INRIA deleted a comment from spoon-bot Jun 27, 2017
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.

5 participants