Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348061 - [1.7] [quick assist] Quick assists to convert multiple catch blocks to a single multi-catch block and vice versa
Summary: [1.7] [quick assist] Quick assists to convert multiple catch blocks to a sing...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.7.1   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-02 07:28 EDT by Deepak Azad CLA
Modified: 2011-08-02 05:45 EDT (History)
3 users (show)

See Also:


Attachments
fix + tests (31.50 KB, patch)
2011-06-09 02:02 EDT, Deepak Azad CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Deepak Azad CLA 2011-06-02 07:28:44 EDT
We should provide 2 new quick assists
- Convert to a single multi-catch block - offered on catch blocks with identical body
- Convert to multiple catch blocks - offered on a multi-catch block

I suppose these should also be available as clean-ups, but this can be done at a later stage.
Comment 1 Deepak Azad CLA 2011-06-02 07:29:12 EDT
I will attach a patch.
Comment 2 Deepak Azad CLA 2011-06-09 02:02:27 EDT
Created attachment 197665 [details]
fix + tests
Comment 3 Deepak Azad CLA 2011-06-09 02:02:52 EDT
Fixed in BETA_JAVA7
Comment 4 Michael Rennie CLA 2011-07-19 16:58:54 EDT
verified.

An example snippet to test with:

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class MultiCatch {
	public static void main(String[] args) {
		File file = new File("");
		try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
			System.err.println("reading...");
		}
		catch(IOException | NullPointerException ex){} 
		catch(IllegalArgumentException iae){}
		
		file = new File("");
		try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
			System.err.println("reading...");
		}
		catch(IOException ioe){} 
		catch(NullPointerException npe){}
		catch(IllegalArgumentException iae){}
	}
}