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: add method CtMethod#getTopDefinitions #1844

Merged
merged 4 commits into from
Feb 16, 2018

Conversation

monperrus
Copy link
Collaborator

fix #1821

@spoon-bot
Copy link
Collaborator

Detected changes by Revapi: 1.

Old API: fr.inria.gforge.spoon:spoon-core:jar:6.2.0-20180209.130552-78

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

Name Change 1
Old none
New method CtMethod::getTopDefinitions()
Code java.method.addedToInterface
Description Method was added to an interface.
Breaking binary: non_breaking,

@INRIA INRIA deleted a comment from spoon-bot Feb 9, 2018
@INRIA INRIA deleted a comment from spoon-bot Feb 9, 2018
// now removing the intermediate methods for which there exists a definition upper in the hierarchy
List<CtMethod<?>> finalMeths = new ArrayList<>(s);
for (CtMethod m1 : s) {
ClassTypingContext context2 = new ClassTypingContext(m1.getDeclaringType());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you try to use existing context? I guess the existing one already contains all the necessary information, so there is no need to create new one for each method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@INRIA INRIA deleted a comment from spoon-bot Feb 9, 2018

// first collect potential declarations of this method in the type hierarchy
ClassTypingContext context = new ClassTypingContext(this.getDeclaringType());
for (Object m : getDeclaringType().map(new AllTypeMembersFunction(CtMethod.class)).list()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about CtQuery#forEach instead of list() and then for(m : list){}? It will be shorter code, faster run and less memory needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not possible since we need two passes on the list

Copy link
Collaborator

Choose a reason for hiding this comment

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

I created a PR on your PR here monperrus#7

@monperrus
Copy link
Collaborator Author

monperrus commented Feb 13, 2018 via email

@monperrus
Copy link
Collaborator Author

done the changes

@spoon-bot
Copy link
Collaborator

Detected changes by Revapi: 1.

Old API: fr.inria.gforge.spoon:spoon-core:jar:6.2.0-20180213.235035-85

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

Name Change 1
Old none
New method CtMethod::getTopDefinitions()
Code java.method.addedToInterface
Description Method was added to an interface.
Breaking binary: non_breaking

@monperrus
Copy link
Collaborator Author

merged your PRPR, note that you can push to my branch directly as well.

@spoon-bot
Copy link
Collaborator

Detected changes by Revapi: 1.

Old API: fr.inria.gforge.spoon:spoon-core:jar:6.2.0-20180215.200548-88

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

Name Change 1
Old none
New method CtMethod::getTopDefinitions()
Code java.method.addedToInterface
Description Method was added to an interface.
Breaking binary: non_breaking,

@pvojtechovsky pvojtechovsky merged commit 21ef328 into INRIA:master Feb 16, 2018
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.

feat: add method getTopDefinitions() to identify first signature in superclass/superinterface
3 participants