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.
When invoking CC to generate a constructor, the only option provided is that of a "default" (no-argument) constructor, even when the superclass has no such constructor. The result is generated code that does not compile. It would be great if the CC would scan the superclass for all constructors, including those with parameters, and provide CC options for constructors of the current class with the same parameters. The resulting code would provide automatic pass-through of the arguments to a generated call to the appropriate super(...) constructor. For instance: public class TestParent { private String s; TestParent(String s) { this.s = s; } } public class TestChild extends TestParent { | (*code-completion invoked*) +-----------------------------------------+ | * TestChild(String) - generate | | o clone() - override Object | | o equals(Object) - override boolean | | o finalize() - override void | | ... | +-----------------------------------------+ } Selecting the first option would generate: public class TestChild extends TestParent { public TestChild(String s) { super(s); } }
> When invoking CC to generate a constructor, the only option provided is that of a "default" (no-argument) constructor, > even when the superclass has no such constructor. The result is generated code that does not compile. Agreed! The IDE never should create code that don't compile. Beside that, I think that Alt + Insert > Constructor... should help you. With it is possible choose the parameters for constructor. Regards.
Yes, that is helpful. Thanks. Still, whatever inspection occurs to generate the constructor list provided by the code insertion dialog should provide that same constructor list to the code completion dialog. These sorts of constructors are similar in function to overridden methods which, when generated by code completion, automatically chain to the superclass's implementation and pass all arguments through.