Bug 36455 - [Formatting] Too long lines look ugly
Summary: [Formatting] Too long lines look ugly
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows NT
: P3 enhancement (vote)
Target Milestone: 3.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-14 10:35 EDT by Sven Burgener CLA
Modified: 2003-10-14 07:18 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Burgener CLA 2003-04-14 10:35:50 EDT
When running "Source", "Format" a snippet such as the following one will get
formatted as follows.

Original code
-------------
JOptionPane.showMessageDialog(this, msg.toString(),                            
 "About", JOptionPane.INFORMATION_MESSAGE, icon);

After formatting
----------------
JOptionPane.showMessageDialog(
	this,
	msg.toString(),
	"About",
	JOptionPane.INFORMATION_MESSAGE,
	icon);

This is as it is now, Eclipse 2.1.

With nested statements having parameters, this can become messy and hard to
read. What I'd prefer (perhaps an option to toggle this could be put into the
"Java"/"Code Formatter" prefs) is the following, which makes it a lot easier to
read.

JOptionPane.showMessageDialog(this, msg.toString(),
                              "About", 
                              JOptionPane.INFORMATION_MESSAGE,
                              icon);

NB: The indentation happens with spaces starting from "JOptionPane". That way,
no matter what you set your tab settings to, it will always look as nicely
aligned as above. If it were indented with tabs, there'd be tabs and then
spaces, as many as the String "JOptionPane.showMessageDialog(" is long.

This obviously is a minor and nice-to-have issue, that's why I'm posting it as a
feature request.
Comment 1 Adam Kiezun CLA 2003-04-14 10:50:37 EDT
formatter lives in jcore
Comment 2 Stephen Colebourne CLA 2003-04-18 12:44:15 EDT
Additional formats for this are also possible:
#1
JOptionPane.showMessageDialog(
    this, msg.toString(), "About", JOptionPane.INFORMATION_MESSAGE, icon);
#2
JOptionPane.showMessageDialog(
    this, msg.toString(), "About",
    JOptionPane.INFORMATION_MESSAGE, icon);
#3
JOptionPane.showMessageDialog(
    this, msg.toString(), "About",
    JOptionPane.INFORMATION_MESSAGE, icon
);
#4
JOptionPane.showMessageDialog(
    this,
    msg.toString(),
    "About",
    JOptionPane.INFORMATION_MESSAGE,
    icon
);
If a change is to be made, then some way to allow for different styles is 
needed.
Comment 3 Olivier Thomann CLA 2003-04-30 09:32:08 EDT
This is currently under investigation within the new code formatter.
Comment 4 Olivier Thomann CLA 2003-10-03 10:24:31 EDT
This is improved with the new formatter.
Fixed and released in HEAD.
Regression test added.
Comment 5 David Audel CLA 2003-10-14 07:18:43 EDT
Verified.