-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Added support for multiline comments #759
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
|
||
assertThat(main.toString()).isEqualTo("" + | ||
"public static void main(java.lang.String[] args) {\n" + | ||
" /*\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest using the following syntax for inline comments:
public static void main(String[] args) {
// Hello
// multiline
// comments!
}
The /** */
is most frequently used for Javadoc, so generating it inside a method body feels awkward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While /**
is for javadoc, /*
is actually the intended multi-line comment syntax: https://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141999.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last revision to this document was made on April 20, 1999
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine if you would prefer not to have it, but that syntax is valid multi-line comment syntax. You can look at other sources and they all distinguish multi-line comments and JavaDoc comments by the extra asterisk. It's not a valid argument to dismiss this by claiming it as JavaDoc.
Edit: see e. g. Wikipedia: https://en.wikipedia.org/wiki/Javadoc#Structure_of_a_Javadoc_comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The multiline comment syntax is valid Java as @octylFractal pointed out. It's common to see single line comments completely replaced by block comments throughout source code. The one that's used for JavaDocs begin with slash followed by two asterisks. /* */
and /** */
are two entirely different things. See here for more information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I totally confused the two. My preference is still for //
- that's less lines and feels more common to me. I haven't seen the /* */
form used in method bodies in a long while.
Modified
addComment
to add multiline comments. Possible fix for #718 .