Skip to content

Commit 310ea59

Browse files
Anmol202005rdiachenko
authored andcommitted
Issue #65: Resolved RenameViolationComments Bug
1 parent 92623b1 commit 310ea59

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,16 @@ 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+
final Comment lastComment = filteredComments
81+
.get(filteredComments.size() - 1);
82+
filteredComments.set(filteredComments.size() - 1,
83+
lastComment.withSuffix(suffixAccumulator.toString()));
84+
result = space.withComments(filteredComments);
85+
}
7786
}
7887
}
7988
return super.visitSpace(result, loc, ctx);

0 commit comments

Comments
 (0)