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

Handle case where imports occur on the same line as other statements #1

Closed
ctubbsii opened this issue Jul 21, 2017 · 1 comment
Closed
Labels

Comments

@ctubbsii
Copy link
Member

If the first import occurs on the same line as the package statement, the package statement will get deleted.

If the last import occurs on the same line as the start of the class, the class start will get deleted.

These can be fixed by tracking where within these lines one begins and the other ends.

@ctubbsii ctubbsii added the bug label Jul 21, 2017
ctubbsii added a commit that referenced this issue Jul 21, 2017
Replace regex parsing with proper java source file parser
Organize code a bit better, with Grouper class

This version doesn't have the false-positive detection on well-formed
Java files, but I have noticed that Java files which put the package
statement before the compilation unit / file header comment do get that
comment duplicated.

This version handles multiple imports on a single line perfectly well.

This version does have issues if the first import occurs on the same
line as the package statement, or if the last import occurs on the same
line as the beginning of the class. This should be corrected in a future
version (See issue #1).
@ctubbsii ctubbsii added this to the 1.7.0 milestone May 10, 2021
@ctubbsii ctubbsii modified the milestones: 1.7.0, 1.8.0 May 24, 2022
@ctubbsii ctubbsii modified the milestones: 1.8.0, 1.9.0 Nov 23, 2022
@ctubbsii ctubbsii modified the milestones: 1.9.0, 1.10.0 May 10, 2023
@hazendaz hazendaz modified the milestones: 1.10.0, 1.11.0 May 27, 2024
@hazendaz hazendaz modified the milestones: 1.11.0, 1.12.0 Jun 27, 2024
@ctubbsii ctubbsii removed this from the 1.12.0 milestone Jul 17, 2024
@ctubbsii
Copy link
Member Author

This isn't really that critical of an issue. The workaround is to format your code using a different plugin before ordering your imports, and to just not put things on the same line. I've had 0 people report this is actually a problem, so it's probably not worth spending any time on.

@ctubbsii ctubbsii closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants