-
Notifications
You must be signed in to change notification settings - Fork 885
Sort imports #37
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
Comments
Look what I found 😉 : eb00300 |
Whow, nice. |
We're planning to stop special-casing |
The CLI now sorts imports according to the new rules (google/styleguide#160), and also removes unused imports. There's also a The API doesn't change imports because it's unclear how that should work with partial formatting. I'm open to ideas there, and using |
I'm not against having an When going down this multi-pass road, the only thing that bothers me with the current implementation is that we repeatedly do the same work and emit a new string in each pass. Maybe we can parse the source only once into some representation that every CodeFormatter/JavadocFormatter/Orderer/Remover/whatever can work with efficiently. After parsing the source into the intermediate representation, the user chooses which formatters to apply and afterwards generates a string from or writes the representation to a Writer/CharSink. Then again, I don't know exactly how formatting is implemented right now and if implementing this idea would be worth the effort. |
I agree it would be better to parse everything once. It would complicate the implementation, though, and the current approach seems to perform well enough in practice. SortImports doesn't parse anything, it just tokenizes imports at the beginning of the file. And the javadoc formatter processes individual comments. So the duplicated effort is mainly between the unused import pass and the actual formatting logic. |
Checkstyle being this picky is quite annoying, I am thinking about disabling this check altogether.
The latest release enables import sorting by default in the CLI. Using |
Apologies for commenting on a older thread. When I used the latest 1.7 version. I found out individual unused import classes are removed. however the wildcard import statements are not. Is that an expected behaviour? |
@nmarkandeya that is expected behaviour, there's some related discussion here: #113 (comment). |
Are there any plans to add feature to sort and group imports as described on the style guide?
The text was updated successfully, but these errors were encountered: