Skip to content

TabsAndIndents: continuationIndentSize fails by !DOCTYPE #4234

Open
@ofaucheux

Description

I am using OpenRewrite Version 8.27.0 and the org.openrewrite.xml.format.TabsAndIndents recept.

The issue: a new line in the <!DOCTYPE> declaration element of an XML file is not indented with the continuationIndentSize as it should be.

Following test reproduces the issue:

    @DocumentExample
    @Test
    void continuationIndentsWithinDOCTYPE() {
        rewriteRun(
          spec -> spec.recipe(toRecipe(() -> new TabsAndIndentsVisitor<>(
            TabsAndIndentsStyle.DEFAULT.withIndentSize(2).withContinuationIndentSize(5)
          ))),
          xml(
            """
              <!DOCTYPE module PUBLIC
                "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
                "https://checkstyle.org/dtds/configuration_1_3.dtd">
              <project>
              </project>
              """,
            """
              <!DOCTYPE module PUBLIC
                   "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
                   "https://checkstyle.org/dtds/configuration_1_3.dtd">
              <project>
              </project>
              """
          )
        );
    }

The result:

    expected: 
	  "<!DOCTYPE module PUBLIC
	       "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
	       "https://checkstyle.org/dtds/configuration_1_3.dtd">
	  <project>
	  </project>"
    but was: 
	  "<!DOCTYPE module PUBLIC
	  "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
	  "https://checkstyle.org/dtds/configuration_1_3.dtd">
	  <project>
	  </project>

as you see, the continuation line into the doctype has not be indented.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtest providedAlready replicated with a unit test, using JUnit pioneer's ExpectedToFail

    Type

    No type

    Projects

    • Status

      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions