Skip to content

Commit

Permalink
Use identicalBody information to promote ClassRenameDiff in case of ties
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Dec 8, 2024
1 parent 30a0161 commit 65203a3
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,29 @@ private TreeSet<UMLClassRenameDiff> findRenameMatchesForRemovedClass(UMLClass re
}
}
}
if(diffSet.size() > 1) {
TreeSet<UMLClassRenameDiff> identicalBodyDiffSet = new TreeSet<UMLClassRenameDiff>(new ClassRenameComparator());
for(UMLClassRenameDiff diff : diffSet) {
List<UMLOperation> operations1 = diff.getOriginalClass().getOperations();
List<UMLOperation> operations2 = diff.getNextClass().getOperations();
int identicalBodies = 0;
if(operations1.size() == operations2.size()) {
for(int i=0; i<operations1.size(); i++) {
UMLOperation op1 = operations1.get(i);
UMLOperation op2 = operations2.get(i);
if(op1.getBodyHashCode() == op2.getBodyHashCode()) {
identicalBodies++;
}
}
}
if(identicalBodies == operations1.size()) {
identicalBodyDiffSet.add(diff);
}
}
if(identicalBodyDiffSet.size() == 1) {
return identicalBodyDiffSet;
}
}
return diffSet;
}

Expand Down Expand Up @@ -1097,6 +1120,29 @@ private TreeSet<UMLClassRenameDiff> findRenameMatchesForAddedClass(UMLClass adde
}
}
}
if(diffSet.size() > 1) {
TreeSet<UMLClassRenameDiff> identicalBodyDiffSet = new TreeSet<UMLClassRenameDiff>(new ClassRenameComparator());
for(UMLClassRenameDiff diff : diffSet) {
List<UMLOperation> operations1 = diff.getOriginalClass().getOperations();
List<UMLOperation> operations2 = diff.getNextClass().getOperations();
int identicalBodies = 0;
if(operations1.size() == operations2.size()) {
for(int i=0; i<operations1.size(); i++) {
UMLOperation op1 = operations1.get(i);
UMLOperation op2 = operations2.get(i);
if(op1.getBodyHashCode() == op2.getBodyHashCode()) {
identicalBodies++;
}
}
}
if(identicalBodies == operations1.size()) {
identicalBodyDiffSet.add(diff);
}
}
if(identicalBodyDiffSet.size() == 1) {
return identicalBodyDiffSet;
}
}
return diffSet;
}

Expand Down

0 comments on commit 65203a3

Please sign in to comment.