Bug 352477 - [1.7] [quickfix] 'Move exception to separate catch block' quick assist should be offered as a quick fix
Summary: [1.7] [quickfix] 'Move exception to separate catch block' quick assist should...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-19 11:26 EDT by Satyam Kandula CLA
Modified: 2011-07-21 03:56 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 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.