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

Support "remove all unused imports" #2280

Merged
merged 3 commits into from
Oct 24, 2022

Conversation

CsCherrYY
Copy link
Contributor

Signed-off-by: Shi Chen chenshi@microsoft.com

See: redhat-developer/vscode-java#2748

removeall.mp4

Signed-off-by: Shi Chen <chenshi@microsoft.com>
@rgrunber rgrunber added this to the End October milestone Oct 21, 2022
Signed-off-by: Shi Chen <chenshi@microsoft.com>
Signed-off-by: Shi Chen <chenshi@microsoft.com>
@rgrunber
Copy link
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
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.

None yet

2 participants