Skip to content

Commit

Permalink
Improved computation of method body line number change
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Oct 23, 2024
1 parent ddda09c commit 7e40c88
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 33 deletions.
11 changes: 10 additions & 1 deletion src/main/java/org/codetracker/FileTrackerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import gr.uom.java.xmi.UMLAbstractClass;
import gr.uom.java.xmi.UMLAnonymousClass;
import gr.uom.java.xmi.UMLAttribute;
import gr.uom.java.xmi.decomposition.OperationBody;
import gr.uom.java.xmi.decomposition.UMLOperationBodyMapper;
import gr.uom.java.xmi.diff.ExtractClassRefactoring;
import gr.uom.java.xmi.diff.ExtractOperationRefactoring;
Expand Down Expand Up @@ -1564,7 +1565,15 @@ private Map<Method, MethodTrackerChangeHistory> processMethodsWithSameSignature(
startMethodChangeHistory.setCurrent(leftMethod);
int leftLines = leftMethod.getLocation().getEndLine() - leftMethod.getLocation().getStartLine();
int rightLines = rightMethod.getLocation().getEndLine() - rightMethod.getLocation().getStartLine();
if (leftLines != rightLines) {
OperationBody leftBody = leftMethod.getUmlOperation().getBody();
OperationBody rightBody = rightMethod.getUmlOperation().getBody();
boolean differInBodyLines = false;
if(leftBody != null && rightBody != null) {
int leftBodyLines = leftBody.getCompositeStatement().getLocationInfo().getEndLine() - leftBody.getCompositeStatement().getLocationInfo().getStartLine();
int rightBodyLines = rightBody.getCompositeStatement().getLocationInfo().getEndLine() - rightBody.getCompositeStatement().getLocationInfo().getStartLine();
differInBodyLines = leftBodyLines != rightBodyLines;
}
if (leftLines != rightLines || differInBodyLines) {
processNestedStatementsAndComments(rightModel, currentVersion, leftModel, parentVersion,
startMethod, rightMethod, leftMethod);
}
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/org/codetracker/FileTrackerWithLocalFilesImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import gr.uom.java.xmi.LocationInfo.CodeElementType;
import gr.uom.java.xmi.UMLAbstractClass;
import gr.uom.java.xmi.UMLAnonymousClass;
import gr.uom.java.xmi.decomposition.OperationBody;
import gr.uom.java.xmi.decomposition.UMLOperationBodyMapper;
import gr.uom.java.xmi.diff.ExtractClassRefactoring;
import gr.uom.java.xmi.diff.ExtractOperationRefactoring;
Expand Down Expand Up @@ -1571,7 +1572,15 @@ private Map<Method, MethodTrackerChangeHistory> processMethodsWithSameSignature(
startMethodChangeHistory.setCurrent(leftMethod);
int leftLines = leftMethod.getLocation().getEndLine() - leftMethod.getLocation().getStartLine();
int rightLines = rightMethod.getLocation().getEndLine() - rightMethod.getLocation().getStartLine();
if (leftLines != rightLines) {
OperationBody leftBody = leftMethod.getUmlOperation().getBody();
OperationBody rightBody = rightMethod.getUmlOperation().getBody();
boolean differInBodyLines = false;
if(leftBody != null && rightBody != null) {
int leftBodyLines = leftBody.getCompositeStatement().getLocationInfo().getEndLine() - leftBody.getCompositeStatement().getLocationInfo().getStartLine();
int rightBodyLines = rightBody.getCompositeStatement().getLocationInfo().getEndLine() - rightBody.getCompositeStatement().getLocationInfo().getStartLine();
differInBodyLines = leftBodyLines != rightBodyLines;
}
if (leftLines != rightLines || differInBodyLines) {
processNestedStatementsAndComments(rightModel, currentVersion, leftModel, parentVersion,
startMethod, rightMethod, leftMethod);
}
Expand Down
Loading

0 comments on commit 7e40c88

Please sign in to comment.