How to keep comment on same line as annotation when reformatting code
已回答
I have a annotated java method like
@SuppressWarnings("PMD") // Explanation of why we are suppressing PMD warnings
public void foo() {
// do something
}
Whenever I reformat the code it changes it to
@SuppressWarnings("PMD")
// Explanation of why we are suppressing PMD warnings
public void foo() {
// do something
}
I want to keep the comment on the same line as the annotation when reformatting the code but I can't figure out how to do that.
请先登录再写评论。
I'm using IntelliJ IDEA 2022.3.3 (Ultimate Edition), Build #IU-223.8836.41, built on March 9, 2023.
Here's the code scheme:
Please also try disabling all the downloaded plugins from `Settings | Plugins | Click the gear button | Disable all the downloaded plugins`.
Thanks for checking. I looked into the issue further and found it's occurring because of line length wrapping. I was using the default line length of 120 and I had a longer comment so it was moving it to the next line. I increase the "Hard wrap at" line length setting and that resolved the problem. Thanks!