-
Notifications
You must be signed in to change notification settings - Fork 419
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 individual "Generate Getters" & "Generate Setters" to Source Action menu #2362
Comments
You should be able to generate the individual getter/setter methods for a field by triggering auto-completion directly in the class body and completing the name of the field. This is getting popular, so maybe we should consider it : #1792 . Allowing users to customize (or eliminate) things like the auto-generated method stub is possible. We just currently haven't provided it yet, although we do for file & type comments. To do it I think we'd need to provide a setting, and then read+update it at https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/PreferenceManager.java#L185 . I just looked in https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/GenerateConstructorsHandler.java#L169, and although cursor position is taken into account, I think we only insert relative AST elements. Things like whitespace aren't represented in that so I don't think we have a way to insert at the exact cursor position. |
It shouldn't be difficult to support just "Getter" & "Setter", although for now there are ways to generate these directly from completion (much like a snippet). The option to get those hints is known as signature help, and can be enabled in settings, @testforstephen , @fbricon , Is there a reason signature help is disabled by default ? Might be good to consider changing this for the sake of visibility. |
I used snippets for getters and setters and that is the reason I advised you to add it. I still think it would be better. Even though, much appreciated. |
Currently when you are typing a method, the completion feature also suggests a full list of the overloaded methods, that's kind of duplicated with signature help. That's why signature help is disabled by default. See more discussion here #2063 Also it makes sense to add two separate "Generate Getters" and "Generate Setters" menus in Source Action. For example, I use constructor to set the field values, but using getters to expose the accessors. |
Re-opening as a request to implement the individual source action items. |
+1 for the individual source actions. I'm going to implement this. |
Feature Request:
We already have an option for generating Getter and Setter together. But we don't have an option to generate Getter and Setter separately while IntelliJ Idea by Jet Brains already has this feature. :(
Can you please disable this option for adding this line when Overriding a method?
The line starting with TODO is a very annoying feature. I always have to remove it. There does not seem to be a big problem here, but still.
Bug:
Whenever I generate a constructor in the active cursor line. The constructor is always generated after the last character (excluding the space). Here's a video clip explaining my issue if you didn't get it.
2022-03-15.20-46-46.mp4
The text was updated successfully, but these errors were encountered: