Skip to content

Commit

Permalink
Avoid duplicate MethodReference objects in getAllOperationInvocations()
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Dec 24, 2024
1 parent 31e727e commit aee92cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,9 @@ else if(statement instanceof StatementObject) {
StatementObject statementObject = (StatementObject)statement;
list.addAll(statementObject.getMethodInvocations());
for(LambdaExpressionObject lambda : statementObject.getLambdas()) {
list.addAll(lambda.getAllOperationInvocations());
if(lambda.getString().contains(JAVA.LAMBDA_ARROW)) {
list.addAll(lambda.getAllOperationInvocations());
}
}
for(AnonymousClassDeclarationObject anonymous : statementObject.getAnonymousClassDeclarations()) {
list.addAll(anonymous.getMethodInvocations());
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -3807,14 +3807,16 @@ private void checkForMovedAndInlinedOperations(List<UMLOperationBodyMapper> mapp
removedOperationInvocations.add(invocation);
}
}
for(AbstractCodeMapping mapping : mapper.getMappings()) {
if(mapping.isExact() && mapping.getReplacementsInvolvingMethodInvocation().isEmpty()) {
for(AbstractCall invocation : mapping.getFragment1().getMethodInvocations()) {
for(ListIterator<AbstractCall> iterator = removedOperationInvocations.listIterator(); iterator.hasNext();) {
AbstractCall matchingInvocation = iterator.next();
if(invocation == matchingInvocation || invocation.actualString().equals(matchingInvocation.actualString())) {
iterator.remove();
break;
if(removedOperationInvocations.size() > 0) {
for(AbstractCodeMapping mapping : mapper.getMappings()) {
if(mapping.isExact() && mapping.getReplacementsInvolvingMethodInvocation().isEmpty()) {
for(AbstractCall invocation : mapping.getFragment1().getMethodInvocations()) {
for(ListIterator<AbstractCall> iterator = removedOperationInvocations.listIterator(); iterator.hasNext();) {
AbstractCall matchingInvocation = iterator.next();
if(invocation == matchingInvocation || invocation.actualString().equals(matchingInvocation.actualString())) {
iterator.remove();
break;
}
}
}
}
Expand Down

0 comments on commit aee92cb

Please sign in to comment.