Bug 568942 - [formatter] Align Parameters in Columns
Summary: [formatter] Align Parameters in Columns
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.18   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-18 17:25 EST by Nathan Reynolds CLA
Modified: 2022-11-20 13:16 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Reynolds CLA 2020-11-18 17:25:53 EST
In Preferences > Java > Code Style > Formatter, one can edit the profile.  In the Indentation > align items in columns, please add the ability to align parameters.  For example, please change this code...

map.put("apple", "red");
map.put("banana", "yellow");
map.put("grape", "green");
map.put("orange", "orange");
map.put("pear", "green");

... into this code ...

map.put("apple",  "red");
map.put("banana", "yellow");
map.put("grape",  "green");
map.put("orange", "orange");
map.put("pear",   "green");

This is a simple example.  When there are many more parameters in a method, then aligning the parameters in columns helps a lot with readability.
Comment 1 Mateusz Matela CLA 2020-11-19 13:07:49 EST
This looks like a formatting that only makes sense in very few places, so it should be feasible to align the code manually and then put it between the formatter:off/on comments.

If this kind of alignment was turned on globally, it would try to align instructions that don't have much in common and that would usually harm readability.

> When there are many more parameters in a method, then aligning the parameters in columns helps a lot with readability.

In that case there's a high change the statements would be wrapped into multiple lines - how should it align then?
Comment 2 Nathan Reynolds CLA 2020-11-19 16:38:46 EST
> If this kind of alignment was turned on globally, it would try to align instructions that don't have much in common and that would usually harm readability.

This only helps if the same method is being called.  If different methods are being called, then alignment would confuse the reader more than help.

> ...lines...wrapped into multiple lines - how should it align then?

If the lines wrap, then do not align the parameters.  Aligning them would not help.
Comment 3 Eclipse Genie CLA 2022-11-20 13:16:27 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.