Add 'Generate constructor' option to 'Show Fixes' options for fields#1405
Add 'Generate constructor' option to 'Show Fixes' options for fields#1405fbricon merged 1 commit intoeclipse-jdtls:masterfrom
Conversation
|
|
||
| // Generate Constructors | ||
| Optional<Either<Command, CodeAction>> generateConstructors = getGenerateConstructorsAction(params, context, type); | ||
| generateConstructors = getGenerateConstructorsAction(params, context, type, JavaCodeActionKind.SOURCE_GENERATE_CONSTRUCTORS); |
There was a problem hiding this comment.
we're basically recomputing the actions a 2nd time, seems suboptimal. Couldn't we just copy the ones we have already and change their kind?
|
Starting from public class Foo {
private String name;
}After applying the code action to generate the constructor, I get: public class Foo {
private String name;
public Foo(String name) {
this.name = name;
}
}So far so good, but then, the |
The code to compute constructors is in GenerateConstructorsHandler, so we can fix it |
Signed-off-by: Snjezana Peco <[email protected]>
|
@fbricon I have updated the PR. |
IntelliJ IDEA creates only one constructor when existing more fields. Eclipse/Java LS creates multiple constructors. |
Fixes redhat-developer/vscode-java#1358
Signed-off-by: Snjezana Peco [email protected]