Skip to content

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

Closed
eclipse-jdtls/eclipse.jdt.ls
#1547

Description

@AlliterativeAlice

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?

Activity

  1. jdneo commented on Sep 15, 2020

    @jdneo
    Collaborator

    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?

  2. added this to the End September 2020 milestone on Sep 16, 2020
  3. ghokun commented on Sep 18, 2020

    @ghokun
    Contributor

    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

  4. jdneo commented on Sep 18, 2020

    @jdneo
    Collaborator

    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

  5. jdneo commented on Sep 23, 2020

    @jdneo
    Collaborator

    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
    }
  6. xtianus79 commented on Apr 30, 2021

    @xtianus79

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions