-
Notifications
You must be signed in to change notification settings - Fork 380
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
Intention to nest/flatten imports #2577
Comments
|
In an ideal world, there would be a configurable import optimizer (see also #2259), that would be able to group imports by std/cargo crates/workspace crates/local imports, sorting imports in each group, nesting/flattening them according to the settings, removing curly braces for single imports etc. Unused imports should be automatically removed. When doing a move or copy refactoring to another file, relevant imports should be copied as well. All reformatting and removing unused imports should happen just on pressing Ctrl-Alt-O, one should almost never have to touch the imports section manually, that is a job for a machine, not for human. This is how it works in the Scala plugin, I've used that for a couple of years so now I see just how much time is wasted by unnecessary manual import maintenance. I'm really looking forward this area being worked on. That said, even the "Import" action for unknown symbols has been a huge help, thank you for that! Sorry for the digress. IMO this should be a configuration setting in an automatic import optimizer, not an intention, at least in the long run. |
|
I impelmented NestUseStatementsIntention. When implementing the feature, I met some issues.
full depth use std::{
io::Write,
sync::{
Arc,
Mutex
},
};only 1 depth use std::{
io::Write,
sync::Arc,
sync::Mutex,
};;
If someone has an opinion, please say it freely. |
2938: INT: Implement "NestUseStatementsIntention" r=vlad20012 a=majecty I implemented "NestUseStatementsIntention". The issue is here #2577 <!-- Hello and thank you for the pull request! We don't have any strict rules about pull requests, but you might check https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTING.md for some hints! Note that we need an electronic CLA for contributions: https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTING.md#cla After you sign the CLA, please add your name to https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTORS.txt :) --> Co-authored-by: Park Juhyung <majecty@gmail.com>
2938: INT: Implement "NestUseStatementsIntention" r=vlad20012 a=majecty I implemented "NestUseStatementsIntention". The issue is here #2577 <!-- Hello and thank you for the pull request! We don't have any strict rules about pull requests, but you might check https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTING.md for some hints! Note that we need an electronic CLA for contributions: https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTING.md#cla After you sign the CLA, please add your name to https://github.com/intellij-rust/intellij-rust/blob/master/CONTRIBUTORS.txt :) --> Co-authored-by: Park Juhyung <majecty@gmail.com>
|
I implemented nest intention to only nest 1 depth and preserve original order. |
|
@vlad20012 |
|
Oh, I'm sorry |
|
Are we need to add an inspection to show programmer that nesting is possible? Because I even didn't know about this feature until I saw that issue |
|
There is bug when nesting use statements like this use foo;
use foo::bar;transformed to use foo::{foo, bar};instead of use foo::{self, bar}; |
3501: INT: Make "unelide lifetimes" intention unavailable in doc comments r=vlad20012 a=vlad20012 It can be too annoying that this intention is available inside all doctest injections 3503: INT: handle conversion of module to self in nest use intention r=vlad20012 a=Kobzol This PR fixes an error in the `Nest use statements` intention mentioned here: #2577 (comment). Before the intention would change this code: ``` use foo; use foo::bar; ``` into ``` use foo::{foo, bar}`; ``` which is incorrect. Now it checks if the grouped path is the same as the base path and converts it to `self` if necessary. Co-authored-by: vlad20012 <beskvlad@gmail.com> Co-authored-by: Jakub Beránek <berykubik@gmail.com>
|
It would be helpful if intellij-rust had the opposite intention: expand grouped imports into one import per line. |
<-->
The text was updated successfully, but these errors were encountered: