Skip to content

Commit

Permalink
Improve conflictingMoveOfTopLevelClass()
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Dec 16, 2024
1 parent ef5e9d4 commit 4bdaef0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
8 changes: 8 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 @@ -776,6 +776,14 @@ private boolean conflictingMoveOfTopLevelClass(UMLClass removedClass, UMLClass a
if(!removedClass.isTopLevel() && !addedClass.isTopLevel()) {
//check if classMoveDiffList contains already a move for the outer class to a different target
for(UMLClassMoveDiff diff : classMoveDiffList) {
if(!diff.getOriginalClass().isTopLevel() && !diff.getMovedClass().isTopLevel()) {
String prefix1 = diff.getOriginalClassName().substring(0, diff.getOriginalClassName().lastIndexOf("."));
String prefix2 = diff.getNextClassName().substring(0, diff.getNextClassName().lastIndexOf("."));
UMLClass outerRemovedClass = getRemovedClass(prefix1);
UMLClass outerAddedClass = getAddedClass(prefix2);
if(outerRemovedClass == null || outerAddedClass == null)
continue;
}
if((diff.getOriginalClass().getName().startsWith(removedClass.getPackageName() + ".") &&
!diff.getMovedClass().getName().startsWith(addedClass.getPackageName() + ".")) ||
(!diff.getOriginalClass().getName().startsWith(removedClass.getPackageName() + ".") &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public void testAllRefactorings() throws Exception {
GitHistoryRefactoringMinerImpl detector = new GitHistoryRefactoringMinerImpl();
TestBuilder test = new TestBuilder(detector, REPOS, Refactorings.All.getValue());
RefactoringPopulator.feedRefactoringsInstances(Refactorings.All.getValue(), Systems.FSE.getValue(), test);
test.assertExpectationsWithGitHubAPI(12349, 20, 232);
test.assertExpectationsWithGitHubAPI(12351, 20, 232);
}
}
33 changes: 27 additions & 6 deletions src/test/resources/oracle/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,8 @@
"type": "Move Method",
"description": "Move Method public onType(typeDescription TypeDescription) : TypeVariableProxy from class net.bytebuddy.dynamic.TargetType.TypeVariableProxy.Extractor to public onType(typeDescription TypeDescription) : TypeVariableProxy from class net.bytebuddy.description.type.generic.GenericTypeDescription.Visitor.Substitutor.ForRawType",
"comment": "Second Opinion, Seems FP since the Extractor is removerd and ForRawType is a new class. Moreover the method is the same since both class implement the same extends the same class | Davood: If you accept moving from a class which no longer exists to a new class, this is TP. Otherwise FP. However, I would mark the entire thing as a rename class. All the methods/attributes of the removed class is being repeated (with small modifications) in the new class. Matin, Davood: FP, condidate move and rename class",
"validation": "TP",
"detectionTools": "RefactoringMiner, RefDiff, RD-1x, RD-2x",
"validation": "FP",
"detectionTools": "RefDiff, RD-1x, RD-2x",
"validators": "Matin, Davood, Nikos"
}, {
"type": "Move Method",
Expand Down Expand Up @@ -1330,15 +1330,36 @@
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Move And Rename Method",
"description": "Move And Rename Method public Extractor(substitute TypeDescription, substitutionMatcher ElementMatcher<? super TypeDescription>) from class net.bytebuddy.dynamic.TargetType.TypeVariableProxy.Extractor to protected ForRawType(substitute TypeDescription, substitutionMatcher ElementMatcher<? super TypeDescription>) from class net.bytebuddy.description.type.generic.GenericTypeDescription.Visitor.Substitutor.ForRawType",
"type": "Extract Attribute",
"description": "Extract Attribute public ARRAY_INTERFACES : GenericTypeList in class net.bytebuddy.description.type.TypeDescription",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Extract Attribute",
"description": "Extract Attribute public ARRAY_INTERFACES : GenericTypeList in class net.bytebuddy.description.type.TypeDescription",
"type": "Move And Rename Class",
"description": "Move And Rename Class net.bytebuddy.dynamic.TargetType.TypeVariableProxy.Extractor moved and renamed to net.bytebuddy.description.type.generic.GenericTypeDescription.Visitor.Substitutor.ForRawType",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Add Class Modifier",
"description": "Add Class Modifier static in class net.bytebuddy.description.type.generic.GenericTypeDescription.Visitor.Substitutor.ForRawType",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Change Class Access Modifier",
"description": "Change Class Access Modifier package to public in class net.bytebuddy.description.type.generic.GenericTypeDescription.Visitor.Substitutor.ForRawType",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Add Method Annotation",
"description": "Add Method Annotation @SuppressWarnings(\"unchecked\") in method public onMethod(methodDescription MethodDescription) : TypeVariableProxy from class net.bytebuddy.description.type.generic.GenericTypeDescription.Visitor.Substitutor.ForRawType",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/oracle/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ d9a2c69a9d1db6072e1d7b7ea4fcbd5c15d20b5d, 3, 0, 0
becced5f0b7bac8200df7a5706b568687b517b90, 11, 0, 1
20d39f7af2165c67d5221f556f58820c992d2cc6, 7, 0, 0
3514aaedf9624222c985cb3abb12df2d9b514b12, 13, 0, 0
372f4ae6cebcd664e3b43cade356d1df233f6467, 58, 0, 1
372f4ae6cebcd664e3b43cade356d1df233f6467, 60, 0, 1
cb98ee25ff52bf97faebe3f45cdef0ced9b4416e, 28, 0, 0
1cfc6f64f64353bc5530a8ce8cdacfc3eba3e7b2, 3, 0, 0
b47634176fa48ad925f79886c6aaca225cb9af64, 3, 0, 0
Expand Down

0 comments on commit 4bdaef0

Please sign in to comment.