Code Style Wrapping

I've been having some very annoying wrapping issues. Maybe I'm doing something wrong or there's some workarounds.

I don't like wrapping on an open bracket '(' or anywhere (before new, etc) ever if a line can be wrapped at a comma.
This has many situations where this occurs.

One is with a ternary statement.
I would like it to look like this:
node = tok.hasMoreTokens() ? new DefaultMutableTreeNode(token, true)
: new DefaultMutableTreeNode(new ClassNodeData(token, (Class) entry.getValue(),
baseClassName, false), false);

Instead it looks like this:
node = tok.hasMoreTokens() ? new DefaultMutableTreeNode(token, true) : new DefaultMutableTreeNode(new ClassNodeData(
token, (Class) entry.getValue(), baseClassName, false), false);

Which goes 20 columns beyond the wrapping limit.
This is a result of wrap if long or chop down if long.
Wrap always fixes my problem in this situation but I don't want every ternary wrapped if it doesn't need to be.

There are other situations where I can't fix it with settings (doesn't fall into a specific wrapping category).
It'll either allow it to go past the limit or wrap in bad places (after equals sign when the first comma is before limit).

I think what I want is smarter wrapping or more control.

1 comment
Comment actions Permalink

This would also be acceptable (done by wrap always as mentioned above):
node = tok.hasMoreTokens()
? new DefaultMutableTreeNode(token, true)
: new DefaultMutableTreeNode(new ClassNodeData(token, (Class) entry.getValue(),
baseClassName, false), false);

0

Please sign in to leave a comment.