From 7030c18c9a9ac5993830f2db3c15a1bea59581b0 Mon Sep 17 00:00:00 2001 From: tsantalis Date: Fri, 3 Jan 2025 21:53:21 -0500 Subject: [PATCH] Enable detection of Rename Class refactoring in commit https://github.com/mockito/mockito/commit/73a861f778e117ad0ccd7388b8d7a614e65c1623 Rename Class org.mockito.internal.debugging.LocationImpl renamed to org.mockito.internal.debugging.Java8LocationImpl --- .../gr/uom/java/xmi/diff/UMLModelDiff.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java b/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java index 5d02ab9ba..d3526c884 100644 --- a/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java +++ b/src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java @@ -1138,6 +1138,7 @@ private TreeSet optimize(TreeSet diffSet TreeSet identicalSignatureDiffSet = new TreeSet(new ClassRenameComparator()); TreeSet identicalPackageDeclarationDocDiffSet = new TreeSet(new ClassRenameComparator()); TreeMap> matchingStatementMap = new TreeMap>(); + TreeMap> identicalMethodMap = new TreeMap>(); for(UMLClassRenameDiff diff : diffSet) { if(diff.getOriginalClass().getPackageDeclarationJavadoc() != null && diff.getNextClass().getPackageDeclarationJavadoc() != null) { if(diff.getOriginalClass().getPackageDeclarationJavadoc().getFullText().equals(diff.getNextClass().getPackageDeclarationJavadoc().getFullText())) { @@ -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 set = new TreeSet(new ClassRenameComparator()); + set.add(diff); + identicalMethodMap.put(count, set); + } + } if(identicalBodies == operations1.size()) { identicalBodyDiffSet.add(diff); } @@ -1224,7 +1236,12 @@ else if(identicalBodyDiffSet.size() < diffSet.size() && identicalStatementDiffSe return identicalPackageDeclarationDocDiffSet; } Map.Entry> 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> firstEntry = identicalMethodMap.firstEntry(); + if(entry != null && entry.getKey() > 0 && firstEntry.getKey() == 0 && entry.getValue().size() == 1) { return entry.getValue(); } }