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

review feature: Add a new method to add a method argument to a specific position. #1422

Closed
wants to merge 3 commits into from

Conversation

surli
Copy link
Collaborator

@surli surli commented Jun 23, 2017

No description provided.

@surli surli changed the title Add a new method to add a method argument to a specific position. feature: Add a new method to add a method argument to a specific position. Jun 23, 2017
@monperrus
Copy link
Collaborator

add a test?

@surli
Copy link
Collaborator Author

surli commented Jun 23, 2017

add a test?

Yep it's planned.

@spoon-bot
Copy link
Collaborator

Revapi Analysis results

Old API: fr.inria.gforge.spoon:spoon-core:jar:5.8.0-20170623.143645-61

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

Detected changes: 1.

Change 1

Name Element
Old none
New method <C extends spoon.reflect.code.CtAbstractInvocation> C spoon.reflect.code.CtAbstractInvocation::addArgument(int, spoon.reflect.code.CtExpression<?>)
Code java.method.addedToInterface
Description Method was added to an interface.
Breaking binary: non_breaking,

@surli surli changed the title feature: Add a new method to add a method argument to a specific position. review feature: Add a new method to add a method argument to a specific position. Jun 26, 2017
@@ -49,6 +49,12 @@
<C extends CtAbstractInvocation<T>> C addArgument(CtExpression<?> argument);

/**
* Adds an argument expression to the invocation at the specified position
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).


secondArg = launcher.getFactory().Core().createLiteral().setValue(12);

invocBar.addArgument(1, secondArg);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting, this should fail with an exception because it's not compatible with the method signature.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not agree with you.
Spoon is not designed to check to validity of the transformation, it is not realistic to have always consistant model.

we can create a scanner that check the consistant of the model but it is not the responsibility of the setters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Interesting, this should fail with an exception because it's not compatible with the method signature.

If you do that, we should do it in all methods, especially if we create addParameter(int position, ...) in CtExecutable: then you'll have an egg-chicken problem, if you use a transformation on the executable and on the invocations, there will be a "not compatible transformation" somewhere.

So I agree with Thomas: we should not do check there, but we should document the fact that those transformation are not checked against the executable.

@spoon-bot
Copy link
Collaborator

Revapi Analysis results

Old API: fr.inria.gforge.spoon:spoon-core:jar:5.8.0-20170625.224633-64

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

Detected changes: 1.

Change 1

Name Element
Old none
New method <C extends spoon.reflect.code.CtAbstractInvocation> C spoon.reflect.code.CtAbstractInvocation::addArgument(int, spoon.reflect.code.CtExpression<?>)
Code java.method.addedToInterface
Description Method was added to an interface.
Breaking binary: non_breaking,

@monperrus
Copy link
Collaborator

monperrus commented Jun 26, 2017 via email

@surli
Copy link
Collaborator Author

surli commented Jun 26, 2017

Yes, starting by the Javadoc of this method.

I changed the javadoc, but in fact we can do the same kind of warning for any remove, add or set method...

@spoon-bot
Copy link
Collaborator

Revapi Analysis results

Old API: fr.inria.gforge.spoon:spoon-core:jar:5.8.0-20170625.224633-64

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

Detected changes: 1.

Change 1

Name Element
Old none
New method <C extends spoon.reflect.code.CtAbstractInvocation> C spoon.reflect.code.CtAbstractInvocation::addArgument(int, spoon.reflect.code.CtExpression<?>)
Code java.method.addedToInterface
Description Method was added to an interface.
Breaking binary: non_breaking,

@monperrus
Copy link
Collaborator

we close this one and remove this code from #1417 (and subsequently from #1358 by rebase)

@surli surli closed this Jun 26, 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.

4 participants