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 60853 - Provide SPI for hooking into Fix Imports
Summary: Provide SPI for hooking into Fix Imports
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker with 2 votes (vote)
Assignee: Dusan Balek
Keywords: API, UI
Depends on:
Reported: 2005-07-11 21:01 UTC by Jesse Glick
Modified: 2012-03-07 15:57 UTC (History)
4 users (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2005-07-11 21:01:04 UTC
For 4.2 apisupport it would be very desirable to be able to hook into the logic
of the Fix Imports feature. For example, when searching for possible package
locations for an identifier like "ErrorManager", ask all SPI impls in lookup to
see if they have any additions. apisupport would notice that ErrorManager is a
class provided by org.openide.util; check if the file in question is part of a
module project; check if that project did not already have org.openide.util in
its dep list; and if so, add one entry to the list of possibilities. This entry
would encapsulate the following info:

1. The package should be "org.openide".

2. The entry should be specially marked in the UI, e.g. to include a label such
as "[and add dependency on the Utilities API]".

3. When fixing the import, also run a callback provided by apisupport (which
would adjust the module's dep list and thus classpath).

Is this feasible?
Comment 1 sigalduek 2005-12-07 09:06:59 UTC
During development of NetBeans Module, its very common to copy portion of code
from other modules sources. Of course, there are some imports that are missing.
The steps that required to be done after the developer copied the code:

           Developer need to  "Fix imports"
           If there are any missing dependencies, The "Fix Import" dialog will
display the missing variables.
           User need to switch to project properties-> LIbraries -> Add Module
dependencies, click on the "Add" button and type the missing class in the Filter. 
           Again, in the editor, use the "Fix imports" .

     It will be a great value to have it in a single action (i.e "Fix
    imports" action will also add the missing dependencies to the project) 
Comment 2 Jesse Glick 2010-09-23 10:51:26 UTC
Done as a separate hint for Maven projects: maven.hints/src/org/netbeans/modules/maven/hints/errors/