Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Bug in JDTCommentBuilder #2032

Merged
merged 4 commits into from
Jun 5, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ private static String cleanComment(Reader comment) {
} else {
//it is potentially multiline comment, which starts with "/*" or "/**"
//check end first
if (line.endsWith("*/")) {
if (line.endsWith("*/") && line.length() > 3) {
//it is last line
line = endCommentRE.matcher(line).replaceFirst("");
isLastLine = true;
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/spoon/test/comment/testclasses/WildComments.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,24 @@ public class WildComments {
/**** starts and ends with 4 * ****/
"** starts and ends with 4 * ***"
};

/* should not cause "Unexpected next line after last line" exception */
public void testSlash() {
/*/
slash and comment
*/

/*
comment and slash
/*/

/*/
slash and comment and slash
/*/

//*/

/*/*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move all these new comment examples above (to line >116). This test expects pairs of tested comment example and expected string content of the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I create a new file for them?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new file

no, just move them up and add expected content of the comment text. For example:
convert this

/*/
slash and comment
*/

to

/*/
slash and comment
*/
"/\nslash and comment"

}
}