Skip to content

Commit

Permalink
Improve comment diff in commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Oct 3, 2024
1 parent 6eca840 commit 713bf73
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
20 changes: 19 additions & 1 deletion src/main/java/gr/uom/java/xmi/diff/UMLCommentListDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,29 @@ public UMLCommentListDiff(List<UMLComment> commentsBefore, List<UMLComment> comm
deletedComments.remove(commentBefore);
addedComments.remove(commentAfter);
}
groupsBeforeToBeRemoved.add(groupBefore);
groupsAfterToBeRemoved.add(groupAfter);
break;
}
}
}
groupsBefore.removeAll(groupsBeforeToBeRemoved);
groupsAfter.removeAll(groupsAfterToBeRemoved);
if(!(allRemainingCommentsBelongToGroups(deletedComments, groupsBefore) && allRemainingCommentsBelongToGroups(addedComments, groupsAfter)))
processRemainingComments(deletedComments, addedComments);
}

private boolean allRemainingCommentsBelongToGroups(List<UMLComment> comments, List<UMLCommentGroup> groups) {
int matches = 0;
for(UMLComment comment : comments) {
for(UMLCommentGroup group : groups) {
if(group.getGroup().contains(comment) && group.getGroup().size() > 1) {
matches++;
break;
}
}
}
processRemainingComments(deletedComments, addedComments);
return matches == comments.size();
}

public UMLCommentListDiff(UMLCommentGroup groupBefore, UMLCommentGroup groupAfter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ line range:1008-1008==line range:1032-1032
line range:1009-1009==line range:1033-1033
line range:1054-1054==line range:1105-1105
line range:1055-1055==line range:1106-1106
line range:1056-1056==line range:1107-1107
line range:1042-1042==line range:1053-1053
line range:1056-1056==line range:1107-1107

0 comments on commit 713bf73

Please sign in to comment.