Bug 313446 - [content assist] automated package determination for an object
Summary: [content assist] automated package determination for an object
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: 3.7 M3   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-18 17:25 EDT by Vivek CLA
Modified: 2010-10-26 14:28 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vivek CLA 2010-05-18 17:25:17 EDT
Build Identifier: M20070212-1330 (Ubuntu version: 3.2.2-5ubuntu2)

Is there a possibility for this?
You may be able to automatically determine package of a Java object based on the assignment.
Say you have a Java statement: 
Date todayDate = Calendar.getInstance().getTime();
We haven't yet added the import statement "import java.util.Date;".  At this point, based on the type of the object returned by getTime(), can we determine that todayDate belongs to java.util.Date (as opposed to other Date classes like java.sql.Date) and automatically create an import statement?



Reproducible: Always
Comment 1 Dani Megert CLA 2010-05-19 03:22:38 EDT
Interesting idea. See also bug 87950. Code assist could provide a required import proposal along with the method proposal.
Comment 2 Srikanth Sankaran CLA 2010-05-19 03:33:31 EDT
Ayush, please follow up
Comment 3 Markus Keller CLA 2010-05-20 10:57:05 EDT
I wouldn't expect that content assist for getTime() automagically adds an import. 

What if wanted to type ...getTime().toSqlDate()? I know that java.util.Date#toSqlDate() doesn't exist, but you get the point.

This should be dealt with in Organize Imports (bug 87950), or the user should just write "Calendar.getInstance().getTime();" and the use Quick Assist (Ctrl+1) to create the new variable.
Comment 4 Vivek CLA 2010-05-20 16:56:06 EDT
>What if wanted to type ...getTime().toSqlDate()? I know that
> java.util.Date#toSqlDate() doesn't exist, but you get the point.

Actually, what I was thinking is that the automatic import statement only gets added if the user added ; to indicate end of line.  Or if the ; already existed and user made some changes to the line then automatic import to kick in after they moved to another line.  
Of course, to ensure that user is not left in the dark, some unobtrusive popup having transparent background that auto-fades could show up -- perhaps towards upper-right corner or somewhere convenient.  The popup would indicate that the import statement was added.  The popup fades away to ensure user doesn't need to take any action. 

I note your point regarding bug 87950.
Comment 5 Ayushman Jain CLA 2010-09-20 08:37:59 EDT
(In reply to comment #4)
> >What if wanted to type ...getTime().toSqlDate()? I know that
> > java.util.Date#toSqlDate() doesn't exist, but you get the point.
> 
> Actually, what I was thinking is that the automatic import statement only gets
> added if the user added ; to indicate end of line.  Or if the ; already existed
> and user made some changes to the line then automatic import to kick in after
> they moved to another line.  
> Of course, to ensure that user is not left in the dark, some unobtrusive popup
> having transparent background that auto-fades could show up -- perhaps towards
> upper-right corner or somewhere convenient.  The popup would indicate that the
> import statement was added.  The popup fades away to ensure user doesn't need
> to take any action. 
> 
> I note your point regarding bug 87950.

Sorry for following up late on this. To me, it doesn't sound very content-assist like to automatically add something without being prompted by a ctrl-space. If the intension is to add the import statement only after the user has typed in the ; signalling end of line, organise imports is a better way of doing that. I dont think its good to expect the user to press CTRL - SPACE after typing in the ';' and find that the import statement has been added. Also, if it anyway has to involve user action, it might as well be done via CTRL+1. The idea of using content assist doesnt sound too convincing to me.
Dani, what do you think?
Comment 6 Dani Megert CLA 2010-09-20 09:42:35 EDT
>Dani, what do you think?
I agree, especially due to the scenario that Markus gave. Note though that content assist does insert imports in some cases, e.g. here:

    HashMap m;
    m.<code assist>
==> inserts import for HashMap.

Suggest to close as WONTFIX.
Comment 7 Ayushman Jain CLA 2010-09-21 02:59:19 EDT
(In reply to comment #6)
> >Dani, what do you think?
> I agree, especially due to the scenario that Markus gave. Note though that
> content assist does insert imports in some cases, e.g. here:
> 
>     HashMap m;
>     m.<code assist>
> ==> inserts import for HashMap.
> 
> Suggest to close as WONTFIX.

Closing as WONTFIX
Comment 8 Olivier Thomann CLA 2010-10-26 14:28:53 EDT
Verified for 3.7M3.