Skip to content

Commit

Permalink
Finalize fine-grained method signature blame
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Aug 27, 2024
1 parent 301517f commit dcc9761
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 25 deletions.
9 changes: 7 additions & 2 deletions src/main/java/org/codetracker/FileTrackerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,8 @@ private Map<Method, MethodTrackerChangeHistory> processMethodsWithSameSignature(
startMethodChangeHistory.get().addChange(leftMethod, rightMethod, ChangeFactory.forMethod(Change.Type.BODY_CHANGE));
if (!leftMethod.equalDocuments(rightMethod))
startMethodChangeHistory.get().addChange(leftMethod, rightMethod, ChangeFactory.forMethod(Change.Type.DOCUMENTATION_CHANGE));
checkIfJavadocChanged(currentVersion, parentVersion, startMethod, rightMethod, leftMethod);
checkSignatureFormatChange(startMethodChangeHistory, rightMethod, leftMethod);
startMethodChangeHistory.get().connectRelatedNodes();
startMethodChangeHistory.elements.remove(currentMethod);
startMethodChangeHistory.elements.add(leftMethod);
Expand Down Expand Up @@ -1309,6 +1311,8 @@ private Map<Method, MethodTrackerChangeHistory> processMethodsWithSameSignature(
startMethodChangeHistory.get().addChange(leftMethod, rightMethod, ChangeFactory.forMethod(Change.Type.BODY_CHANGE));
if (!leftMethod.equalDocuments(rightMethod))
startMethodChangeHistory.get().addChange(leftMethod, rightMethod, ChangeFactory.forMethod(Change.Type.DOCUMENTATION_CHANGE));
checkIfJavadocChanged(currentVersion, parentVersion, startMethod, rightMethod, leftMethod);
checkSignatureFormatChange(startMethodChangeHistory, rightMethod, leftMethod);
startMethodChangeHistory.get().connectRelatedNodes();
startMethodChangeHistory.setCurrent(leftMethod);
processNestedStatementsAndComments(rightModel, currentVersion, leftModel, parentVersion,
Expand All @@ -1322,8 +1326,9 @@ private Map<Method, MethodTrackerChangeHistory> processMethodsWithSameSignature(

private void checkSignatureFormatChange(MethodTrackerChangeHistory startMethodChangeHistory, Method rightMethod, Method leftMethod) {
if (leftMethod.signatureLines() != rightMethod.signatureLines()) {
//startMethodChangeHistory.get().addChange(leftMethod, rightMethod, ChangeFactory.forMethod(Change.Type.SIGNATURE_FORMAT_CHANGE));
//startMethodChangeHistory.get().connectRelatedNodes();
startMethodChangeHistory.get().addChange(leftMethod, rightMethod, ChangeFactory.forMethod(Change.Type.SIGNATURE_FORMAT_CHANGE));
startMethodChangeHistory.processChange(leftMethod, rightMethod);
startMethodChangeHistory.get().connectRelatedNodes();
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/codetracker/FileTrackerWithLocalFilesImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,7 @@ private Map<Method, MethodTrackerChangeHistory> processMethodsWithSameSignature(
Method leftMethod = getMethod(leftModel, parentVersion, rightMethod::equalIdentifierIgnoringVersion);
if (leftMethod != null) {
checkIfJavadocChanged(currentVersion, parentVersion, startMethod, rightMethod, leftMethod);
checkSignatureFormatChange(startMethodChangeHistory, rightMethod, leftMethod);
continue;
}
//CHANGE BODY OR DOCUMENT
Expand Down Expand Up @@ -1259,6 +1260,8 @@ private Map<Method, MethodTrackerChangeHistory> processMethodsWithSameSignature(
startMethodChangeHistory.get().addChange(leftMethod, rightMethod, ChangeFactory.forMethod(Change.Type.BODY_CHANGE));
if (!leftMethod.equalDocuments(rightMethod))
startMethodChangeHistory.get().addChange(leftMethod, rightMethod, ChangeFactory.forMethod(Change.Type.DOCUMENTATION_CHANGE));
checkIfJavadocChanged(currentVersion, parentVersion, startMethod, rightMethod, leftMethod);
checkSignatureFormatChange(startMethodChangeHistory, rightMethod, leftMethod);
startMethodChangeHistory.get().connectRelatedNodes();
startMethodChangeHistory.elements.remove(currentMethod);
startMethodChangeHistory.elements.add(leftMethod);
Expand Down Expand Up @@ -1286,6 +1289,7 @@ private Map<Method, MethodTrackerChangeHistory> processMethodsWithSameSignature(
Method leftMethod = getMethod(leftModel, parentVersion, rightMethod::equalIdentifierIgnoringVersion);
if (leftMethod != null) {
checkIfJavadocChanged(currentVersion, parentVersion, startMethod, rightMethod, leftMethod);
checkSignatureFormatChange(startMethodChangeHistory, rightMethod, leftMethod);
startMethodChangeHistory.setCurrent(leftMethod);
continue;
}
Expand Down Expand Up @@ -1314,6 +1318,8 @@ private Map<Method, MethodTrackerChangeHistory> processMethodsWithSameSignature(
startMethodChangeHistory.get().addChange(leftMethod, rightMethod, ChangeFactory.forMethod(Change.Type.BODY_CHANGE));
if (!leftMethod.equalDocuments(rightMethod))
startMethodChangeHistory.get().addChange(leftMethod, rightMethod, ChangeFactory.forMethod(Change.Type.DOCUMENTATION_CHANGE));
checkIfJavadocChanged(currentVersion, parentVersion, startMethod, rightMethod, leftMethod);
checkSignatureFormatChange(startMethodChangeHistory, rightMethod, leftMethod);
startMethodChangeHistory.get().connectRelatedNodes();
startMethodChangeHistory.setCurrent(leftMethod);
processNestedStatementsAndComments(rightModel, currentVersion, leftModel, parentVersion,
Expand All @@ -1325,6 +1331,14 @@ private Map<Method, MethodTrackerChangeHistory> processMethodsWithSameSignature(
return notFoundMethods;
}

private void checkSignatureFormatChange(MethodTrackerChangeHistory startMethodChangeHistory, Method rightMethod, Method leftMethod) {
if (leftMethod.signatureLines() != rightMethod.signatureLines()) {
startMethodChangeHistory.get().addChange(leftMethod, rightMethod, ChangeFactory.forMethod(Change.Type.SIGNATURE_FORMAT_CHANGE));
startMethodChangeHistory.processChange(leftMethod, rightMethod);
startMethodChangeHistory.get().connectRelatedNodes();
}
}

private void checkIfJavadocChanged(Version currentVersion, Version parentVersion, Method startMethod,
Method rightMethod, Method leftMethod) {
UMLJavadoc leftJavadoc = leftMethod.getUmlOperation().getJavadoc();
Expand Down
Loading

0 comments on commit dcc9761

Please sign in to comment.