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.
Currently there is code completion to create a constructor whose parameter list matches the instance fields of the class. For example given the class class Example { int a, b; } Ctrl+Space offers to generate a constructor "Example(int a, int b)". It would be nice if it would also offer to generate a constructor that takes the parameters of super class constructors. For example, given class Base { Base(int a, int b) { } } class Sub extends Base { int c, d; } one could use CC to generate the following constructor: Sub(int a, int b, int c, int d) { super(a, b); this.c = c; this.d = d; } I run across this use case alot when subclassing. The need to pass on super class parameters actually seems to occur more frequently than the need to initialize instance fields one-to-one from constructor parameters. There is a bit of a question which combinations of instance fields and super class parameters should be offered. Currently, generation of a default constructor (no parameters) and of an instance fields constructor (instance fields as parameters) is offered. These should be kept, IMO. In addition, for each super class constructor with a non-empty parameter list, generation of a constructor with both instance fields and super class parameters should be offered. Should constructors with only super class parameters (i.e. without instance field parameters) also be offered? I'm not sure, but it seems to me that this use case is less typical, and given multiple super class constructors this would double the offered list. To summarize: Given the Base/Sub example above, the following constructors should be offered for Sub: Sub() // default constructor (already offered now) Sub(int c, int d) // instance fields only (already offered now) Sub(int a, int b, int c, int d) // instance fields and super class constructor parameters Probably not really needed: Sub(int a, int b) // super class constructor parameters only