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 212656 - Patch for: Add fixable hint: "Search and add library for unknown symbol" in a NBM project
Summary: Patch for: Add fixable hint: "Search and add library for unknown symbol" in a...
Status: RESOLVED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Martin Kozeny
URL:
Keywords: PATCH_AVAILABLE
Depends on:
Blocks:
 
Reported: 2012-05-17 17:15 UTC by markiewb
Modified: 2013-04-28 02:17 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
example (57.30 KB, image/png)
2012-05-17 17:15 UTC, markiewb
Details
patch for apisupport.ant (3.24 KB, patch)
2012-09-02 12:05 UTC, markiewb
Details | Diff
patch for java.hint (19.13 KB, patch)
2012-09-02 12:05 UTC, markiewb
Details | Diff
Live example of patches in action (164.63 KB, image/png)
2012-09-02 12:07 UTC, markiewb
Details
Proposed patch - hint was moved to apisupport.ant (23.84 KB, patch)
2013-04-18 21:42 UTC, markiewb
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description markiewb 2012-05-17 17:15:37 UTC
Created attachment 119582 [details]
example

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
Comment 1 markiewb 2012-09-02 12:05:19 UTC
Created attachment 123801 [details]
patch for apisupport.ant
Comment 2 markiewb 2012-09-02 12:05:37 UTC
Created attachment 123802 [details]
patch for java.hint
Comment 3 markiewb 2012-09-02 12:07:08 UTC
Created attachment 123803 [details]
Live example of patches in action
Comment 4 markiewb 2012-09-02 12:17:22 UTC
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!
Comment 5 Jan Lahoda 2012-09-02 18:07:29 UTC
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.
Comment 6 markiewb 2012-09-03 20:53:02 UTC
(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.
Comment 7 Martin Kozeny 2013-03-27 14:06:04 UTC
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.
Comment 8 markiewb 2013-04-18 21:42:10 UTC
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.

Details:
* 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)
Comment 9 Martin Kozeny 2013-04-24 12:24:25 UTC
Thanks a lot Benno for providing patch, hint is now correctly implemented and works fine.
Comment 10 Martin Kozeny 2013-04-24 13:03:01 UTC
https://hg.netbeans.org/core-main/rev/936fda5b295a
Comment 11 Quality Engineering 2013-04-28 02:17:41 UTC
Integrated into 'main-golden', will be available in build *201304272301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/936fda5b295a
User: Benno Markiewicz <markiewb@netbeans.org>
Log: #212656: Added fixable hint: "Search and add library for unknown symbol" in a NBM project.