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 232538 - Fix imports after invoking hint: "Search and add library for unknown symbol"
Summary: Fix imports after invoking hint: "Search and add library for unknown symbol"
Status: RESOLVED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Martin Kozeny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-10 21:52 UTC by markiewb
Modified: 2013-10-16 12:44 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description markiewb 2013-07-10 21:52:14 UTC
This is a follow-up to Bug 212656 - Patch for: Add fixable hint: "Search and add library for unknown symbol" in a NBM project

Steps:
* create a new NBM project
* type "Node a=null;" in method body -> Node is unknown and underlined in red
* press ALT-ENTER -> hints open
* choose "Search Module Dependency for Node" hint -> Dialog pops up
* choose Nodes API as dependency

-->
ACTUAL: Node is unknown and underlined in red - it requires an import of org.openide.nodes.Node to be compilable
EXPECTED: Node is unknown and underlined in red, NetBeans asks whether the user wants to "fix imports". If yes NetBeans invokes the existing action "Fix imports..."
Comment 1 Martin Kozeny 2013-09-10 08:31:13 UTC
Benno, why do you think, that it is wrong how it works now? After adding Nodes API dependency, you will get will get among hints "Add import for org.openide.nodes.Node", which is accoding to me alright, b/c you still have to choose appropriate import for your using of class Node. Fix imports is used only for reorganizing imports in class e.g. remove unused imports...
Comment 2 markiewb 2013-09-11 15:52:26 UTC
(In reply to Martin Kozeny from comment #1)
> Benno, why do you think, that it is wrong how it works now? After adding
> Nodes API dependency, you will get will get among hints "Add import for
> org.openide.nodes.Node", which is accoding to me alright, b/c you still have
> to choose appropriate import for your using of class Node. Fix imports is
> used only for reorganizing imports in class e.g. remove unused imports...

I understand and know that is possible (currently working this way), but I invoked the hint "Search and add library for unknown symbol" to help me to fix the compile error. I don't want to execute another hint to add an import statement when there is only one possible match.

Let go into details...

After choosing a dependency in the dialog ...
* if there is only one possible import (ONLY from the newly added dependency) NB should add an import statement for this one possible match
* if there are more than one possible imports (ONLY from the newly added dependency) NB should show a dialog to choose from all these importable matches (like the "fix imports" dialog). The user can choose one of them and an import statement is added.

How about this?
Comment 3 Martin Kozeny 2013-09-12 12:14:43 UTC
Ok I suggest this:

If there is a unique import from added dependency or dependencies (in 99% there is), NetBeans should automatically add import to class file as we can expect, that when there is a dependency(ies) added, programmer want to add import from that dependency(ies). If there isn't or there are more possible imports, nothing changed from actual state. Is it ok for you?

Your second part of this enhancement:

* if there are more than one possible imports (ONLY from the newly added dependency) NB should show a dialog to choose from all these importable matches (like the "fix imports" dialog). The user can choose one of them and an import statement is added.

is little bit diffucult, b/c you have to somehow hold the context, that you add those dependencies and after that you want to only choose from that dependencies.
Comment 4 markiewb 2013-09-12 18:36:16 UTC
(In reply to Martin Kozeny from comment #3)
> Ok I suggest this:
> 
> If there is a unique import from added dependency or dependencies (in 99%
> there is), NetBeans should automatically add import to class file as we can
> expect, that when there is a dependency(ies) added, programmer want to add
> import from that dependency(ies). If there isn't or there are more possible
> imports, nothing changed from actual state. Is it ok for you?
> 
That would be good! If 99% of the cases are fulfilled then it is enough.

> Your second part of this enhancement:
> 
> * if there are more than one possible imports (ONLY from the newly added
> dependency) NB should show a dialog to choose from all these importable
> matches (like the "fix imports" dialog). The user can choose one of them and
> an import statement is added.
> 
> is little bit diffucult, b/c you have to somehow hold the context, that you
> add those dependencies and after that you want to only choose from that
> dependencies.
So leave it out. The impl of the usecase above is good enough.
Comment 5 Martin Kozeny 2013-10-16 12:44:23 UTC
https://hg.netbeans.org/core-main/rev/282e21416425