eclipse-jdt / eclipse-jdt/eclipse.jdt.ui
Allow importing multiple static methods with same name but different signatures
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 59
- Forks
- 127
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 37
Description
Description:
Since eclipse.jdt.ui#2043, the "Source > Add Import (Ctrl+Shift+M)" action is blocked if a method with the same name already exists (is imported) in the file.
Currently, if I want to import two static methods with the same name from different classes, the import action is blocked after the first import — even though the methods have different parameter types.
I understand that it may not be feasible to fully check the requested static import for semantic conflicts in the file.
Example:
import static com.example.Util1.process; // first import works
// Trying to import the next one via Ctrl+Shift+M fails:
import static com.example.Util2.process;
public class Test {
public void run() {
process("text"); // from Util1
process(123); // from Util2
}
}
In the example above, both process methods exist in different classes and have different parameter types, but the second import is blocked.
Proposed improvement:
Add a workspace preference.
When disabled, Eclipse would allow multiple static imports with the same method name, regardless of potential name collisions.
This would allow developers to decide whether they prefer safety (current behavior) or flexibility (allow same-name imports).
Thanks in advance
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Source > Add Import (Ctrl+Shift+M) action and trace the existing same-name static-import check. Then locate the workspace-preference wiring and related tests; done means the preference switches between blocking and allowing same-name imports while preserving the described behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100