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.
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.
Created attachment 39560 [details] Screenshot fragment
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.
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?
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.
*** Issue 98044 has been marked as a duplicate of this issue. ***
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.
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.
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.