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

Unexpected indent printed out when printing Java multiline string. #5983

Open
treenwang opened this issue Sep 30, 2024 · 0 comments
Open

Unexpected indent printed out when printing Java multiline string. #5983

treenwang opened this issue Sep 30, 2024 · 0 comments
Labels

Comments

@treenwang
Copy link
Contributor

treenwang commented Sep 30, 2024

Describe the bug

Unexpected indent printed out when printing Java multiline string.

Source code you are trying to analyze/transform

No response

Source code for your Spoon processing

@Test
	void testMultilineString(){
		CtType<?> ctType = Launcher.parseClass("class A{ void a(){var s = \"\"\"\na\n\"\"\";} }");
		System.out.println(ctType.toStringWithImports());
		Assertions.assertEquals("class A {\n" +
			"    void a() {\n" +
			"        var s = \"\"\"\na\"\"\";\n" +
			"    }\n" +
			"}\n", ctType.toStringWithImports());
	}

Actual output

class A {
    void a() {
        var s = """
        a
        """;
    }
}

Expected output

class A {
	void a() {
		var s = """
a
""";
	}
}

Spoon Version

11.1.0

JVM Version

Java 17+

What operating system are you using?

MacOS

@treenwang treenwang added the bug label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant