Created attachment 119582 [details]
When developing a NetBeans module i often do not know exactly from which libraries i have to import from. This should be improved the following way:
Example: I want to use the NbEditorUtilities class (which is not in classpath). I type the classname. An error appears complaining that "the symbol is unknown". Now i like to have a fixable hint named "Search and add library for unknown symbol", which opens the "Add module dependency"-dialog. The dialog is prefilled with the currently unknown classname. Then i select the library and OK. The library is added to the classpath and the error is gone.
NetBeans IDE Dev (Build 201205090400) /7.2
Created attachment 123801 [details]
patch for apisupport.ant
Created attachment 123802 [details]
patch for java.hint
Created attachment 123803 [details]
Live example of patches in action
I added a working patch based on modifications of the modules apisupport.ant and java.hint. It contains fixable hint for an unresolved class which opens the NetBeans plattform module dependency dialog. The dialog will be prefilled with the name of the unresolved class.
Note: I had to alter the friend-packages of apisupport.ant, so that the java.hint module can access the "add dependency"-dialog of apisupport.ant. I know that it is bad, but the NB-devs still can decide if its worth to change the public API and this way accept the proposed hint.
Note: You have to apply both patches.
See it in action via screenshot http://netbeans.org/bugzilla/attachment.cgi?id=123803.
Please review it!
First of all, thank you for the patch.
Unfortunately, I don't think it can be applied in the current state. First, it makes the java cluster dependent on the apisupport cluster, but there is already the opposite dependency, and I don't think cyclic dependencies are supported even on cluster level.
But even if that weren't a problem, I would argue that:
-java.hints should not do work specific to a project type - otherwise it might need to depend on all project types. Note that even maven which does something similar is not being handled by java.hints.
-(my opinion only, the ultimate decision is up to the maintainer of apisupport.ant): publishing two "random" packages from a module, even to friends only, seems not right. If absolutely needed, an API should be created for the needed functionality.
I see two possible solutions:
1. simple: basically take the SearchModuleDependency from the patch, and place it into some appropriate apisupport.* module (simplest would be apisupport.ant, and that might be acceptable - depends on the maintainer of that module). That module would need to become a friend of java.hints.legacy.spi, but I am fine with whatever apisupport.* module becoming a friend of it.
2. proper: create an SPI to handle unresolvable identifier error - providers like maven and apisupport(.ant?) could simply plug in to provide only their project-type specific handling. A java.hints class (ImportClass, presumably) would do the generic checking (which it must do already anyway).
If you would like to use solution 1, please reassign to the apisupport product, as it no longer has much to do with java.hints. Thanks.
(In reply to comment #5)
> I see two possible solutions:
> 1. simple: basically take the SearchModuleDependency ...
> 2. proper: create an SPI to handle unresolvable identifier error ...
> If you would like to use solution 1, please reassign to the apisupport product,
> as it no longer has much to do with java.hints. Thanks.
Thanks Jan for the details. As a contributer i cannot decide anything about your intermodule-dependencies.
But i will follow your tip and reassign the issue to apisupport.
Benno, also thanks for the patch from me. Could you please rewrite it according Honza Lahoda's solution 1. in order to integrate it to NetBeans? Thanks.
Created attachment 133576 [details]
Proposed patch - hint was moved to apisupport.ant
(In reply to comment #7)
> Benno, also thanks for the patch from me. Could you please rewrite it according
> Honza Lahoda's solution 1. in order to integrate it to NetBeans? Thanks.
@Martin: I rewrote the code according the solution 1 and regenerated the patch. Please have a look and review the patch.
* The hint is now included in apisupport.ant.
* apisupport.ant is now a friend module of java.hint.api.spi (to access ErrorRule)
* some dependencies were added to apisupport.ant (like editor.hints/lexer/java lexer to fulfill the imports)
Thanks a lot Benno for providing patch, hint is now correctly implemented and works fine.
Integrated into 'main-golden', will be available in build *201304272301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Benno Markiewicz <firstname.lastname@example.org>
Log: #212656: Added fixable hint: "Search and add library for unknown symbol" in a NBM project.