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

Comments cannot be parsed properly #4624

Merged
merged 8 commits into from
Oct 30, 2024
Merged

Comments cannot be parsed properly #4624

merged 8 commits into from
Oct 30, 2024

Conversation

Laurens-W
Copy link
Contributor

@Laurens-W Laurens-W commented Oct 29, 2024

What's changed?

Identified a setup of comments that doesn't get parsed properly and added that as reproducer testcase

Anyone you would like to review specifically?

@nielsdebruin @timtebeek

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@Laurens-W Laurens-W added bug Something isn't working parser-java labels Oct 29, 2024
@Laurens-W
Copy link
Contributor Author

Looks like the issue is related to the ending */ and beginning /* delimiters being on the same line

@nielsdebruin
Copy link
Contributor

With @Laurens-W, I looked at and debugged the code. In the end, we found that removing the +2 increment (see commit) resolves the issue. However, we are uncertain what the original reasoning behind this +2 instead of +1 increment was.

@nielsdebruin nielsdebruin marked this pull request as ready for review October 29, 2024 16:19
@Laurens-W Laurens-W removed their assignment Oct 29, 2024
@timtebeek
Copy link
Contributor

@nielsdebruin thanks for diving in! This seems to have resulted in some new failures in methodWithSuffixMultiComment().
https://ge.openrewrite.org/s/2h7bdj253sf7m/tests/overview?outcome=FAILED

diff --git a/Test.java b/Test.java	
index 5d28d39..c911b87 100644	
--- a/Test.java	
+++ b/Test.java	
@@ -1,3 +1,3 @@ 	
 class Test {	
-    public void foo() { }/*Comments*/	
+    public void foo() { }///Comments*/	
 }	
\ No newline at end of file	

Would you mind having a look at those?

Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Great to see you've worked out a way to get the test going; From my local tests it seems the continue isn't necessary, and we can instead evaluate the if (!inMultiLineComment && !inSingleLineComment) below like normal. Would you agree? Or is there a failing scenario we can code up where that would not work?

@timtebeek timtebeek merged commit ed1a481 into main Oct 30, 2024
2 checks passed
@timtebeek timtebeek deleted the comment-parse-issue branch October 30, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser-java
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

rewrite-java - Parser issue with consecutive comment blocks
3 participants