Skip to content

Commit

Permalink
Improvement over previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Oct 20, 2024
1 parent 8ee773e commit 3bf9a06
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5805,7 +5805,11 @@ else if(pMapping.getFragment1().getLocationInfo().getStartLine() >= first.getFra
if(!mappingSet.isEmpty()) {
Pair<CompositeStatementObject, CompositeStatementObject> switchParentEntry = null;
Map<LeafMapping, Pair<CompositeStatementObject, CompositeStatementObject>> catchBlockMap = null;
if((switchParentEntry = multipleMappingsUnderTheSameSwitch(mappingSet)) != null) {
if(variableDeclarationMappingsWithSameReplacementTypes(mappingSet)) {
//postpone mapping
postponedMappingSets.add(mappingSet);
}
else if((switchParentEntry = multipleMappingsUnderTheSameSwitch(mappingSet)) != null) {
LeafMapping bestMapping = findBestMappingBasedOnMappedSwitchCases(switchParentEntry, mappingSet);
if(canBeAdded(bestMapping, parameterToArgumentMap)) {
addToMappings(bestMapping, mappingSet);
Expand Down Expand Up @@ -8484,7 +8488,20 @@ else if(mapping.getReplacementTypes().containsAll(replacementTypes) || replaceme
return false;
}
if(mappingsWithSameReplacementTypes.size() == mappingSet.size()) {
return true;
List<VariableScope> scopes = new ArrayList<VariableScope>();
for(LeafMapping m : mappingsWithSameReplacementTypes) {
scopes.add(m.getFragment2().getVariableDeclarations().get(0).getScope());
}
int overlaps = 0;
for(int i=0; i<scopes.size(); i++) {
for(int j=i+1; j<scopes.size(); j++) {
if(scopes.get(i).overlaps(scopes.get(j))) {
overlaps++;
}
}
}
if(overlaps > 0)
return true;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,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(12274, 20, 232);
test.assertExpectationsWithGitHubAPI(12290, 20, 232);
}
}
112 changes: 112 additions & 0 deletions src/test/resources/oracle/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -82573,6 +82573,118 @@
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Move And Rename Method",
"description": "Move And Rename Method public readLong() : long from class com.hazelcast.internal.metrics.impl.GaugeImpl to public read() : long from class com.hazelcast.internal.metrics.impl.LongGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Move And Rename Method",
"description": "Move And Rename Method public readDouble() : double from class com.hazelcast.internal.metrics.impl.GaugeImpl to public read() : double from class com.hazelcast.internal.metrics.impl.DoubleGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Change Variable Type",
"description": "Change Variable Type longInput : LongProbe<S> to longFunction : LongProbeFunction in method public read() : long from class com.hazelcast.internal.metrics.impl.LongGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Change Variable Type",
"description": "Change Variable Type source : S to source : Object in method public read() : long from class com.hazelcast.internal.metrics.impl.LongGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Change Variable Type",
"description": "Change Variable Type doubleInput : DoubleProbe<S> to doubleFunction : DoubleProbeFunction in method public read() : double from class com.hazelcast.internal.metrics.impl.DoubleGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Change Variable Type",
"description": "Change Variable Type source : S to source : Object in method public read() : double from class com.hazelcast.internal.metrics.impl.DoubleGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Change Variable Type",
"description": "Change Variable Type longInput : LongProbe<S> to longFunction : LongProbeFunction in method public read() : double from class com.hazelcast.internal.metrics.impl.DoubleGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Change Variable Type",
"description": "Change Variable Type doubleInput : DoubleProbe<S> to doubleFunction : DoubleProbeFunction in method public read() : long from class com.hazelcast.internal.metrics.impl.LongGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Change Variable Type",
"description": "Change Variable Type input : Object to function : ProbeFunction in method public read() : double from class com.hazelcast.internal.metrics.impl.DoubleGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Change Variable Type",
"description": "Change Variable Type input : Object to function : ProbeFunction in method public read() : long from class com.hazelcast.internal.metrics.impl.LongGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Rename Variable",
"description": "Rename Variable longInput : LongProbe<S> to longFunction : LongProbeFunction in method public read() : long from class com.hazelcast.internal.metrics.impl.LongGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Rename Variable",
"description": "Rename Variable doubleInput : DoubleProbe<S> to doubleFunction : DoubleProbeFunction in method public read() : double from class com.hazelcast.internal.metrics.impl.DoubleGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Rename Variable",
"description": "Rename Variable input : Object to function : ProbeFunction in method public read() : long from class com.hazelcast.internal.metrics.impl.LongGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Rename Variable",
"description": "Rename Variable doubleInput : DoubleProbe<S> to doubleFunction : DoubleProbeFunction in method public read() : long from class com.hazelcast.internal.metrics.impl.LongGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Rename Variable",
"description": "Rename Variable longInput : LongProbe<S> to longFunction : LongProbeFunction in method public read() : double from class com.hazelcast.internal.metrics.impl.DoubleGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Rename Variable",
"description": "Rename Variable input : Object to function : ProbeFunction in method public read() : double from class com.hazelcast.internal.metrics.impl.DoubleGaugeImpl",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}],
"refDiffExecutionTime": 5604
}, {
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 @@ -250,7 +250,7 @@ ce4b0e22659c16ae83d421f9621fd3e922750764, 2, 0, 0
72dda3404820a82d53f1a16bb2ed9ad95f745d3c, 6, 0, 0
35b6c869546a7968b6fd2f640add6eea87e03c22, 78, 0, 2
4184c577f4bbc57f3ac13639557cfd99cdaca3e7, 4, 0, 0
30c4ae09745d6062077925a54f27205b7401d8df, 270, 0, 4
30c4ae09745d6062077925a54f27205b7401d8df, 286, 0, 4
03573a655bcbb77f7a76d8e22d851cc22796b4f8, 3, 0, 0
043030723632627b0908dca6b24dae91d3dfd938, 10, 0, 0
e3b0d87b3ca0fd27cec39937cb3dc3a05b0cfc4e, 4, 0, 0
Expand Down

0 comments on commit 3bf9a06

Please sign in to comment.