IDEA 10.0.2 - Line wrapping issue
I'm sure I don't have my line wrapping settings quite right, but can you help me figure out what I need to do to get the following to wrap as I would like. Here is what the formatting was previous to running IDEA's formatter.
TestHelper.checkBorder(new LineBorderUIResource(LookAndFeelConstants.decodeColor("#XXXXXXX")),
"XXXScrollPane.border", new JScrollPane());
After running the formatter ----
TestHelper
.checkBorder(new LineBorderUIResource(LookAndFeelConstants.decodeColor("#XXXXXXX")),
"XXXScrollPane.border", new JScrollPane());
What I would like to have it formatted as ------
TestHelper.checkBorder(
new LineBorderUIResource(LookAndFeelConstants.decodeColor("#XXXXXXX")),
"XXXScrollPane.border", new JScrollPane());
Thanks for your help!
请先登录再写评论。
Hi Angella,
Please try to set the following:
Regards, Denis
I have that setting already. Any other ideas?
Please provide your code style settings and exact file that you're reformatting.
Denis
I've saved them as Global Settings. Can you direct me on how to export those? Thanks!
The code style settings are stored at *.xml file under the following directory - ${user.home}/.IdeaIC10/config/codestyles
Also provide please exact source file that you're trying to format.
Denis
Update: provided path is the one used by Community Edition. Please use ${user.home}/.IntelliJIdea10/config/codestyles in case of Ultimate Edition
Try enabling this:
Project Settings -> Code Style -> Wrapping and Braces -> Method call arguments - 'Take priority over call chain formatting'
I turned that one off, because it was causing the formatting to not make commas take precedence when formatting, so a line like:
final JComboBox comboBox = new CustomComboBox(getText(), getComboBoxItems(something, something, somthing));
Became---------------------
final JComboBox comboBox = new CustomComboBox(getText(), getComboBoxItems(something,
something, somthing));
Instead of ------------------------
final JComboBox comboBox = new CustomComboBox(getText(),
getComboBoxItems(something, something, somthing));
Yes, I think I had a similar problem -- no combination of flags gave me a satisfactory result in 100% of the cases. I set it up to produce an acceptable result in most cases, and in the remaining cases reformat manually.
Hi Sergei,
Have you filled any tickets to IJ tracker for that?
Denis
I don't think I did. I simply put up with it, because in most of the cases formatting works fine for me, and I don't have too much poorly formatted code to deal with on a regular basis.
I like Angella's examples though, they are pretty illustrative of the formatting issues I face.
Having just given it a thought, my personal wrapping preference for long lines are:
An insanely complex example (I've just made it up, it is not some real code!):
...becomes something like:
The major problem I am having is how to formalise it into configuration options (and that's probably why I did not submit it before). I can still file a youtrack ticket with the above information, if you like.
Kind regards,
Sergei
We can elaborate that a little bit more and then create a ticket with the summarized results if necessary.
I see two use-cases that need clarification for now:
Denis
In my made up example, the right margin would be about 45 columns, just to demonstrate the wrapping of the nested calls and expressions. In reality, I also have right margin set at 120 columns, but even then I cannot always achieve satisfactory look after automatic reformatting. It may be the case that there's simply no universal recipe, which would apply in all cases.
However, you've got the main points:
The main problem with code formatting is that there are many ways to format the same code fragment, and it is always down to personal preferences and taste. The formatting engine must be very flexible and configurable to be able to accommodate all possible formatting options.
I have never used Jalopy, for instance. Maybe I need to have a look at what's available there, and attempt to suggest the missing features in youtrack.
But at the end of the day, I have already reached a stage, when I have no problems working with (and maintaining) a number of projects, in a variety of formatting styles. That's why this issue has always been at the bottom of my priority list.
Hi Sergey,
I agree that introducing 'wrap priority' facility would bring additional flexibility to the formatter. However, that doesn't seem too demanded (at least for now).
P.S. Sorry for the long delay.
Denis
Thanks for all of the feedback. I have entered a bug on this formatting issue, which I expect will be downgraded to an enhancement. Please vote if you agree with my assessment!
http://youtrack.jetbrains.net/issue/IDEA-66072