eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

Clean up "Use Multi-catch" does not removed then unused imports

Open
#125 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
59
Forks
127
Avg merge
23h 30m
Merged PRs (30d)
35

Description

If one applies the clean-up "Use Multi-catch" to the following code snippets, the afterwards unused import for `IOException` is not removed:
```
package test;
import java.io.IOException;

public class Test {
public void m() {
try {
m1();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
private void m1() throws Exception {
}
}
```
Expected is the following code, but at the moment the import is not removed.
```
package test;
public class Test {
public void m() {
try {
m1();
} catch (Exception e) {
e.printStackTrace();
}
}
private void m1() throws Exception {
}
}
```
The example makes a bit more sense when the called method is defined in another Class and lists both `IOException` and `Exception` in its throws list.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue using the Java snippets in the report and apply the “Use Multi-catch” cleanup. Compare the result with the expected code: the redundant catch should be removed and the now-unused IOException import should also disappear.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.