Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Added support for multiline comments #759

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

devsh0
Copy link

@devsh0 devsh0 commented Jan 24, 2020

Modified addComment to add multiline comments. Possible fix for #718 .

Copy link
Collaborator

@Egorand Egorand left a 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" +
Copy link
Collaborator

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.

Copy link
Contributor

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

Copy link
Collaborator

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

Copy link
Contributor

@octylFractal octylFractal Jan 27, 2020

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

Copy link
Author

@devsh0 devsh0 Jan 27, 2020

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.

Copy link
Collaborator

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants