Comment Formatting
prettier-plugin-java version: 2.6.4
# Options (if any):
--print-width 120
Input:
// some comment some comment some comment some comment some comment some comment some comment some comment some comment some comment some comment some comment some comment
public SomeClass() {}
Output:
// some comment some comment some comment some comment some comment some comment some comment some comment some comment some comment some comment some comment some comment
public SomeClass() {}
Expected behavior: Does Prettier not format comment sections? As I see, it has even issues with formatting the code which is in one line with a comment. Is it right? Or there is some new version with fixed comment formatting?
found the same behavior
prettier-plugin-java version: 2.6.4 prettier version:3.3.3
additionally found out that prettier will do the formating twice of the same file as it will format the comment section wrong.
example
Input:
private boolean isClassList(Class<?> clazz) {
if (clazz.isArray()) { //test
return true;
} else {
return false;
}
}
Output after first format call to prettier
private boolean isClassList(Class<?> clazz) {
if (
clazz.isArray()
) { //test
return true;
} else {
return false;
}
}
Output after second call to same file with no additional editing:
private boolean isClassList(Class<?> clazz) {
if (clazz.isArray()) { //test
return true;
} else {
return false;
}
}
This is similar to #651, which asked for the same, though specifically mentioned Javadocs. At the moment, this plugin does not modify the contents of comments in any way, it merely moves them as necessary. Prettier itself has not yet implemented this either (see prettier/prettier#265), which I think is the primary reason we haven't done so in this plugin. The Prettier team seemed receptive to the idea of formatting comments when that issue was opened in 2017, but it's had very little activity since then. None of that is to say that we couldn't implement this ourselves, we just wouldn't be able to lean on the Prettier team's decisions made surrounding it.
The issue mentioned by @storylord85 is unrelated to wrapping comment contents, but instead seems to be related to #592.