Bug 44493 - Improve formatting of throws clauses
Summary: Improve formatting of throws clauses
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-08 16:04 EDT by Olivier Thomann CLA
Modified: 2018-07-14 16:39 EDT (History)
1 user (show)

See Also:


Attachments
Latest result (173 bytes, text/plain)
2003-11-25 14:24 EST, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2003-10-08 16:04:47 EDT
Using 1008, the NullPointerException should be indented one more time.
public class X {
	void foo() throws java.io.IOException, java.lang.IllegalArgumentException,
java.lang.NullPointerException {
	}
}
Comment 1 Philipe Mulet CLA 2003-10-08 17:26:46 EDT
should use compact shift indent alignment
Comment 2 Olivier Thomann CLA 2003-11-25 13:00:37 EST
I get this:
public class X {
	void foo()
			throws java.io.IOException, java.lang.IllegalArgumentException, 
			java.lang.NullPointerException {
	}
}

I think it makes more sense to remove the alignment on the throws and let the
exceptions being aligned on the next line.
So we would get:
public class X {
	void foo() throws java.io.IOException, java.lang.IllegalArgumentException,
		java.lang.NullPointerException {
	}
}

Jindent formats it like that:
public class X {

    void foo() throws java.io.IOException,
                      java.lang.IllegalArgumentException,
                      java.lang.NullPointerException {}
}

Do we want something similar?
Comment 3 Olivier Thomann CLA 2003-11-25 14:24:19 EST
Open attached file to see the latest result. I prefer this solution. JIndent is
quite inconsistent for the throw clause alignment and I didn't find any specific
details on this in the Sun conventions.
Comment 4 Olivier Thomann CLA 2003-11-25 14:24:38 EST
Created attachment 6949 [details]
Latest result
Comment 5 Philipe Mulet CLA 2003-11-26 07:00:59 EST
Wondering if the #throws clause shouldn't remain on the same line ? 
This is why I thought the compact shift indent would do the trick...

public class X {
  void foo() throws java.io.IOException, java.lang.IllegalArgumentException,
                 java.lang.NullPointerException {
  }
}
Comment 6 Philipe Mulet CLA 2003-11-26 07:01:56 EST
If the line then gets too long, it should then try to format as described in 
comment #4.
Comment 7 Olivier Thomann CLA 2003-11-26 08:17:43 EST
The problem is that the "throws" keyword is part of the alignment. Then as soon
as you split, throws moves to the next line. I don't see how to keep throws on
the first line.
Comment 8 Olivier Thomann CLA 2003-11-26 14:16:30 EST
I was not using the right alignment.
Now I get:

public class X {
    void foo() throws java.io.IOException, java.lang.IllegalArgumentException,
            java.lang.NullPointerException {
    }
}

Consider as fixed.
Regression test added. Reopen if it is not working as expected. I am not doing
any split between the throws and the first exception name. This prevents from
having throws at the end of the line.
Comment 9 David Audel CLA 2003-12-16 11:53:03 EST
Verified for 3.0M6