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

[Feature Request] Provide more code action options on save #1379

Closed
AlliterativeAlice opened this issue Apr 11, 2020 · 5 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#1547

Comments

@AlliterativeAlice
Copy link

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?

@jdneo
Copy link
Collaborator

jdneo commented Sep 15, 2020

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).

@fbricon @akaroml @testforstephen @Eskibear what do you think?

@ghokun
Copy link
Contributor

ghokun commented 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.
Screenshot_2020-09-18_11-00-04

@jdneo
Copy link
Collaborator

jdneo commented 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 final action

@jdneo
Copy link
Collaborator

jdneo commented Sep 23, 2020

For anyone who want to add final modifiers where possible on save, please add the following settings into your settings.json

"editor.codeActionsOnSave": {
    "source.generate.finalModifiers": true
}

@xtianus79
Copy link

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.

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