Skip to content

Apply module requirements during Organize Imports cleanup on save - #4574

Open
shin19991207 wants to merge 1 commit into
redhat-developer:mainfrom
shin19991207:fix-organize-imports-cleanups
Open

shin19991207 wants to merge 1 commit into
redhat-developer:mainfrom
shin19991207:fix-organize-imports-cleanups

Conversation

@shin19991207

Copy link
Copy Markdown
Member

Related to #1388

When java.cleanup.actions includes organizeImports, saving a Java file currently applies only edits for that file. A required change to module-info.java is lost.

Request the multi-file java/cleanup result during the save event. Return edits for the saved document to the save participant and apply edits for other documents as a VS Code workspace edit. Other save configurations continue through the existing handler; request failures fall back to it.

This depends on eclipse-jdtls/eclipse.jdt.ls#3982, which provides the multi-file cleanup result.

Tested manually:

  1. Create App.java:
package demo;

public class App {
    HttpClient client;
}
  1. Create module-info.java:
module demo {
}
  1. Set "java.cleanup.actions": ["organizeImports"]
  2. Edit and save App.java. Expected that App.java gains the import and module-info.java gains requires java.net.http;.

Signed-off-by: Morgan Chang <shin19991207@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant