Bug 377658 - [quick fix] 'Add Import' Quickfix should consider return type of RHS of an assignment
Summary: [quick fix] 'Add Import' Quickfix should consider return type of RHS of an as...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 87950
Blocks:
  Show dependency tree
 
Reported: 2012-04-25 12:01 EDT by Marcel Bruch CLA
Modified: 2013-02-19 08:03 EST (History)
3 users (show)

See Also:


Attachments
not that smart quickfix for type imports (40.43 KB, image/png)
2012-04-25 12:01 EDT, Marcel Bruch CLA
no flags Details
Another scenario in throw/catch statements (84.65 KB, image/png)
2012-04-27 10:03 EDT, Marcel Bruch CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel Bruch CLA 2012-04-25 12:01:11 EDT
Created attachment 214541 [details]
not that smart quickfix for type imports

Given a field declaration of

Logger log = org.slf4j.LoggerFactory.getLogger(getClass());

with Logger not being imported yet, quickfix proposes all types of Logger but the only correct one is at the bottom of the list (see screenshot).

It would be nice if quickfix would consider the right hand side of the assignment to determine the best matching type.
Comment 1 Marcel Bruch CLA 2012-04-27 10:03:53 EDT
Created attachment 214704 [details]
Another scenario in throw/catch statements

In this case an instance of the aether exception is thrown. It's not a supertype of the other exception which makes the first proposal a false recommendation.
Comment 2 Markus Keller CLA 2012-04-27 13:29:30 EDT
This would be even more useful for Organize Imports (bug 87950).
Comment 3 Marcel Bruch CLA 2012-05-12 04:31:44 EDT
Since this is an "old" bug (origins in bug 87950): Is this something that waits for external contributions or will it become part of the planned features for 3.9?



BTW:
Each semester we organize an Eclipse hands-on in which students develop a feature for one of our university projects. These topics should be solvable in ~180 hours by a student in the 5th semester. To me these enhancements look like good candidate topics for this hands-on. 

Let me know if JDT team would be interested in this. Give a (short) list of non-urgent features you think can be solved by students, I can announce these topics, search for students that do open-source coding for grades, and assist them to get going. In conjunction with Gerrit I can imagine this to work out quite well for JDT.
Comment 4 Dani Megert CLA 2012-05-14 04:41:59 EDT
(In reply to comment #3)
> Since this is an "old" bug (origins in bug 87950): Is this something that waits
> for external contributions or will it become part of the planned features for
> 3.9?

The JDT team will have to focus its time during Kepler on Java 8 plus critical bug fixes. Most likely we won't have time for any other feature work. This also means, no time to accept larger contributions.
Comment 5 Markus Keller CLA 2012-05-14 07:06:45 EDT
Another common problem for such bugs is that the right solution is usually not to add code that implements the request, but to find existing code that already implements most of the feature (ASTResolving#guessBindingForReference(ASTNode) in this case) and then
- make the code reusable without breaking existing clients
- make sure you don't add performance problems (not a big deal for "Add Import", but a crucial point for "Organize Imports")