Skip to content

Commit

Permalink
Eliminate False positive overlapping refactoring after discarding
Browse files Browse the repository at this point in the history
Extract and Move Method refactoring
apache/hadoop@58afe43
  • Loading branch information
tsantalis committed Feb 6, 2025
1 parent 77e5715 commit c7f80f5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
7 changes: 6 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 @@ -4905,19 +4905,24 @@ private void createExtractAndMoveMethodRefactoring(UMLOperation addedOperation,
ExtractOperationRefactoring extractOperationRefactoring =
new ExtractOperationRefactoring(operationBodyMapper, mapper.getContainer2(), addedOperationInvocations);
refactorings.add(extractOperationRefactoring);
refactorings.addAll(operationBodyMapper.getRefactorings());
//compute refactorings
operationBodyMapper.getRefactorings();
deleteAddedOperation(addedOperation);
mapper.addChildMapper(operationBodyMapper);
if(!nested) {
MappingOptimizer optimizer = new MappingOptimizer(mapper.getClassDiff());
optimizer.optimizeDuplicateMappingsForExtract(mapper, refactorings);
refactorings.addAll(operationBodyMapper.getRefactoringsAfterPostProcessing());

Set<UMLOperationBodyMapper> mappers = findMappersWithTheSameFragment1(operationBodyMapper.getMappings());
if(mappers.size() > 0) {
mappers.add(operationBodyMapper);
optimizer.optimizeDuplicateMappingsForMoveCode(new ArrayList<>(mappers), refactorings);
}
}
else {
refactorings.addAll(operationBodyMapper.getRefactoringsAfterPostProcessing());
}
}

private UMLOperationBodyMapper createMapperForExtractAndMove(UMLOperation addedOperation,
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(12417, 16, 226);
test.assertExpectationsWithGitHubAPI(12416, 16, 226);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public void testAllRefactorings() throws Exception {
.or(Refactorings.SplitMethod.getValue());
TestBuilder test = new TestBuilder(detector, REPOS, types);
RefactoringPopulator.feedTSERefactoringInstances(test);
test.assertExpectationsWithGitHubAPI(2987, 253, 387);
test.assertExpectationsWithGitHubAPI(2987, 252, 387);
}
}
7 changes: 0 additions & 7 deletions src/test/resources/oracle/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -79728,13 +79728,6 @@
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Rename Parameter",
"description": "Rename Parameter stackName : String to name : String in method public pathElement(name String) : PathElement from class org.infinispan.server.jgroups.subsystem.StackResourceDefinition",
"comment": "<p>Extract And Move Method</p>",
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": "Nikos"
}, {
"type": "Extract Variable",
"description": "Extract Variable config : ProtocolConfiguration in method package createProtocols(stack ProtocolStackConfiguration, multicastCapable boolean) : List<org.jgroups.conf.ProtocolConfiguration> from class org.infinispan.server.jgroups.JChannelFactory",
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 @@ -380,7 +380,7 @@ eb500cca282e39d01a9882e1d0a83186da6d1a26, 3, 0, 0
8707194f003444a9fb8e00bffa2893ef0c2492c6, 4, 0, 0
f36b736cf1206dd1af794d6fb4cee967a3553b1f, 1, 0, 0
d403a0b2322a74dde824094d67b7997c1c371883, 4, 0, 1
8f446b6ddf540e1b1fefca34dd10f45ba7256095, 341, 3, 19
8f446b6ddf540e1b1fefca34dd10f45ba7256095, 340, 3, 19
0bb4cca1105fc6eb86e7c4b75bfff3dbbd55f0c8, 4, 0, 0
c142b8ca3e9f9467931987ee16805cf53e6bc5d2, 5, 0, 0
d7f781da42e54824c17875a6036d3448672637f5, 10, 0, 0
Expand Down

0 comments on commit c7f80f5

Please sign in to comment.