-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'Generate constructor' option to 'Show Fixes' options for fields #1405
Conversation
@@ -140,7 +144,7 @@ public SourceAssistProcessor(PreferenceManager preferenceManager) { | |||
} | |||
|
|||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
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]