Skip to content

Commit

Permalink
Handle special case where there is only a single comment group.
Browse files Browse the repository at this point in the history
This is important for package declaration comments
  • Loading branch information
tsantalis committed Oct 3, 2024
1 parent 8bee99e commit 902f6cf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 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 @@ -28,6 +28,8 @@ public UMLCommentListDiff(List<UMLComment> commentsBefore, List<UMLComment> comm
//check if there exist comment groups, consecutive line comments
List<UMLCommentGroup> groupsBefore = createCommentGroups(commentsBefore);
List<UMLCommentGroup> groupsAfter = createCommentGroups(commentsAfter);
int groupsBeforeSize = groupsBefore.size();
int groupsAfterSize = groupsAfter.size();
List<UMLCommentGroup> groupsBeforeToBeRemoved = new ArrayList<UMLCommentGroup>();
List<UMLCommentGroup> groupsAfterToBeRemoved = new ArrayList<UMLCommentGroup>();
for(UMLCommentGroup groupBefore : groupsBefore) {
Expand Down Expand Up @@ -68,8 +70,10 @@ public UMLCommentListDiff(List<UMLComment> commentsBefore, List<UMLComment> comm
}
groupsBefore.removeAll(groupsBeforeToBeRemoved);
groupsAfter.removeAll(groupsAfterToBeRemoved);
if(!(allRemainingCommentsBelongToGroups(deletedComments, groupsBefore) && allRemainingCommentsBelongToGroups(addedComments, groupsAfter)))
if(!(allRemainingCommentsBelongToGroups(deletedComments, groupsBefore) && allRemainingCommentsBelongToGroups(addedComments, groupsAfter)) ||
(groupsBeforeSize <= 1 && groupsAfterSize <= 1)) {
processRemainingComments(deletedComments, addedComments);
}
}

private boolean allRemainingCommentsBelongToGroups(List<UMLComment> comments, List<UMLCommentGroup> groups) {
Expand Down

0 comments on commit 902f6cf

Please sign in to comment.