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

Generate toString() limitation #3480

Closed
BlackCherryCat opened this issue Jan 28, 2024 · 3 comments
Closed

Generate toString() limitation #3480

BlackCherryCat opened this issue Jan 28, 2024 · 3 comments

Comments

@BlackCherryCat
Copy link

Generate toString() action will only generate a toString method with the class fields instead of with the super class fields too

Environment
  • Operating System: Windows 11 23H2
  • JDK version: 17.0.10
  • Visual Studio Code version: 1.85.2
  • Java extension version: 1.26.0
Steps To Reproduce
  1. Right click and choose Source code action
  2. Click on Generate toString()...
Current Result

Only generates a toString method with the class fields

Expected Result

Generate a toString method with the class fields super's class fields

Additional Informations

Super class:
Captura de pantalla 2024-01-28 190417

Child class with the toString method generated:
Captura de pantalla 2024-01-28 190430

@rgrunber
Copy link
Member

I can confirm this is an issue. The Eclipse UI definitely permits it though, so I think it should be possible to do it as well.

image

I think this is just a matter of correctly configuring the APIs to allow this.
Similar to #2639 (comment) .

I'm inclined to close this as a duplicate of that, and we can address both aspects (inheriting method, inheriting fields) in a single improvement.

@BlackCherryCat
Copy link
Author

For me it's fine if we merge this issue with the other that you have mencioned, but that issue is almost two years old, altough is the same topic.
We can include this issue in the mencioned issue under the same name, but with a more generic name, like this issue

@rgrunber
Copy link
Member

This should be fixed in pre-release and will be out in the 1.29.0 release. I think we still identified some issues worth fixing in eclipse-jdtls/eclipse.jdt.ls#3055 (review) but it should be possible to use inherited members in forming to toString declaration now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants