openrewrite / rewrite

Automated mass refactoring of source code.

Home Page:https://docs.openrewrite.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

parser issue: a `<!--` style comment inside javadoc causes "is not print idempotent" parsing error

valters opened this issue · comments

What version of OpenRewrite are you using?

I am using

  • Maven plugin 5.36.0

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a multi-module project.
Please see https://github.com/valters/test-openrewrite for repro case

What is the smallest, simplest way to reproduce the problem?

I happen to have a java file with auto-generated javadoc comment like this:

/**
 *  <!--
 Does this html-style comment cause a "is not print idempotent" parsing problem?
 -->
 */
public class FailsToParse {
}

What did you expect to see?

The file should be processed normally as it does not have anything of note in it.

What did you see instead?

(...)
[WARNING] There were problems parsing some source files
[WARNING] There were problems parsing source-problems/src/main/java/ch/vingolds/testopenrewrite/FailsToParse.java
[WARNING] java.lang.IllegalStateException: source-problems/src/main/java/ch/vingolds/testopenrewrite/FailsToParse.java is not print idempotent. 
diff --git a//Users/valters.vingolds/_sandbox/test-openrewrite/source-problems/src/main/java/ch/vingolds/testopenrewrite/FailsToParse.java b//Users/valters.vingolds/_sandbox/test-openrewrite/source-problems/src/main/java/ch/vingolds/testopenrewrite/FailsToParse.java
index 8442fdd..0733a49 100644
--- a//Users/valters.vingolds/_sandbox/test-openrewrite/source-problems/src/main/java/ch/vingolds/testopenrewrite/FailsToParse.java
+++ b//Users/valters.vingolds/_sandbox/test-openrewrite/source-problems/src/main/java/ch/vingolds/testopenrewrite/FailsToParse.java
@@ -4,6 +4,8 @@ 
  *  <!--
  Does this html-style comment cause a "is not print idempotent" parsing problem?
  -->
+
+
  */
 public class FailsToParse {
 }

  org.openrewrite.Parser.requirePrintEqualsInput(Parser.java:52)
[INFO] Project [parent-test-openrewrite] Parsing source files
(...)

What is the full stack trace of any errors you encountered?

No error, just unexpected parsing weakness.

Very similar to #4248 bug report