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

Bug 348061

Summary: [1.7] [quick assist] Quick assists to convert multiple catch blocks to a single multi-catch block and vice versa
Product: [Eclipse Project] JDT Reporter: Deepak Azad <deepakazad>
Component: UIAssignee: Deepak Azad <deepakazad>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: deepakazad, markus.kell.r, Michael_Rennie
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
fix + tests none

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){}
	}
}