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

Add Code Action: Generate toString()... #873

Merged
merged 3 commits into from
Apr 15, 2019

Conversation

testforstephen
Copy link
Collaborator

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

User setting to configure generate toString template:
image

QuickPick to select the fields to include in the toString method.
image

@testforstephen
Copy link
Collaborator Author

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

Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
@fbricon fbricon merged commit 61aa100 into redhat-developer:master Apr 15, 2019
@testforstephen testforstephen deleted the jinbo_tostring branch April 16, 2019 01:22
@fbricon fbricon added this to the Mid April 2019 milestone Apr 16, 2019
@dmarrazzo
Copy link

Amazing! Thank you very much. Can you give some information on the template building rules?
For example, I'd like to add the object package name.

@testforstephen
Copy link
Collaborator Author

@dmarrazzo Here are the supported template variables.

${object.className} inserts the class name as a simple String
${object.getClassName} inserts a call to this.getClass.getName()
${object.superToString} inserts a call to super.toString()
${object.hashCode} inserts a call to this.hashCode()
${object.identityHashCode} inserts a call to System.identityHashCode(this)
${member.name} inserts the first member's name
${member.name()} inserts the first member's name followed by parenthesis in case of methods
${member.value} inserts the first member's value
${otherMembers} inserts the remaining members. For each member, the template fragment between the first and the last ${member.} variable is evaluated and appended to the result. The characters between the last ${member.} and ${otherMembers} define the separator that is inserted between members (${otherMembers} must stand after the last ${member.*} variable).

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.

3 participants