Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350311 - [1.7][quick assist] Extract multi-catch type to separate catch clause
Summary: [1.7][quick assist] Extract multi-catch type to separate catch clause
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: 3.7.1   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-24 13:45 EDT by Markus Keller CLA
Modified: 2011-08-02 05:45 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-06-24 13:45:29 EDT
BETA_JAVA7

Add a quick fix on a type in a multi-catch clause that extracts the type into a separate catch clause.

Example: Pick out NoSuchMethodException to handle it specially:

package multicatch;
import java.lang.reflect.InvocationTargetException;
public class Reflect {
	public static void main(String[] args) {
		try {
			String.class.getConstructor().newInstance();
		} catch (InstantiationException | IllegalAccessException
				| IllegalArgumentException | InvocationTargetException
				| NoSuchMethodException | SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

After this is done, it looks strange that the 'Convert to a single multi-catch block' is not available on a on a type inside a multi-catch clause. Should enable it everywhere inside the CatchClause except for the body Block.
Comment 1 Deepak Azad CLA 2011-06-24 14:01:31 EDT
Nice idea. Though we can make it more general - select one or more types and move them to a new catch block. I guess the body of the new catch block should be a copy of the current one.
Comment 2 Deepak Azad CLA 2011-07-06 22:47:32 EDT
Fix contained in patch in bug 348860 comment 11.

Fixed in BETA_JAVA7.
Comment 3 Satyam Kandula CLA 2011-07-19 11:50:52 EDT
Verified using patch 1.0.0.v20110714-1400