| Summary: | [organize imports] Auto-import could be smarter | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Brian Cort <briancort> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 3.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | stalebug | ||
|
Description
Brian Cort
Moving to JDT UI we can only do that if there is really ony one method matching. And I think it only works for Enums Martin, I believe you are misunderstanding my bug report, since it has nothing to do with enums.
Suppose I define the following classes:
package my.pkg1;
public class Color {
}
-----
package your.pkg2;
public class Color {
}
public class Thing {
public void setColor(Color c) {} // <-- expects a your.pkg2.Color since its in the same package
}
------
And then suppose I'm working in another class in another package:
package other.pkg;
class CCCC {
public CCCC() {
your.pkg2.Thing thing = new your.pkg2.Thing();
thing.setColor(new Color());
^^----------------------------- cursor is HERE
}
}
If I put the cursor where indicated and press Ctrl-Shift-M (auto-import), a dialog will come up asking whether I mean 'my.pkg.Color', 'your.pkg2.Color', 'java.awt.Color', etc. This is unnecessary since the only valid type for the method is 'your.pkg2.Color'.
This issue affects me on a daily basis as I interact with quite a few 2d and 3d libraries and they all define commonly named classes such as 'polygon, color', etc.
Thanks for your attention.
ok, your're right I realized this bug could be generalized to include another case where import could be smarter. I'm not sure if this should be filed as a separate issue: When defining a type in an assignment statement, the import should be automatic. So extending my example from comment 3: If your.pkg2.Thing had a method 'Color getColor() {...} Then anywhere I type Color c = new your.pkg2.Thing().getColor() I should not need to select which Color I mean in the import dialog. An option to auto-import whenever possible (without needing to move the cursor over the unknown element and press ctrl-shift-M) would be the next step and make things much smoother. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |