Skip to content

Commit

Permalink
Fix false positives in inferClassRenameBasedOnFilePaths() when the
Browse files Browse the repository at this point in the history
UMLClassRenameDiff used for inference corresponds to inner classes
junit-team/junit5@89a0201
  • Loading branch information
tsantalis committed Jan 15, 2025
1 parent f6d8175 commit 66f2733
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/gr/uom/java/xmi/UMLAbstractClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,9 @@ else if(operation.isConstructor() && commonTokens >= Math.max(tokens1.length, to
if(commonOperations.size() > Math.floor(totalOperations/2.0) || commonOperations.containsAll(this.operations)) {
return new MatchResult(commonOperations.size(), commonAttributes.size(), identicalOperations.size(), totalOperations, totalAttributes, true);
}
else if(commonAttributes.size() == totalAttributes && totalAttributes > 0 && commonOperations.size() > 0) {
return new MatchResult(commonOperations.size(), commonAttributes.size(), identicalOperations.size(), totalOperations, totalAttributes, true);
}
else {
return new MatchResult(commonOperations.size(), commonAttributes.size(), identicalOperations.size(), totalOperations, totalAttributes, false);
}
Expand Down
3 changes: 2 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 @@ -1272,7 +1272,8 @@ public void inferClassRenameBasedOnFilePaths(UMLClassMatcher matcher) throws Ref
UMLClass addedClass = addedClassIterator.next();
String addedClassFilePath = addedClass.getSourceFile();
for(UMLClassRenameDiff classRenameDiff : classRenameDiffList) {
if(classRenameDiff.getOriginalClass().getSourceFile().equals(removedClassFilePath) &&
if(classRenameDiff.getOriginalClass().isTopLevel() && classRenameDiff.getNextClass().isTopLevel() &&
classRenameDiff.getOriginalClass().getSourceFile().equals(removedClassFilePath) &&
classRenameDiff.getNextClass().getSourceFile().equals(addedClassFilePath)) {
MatchResult matchResult = matcher.match(removedClass, addedClass);
if(matchResult.getMatchedOperations() > 0 || matchResult.getMatchedAttributes() > 0) {
Expand Down

0 comments on commit 66f2733

Please sign in to comment.