Don't unnecessarily unnest imports for import insertion

This commit is contained in:
Lukas Wirth 2020-09-25 15:19:22 +02:00
parent 9d3483a74d
commit e1d6981f90
4 changed files with 203 additions and 45 deletions

View file

@ -383,6 +383,16 @@ impl Module {
pub fn find_use_path(self, db: &dyn DefDatabase, item: impl Into<ItemInNs>) -> Option<ModPath> {
hir_def::find_path::find_path(db, item.into(), self.into())
}
/// Finds a path that can be used to refer to the given item from within
/// this module, if possible. This is used for returning import paths for use-statements.
pub fn find_use_path_prefixed(
self,
db: &dyn DefDatabase,
item: impl Into<ItemInNs>,
) -> Option<ModPath> {
hir_def::find_path::find_path_prefixed(db, item.into(), self.into())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]