Skip to content

Commit

Permalink
Enable detection of Rename Class refactoring in commit
Browse files Browse the repository at this point in the history
mockito/mockito@73a861f
Rename Class	org.mockito.internal.debugging.LocationImpl renamed to org.mockito.internal.debugging.Java8LocationImpl
  • Loading branch information
tsantalis committed Jan 4, 2025
1 parent 93b8d9d commit 7030c18
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,7 @@ private TreeSet<UMLClassRenameDiff> optimize(TreeSet<UMLClassRenameDiff> diffSet
TreeSet<UMLClassRenameDiff> identicalSignatureDiffSet = new TreeSet<UMLClassRenameDiff>(new ClassRenameComparator());
TreeSet<UMLClassRenameDiff> identicalPackageDeclarationDocDiffSet = new TreeSet<UMLClassRenameDiff>(new ClassRenameComparator());
TreeMap<Integer, TreeSet<UMLClassRenameDiff>> matchingStatementMap = new TreeMap<Integer, TreeSet<UMLClassRenameDiff>>();
TreeMap<Integer, TreeSet<UMLClassRenameDiff>> identicalMethodMap = new TreeMap<Integer, TreeSet<UMLClassRenameDiff>>();
for(UMLClassRenameDiff diff : diffSet) {
if(diff.getOriginalClass().getPackageDeclarationJavadoc() != null && diff.getNextClass().getPackageDeclarationJavadoc() != null) {
if(diff.getOriginalClass().getPackageDeclarationJavadoc().getFullText().equals(diff.getNextClass().getPackageDeclarationJavadoc().getFullText())) {
Expand Down Expand Up @@ -1201,6 +1202,17 @@ else if(op1.getBody() != null && op2.getBody() != null) {
matchingStatementMap.put(matchingStatements, set);
}
}
else {
int count = diff.getMatchResult().getIdenticalBodyOperations();
if(identicalMethodMap.containsKey(count)) {
identicalMethodMap.get(count).add(diff);
}
else {
TreeSet<UMLClassRenameDiff> set = new TreeSet<UMLClassRenameDiff>(new ClassRenameComparator());
set.add(diff);
identicalMethodMap.put(count, set);
}
}
if(identicalBodies == operations1.size()) {
identicalBodyDiffSet.add(diff);
}
Expand All @@ -1224,7 +1236,12 @@ else if(identicalBodyDiffSet.size() < diffSet.size() && identicalStatementDiffSe
return identicalPackageDeclarationDocDiffSet;
}
Map.Entry<Integer, TreeSet<UMLClassRenameDiff>> entry = matchingStatementMap.lastEntry();
if(entry != null && entry.getValue().size() == 1) {
if(entry != null && entry.getKey() > 0 && entry.getValue().size() == 1) {
return entry.getValue();
}
entry = identicalMethodMap.lastEntry();
Map.Entry<Integer, TreeSet<UMLClassRenameDiff>> firstEntry = identicalMethodMap.firstEntry();
if(entry != null && entry.getKey() > 0 && firstEntry.getKey() == 0 && entry.getValue().size() == 1) {
return entry.getValue();
}
}
Expand Down

0 comments on commit 7030c18

Please sign in to comment.