This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 67873

Summary: Automatic import of new classes from code completion
Product: editor Reporter: khaipi <khaipi>
Component: Completion & TemplatesAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: blocker CC: markiewb
Priority: P3    
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description khaipi 2005-10-31 22:10:06 UTC
Any new class that is referenced in typed-in code or code produced with the 
assistance of code completion should automatically be imported (like it is in 
Eclipse).  At the moment it will first display the line with the squiggly red 
line under it and then you have to go to Source->Fix Imports to get it to 
happen.  Why not just have it automatic?
Comment 1 khaipi 2005-11-05 02:50:37 UTC
Perhaps the functionality of automatic imports should be optional so that those 
who prefer the older system can have it still.
Comment 2 Jiri Prox 2006-06-06 17:11:35 UTC
Necessary imports are already added when item from code completion is selected.
Comment 3 java_dev 2012-10-17 19:06:54 UTC
Auto-importing has to solve the problem of reasonably inferring the intentions of the programmer- do they want to import a class or create a class or create an inner class? 

It's impossible to know for sure, but   something like the following would go a long way to enhancing auto-import. Netbeans should auto-import when a class unambiguously matches one in packages which are

1) very common (java.* javax.* etc.). 

For example, I am guessing that most people use the libs in the JDK, even though there classes with the same names in say, trove. 

People using trove often times want it for ONE package or even a specific class. So an option would be to always auto-import from the JDK even if matching trove classes were found. satisfactory tweaking of this default behaviour might be achievable using 3 below .

2) OR listed explicitly by the developer on a configuration screen.

3) AND not on a developer-specified excludes list (say if I were creating my own swing widgets with the same names as the original swing widgets, then I might want to exclude swing from auto-import)


HTH
Comment 4 java_dev 2012-10-17 19:08:02 UTC
Auto-importing has to solve the problem of reasonably inferring the intentions of the programmer- do they want to import a class or create a class or create an inner class? 

It's impossible to know for sure, but   something like the following would go a long way to enhancing auto-import. Netbeans should auto-import when a class unambiguously matches one in packages which are

1) very common (java.* javax.* etc.). 

For example, I am guessing that most people use the libs in the JDK, even though there classes with the same names in say, trove. 

People using trove often times want it for ONE package or even a specific class. So an option would be to always auto-import from the JDK even if matching trove classes were found. satisfactory tweaking of this default behaviour might be achievable using 3 below .

2) OR listed explicitly by the developer on a configuration screen.

3) AND not on a developer-specified excludes list (say if I were creating my own swing widgets with the same names as the original swing widgets, then I might want to exclude swing from auto-import)


HTH
Comment 5 ecerichter 2012-10-17 19:17:48 UTC
If this is implemented, then there should be a way to disable it.
IMHO, I would not like IDE making decisions for me: would lead to bugs of difficult identification.

Perhaps, when I work with GWT, lots of classes has similar names as the ones found in Swing and other packages, and sometimes I have to correctly choose from one or other.