Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/navigation_target.rs')
| -rw-r--r-- | crates/ide/src/navigation_target.rs | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/crates/ide/src/navigation_target.rs b/crates/ide/src/navigation_target.rs index 7d5d9057cb..4c4d57f0f4 100644 --- a/crates/ide/src/navigation_target.rs +++ b/crates/ide/src/navigation_target.rs @@ -51,7 +51,8 @@ pub struct NavigationTarget { pub kind: Option<SymbolKind>, pub container_name: Option<Symbol>, pub description: Option<String>, - pub docs: Option<Documentation>, + // FIXME: Use the database lifetime here. + pub docs: Option<Documentation<'static>>, /// In addition to a `name` field, a `NavigationTarget` may also be aliased /// In such cases we want a `NavigationTarget` to be accessible by its alias pub alias: Option<Symbol>, @@ -157,7 +158,7 @@ impl NavigationTarget { full_range, SymbolKind::Module, ); - res.docs = module.docs(db); + res.docs = module.docs(db).map(Documentation::into_owned); res.description = Some( module.display(db, module.krate().to_display_target(db)).to_string(), ); @@ -429,7 +430,7 @@ where D::KIND, ) .map(|mut res| { - res.docs = self.docs(db); + res.docs = self.docs(db).map(Documentation::into_owned); res.description = hir::attach_db(db, || { Some(self.display(db, self.krate(db).to_display_target(db)).to_string()) }); @@ -522,7 +523,7 @@ impl TryToNav for hir::ExternCrateDecl { SymbolKind::Module, ); - res.docs = self.docs(db); + res.docs = self.docs(db).map(Documentation::into_owned); res.description = Some(self.display(db, krate.to_display_target(db)).to_string()); res.container_name = container_name(db, *self); res @@ -544,10 +545,9 @@ impl TryToNav for hir::Field { FieldSource::Named(it) => { NavigationTarget::from_named(db, src.with_value(it), SymbolKind::Field).map( |mut res| { - res.docs = self.docs(db); - res.description = hir::attach_db(db, || { - Some(self.display(db, krate.to_display_target(db)).to_string()) - }); + res.docs = self.docs(db).map(Documentation::into_owned); + res.description = + Some(self.display(db, krate.to_display_target(db)).to_string()); res }, ) @@ -586,7 +586,7 @@ impl TryToNav for hir::Macro { self.kind(db).into(), ) .map(|mut res| { - res.docs = self.docs(db); + res.docs = self.docs(db).map(Documentation::into_owned); res }), ) @@ -916,7 +916,7 @@ pub(crate) fn orig_range_with_focus_r( ) -> UpmappingResult<(FileRange, Option<TextRange>)> { let Some(name) = focus_range else { return orig_range_r(db, hir_file, value) }; - let call_kind = || db.lookup_intern_macro_call(hir_file.macro_file().unwrap()).kind; + let call = || db.lookup_intern_macro_call(hir_file.macro_file().unwrap()); let def_range = || db.lookup_intern_macro_call(hir_file.macro_file().unwrap()).def.definition_range(db); @@ -942,7 +942,8 @@ pub(crate) fn orig_range_with_focus_r( // name lies outside the node, so instead point to the macro call which // *should* contain the name _ => { - let kind = call_kind(); + let call = call(); + let kind = call.kind; let range = kind.clone().original_call_range_with_input(db); //If the focus range is in the attribute/derive body, we // need to point the call site to the entire body, if not, fall back @@ -954,7 +955,7 @@ pub(crate) fn orig_range_with_focus_r( { range } else { - kind.original_call_range(db) + kind.original_call_range(db, call.krate) } } }, @@ -983,11 +984,14 @@ pub(crate) fn orig_range_with_focus_r( }, ), // node is in macro def, just show the focus - _ => ( - // show the macro call - (call_kind().original_call_range(db), None), - Some((focus_range, Some(focus_range))), - ), + _ => { + let call = call(); + ( + // show the macro call + (call.kind.original_call_range(db, call.krate), None), + Some((focus_range, Some(focus_range))), + ) + } } } // lost name? can't happen for single tokens |