Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349314 - [1.7][formatter] Line wrapping for multi-catch arguments
Summary: [1.7][formatter] Line wrapping for multi-catch arguments
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.7.1   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-14 09:34 EDT by Ayushman Jain CLA
Modified: 2011-08-05 02:54 EDT (History)
4 users (show)

See Also:
Olivier_Thomann: review+


Attachments
proposed fix v1.0 + regression tests (43.18 KB, patch)
2011-06-27 08:32 EDT, Ayushman Jain CLA
no flags Details | Diff
proposed fix v1.1 + regression tests (44.20 KB, patch)
2011-06-28 01:48 EDT, Ayushman Jain CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.