Skip to content

Commit

Permalink
Final fix for issue #828 (supports attribute moves)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Dec 18, 2024
1 parent 66ed791 commit 363711a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
18 changes: 18 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 @@ -2736,6 +2736,24 @@ private List<Refactoring> getSplitClassRefactorings(List<RenamePackageRefactorin
refactorings.add(move);
refactorings.addAll(mapperRefactorings);
}
for(Pair<UMLAttribute, UMLAttribute> pair : renameDiff.getCommonAtrributes()) {
MoveAttributeRefactoring move = new MoveAttributeRefactoring(pair.getLeft(), pair.getRight());
refactorings.add(move);
}
for(Pair<UMLEnumConstant, UMLEnumConstant> pair : renameDiff.getCommonEnumConstants()) {
MoveAttributeRefactoring move = new MoveAttributeRefactoring(pair.getLeft(), pair.getRight());
refactorings.add(move);
}
for(UMLAttributeDiff attributeDiff : renameDiff.getAttributeDiffList()) {
MoveAttributeRefactoring move = new MoveAttributeRefactoring(attributeDiff.getRemovedAttribute(), attributeDiff.getAddedAttribute());
refactorings.add(move);
refactorings.addAll(attributeDiff.getRefactorings());
}
for(UMLEnumConstantDiff attributeDiff : renameDiff.getEnumConstantDiffList()) {
MoveAttributeRefactoring move = new MoveAttributeRefactoring(attributeDiff.getRemovedEnumConstant(), attributeDiff.getAddedEnumConstant());
refactorings.add(move);
refactorings.addAll(attributeDiff.getRefactorings());
}
}
if(!classSplitDiff.samePackage()) {
RenamePattern renamePattern = refactoring.getRenamePattern();
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(12356, 20, 232);
test.assertExpectationsWithGitHubAPI(12362, 20, 232);
}
}
42 changes: 42 additions & 0 deletions src/test/resources/oracle/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -112058,6 +112058,48 @@
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Move Attribute",
"description": "Move Attribute private TOKEN_VALUE_TO_NAME : String[] from class com.puppycrawl.tools.checkstyle.utils.Utils to private TOKEN_VALUE_TO_NAME : String[] from class com.puppycrawl.tools.checkstyle.utils.TokenUtils",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Move Attribute",
"description": "Move Attribute private PATH_DENORMALIZER : String from class com.puppycrawl.tools.checkstyle.utils.UtilsTest to private PATH_DENORMALIZER : String from class com.puppycrawl.tools.checkstyle.utils.CommonUtilsTest",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Move Attribute",
"description": "Move Attribute private TOKEN_NAME_EXCEPTION_PREFIX : String from class com.puppycrawl.tools.checkstyle.utils.Utils to private TOKEN_NAME_EXCEPTION_PREFIX : String from class com.puppycrawl.tools.checkstyle.utils.TokenUtils",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Move Attribute",
"description": "Move Attribute private TOKEN_ID_EXCEPTION_PREFIX : String from class com.puppycrawl.tools.checkstyle.utils.Utils to private TOKEN_ID_EXCEPTION_PREFIX : String from class com.puppycrawl.tools.checkstyle.utils.TokenUtils",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Move Attribute",
"description": "Move Attribute private TOKEN_IDS : int[] from class com.puppycrawl.tools.checkstyle.utils.Utils to private TOKEN_IDS : int[] from class com.puppycrawl.tools.checkstyle.utils.TokenUtils",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Move Attribute",
"description": "Move Attribute private TOKEN_NAME_TO_VALUE : ImmutableMap<String,Integer> from class com.puppycrawl.tools.checkstyle.utils.Utils to private TOKEN_NAME_TO_VALUE : ImmutableMap<String,Integer> from class com.puppycrawl.tools.checkstyle.utils.TokenUtils",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}],
"refDiffExecutionTime": null
}, {
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 @@ -394,7 +394,7 @@ c9c475a6c7a8cb728ba1c091b386db46f11a781f, 2, 0, 0
0a1a4c6e94c9b3b73b21b323f14ae7b7337b1b44, 4, 0, 0
a07cae0aca9f9072256b3a5fd05779e8d69b9748, 8, 0, 0
febbc986cb25ed460ea601c0a68c7d2597f89ee4, 3, 0, 0
cdf3e56bacd3895262af8a1df9ca5c81f4071970, 54, 0, 0
cdf3e56bacd3895262af8a1df9ca5c81f4071970, 60, 0, 0
de022d2434e58dd633fd50a7f9bb50565a8767b5, 83, 0, 0
9d44f0e06232661259681d64002dd53c7c43099d, 11, 0, 0
b6565814805dfb2d989be25c11d4fb4cf8fb1d84, 10, 0, 0
Expand Down

0 comments on commit 363711a

Please sign in to comment.