diff options
author | Lukas Wirth <[email protected]> | 2020-09-25 14:19:22 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2020-09-25 14:19:22 +0100 |
commit | e1d6981f90ba7852e949141dad0add855b57184a (patch) | |
tree | b999ae8577aee299cb6d3592fcf8532f1b6abf75 /crates/hir/src | |
parent | 9d3483a74dba6b0a338230fd003d91a0447c5398 (diff) |
Don't unnecessarily unnest imports for import insertion
Diffstat (limited to 'crates/hir/src')
-rw-r--r-- | crates/hir/src/code_model.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index a2a166e0a..567fd91af 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs | |||
@@ -383,6 +383,16 @@ impl Module { | |||
383 | pub fn find_use_path(self, db: &dyn DefDatabase, item: impl Into<ItemInNs>) -> Option<ModPath> { | 383 | pub fn find_use_path(self, db: &dyn DefDatabase, item: impl Into<ItemInNs>) -> Option<ModPath> { |
384 | hir_def::find_path::find_path(db, item.into(), self.into()) | 384 | hir_def::find_path::find_path(db, item.into(), self.into()) |
385 | } | 385 | } |
386 | |||
387 | /// Finds a path that can be used to refer to the given item from within | ||
388 | /// this module, if possible. This is used for returning import paths for use-statements. | ||
389 | pub fn find_use_path_prefixed( | ||
390 | self, | ||
391 | db: &dyn DefDatabase, | ||
392 | item: impl Into<ItemInNs>, | ||
393 | ) -> Option<ModPath> { | ||
394 | hir_def::find_path::find_path_prefixed(db, item.into(), self.into()) | ||
395 | } | ||
386 | } | 396 | } |
387 | 397 | ||
388 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 398 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |