Improvement in case of statement with multiple lambdas
where one of them is replacing an anonymous class declaration
@@ -3817,12 +3817,14 @@ public class UMLOperationBodyMapper implements Comparable<UMLOperationBodyMapper
}
}
}
- if(anonymousClassDeclarations1.size() == 1 && anonymousClassDeclarations2.size() == 0 && operation1 != null && lambdas2.size() == 1) {
+ if(anonymousClassDeclarations1.size() == 1 && anonymousClassDeclarations2.size() == 0 && operation1 != null && lambdas2.size() >= 1) {
AnonymousClassDeclarationObject anonymousClassDeclaration1 = anonymousClassDeclarations1.get(0);
UMLAnonymousClass anonymousClass1 = operation1.findAnonymousClass(anonymousClassDeclaration1);
if(anonymousClass1.getOperations().size() == 1) {
UMLOperation anonymousClass1Operation = anonymousClass1.getOperations().get(0);
- UMLOperationBodyMapper mapper = new UMLOperationBodyMapper(anonymousClass1Operation, lambdas2.get(0), this);
+ for(int i=0; i<lambdas2.size(); i++) {
+ LambdaExpressionObject lambda2 = lambdas2.get(i);
+ UMLOperationBodyMapper mapper = new UMLOperationBodyMapper(anonymousClass1Operation, lambda2, this);
int mappings = mapper.mappingsWithoutBlocks();
if(mappings > 0) {
int nonMappedElementsT1 = mapper.nonMappedElementsT1();
@@ -3835,7 +3837,7 @@ public class UMLOperationBodyMapper implements Comparable<UMLOperationBodyMapper
this.nonMappedLeavesT1.addAll(mapper.nonMappedLeavesT1);
this.nonMappedLeavesT2.addAll(mapper.nonMappedLeavesT2);
if(this.operation1 != null && this.operation2 != null) {
- ReplaceAnonymousWithLambdaRefactoring ref = new ReplaceAnonymousWithLambdaRefactoring(anonymousClass1, lambdas2.get(0), operation1, operation2);
+ ReplaceAnonymousWithLambdaRefactoring ref = new ReplaceAnonymousWithLambdaRefactoring(anonymousClass1, lambda2, operation1, operation2);
this.refactorings.add(ref);
this.refactorings.addAll(mapper.getRefactorings());
}
@@ -3844,6 +3846,7 @@ public class UMLOperationBodyMapper implements Comparable<UMLOperationBodyMapper
}
}
}
+ }
return null;
}
