Skip to content
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

Enable generate hashCode and equals source action #814

Merged
merged 4 commits into from
Mar 11, 2019

Conversation

testforstephen
Copy link
Collaborator

@testforstephen testforstephen commented Feb 27, 2019

Signed-off-by: Jinbo Wang jinbwan@microsoft.com

Feature #597.

image

Prompt to select fields to include:
image

@testforstephen
Copy link
Collaborator Author

Peer PR on eclipse.jdt.ls side eclipse-jdtls/eclipse.jdt.ls#940

Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
src/sourceAction.ts Outdated Show resolved Hide resolved
src/sourceAction.ts Outdated Show resolved Hide resolved
src/sourceAction.ts Outdated Show resolved Hide resolved
src/protocol.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@fbricon fbricon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of remarks so far (we can get rid of one prompt and improve the dialog - I like clear actionable choices ), but that's a promising start. I still need to get my head around the API though.

@fbricon fbricon added this to the Mid March 2019 milestone Feb 28, 2019
Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
Copy link
Collaborator

@fbricon fbricon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should expose at least one more option, to use instance of to perform comparisons.
So I'd change the preferences to have:

  • "java.codeGeneration.hashcodeEquals.useJava7Objects".
  • "java.codeGeneration.hashcodeEquals.compareInstanceOf"

Eventually, we might as well expose generateComments and useBrackets

…ettings

Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
…action

Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
@fbricon fbricon merged commit d8cc49d into redhat-developer:master Mar 11, 2019
@fbricon
Copy link
Collaborator

fbricon commented Mar 11, 2019

Here are the new preferences controlling the code generation:

  • java.codeGeneration.hashCodeEquals.useJava7Objects: Use Objects.hash and Objects.equals when generating the hashCode and equals methods. This setting only applies to Java 7 and higher. Defaults to false.
  • java.codeGeneration.hashCodeEquals.useInstanceof: Use 'instanceof' to compare types when generating the hashCode and equals methods. Defaults to false.
  • java.codeGeneration.hashCodeEquals.useBlocks: Use blocks in 'if' statements when generating the hashCode and equals methods. Defaults to false.
  • java.codeGeneration.hashCodeEquals.generateComments: Generate method comments when generating the hashCode and equals methods. Defaults to false.

@testforstephen testforstephen deleted the jinbo_hashcodeequals branch March 12, 2019 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants