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 LambdaFilter #1315

Merged
merged 2 commits into from
May 21, 2017
Merged

Conversation

pvojtechovsky
Copy link
Collaborator

This Filter matches all CtLambdas which are implementing one of defined interfaces.

It will be used by #1291 to found all lambdas of all methods with same signature.

@pvojtechovsky pvojtechovsky changed the title feature LambdaFilter review: feature LambdaFilter May 20, 2017
* Allows to search for lambdas implemented by different interfaces.
* @param typeInfo interface whose lambda implementations it is searching for
*/
public LambdaFilter addImplementingInterface(CtTypeInformation typeInfo) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

not tested

if (typeInfo instanceof CtType) {
if (typeInfo instanceof CtInterface) {
qualifiedNamesOfInterfaces.add(typeInfo.getQualifiedName());
} //else ignore that request, because lambda can implement only interfaces
Copy link
Collaborator

Choose a reason for hiding this comment

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

silent ignore is hard to debug. throwing an exception is better?

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 already had exception there, but I learned that there exists CtExecutionReferences whose parent is NOT CtInvocation. So I have to ignore them - it is not a bug. It is part of that algorithm.

public void testLambdaFilter() throws Exception {
List<String> methodNames = foo.filterChildren(new LambdaFilter((CtInterface<?>) foo.getNestedType("CheckPerson"))).map((CtLambda l)->l.getParent(CtMethod.class).getSimpleName()).list();
assertHasStrings(methodNames);
methodNames = foo.filterChildren(new LambdaFilter((CtInterface<?>) foo.getNestedType("Check"))).map((CtLambda l)->l.getParent(CtMethod.class).getSimpleName()).list();
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's try to use and hence specify the three different constructors?

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 do not understand. Please explain your question/suggestion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only one constructor is tested

I understand ... working on it

@monperrus
Copy link
Collaborator

monperrus commented May 21, 2017 via email

@pvojtechovsky
Copy link
Collaborator Author

This is finished from my point of view.

@monperrus monperrus merged commit 4a41286 into INRIA:master May 21, 2017
@monperrus
Copy link
Collaborator

@pvojtechovsky
Copy link
Collaborator Author

You are welcome ;-)
Thanks for the tip with constructors! Going to sleep today.

@pvojtechovsky pvojtechovsky deleted the feaLambdaFilter branch May 21, 2017 20:42
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