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

Bug 352477

Summary: [1.7] [quickfix] 'Move exception to separate catch block' quick assist should be offered as a quick fix
Product: [Eclipse Project] JDT Reporter: Satyam Kandula <satyam.kandula>
Component: UIAssignee: Deepak Azad <deepakazad>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert, deepakazad
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Satyam Kandula CLA 2011-07-19 11:26:04 EDT
Paste in the following code into the package explorer
#########
import java.io.FileNotFoundException;
import java.io.IOException;

class MultiCatch {
    void foo() {
        try {
            throw new IOException();
        } catch (FileNotFoundException | IOException ex) {
        } 
    }
}
########
Notice that there is an error for the catch block. There is a quick assist to separate the catch blocks, but there should be a quick fix to separate the catch clauses.
Comment 1 Satyam Kandula CLA 2011-07-19 11:44:32 EDT
I filed this before reading bug 348860 completely. I see that the main concern is that there may be many quick fixes otherwise. Can't we propose to separate out the only selected catch argument?
Comment 2 Deepak Azad CLA 2011-07-19 12:01:08 EDT
(In reply to comment #1)
> I filed this before reading bug 348860 completely. I see that the main concern
> is that there may be many quick fixes otherwise. Can't we propose to separate
> out the only selected catch argument?

That's fine Satyam. The concern in that bug was about "Remove catch clause" and "Replace catch clause with throws" quick assists which work on the whole catch clause. However, 'Move exception to separate catch block' works on the selected exception(s) hence it is reasonable to offer it as well.

I will take a look.

Notes to self
- The catch clause for subtype should be created before the catch clause containing the super type.
- Also consider the case when there is more than one subtype-supertype relationship in a multi-catch clause.