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

rewise RemoveUnusedImportsVisitor #5055

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

punkratz312
Copy link

@punkratz312 punkratz312 commented Feb 18, 2025

basically only extract till you drop and there is a lot to be extracted from 👍

Mainly applied: https://checkstyle.sourceforge.io/checks/coding/variabledeclarationusagedistance.html

example: openrewrite/rewrite-static-analysis#469

@punkratz312 punkratz312 changed the title rewrite RemoveUnusedImports apply ExecutionContextJavaIsoVisitor rewise RemoveUnusedImports and extract RemoveUnusedImportsJavaIsoVisitor Feb 18, 2025
@punkratz312 punkratz312 changed the title rewise RemoveUnusedImports and extract RemoveUnusedImportsJavaIsoVisitor rewise RemoveUnusedImportsVisitor Feb 18, 2025
@punkratz312 punkratz312 marked this pull request as ready for review February 18, 2025 12:11
punkratz312 and others added 3 commits February 18, 2025 18:00
…ports.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ports.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ports.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
// whenever an import statement is found to be used and not already in use it should be marked true
Set<String> checkedImports = new HashSet<>();
Set<String> usedWildcardImports = new HashSet<>();
Set<String> usedStaticWildcardImports = new HashSet<>();
ImportLayoutStyle layoutStyle =
Copy link
Author

Choose a reason for hiding this comment

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

@punkratz312
Copy link
Author

Is this any good, @MBoegers?

It's quite a lot of code, and the block is long, containing what seems to be another class with subroutines.
I've tried to separate some concerns to help structure it better.

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

Successfully merging this pull request may close these issues.

2 participants