Skip to content

Commit 8c97eb0

Browse files
committed
Issue #65: Resolved RenameViolationComments Bug
1 parent 92623b1 commit 8c97eb0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/test/java/org/checkstyle/autofix/RemoveViolationComments.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,15 @@ public Space visitSpace(Space space, Space.Location loc, ExecutionContext ctx) {
7373
else {
7474
result = space.withComments(filteredComments);
7575
if (!suffixAccumulator.isEmpty()) {
76-
result = result.withWhitespace(suffixAccumulator.toString());
76+
if (filteredComments.isEmpty()) {
77+
result = result.withWhitespace(suffixAccumulator.toString());
78+
}
79+
else {
80+
Comment lastComment = filteredComments.get(filteredComments.size() - 1);
81+
filteredComments.set(filteredComments.size() - 1,
82+
lastComment.withSuffix(suffixAccumulator.toString()));
83+
result = space.withComments(filteredComments);
84+
}
7785
}
7886
}
7987
return super.visitSpace(result, loc, ctx);

0 commit comments

Comments
 (0)