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

deprecate java.saveActions.organizeImports #3015

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CsCherrYY
Copy link
Contributor

fix #2207, #659

A recommended way to organize imports in VS Code should be configuring generic editor.codeActionsOnSave. In this way, the java specific configuration can be deprecated to avoid any misunderstanding (it also seems to not work now).

Signed-off-by: Shi Chen <chenshi@microsoft.com>
@CsCherrYY CsCherrYY changed the title deprecate 'java.saveActions.organizeImports' deprecate java.saveActions.organizeImports Mar 22, 2023
@rgrunber
Copy link
Member

Agreed. Not only that, but we also have java.cleanup.actionsOnSave which is LS supported, so it will work for clients other than VS Code. If you just add to https://github.com/eclipse/eclipse.jdt.ls/blob/702d59eb54f6bdd5e8bf1efbec3db2856b3a6339/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/cleanup/CleanUpRegistry.java#L42-L52 and are able to get organize imports to support the https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/cleanup/ISimpleCleanUp.java interface.

@CsCherrYY
Copy link
Contributor Author

@rgrunber do you mean we could add the organize imports support into java.cleanup.actionsOnSave?

  • For VS Code, i suggest we can find a way to also integrate java.cleanup.actionsOnSave into editor.codeActionsOnSave, maybe a way is to make clean ups as code actions so that they can have corresponding code action ids. (I'm not familiar with this implementation, please correct me if I'm wrong :))
  • For jdtls and other clients, since other clients might not have editor.codeActionsOnSave, we can also keep current implementation for the compatiblity.

@rgrunber
Copy link
Member

Yup, something as simple as rgrunber/eclipse.jdt.ls@2497722 seems to work. You can then just set "java.cleanup.actionsOnSave": ["organizeImports"] in VS Code settings (it will complain because it isn't a known value but the LS will respect it).

We could definitely look at ways to integrate with editor.codeActionsOnSave since that works based on the code action id/kind and opens up possibilities to even more save actions. The main downside is the setting is only for VS Code.

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

Successfully merging this pull request may close these issues.

"java.saveActions.organizeImports" setting doesn't work on Windows
2 participants