Skip to content

Support "remove all unused imports"#2280

Merged
rgrunber merged 3 commits intoeclipse-jdtls:masterfrom
CsCherrYY:cs-remove-all-unused-imports
Oct 24, 2022
Merged

Support "remove all unused imports"#2280
rgrunber merged 3 commits intoeclipse-jdtls:masterfrom
CsCherrYY:cs-remove-all-unused-imports

Conversation

@CsCherrYY
Copy link
Copy Markdown
Contributor

Signed-off-by: Shi Chen [email protected]

See: redhat-developer/vscode-java#2748

removeall.mp4

@CsCherrYY CsCherrYY marked this pull request as ready for review October 21, 2022 08:43
@rgrunber rgrunber added this to the End October milestone Oct 21, 2022
@rgrunber
Copy link
Copy Markdown
Contributor

rgrunber commented Oct 24, 2022

I'll merge this as the problem is a bit of a corner case, but there is a bug that I noticed. It seems to be an upstream issue with diagnostics though.

remove-all-unused-imports-bug

Basically "Organize Imports" does the right thing, but "Remove all unused imports" only removes the imports that have an "unused" diagnostic (unused, unresolved, duplicate, etc.). In other words it's based on the diagnostics emitted rather than whether it truly is unused. However, when you create some import that can't be resolved, other diagnostics don't seem to be emitted, causing the issue.

@rgrunber rgrunber merged commit 8472ed0 into eclipse-jdtls:master Oct 24, 2022
@CsCherrYY CsCherrYY deleted the cs-remove-all-unused-imports branch October 25, 2022 02:03
@CsCherrYY
Copy link
Copy Markdown
Contributor Author

@rgrunber Yeah, I can also reproduce it via eclipse "Clean Up". it seems that if there are error markers about "import can not be resolved" related to import statements, the unused markers will be skipped to generate.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants