You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Provide more code action options on save #1379
In the Eclipse Java configuration, under Java -> Editor -> Save Actions, there's an "Additional Actions" option which allows one to configure a wide range of additional code formatting options to be applied on save (e.g. "Use modifier for final where possible"). Since these options aren't part of the Eclipse formatter XML settings, there's no way to have them performed on save in Visual Studio Code. Most are available as code actions, but can't be added to the editor.codeActionsOnSave setting AFAIK. Would it be possible to add the ability to perform these actions on save?
Reacted by Ronak Gandhi, Benjamin Kluck, Luis Fernando Planella Gonzalez, dlicois, mustangore, Gokhun, Christoph Pirkl and Matteo Hausner
I believe we can give Change modifiers to final where possible a specified code action kind to make this happen (currently it's a general kind).
BTW, IMO this code action should be grouped as one of the source actions instead of a refactoring. (Considering it's operating the whole document and this pattern is similar with other source actions like organize import).
Eclipse also provides a feature called Clean up. It is like save actions but does not work on save. You have to call it explicitly. Unlike save actions, clean up profile can be exported to an xml file. This exported xml file can be used like the formatter one.
Hi @ghokun, would you mind to create a new issue for this request? The on save code action is a big topic and track all the actions in one issue is not that convenient. I think this one is mainly for the add final action
Activity
jdneo commentedon Sep 15, 2020
I believe we can give
Change modifiers to final where possiblea specified code action kind to make this happen (currently it's a general kind).BTW, IMO this code action should be grouped as one of the source actions instead of a refactoring. (Considering it's operating the whole document and this pattern is similar with other source actions like
organize import).@fbricon @akaroml @testforstephen @Eskibear what do you think?
ghokun commentedon Sep 18, 2020
Eclipse also provides a feature called Clean up. It is like save actions but does not work on save. You have to call it explicitly. Unlike save actions, clean up profile can be exported to an xml file. This exported xml file can be used like the formatter one.

jdneo commentedon Sep 18, 2020
Hi @ghokun, would you mind to create a new issue for this request? The on save code action is a big topic and track all the actions in one issue is not that convenient. I think this one is mainly for the
add finalactionjdneo commentedon Sep 23, 2020
For anyone who want to add final modifiers where possible on save, please add the following settings into your
settings.jsonxtianus79 commentedon Apr 30, 2021
I don't get it. Is there other code clean up and save actions that are on save. This post is almost over a year old.