Community
Participate
Working Groups
Build 20031009 The following expression is leading to unoptimal formatting: scope.problemReporter().typeMismatchErrorActualTypeExpectedType( enclosingInstance, enclosingInstanceType, inheritedBinding.declaringClass.enclosingType()); it should give more importance to breaking arguments than cascade.
This is the kind of things that need to be tune up.
In particular, it should also deal with cases where multiple message senders are using arguments. Likely the outermost should break first.
I should not be difficult to set this.
*** Bug 45141 has been marked as a duplicate of this bug. ***
Now we have: scope.problemReporter().typeMismatchErrorActualTypeExpectedType( enclosingInstance, enclosingInstanceType, inheritedBinding.declaringClass.enclosingType()); For me this is good enough.
There is something wrong with my latest changes. The splits are not done where I'd like.
Right now I end up with: scope .problemReporter() .typeMismatchErrorActualTypeExpectedType(enclosingInstance, enclosingInstanceType, inheritedBinding.declaringClass .enclosingType()); .enclosingType() is at the end of the previous line. Ideally I'd like to get .problemReporter().typeMismatchErrorActualTypeExpectedType( on the same line than "scope". Need to investigate why it is done this way.
Now I have: scope.problemReporter().typeMismatchErrorActualTypeExpectedType( enclosingInstance, enclosingInstanceType, inheritedBinding.declaringClass.enclosingType()); It looks much better. Does this look the way you expected it to be?
I consider this good enough. If not, then reopen it. Fixed and released in HEAD. Regression test added.
I think I would use a compact mode for arguments once splitting... is it configurable ? And if so, does it work ? It feels more natural to me to default to: scope.problemReporter().typeMismatchErrorActualTypeExpectedType( enclosingInstance, enclosingInstanceType, inheritedBinding.declaringClass.enclosingType());
reopening
The compact mode is what I used. No, this is not configurable for now. This specific case is a case where we are formatting a cascading message send. This is different from a simple message send with arguments. If this solution is not good enough, then we might want to revisit the whole idea of nested alignment.
If I change the alignment of message arguments inside a cascading message send to M_NEXT_PER_LINE_SPLIT , I get: scope.problemReporter().typeMismatchErrorActualTypeExpectedType( enclosingInstance, enclosingInstanceType, inheritedBinding.declaringClass.enclosingType()); So this could be an option.
My concern is that would then be done for any arguments inside the cascading message send, not just the last one.
For example, if you have this: scope.problemReporter(enclosingInstance, enclosingInstanceType, inheritedBinding.declaringClass.enclosingType()).typeMismatchErrorActualTypeExpectedType(); It ends up like this: scope.problemReporter( enclosingInstance, enclosingInstanceType, inheritedBinding.declaringClass.enclosingType()) .typeMismatchErrorActualTypeExpectedType(); I am not sure this is what you want.
Suggestion below, in case of cascade longer than 1 ? aaa .foo( bbb, ccc) .bar( ddd, eee)
This is clearly not following the java conventions. I think it is doable using different kind of alignment. I will investigate.
We should at least support the standard conventions, my suggestion is somewhat deluxe...
The result following the standard conventions would be: scope.problemReporter().typeMismatchErrorActualTypeExpectedType( enclosingInstance, enclosingInstanceType, inheritedBinding.declaringClass.enclosingType()); Always use a compact split.
If I allow the alignment kind to be changed for cascaded method invocations, we can get this: scope .problemReporter( enclosingInstance, enclosingInstanceType, inheritedBinding.declaringClass.enclosingType()) .typeMismatchErrorActualTypeExpectedType(); I think this is pretty close to what you wanted. Closed as fixed.
Verified for 3.0-M7 with build I200402102000.