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 98041 - Consider providing support for resolving not yet imported classes
Summary: Consider providing support for resolving not yet imported classes
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: Sun All
: P3 blocker (vote)
Assignee: Dusan Balek
URL:
Keywords:
: 98044 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-03-15 22:18 UTC by _ pcw
Modified: 2007-03-23 09:33 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Screenshot fragment (9.62 KB, image/png)
2007-03-15 22:18 UTC, _ pcw
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ pcw 2007-03-15 22:18:26 UTC
See attached screenshot.

Specifically, I invoked code completion at the tail end of an expression like
"Map<X, Y> foo = new Concurrent^".

I was expecting to see a list of the Concurrent map classes from
java.util.concurrent.  What I got was an empty list saying I needed to hit
Ctrl-Space again.

What possible use is this second step in this context?  Note that in 5.5, the
list would be correct on the first ctrl-space, no second typing required.
Comment 1 _ pcw 2007-03-15 22:18:56 UTC
Created attachment 39560 [details]
Screenshot fragment
Comment 2 Jiri Prox 2007-03-16 09:31:48 UTC
Is class java.util.Map imported? If yes, all subclasses (filtered according to
entered prefix) of Map should be shown when the ctrl-space if pressed just once. 
Comment 3 _ pcw 2007-03-16 09:56:45 UTC
No, Map was not imported at the time.  I'll have to think about this, not sure I
like the direction this appears to be heading.

This might be good for people who do package imports (e.g java.util.*) but we do
imports by classname and that means a fair bit of code will get written against
classes that are not imported.

I guess you're saying this is by design then?
Comment 4 Jiri Prox 2007-03-16 10:18:22 UTC
This is not dependent of the style of import statements. Does not matter if you
have imported single class or whole package.

The problem is that when you write:
Map m = new ^
when Map is not imported, the IDE does not know what type is variable m and what
classes can be assigned to it. 
Since the type is unresolved and there are not any classes starting with
Concurrent* available in current scope (it means the package
java.util.concurrent.* is not imported as well, am I right? ) the first code
completion popup provides nothing. After pressing ctrl-space for second time the
all symbols CC is shown, providing all possible classes (regardless if they are
imported or suitable in current position).
That's the way it works now. If you have any suggestions for improving you're
welcome.
Comment 5 Dusan Balek 2007-03-16 11:16:50 UTC
*** Issue 98044 has been marked as a duplicate of this issue. ***
Comment 6 _ pcw 2007-03-16 20:14:51 UTC
Yes, it is dependent on package vs. name imports.  If I'm using collections in a
given java file, w/ package imports, then one import will get the entire
virtually all the collection classes.  OTOH, if I import by name, then every new
collection type will suffer the described behavior up to the point where I stop
using new interfaces in the affected file (well, unless I happen to use
java.util.Collection which most/all of the others derive from, but I rarely use
that one).

My suggestion is that if the first list comes back blank, then the IDE should
automatically put up the second list rather than requiring me to type an
additional Ctrl-Space to get it.  I don't see any value in presenting an empty list.
Comment 7 Jiri Prox 2007-03-16 20:47:04 UTC
Sorry I haven't express myself quite clearly. I've meant the import style is
independent on working of code completion. It's only important that the variable
on the left side is resolved. The code completion window consists of two parts
(separated by line), both can be empty. The upper part was previously called
"smart" and provides all subtypes of the class on the left size - independently
if  they are imported or not, in the bottom part is normal code completion
providing all imported classes (even if their type does not suite). If both
lists are empty the completion provides "no suggestion". The automatic switching
to all symbols completion was turned off. It appears to be too complicated for
users, they often lose control of completion scope.

Comment 8 Dusan Balek 2007-03-19 13:00:22 UTC
*** Issue 98044 has been marked as a duplicate of this issue. ***
Comment 9 Dusan Balek 2007-03-23 09:33:37 UTC
Current behavior is as designed. Since 'javac' compiler is used by the current
code dompletion infrastructure to resolve type of the variable on the left side,
the corresponding type has to be imported.

We should perhaps consider providing a support for resolving not yet imported
classes in code completion, however this will be hardly done in 6.0 timeframe.
Changing to enhancement.