Question

I'd like to configure the Eclipse java formatter to format chained method calls like that:

lblName
        .setX(last.getX() + last.getWidth())
        .setY(0)
        .setHeight(this.height)
        .setWidth(80);

My problem is, that I don't know how to make it only format it like this, if the first method call already is placed in the second line. This call should be untouched:

lblName.setX(last.getX() + last.getWidth()).setY(0).setHeight(this.height).setWidth(80);
Was it helpful?

Solution

You say:

...if the first method call already is placed...call should be untouched...

If you don't want the formatter to wrap already wrapped lines, have a look at this panel:

enter image description here

OTHER TIPS

That's not possible. You can either have a line break after each method call, after a certain character limit per line, or not at all.

That said, your request is also not well thought. Writing two times the same code with differences only in line breaks (e.g. by two different people in the same team) should lead to getting the same formatted code for committing to a common repository.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top