Bug 45159 - Source Formatter: Wrapping needs to be intelligent.
Summary: Source Formatter: Wrapping needs to be intelligent.
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 65974 (view as bug list)
Depends on:
Blocks: 49896
  Show dependency tree
 
Reported: 2003-10-18 11:41 EDT by Robert (Kraythe) Simmons CLA
Modified: 2009-08-30 02:40 EDT (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 Robert (Kraythe) Simmons CLA 2003-10-18 11:41:47 EDT
The in addition to settign line length, the user should be able to set how to 
wrap things similarly to the way jalopy does now (but better naturally. =)) 
You should be able to tell the formatter to wrap the extends keyword down if 
there are more extends types than can fit on a line and same with throws and 
implmenets. 

In addition the wrapping of method call chains should be configurable. 

I should be able to enter:

foo.bar().xmeth().yMeth(); 

and come out with: 

foo.bar()
   .xmeth()
   .yMeth();

In addition the parameters should be able to wrap if exceeded and deep indent.
Comment 1 Eric Seynaeve CLA 2003-10-23 04:25:37 EDT
Another nice option would be to indicate that the code formatter should be less
wasteful of the vertical space. At the moment, following is the result of the
code formatter:

  private static final String[] ACCEPTABLE_NAMES =
    new String[] {
      "ABIS",
      "ING",
      "DEXIA",
      "Fortis",
      "Nationale Bank België",
      "Studio100" };

I would like to see the following:

  private static final String[] ACCEPTABLE_NAMES =
    new String[] {"ABIS", "ING", "DEXIA", "Fortis","Nationale Bank België",
                  "Studio100"};

or something very similar to it.

Eclipse version: 3.0M4 on Win 2000 (Build id: 200310101454)
Comment 2 Olivier Thomann CLA 2003-10-23 07:47:26 EDT
Did you enable the new formatter?
Go to Preferences>Java>Work in progress.
Comment 3 Eric Seynaeve CLA 2003-10-23 07:55:02 EDT
<blush>Ooops</blush>

This is the result with the new formatter:

  private static final String[] ACCEPTABLE_NAMES = new String[]{
    "ABIS", "ING", "DEXIA", "Fortis", "Nationale Bank België",
    "Studio100"};

Incredible work. Thanks and sorry for disturbance. :-)
Comment 4 Olivier Thomann CLA 2003-10-23 08:04:11 EDT
Ok to close then?
Comment 5 Eric Seynaeve CLA 2003-10-23 08:11:49 EDT
I don't know about Robert's request, but for me most of it seems solved. I will
check some more during the weekend (found a couple of things/details and want to
bundle them together as test cases).
Comment 6 Eric Seynaeve CLA 2003-10-28 11:42:22 EST
Here are some tests I did and which turned out strange results. All line lengths
are set to 72 characters (print margin, max. code line length, max. comment line
length). Tab length is 4.

First a case where we go over the line length:
	// - 1 ------- 2 ------- 3 ------- 4 ------- 5 ------- 6 ------- 7
	// 89012345678901234567890123456789012345678901234567890123456789012
	private static final String[] UNACCEPTABLE_FIRST_NAMES = new String[]{
			"Paul1", "1Paul", "-Paul", "Paul-", "2", "Paul@some"};

Here, we clearly pass the indicated line length and, furthermore, the formatting
of the assertEquals method is a bit weird.
	// - 1 ------- 2 ------- 3 ------- 4 ------- 5 ------- 6 ------- 7
	// 89012345678901234567890123456789012345678901234567890123456789012
	public void testPersonEquality() {
		try {
			Person p1c = cloneNewP1();
			Assert
					.assertEquals(
							"Two person objects with same name and pno are not equal",
							p1, p1c);
		} catch (MalformedNameException e) {
			Assert.fail("Unexpected MalformedNameException");
		} catch (WrongPersonNumberException e) {
			Assert.fail("Unexpected WrongPersonNumberException");
		}
	}

A case where the line is cut on character before the indicated maximum line length:
	// - 1 ------- 2 ------- 3 ------- 4 ------- 5 ------- 6 ------- 7
	// 89012345678901234567890123456789012345678901234567890123456789012
	String[] s = {"18", "bb", "cc", "dd", "ee", "ff", "gg", "hh", "ii",
			"jj", "kk", "ll", "mm"};
	String[] st = {"19", "bb", "cc", "dd", "ee", "ff", "gg", "hh",
			"ii", "jj", "kk", "ll", "mm"};

Sometimes, code is touched which does not need to be formatted. The unformatted
code (remember: tab is 4 characters):
			} catch (WrongPersonNumberException e2) { 
				// ignore expected exception
			}

The formatted code (1st time formatted):
			} catch (WrongPersonNumberException e2) {// ignore expected
													 // exception
			}
The formatted code (formatted above a second time):
			} catch (WrongPersonNumberException e2) { // ignore
													  // expected
				// exception
			}
The formatted code (formatted a third time):
			} catch (WrongPersonNumberException e2) { // ignore
				// expected
				// exception
			}
After this third time, the formatting stays stable. With one indentation level
less, it does not jump around so much.

I hope I'm not veering to much off topic here.
Comment 7 Olivier Thomann CLA 2004-05-19 15:33:59 EDT
Reconsider post 3.0.
Comment 8 Olivier Thomann CLA 2004-06-08 22:23:02 EDT
*** Bug 65974 has been marked as a duplicate of this bug. ***
Comment 9 Robert (Kraythe) Simmons CLA 2004-09-20 14:53:31 EDT
This can be done with wrap on columns but it doesnt work because of bug number 
49896. If tabs are on, nothing lines up. Reopened in accordance with re-
opening 49896.
Comment 10 Philipe Mulet CLA 2005-04-07 08:01:36 EDT
Deferring post 3.1
Comment 11 Robert (Kraythe) Simmons CLA 2005-04-08 04:21:34 EDT
Deferring BASIC and CORE formatting code is not a good idea. 
Comment 12 Olivier Thomann CLA 2005-04-08 08:51:21 EDT
The focus right now is on performance. Nothing prevents you from providing patches.
Comment 13 Eclipse Webmaster CLA 2009-08-30 02:40:09 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.