Increased the number of detected Replace Anonymous with Lambda
instances to 5893 in commit
which is higher than the number reported in the paper "Understanding the Use of Lambda Expressions in Java" OOPSLA 2017 (5654)
@@ -3857,8 +3857,9 @@ public class UMLOperationBodyMapper implements Comparable<UMLOperationBodyMapper
}
}
}
- if(anonymousClassDeclarations1.size() == 1 && anonymousClassDeclarations2.size() == 0 && (operation1 != null || attribute1 != null) && lambdas2.size() >= 1) {
- AnonymousClassDeclarationObject anonymousClassDeclaration1 = anonymousClassDeclarations1.get(0);
+ if(anonymousClassDeclarations1.size() >= 1 && (operation1 != null || attribute1 != null) && lambdas2.size() >= 1) {
+ for(int i=0; i<anonymousClassDeclarations1.size(); i++) {
+ AnonymousClassDeclarationObject anonymousClassDeclaration1 = anonymousClassDeclarations1.get(i);
UMLAnonymousClass anonymousClass1 = null;
if(operation1 != null)
anonymousClass1 = operation1.findAnonymousClass(anonymousClassDeclaration1);
@@ -3866,8 +3867,8 @@ public class UMLOperationBodyMapper implements Comparable<UMLOperationBodyMapper
anonymousClass1 = attribute1.findAnonymousClass(anonymousClassDeclaration1);
if(anonymousClass1.getOperations().size() == 1) {
UMLOperation anonymousClass1Operation = anonymousClass1.getOperations().get(0);
- for(int i=0; i<lambdas2.size(); i++) {
- LambdaExpressionObject lambda2 = lambdas2.get(i);
+ for(int j=0; j<lambdas2.size(); j++) {
+ LambdaExpressionObject lambda2 = lambdas2.get(j);
UMLOperationBodyMapper mapper = new UMLOperationBodyMapper(anonymousClass1Operation, lambda2, this);
int mappings = mapper.mappingsWithoutBlocks();
if(mappings > 0) {
@@ -3895,6 +3896,7 @@ public class UMLOperationBodyMapper implements Comparable<UMLOperationBodyMapper
}
}
}
+ }
return null;
}
