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

edge cases for ReloadableJava17JavadocVisitor #3650

Open
bnaudts opened this issue Oct 30, 2023 · 1 comment
Open

edge cases for ReloadableJava17JavadocVisitor #3650

bnaudts opened this issue Oct 30, 2023 · 1 comment
Labels
bug Something isn't working parser-java

Comments

@bnaudts
Copy link

bnaudts commented Oct 30, 2023

What version of OpenRewrite are you using?

I am using

  • OpenRewrite 8.9.0-SNAPSHOT, main branch, commit 0d884d4

How are you running OpenRewrite?

In IntelliJ, but also using the latest Gradle plugin, latest SNAPSHOT version.

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

The following are a number of tests that can be inserted into org.openrewrite.java.tree.JavadocTest.
Each detail a minor JavaDoc parsing issue.

    @Test
    void unicodeAmpersand() {
        rewriteRun(
          java("""
            package com.foo;

             /**
              * {@code
              * \\u0040Override
              * public void method() {
              * }
              */
             @SuppressWarnings
             class Bar { }
             """)
        );
    }

    @Test
    void unicodeAccent() {
        rewriteRun(
          java("""
            package com.foo;

             /**
              * @author Xx\\u00e9
             */
             class Bar { }
             """)
        );
    }

    @Test
    void badlyClosedXmlTags() {
        rewriteRun(
          java("""
            package com.foo;
            /**
             <!--Optional:->
             <urn:portalId>?</urn:portalId-->
            */

            class Bar { }
            """)
        );
    }

    @Test
    void unicodeSpace() {
        rewriteRun(java("""
          package com.foo;

          /**
           * Strip characters that are not allowed in an XML document : those below ASCII 32 (HEX 20 -> in java < '\\u0020')
           */
          public class Bar { }
          """));
    }

    @Test
    void splitAtDot() {
        rewriteRun(java("""
          package com.foo;
          	/**
          	 * @see a.b.Type#method(a.b.c.
          	 * d.Type)
          	 */
          class Bar { }
          """));
    }

    @Test
    void combinedCommentsWithoutSpace() {
        // solved by adding a space between */ and /*
        rewriteRun(java("""
          package com.foo;
          class Bar {
          	/**
          	 * xx
          	 *//*
               void method() {
               }*/
          }
          """));
    }

    @Test
    void spaceStarAfterStartOfJavaDoc() {
        // remove the * after /**
        rewriteRun(java("""
          package com.foo;
           /**	 *
            * @author x
            */
          class Bar { }
          """));
    }

    @Test
    void bracketNotClosedInJavaDoc() {
        rewriteRun(java("""
          package com.foo;
          	/**
          	 * {@link Foo#method(int, int) xyz
          	 * @abc
          	 */
          class Bar { }
          """));
    }

What did you expect to see?

A green test.
I have no particular interest in exactly how the parser solves the issue (i.e., by ignoring, or correcting), just that it does not fail on the whole file.

What did you see instead?

A red test, i.e., parsing stops with an error.

@bnaudts bnaudts added the bug Something isn't working label Oct 30, 2023
@timtebeek
Copy link
Contributor

Thanks a lot for these detailed reports @bnaudts ! Really helpful to have them in a format we can directly run.I'll see if we can fit in a fix of these issues, as indeed this should not break parsing your project.

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
Status: Backlog
Development

No branches or pull requests

3 participants