-
Notifications
You must be signed in to change notification settings - Fork 918
Description
Apache NetBeans version
Apache NetBeans 28
What happened
In a new-expression with diamond operator (<>) for a generic class, like new Example<>, code completion to select between constructors works before the diamond operator, but not after it; the popup shows "No suggestions". Strangely, it does work for classes like ArrayList from the JDK. It does not work for in-project classes, or for other dependencies, like for example JAXBElement in javax/jakarta.xml.bind.
Language / Project Type / NetBeans Component
Java, Editor
How to reproduce
In a Java project, add the following class:
public class Example<T> {
public Example(T value) { }
public Example(String name, T value) { }
}Anywhere in the project, in an expression/statement context, enter the partial expression new Example<>. Add an import for the class if necessary.
Invoke code completion before the <> => the popup shows both constructors, and Example<T> as a third entry.
Invoke code completion after the <> => the popup shows "No suggestions".
Add the JAXB API as a dependency and try the same for new JAXBElement<> => same result.
Do the same for (java.util) new ArrayList<> => code completion shows all three constructors both before and after the diamond operator.
Did this work correctly in an earlier version?
No / Don't know
Operating System
Windows
JDK
JDK 21
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
When adding type parameters, i.e. not using the diamond operator, code completion does work after type-argument list, as in new Example<String>.
Are you willing to submit a pull request?
No