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

UseTextBlocks creating unnecessary trailing escape #555

Closed
protocol7 opened this issue Sep 14, 2024 · 1 comment · Fixed by #558
Closed

UseTextBlocks creating unnecessary trailing escape #555

protocol7 opened this issue Sep 14, 2024 · 1 comment · Fixed by #558
Labels
bug Something isn't working test provided

Comments

@protocol7
Copy link

protocol7 commented Sep 14, 2024

What version of OpenRewrite are you using?

  • org.openrewrite:rewrite-core:8.35.0
  • org.openrewrite.recipe:rewrite-migrate-java:2.24.0

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

  @Test
  void textBlockTrailingEscape() {
    assertEquals(
        """
        hello\
        """,
        """
        hello""");

    rewriteRun(
        spec -> spec.recipe(new UseTextBlocks()),
        java(
            """
             package com.helloworld;

             public class Main {
                 String foo =
                     "hello\\n"
                         + "world";
            }""",
            """
             package com.helloworld;

             public class Main {
                 String foo =
                     \"""
                     hello
                     world\""";
            }""",
            src -> src.markers(javaVersion(17))));
  }

What did you expect to see?

The escape after world is not needed are merely adds noise. Instead, the text block could be:

"""
hello
world"""

Are you interested in contributing a fix to OpenRewrite?

Likely not in the near-term due to other commitments.

@protocol7 protocol7 added the bug Something isn't working label Sep 14, 2024
@timtebeek timtebeek moved this to Backlog in OpenRewrite Sep 15, 2024
@timtebeek
Copy link
Contributor

Thanks for the clear example!

@timtebeek timtebeek linked a pull request Sep 15, 2024 that will close this issue
3 tasks
@timtebeek timtebeek linked a pull request Sep 18, 2024 that will close this issue
3 tasks
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenRewrite Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working test provided
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants