Skip to content

Commit 4bdaef0

Browse files
committed
Improve conflictingMoveOfTopLevelClass()
junit-team/junit4@877750a
1 parent ef5e9d4 commit 4bdaef0

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

src/main/java/gr/uom/java/xmi/diff/UMLModelDiff.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,14 @@ private boolean conflictingMoveOfTopLevelClass(UMLClass removedClass, UMLClass a
776776
if(!removedClass.isTopLevel() && !addedClass.isTopLevel()) {
777777
//check if classMoveDiffList contains already a move for the outer class to a different target
778778
for(UMLClassMoveDiff diff : classMoveDiffList) {
779+
if(!diff.getOriginalClass().isTopLevel() && !diff.getMovedClass().isTopLevel()) {
780+
String prefix1 = diff.getOriginalClassName().substring(0, diff.getOriginalClassName().lastIndexOf("."));
781+
String prefix2 = diff.getNextClassName().substring(0, diff.getNextClassName().lastIndexOf("."));
782+
UMLClass outerRemovedClass = getRemovedClass(prefix1);
783+
UMLClass outerAddedClass = getAddedClass(prefix2);
784+
if(outerRemovedClass == null || outerAddedClass == null)
785+
continue;
786+
}
779787
if((diff.getOriginalClass().getName().startsWith(removedClass.getPackageName() + ".") &&
780788
!diff.getMovedClass().getName().startsWith(addedClass.getPackageName() + ".")) ||
781789
(!diff.getOriginalClass().getName().startsWith(removedClass.getPackageName() + ".") &&

src/test/java/org/refactoringminer/test/TestAllRefactorings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ public void testAllRefactorings() throws Exception {
1717
GitHistoryRefactoringMinerImpl detector = new GitHistoryRefactoringMinerImpl();
1818
TestBuilder test = new TestBuilder(detector, REPOS, Refactorings.All.getValue());
1919
RefactoringPopulator.feedRefactoringsInstances(Refactorings.All.getValue(), Systems.FSE.getValue(), test);
20-
test.assertExpectationsWithGitHubAPI(12349, 20, 232);
20+
test.assertExpectationsWithGitHubAPI(12351, 20, 232);
2121
}
2222
}

src/test/resources/oracle/data.json

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,8 @@
885885
"type": "Move Method",
886886
"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",
887887
"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",
888-
"validation": "TP",
889-
"detectionTools": "RefactoringMiner, RefDiff, RD-1x, RD-2x",
888+
"validation": "FP",
889+
"detectionTools": "RefDiff, RD-1x, RD-2x",
890890
"validators": "Matin, Davood, Nikos"
891891
}, {
892892
"type": "Move Method",
@@ -1330,15 +1330,36 @@
13301330
"detectionTools": "RefactoringMiner",
13311331
"validators": null
13321332
}, {
1333-
"type": "Move And Rename Method",
1334-
"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",
1333+
"type": "Extract Attribute",
1334+
"description": "Extract Attribute public ARRAY_INTERFACES : GenericTypeList in class net.bytebuddy.description.type.TypeDescription",
13351335
"comment": null,
13361336
"validation": "TP",
13371337
"detectionTools": "RefactoringMiner",
13381338
"validators": null
13391339
}, {
1340-
"type": "Extract Attribute",
1341-
"description": "Extract Attribute public ARRAY_INTERFACES : GenericTypeList in class net.bytebuddy.description.type.TypeDescription",
1340+
"type": "Move And Rename Class",
1341+
"description": "Move And Rename Class net.bytebuddy.dynamic.TargetType.TypeVariableProxy.Extractor moved and renamed to net.bytebuddy.description.type.generic.GenericTypeDescription.Visitor.Substitutor.ForRawType",
1342+
"comment": null,
1343+
"validation": "TP",
1344+
"detectionTools": "RefactoringMiner",
1345+
"validators": null
1346+
}, {
1347+
"type": "Add Class Modifier",
1348+
"description": "Add Class Modifier static in class net.bytebuddy.description.type.generic.GenericTypeDescription.Visitor.Substitutor.ForRawType",
1349+
"comment": null,
1350+
"validation": "TP",
1351+
"detectionTools": "RefactoringMiner",
1352+
"validators": null
1353+
}, {
1354+
"type": "Change Class Access Modifier",
1355+
"description": "Change Class Access Modifier package to public in class net.bytebuddy.description.type.generic.GenericTypeDescription.Visitor.Substitutor.ForRawType",
1356+
"comment": null,
1357+
"validation": "TP",
1358+
"detectionTools": "RefactoringMiner",
1359+
"validators": null
1360+
}, {
1361+
"type": "Add Method Annotation",
1362+
"description": "Add Method Annotation @SuppressWarnings(\"unchecked\") in method public onMethod(methodDescription MethodDescription) : TypeVariableProxy from class net.bytebuddy.description.type.generic.GenericTypeDescription.Visitor.Substitutor.ForRawType",
13421363
"comment": null,
13431364
"validation": "TP",
13441365
"detectionTools": "RefactoringMiner",

src/test/resources/oracle/expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ d9a2c69a9d1db6072e1d7b7ea4fcbd5c15d20b5d, 3, 0, 0
128128
becced5f0b7bac8200df7a5706b568687b517b90, 11, 0, 1
129129
20d39f7af2165c67d5221f556f58820c992d2cc6, 7, 0, 0
130130
3514aaedf9624222c985cb3abb12df2d9b514b12, 13, 0, 0
131-
372f4ae6cebcd664e3b43cade356d1df233f6467, 58, 0, 1
131+
372f4ae6cebcd664e3b43cade356d1df233f6467, 60, 0, 1
132132
cb98ee25ff52bf97faebe3f45cdef0ced9b4416e, 28, 0, 0
133133
1cfc6f64f64353bc5530a8ce8cdacfc3eba3e7b2, 3, 0, 0
134134
b47634176fa48ad925f79886c6aaca225cb9af64, 3, 0, 0

0 commit comments

Comments
 (0)