Skip to content

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

Merged
datho7561 merged 1 commit into
redhat-developer:mainfrom
shin19991207:fix-organize-imports-cleanups
Nov 18, 2026
Merged

datho7561 merged 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;.

@datho7561 datho7561 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks, Morgan!

@datho7561
datho7561 merged commit d25cdc3 into redhat-developer:main Nov 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants