Skip to content

Commit

Permalink
Handle Merge Method in okhttp-JavaNetAuthenticator-authenticate.json
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Nov 11, 2024
1 parent f5f8622 commit ca71dc7
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 122 deletions.
34 changes: 34 additions & 0 deletions src/main/java/org/codetracker/BlockTrackerChangeHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ else if (mapping instanceof LeafMapping && mapping.getFragment1() instanceof Sta
Method methodAfter = Method.of(mergeOperationRefactoring.getNewMethodAfterMerge(), currentVersion);
if (equalMethod.test(methodAfter)) {
int mergeMatches = 0;
AbstractCodeFragment fragment2 = null;
int fragment2Matches = 0;
for (UMLOperationBodyMapper bodyMapper : mergeOperationRefactoring.getMappers()) {
for (AbstractCodeMapping mapping : bodyMapper.getMappings()) {
if (mapping instanceof CompositeStatementObjectMapping) {
Expand Down Expand Up @@ -491,10 +493,42 @@ else if (mapping instanceof LeafMapping && mapping.getFragment1() instanceof Sta
}
}
}
for (CompositeStatementObject composite : bodyMapper.getNonMappedInnerNodesT2()) {
Block blockAfter = Block.of(composite, bodyMapper.getContainer2(), currentVersion);
if (blockAfter.equalIdentifierIgnoringVersion(rightBlock)) {
if (fragment2 == null) {
fragment2 = composite;
}
else if (fragment2.equals(composite)) {
fragment2Matches++;
}
}
}
for (AbstractCodeFragment fragment : bodyMapper.getNonMappedLeavesT2()) {
if (fragment instanceof StatementObject) {
Block blockAfter = Block.of((StatementObject) fragment, bodyMapper.getContainer2(), currentVersion);
if (blockAfter.equalIdentifierIgnoringVersion(rightBlock)) {
if (fragment2 == null) {
fragment2 = fragment;
}
else if (fragment2.equals(fragment)) {
fragment2Matches++;
}
}
}
}
}
if(mergeMatches > 0) {
return true;
}
if(fragment2 != null && mergeOperationRefactoring.getMappers().size() == fragment2Matches + 1) {
Block blockBefore = Block.of(fragment2 instanceof StatementObject ? (StatementObject) fragment2 : (CompositeStatementObject) fragment2, mergeOperationRefactoring.getNewMethodAfterMerge(), parentVersion);
Block blockAfter = Block.of(fragment2 instanceof StatementObject ? (StatementObject) fragment2 : (CompositeStatementObject) fragment2, mergeOperationRefactoring.getNewMethodAfterMerge(), currentVersion);
blockChangeHistory.handleAdd(blockBefore, blockAfter, "new block");
elements.add(blockBefore);
blockChangeHistory.connectRelatedNodes();
return true;
}
}
break;
}
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/org/codetracker/BlockTrackerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ else if (leftOperation instanceof UMLInitializer && rightOperation instanceof UM
{
//Local Refactoring
List<Refactoring> refactorings = umlModelDiffLocal.getRefactorings();
boolean found = changeHistory.checkForExtractionOrInline(currentVersion, parentVersion, equalMethod, rightBlock, refactorings);
boolean found = changeHistory.isMergeMultiMapping(currentVersion, parentVersion, equalMethod, rightBlock, refactorings);
if (found) {
historyReport.step4PlusPlus();
break;
}
found = changeHistory.checkForExtractionOrInline(currentVersion, parentVersion, equalMethod, rightBlock, refactorings);
if (found) {
historyReport.step4PlusPlus();
break;
Expand Down Expand Up @@ -435,7 +440,12 @@ else if (leftOperation instanceof UMLInitializer && rightOperation instanceof UM
{
//Local Refactoring
List<Refactoring> refactorings = umlModelDiffLocal.getRefactorings();
boolean found = changeHistory.checkForExtractionOrInline(currentVersion, parentVersion, equalMethod, rightBlock, refactorings);
boolean found = changeHistory.isMergeMultiMapping(currentVersion, parentVersion, equalMethod, rightBlock, refactorings);
if (found) {
historyReport.step4PlusPlus();
break;
}
found = changeHistory.checkForExtractionOrInline(currentVersion, parentVersion, equalMethod, rightBlock, refactorings);
if (found) {
historyReport.step4PlusPlus();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ else if (leftOperation instanceof UMLInitializer && rightOperation instanceof UM
{
//Local Refactoring
List<Refactoring> refactorings = umlModelDiffLocal.getRefactorings();
boolean found = changeHistory.checkForExtractionOrInline(currentVersion, parentVersion, equalMethod, rightBlock, refactorings);
boolean found = changeHistory.isMergeMultiMapping(currentVersion, parentVersion, equalMethod, rightBlock, refactorings);
if (found) {
historyReport.step4PlusPlus();
break;
}
found = changeHistory.checkForExtractionOrInline(currentVersion, parentVersion, equalMethod, rightBlock, refactorings);
if (found) {
historyReport.step4PlusPlus();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,52 +25,23 @@
"parentCommitId": "9ecff8f961c321098c2598097fb5289e968ef1ac",
"commitId": "0bfd6048574d61c138fd417051ae2a1bcb44638f",
"commitTime": 1450450613,
"changeType": "body change",
"changeType": "introduced",
"elementFileBefore": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$for(63-78)",
"elementNameBefore": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Proxy, Response)$for(41-54)",
"elementFileAfter": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Route, Response)$for(45-68)"
},
{
"parentCommitId": "ee3114d07c9ca89a00f4c1028b70fc2fab184301",
"commitId": "c07f55ac92d1e931260711edae987b51bee0be3d",
"commitTime": 1450157856,
"changeType": "body change",
"elementFileBefore": "okhttp/src/main/java/com/squareup/okhttp/internal/http/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/com.squareup.okhttp.internal.http.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$for(63-78)",
"elementFileAfter": "okhttp/src/main/java/com/squareup/okhttp/internal/http/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/com.squareup.okhttp.internal.http.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$for(63-78)"
},
{
"parentCommitId": "a52c510810f896fcafa78033b29148b49c7db7ca",
"commitId": "4c90a2e04a83646597a506a80b5a885d5c515bf0",
"commitTime": 1438563686,
"changeType": "body change",
"elementFileBefore": "okhttp/src/main/java/com/squareup/okhttp/internal/http/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/com.squareup.okhttp.internal.http.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$for(65-80)",
"elementFileAfter": "okhttp/src/main/java/com/squareup/okhttp/internal/http/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/com.squareup.okhttp.internal.http.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$for(63-78)"
"elementNameAfter": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Route, Response)$for(45-68)",
"comment": "Merge Method [public authenticate(proxy Proxy, response Response) : Request, public authenticateProxy(proxy Proxy, response Response) : Request] to public authenticate(route Route, response Response) : Request in class okhttp3.internal.http.AuthenticatorAdapter"
},
{
"parentCommitId": "b6d8f809e33d989895a49c9454c4a492119d344c",
"commitId": "d111f4cd19d3d69558dd2186d778efb69b90b1e3",
"commitTime": 1399736107,
"changeType": "body change",
"elementFileBefore": "okhttp/src/main/java/com/squareup/okhttp/internal/huc/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/com.squareup.okhttp.internal.huc.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$for(63-78)",
"elementFileAfter": "okhttp/src/main/java/com/squareup/okhttp/internal/huc/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/com.squareup.okhttp.internal.huc.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$for(63-78)"
},
{
"parentCommitId": "f5111c28356431c6c5d1e71dd1bbced9a8016cd8",
"commitId": "e920196fbd71822fc284ab76204bf75f95d3265a",
"commitTime": 1398096023,
"parentCommitId": "9ecff8f961c321098c2598097fb5289e968ef1ac",
"commitId": "0bfd6048574d61c138fd417051ae2a1bcb44638f",
"commitTime": 1450450613,
"changeType": "introduced",
"elementFileBefore": "okhttp/src/main/java/com/squareup/okhttp/internal/huc/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/com.squareup.okhttp.internal.huc.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$for(63-78)",
"elementFileAfter": "okhttp/src/main/java/com/squareup/okhttp/internal/huc/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/com.squareup.okhttp.internal.huc.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$for(63-78)",
"comment": "added with method"
"elementFileBefore": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$for(63-78)",
"elementFileAfter": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Route, Response)$for(45-68)",
"comment": "Merge Method [public authenticate(proxy Proxy, response Response) : Request, public authenticateProxy(proxy Proxy, response Response) : Request] to public authenticate(route Route, response Response) : Request in class okhttp3.internal.http.AuthenticatorAdapter"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,23 @@
"parentCommitId": "9ecff8f961c321098c2598097fb5289e968ef1ac",
"commitId": "0bfd6048574d61c138fd417051ae2a1bcb44638f",
"commitTime": 1450450613,
"changeType": "expression change",
"changeType": "introduced",
"elementFileBefore": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$if(72-72)",
"elementNameBefore": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Proxy, Response)$if(48-48)",
"elementFileAfter": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Route, Response)$if(62-67)"
"elementNameAfter": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Route, Response)$if(62-67)",
"comment": "Merge Method [public authenticate(proxy Proxy, response Response) : Request, public authenticateProxy(proxy Proxy, response Response) : Request] to public authenticate(route Route, response Response) : Request in class okhttp3.internal.http.AuthenticatorAdapter"
},
{
"parentCommitId": "9ecff8f961c321098c2598097fb5289e968ef1ac",
"commitId": "0bfd6048574d61c138fd417051ae2a1bcb44638f",
"commitTime": 1450450613,
"changeType": "body change",
"changeType": "introduced",
"elementFileBefore": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$if(72-72)",
"elementFileAfter": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Route, Response)$if(62-67)"
},
{
"parentCommitId": "f5111c28356431c6c5d1e71dd1bbced9a8016cd8",
"commitId": "e920196fbd71822fc284ab76204bf75f95d3265a",
"commitTime": 1398096023,
"changeType": "introduced",
"elementFileBefore": "okhttp/src/main/java/com/squareup/okhttp/internal/huc/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/com.squareup.okhttp.internal.huc.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$if(72-72)",
"elementFileAfter": "okhttp/src/main/java/com/squareup/okhttp/internal/huc/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/com.squareup.okhttp.internal.huc.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$if(72-72)",
"comment": "added with method"
"elementNameAfter": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Route, Response)$if(62-67)",
"comment": "Merge Method [public authenticate(proxy Proxy, response Response) : Request, public authenticateProxy(proxy Proxy, response Response) : Request] to public authenticate(route Route, response Response) : Request in class okhttp3.internal.http.AuthenticatorAdapter"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,26 @@
"startCommitId": "8e2116fddcc1f9ad2b15d03fbc8918e30831d6a2",
"expectedChanges": [
{
"parentCommitId": "ee3114d07c9ca89a00f4c1028b70fc2fab184301",
"commitId": "c07f55ac92d1e931260711edae987b51bee0be3d",
"commitTime": 1450157856,
"changeType": "expression change",
"elementFileBefore": "okhttp/src/main/java/com/squareup/okhttp/internal/http/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/com.squareup.okhttp.internal.http.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$if(65-65)",
"elementFileAfter": "okhttp/src/main/java/com/squareup/okhttp/internal/http/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/com.squareup.okhttp.internal.http.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$if(65-65)"
"parentCommitId": "9ecff8f961c321098c2598097fb5289e968ef1ac",
"commitId": "0bfd6048574d61c138fd417051ae2a1bcb44638f",
"commitTime": 1450450613,
"changeType": "introduced",
"elementFileBefore": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Proxy, Response)$if(43-43)",
"elementFileAfter": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Route, Response)$if(47-47)",
"comment": "Merge Method [public authenticate(proxy Proxy, response Response) : Request, public authenticateProxy(proxy Proxy, response Response) : Request] to public authenticate(route Route, response Response) : Request in class okhttp3.internal.http.AuthenticatorAdapter"
},
{
"parentCommitId": "f5111c28356431c6c5d1e71dd1bbced9a8016cd8",
"commitId": "e920196fbd71822fc284ab76204bf75f95d3265a",
"commitTime": 1398096023,
"parentCommitId": "9ecff8f961c321098c2598097fb5289e968ef1ac",
"commitId": "0bfd6048574d61c138fd417051ae2a1bcb44638f",
"commitTime": 1450450613,
"changeType": "introduced",
"elementFileBefore": "okhttp/src/main/java/com/squareup/okhttp/internal/huc/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/com.squareup.okhttp.internal.huc.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$if(65-65)",
"elementFileAfter": "okhttp/src/main/java/com/squareup/okhttp/internal/huc/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/com.squareup.okhttp.internal.huc.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$if(65-65)",
"comment": "added with method"
"elementFileBefore": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameBefore": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticateProxy(Proxy, Response)$if(65-65)",
"elementFileAfter": "okhttp/src/main/java/okhttp3/internal/http/AuthenticatorAdapter.java",
"elementNameAfter": "okhttp/src/main/java/okhttp3.internal.http.AuthenticatorAdapter#authenticate(Route, Response)$if(47-47)",
"comment": "Merge Method [public authenticate(proxy Proxy, response Response) : Request, public authenticateProxy(proxy Proxy, response Response) : Request] to public authenticate(route Route, response Response) : Request in class okhttp3.internal.http.AuthenticatorAdapter"
}
]
}
Loading

0 comments on commit ca71dc7

Please sign in to comment.