Skip to content

JavaScript: whitespace attachment failure with multi-line for #7951

Description

@greg-at-moderne

What version of OpenRewrite are you using?

Current main = cd4edc6

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

Add the following section:

        `
        for (
          let i = 0; i < numberOfConnections; i++
        ) {}
        `

to rewrite-javascript/rewrite/test/javascript/whitespace-attachment.test.ts

What did you see instead?

 FAIL  test/javascript/whitespace-attachment.test.ts > whitespace should be attached to the outermost element > for (
  let i = 0; i < numberOfConnections; i++
) {}

AssertionError: expected [ Array(1) ] to deeply equal []

- Expected
+ Received

- []
+ [
+   "J.VariableDeclarations has child J.Modifier starting with whitespace |
+   |. The whitespace should rather be attached to J.VariableDeclarations around J.Modifier{Text(
+   ), Text(let)}.",
+ ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions