Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 86169

Summary: [ca] JSP Java content assist should auto-import necessary class
Product: [WebTools] WTP Source Editing Reporter: Phillip Avery <pavery>
Component: jst.jspAssignee: Phillip Avery <pavery>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: ms
Version: 1.5   
Target Milestone: 1.5 M5   
Hardware: All   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Bug in the auto-import implementation when html tags in page none

Description Phillip Avery CLA 2005-02-22 12:57:05 EST
JSP Java content assist should auto-import a necessary package/class if a class is 
selected from content assist who is not imported already.

In regular JSP syntax it would insert <%@page import="org.foo.Class"%>

in XML-JSP syntax it would <jsp:directive.page import="org.foo.Class"/>

These would probably be inserted at the top of the file (if that's convention)
and under <jsp:root> if it's XML-JSP.
Comment 1 Mark Sederqvist CLA 2005-06-24 18:43:23 EDT
This will be a good and important feature for JSP editing, compared with the 
current behavior, which is to insert the fully qualified type name when 
selected via content assist.

Additionally, the JSP page import directive should be updated when classes are 
refactored. I believe this works for class renaming currently, but it does not 
work for moving classes between packages. Maybe this should be adressed as a 
separate defect/feature request?
Comment 2 David Mansfield CLA 2005-11-29 11:37:24 EST
this is a huge missing component?  how is it that this hasn't happened?
Comment 3 Phillip Avery CLA 2005-11-29 17:48:46 EST
One place we could do this is JSPProposalCollector#createJavaCompletionProposal()

If we detect that the name is fully qualified, we can create a special proposal that add the import (if it's not there already...).  

We should look @ how JDT does it.
Comment 4 Phillip Avery CLA 2006-01-11 10:16:29 EST
I checked a fix for this into HEAD.

In JSPProposalCollector I detect if the proposal is an (undesirable) fully qualified Type name.  I then create a special completion proposal that inserts the import statement (AutoImportProposal).
Comment 5 Vincent Cariven CLA 2006-01-14 12:26:44 EST
Created attachment 33029 [details]
Bug in the auto-import implementation when html tags in page

I checked the feature in the build I200601130122 (January 13, 2006).
First, what a pleasure to see the auto import feature implemented : Thanks !!!

In a blank new file, the auto-import runs well. 
But when the file is containing HTML tags, import directive is added the line up the first html tag and the cursor is left inside the import directive.
Comment 6 David Williams CLA 2006-03-04 01:05:22 EST
This change is a bulk update of all _un_targeted, fixed, resolved bugs upon release of M5. This particular bug _might_ have been fixed earlier than M5. (Feel free to correct). 

Comment 7 John Lanuti CLA 2006-11-28 15:59:38 EST
This is part of a mass update to close out all stale WTP resolved bugs from the 1.0.x and 1.5.0 timeframe.  If you feel this bug was closed inappropriately, please reopen.

Thanks, John Lanuti