Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 349314

Summary: [1.7][formatter] Line wrapping for multi-catch arguments
Product: [Eclipse Project] JDT Reporter: Ayushman Jain <amj87.iitr>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: deepakazad, markus.kell.r, Olivier_Thomann, satyam.kandula
Version: 3.7Flags: Olivier_Thomann: review+
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
proposed fix v1.0 + regression tests
none
proposed fix v1.1 + regression tests none

Description Ayushman Jain CLA 2011-06-14 09:34:20 EDT
BETA_JAVA7

In the below given test case, we currently have no option in the formatter to wrap exceptions inside a multi-catch. So the exceptions never get wrapped currently. It will be good to have such an option.

class MultiCatch {
	void foo() {
		try {
			throw new FileNotFoundException();
		} catch (FileNotFoundException | IOException | RuntimeException | ArrayIndexOutOfBoundsException | IllegalArgumentException ex) {
		}
	}

}
Comment 1 Ayushman Jain CLA 2011-06-27 08:32:07 EDT
Created attachment 198641 [details]
proposed fix v1.0 + regression tests

This patch adds just an aligment option for exceptions in a multi catch. The spacing before or after the '|' is decided by the option DefaultCodeFormatterOptions.insert_space_before_binary_operator and insert_space_after_binary_operator

By default the alignment is set to Wrap when necessary with Default indentation
Comment 2 Ayushman Jain CLA 2011-06-27 08:32:58 EDT
Olivier, the patch is very similar to that in bug 349396. Can you review this as well? Thanks!
Comment 3 Markus Keller CLA 2011-06-27 15:02:31 EDT
(In reply to comment #1)
> Created attachment 198641 [details] [diff]
> proposed fix v1.0 + regression tests

+		final Object alignmentForUnionTypeInMulticatch = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH);
+		if (alignmentForResourcesInTry != null) {

The 'if' tests the wrong variable here.
Comment 4 Olivier Thomann CLA 2011-06-27 15:30:56 EDT
Same comment as Markus. Otherwise it looks good.
Comment 5 Ayushman Jain CLA 2011-06-28 01:48:56 EDT
Created attachment 198704 [details]
proposed fix v1.1 + regression tests

Thanks Markus, Olivier
Comment 6 Ayushman Jain CLA 2011-06-28 01:59:55 EDT
Released in BETA_JAVA7 branch
Comment 7 Deepak Azad CLA 2011-07-19 08:08:07 EDT
Verified with v20110714-1300.