Skip to content

Poor indenting of nested expressions #591

@cal101

Description

@cal101

When formatting

class Formatting {
    StringBuilder m1() {
        return new StringBuilder();
    }
    StringBuilder m2(String p1, StringBuilder p2) {
        return new StringBuilder();
    }
 
    def main(args) {
        println(m1().
                append("a").
                append("b").
                append("c").
                append(m2(
                "x",
                m1().
                append("aa").
                append("ab"))))
    }
}

I expected something at least as what IDEA produces:

class Formatting {
    StringBuilder m1() {
        return new StringBuilder();
    }

    StringBuilder m2(String p1, StringBuilder p2) {
        return new StringBuilder();
    }

    def main(args) {
        println(m1().
                append("a").
                append("b").
                append("c").
                append(m2(
                        "x",
                        m1().
                                append("aa").
                                append("ab"))))
    }
}

so the nesting of the expressions gets respected.
I develop a groovy DSL and proper indentation of the expressions is a must to avoid nesting errors.

If you provide a hint to the relevant code I may actually be able to help.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions