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

doc: clarifies contracts of @DerivedProperty #1613

Merged
merged 3 commits into from
Oct 23, 2017

Conversation

monperrus
Copy link
Collaborator

per our discussion on #1586, PropertyGetter can be used for @DerivedProperty as well

@pvojtechovsky
Copy link
Collaborator

I do not understand purpose of this change. But I do not need to know everything. I just cannot review this PR. I personaly would keep this annotation in the model. It had a meening

@@ -175,6 +176,8 @@ public void replace(CtStatement element) {
if (type != null) {
type.setParent(this);
}
// even if the setter delegates to getExecutable, it makes sense to create an event
getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, TYPE, type, getExecutable().getType());
Copy link
Collaborator

Choose a reason for hiding this comment

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

So model change listener will be called twice for single modification? I do not like it.
@monperrus Could you explain why it is good?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you're right, it's not good.

@monperrus
Copy link
Collaborator Author

The most convincing reason to keep @DerivedProperty is in ASTChecker with this contract.

Contract: a setter with @DerivedProperty never triggers a model intercession event.

So let's make this PR only a clarification one.

@monperrus monperrus changed the title fix: remove confusing @DerivedProperty doc: clarifies contracts of @DerivedProperty Oct 17, 2017
* For instance {@link CtType#getFields()} is derived from {@link CtType#getTypeMembers()}
*
* This annotation is used for specifying CtScanner: derived properties are never scanned.
* It can be put on getter ond setters.
Copy link
Collaborator

Choose a reason for hiding this comment

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

ond -> and

* It can be put on getter ond setters.
*
* Contracts:
* - A setter with @DerivedProperty never triggers a model intercession event.
Copy link
Collaborator

Choose a reason for hiding this comment

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

intercession event

Do you mean something like this?

class CtConstructorCallImpl
...
	@DerivedProperty
	public <T extends CtActualTypeContainer> T addActualTypeArgument(CtTypeReference<?> actualTypeArgument) {
		if (getExecutable() != null) {
			getExecutable().addActualTypeArgument(actualTypeArgument);
		}
		return (T) this;
	}

It triggers the event, but not directly on the this node, but on some delegate? Did I understood it well? Improve description?

Is there a test for setters which does not start with set prefix, but with add/remove?

@INRIA INRIA deleted a comment from spoon-bot Oct 18, 2017
@INRIA INRIA deleted a comment from spoon-bot Oct 18, 2017
@INRIA INRIA deleted a comment from spoon-bot Oct 18, 2017
@monperrus
Copy link
Collaborator Author

monperrus commented Oct 23, 2017

clarified contract.

@pvojtechovsky pvojtechovsky merged commit d19eaaa into INRIA:master Oct 23, 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.

2 participants