aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/display
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-17 11:00:39 +0000
committerGitHub <[email protected]>2020-12-17 11:00:39 +0000
commitd641bccb0ffec543fa444ba523e8d4b63078fa53 (patch)
tree6695e5ebfeb9563bf5358a0cb89abe8456ac9172 /crates/ide/src/display
parentd21f5f7d6e13b93d64235f13ac18e447af8d59e4 (diff)
parent55faa2daa3fc8bd213038a012b1c5e9ad5fd3736 (diff)
Merge #6907
6907: Lifetime reference search r=matklad a=Veykril PR #6787 but rewritten to make use of the HIR now. This only applies to Lifetimes, not labels. Also Higher-Ranked Trait Bounds aren't supported yet, but I feel like this PR is big enough as is which is why I left them out after noticing I forgot about them. Supporting renaming required slight changes in the renaming module as lifetime names aren't allowed for anything but lifetimes(and labels) and vice versa for normal names. Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide/src/display')
-rw-r--r--crates/ide/src/display/navigation_target.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs
index 234f80a3a..ce0f4214c 100644
--- a/crates/ide/src/display/navigation_target.rs
+++ b/crates/ide/src/display/navigation_target.rs
@@ -9,7 +9,7 @@ use ide_db::{defs::Definition, RootDatabase};
9use syntax::{ 9use syntax::{
10 ast::{self, NameOwner}, 10 ast::{self, NameOwner},
11 match_ast, AstNode, SmolStr, 11 match_ast, AstNode, SmolStr,
12 SyntaxKind::{self, IDENT_PAT, TYPE_PARAM}, 12 SyntaxKind::{self, IDENT_PAT, LIFETIME_PARAM, TYPE_PARAM},
13 TextRange, 13 TextRange,
14}; 14};
15 15
@@ -182,6 +182,7 @@ impl TryToNav for Definition {
182 Definition::SelfType(it) => Some(it.to_nav(db)), 182 Definition::SelfType(it) => Some(it.to_nav(db)),
183 Definition::Local(it) => Some(it.to_nav(db)), 183 Definition::Local(it) => Some(it.to_nav(db)),
184 Definition::TypeParam(it) => Some(it.to_nav(db)), 184 Definition::TypeParam(it) => Some(it.to_nav(db)),
185 Definition::LifetimeParam(it) => Some(it.to_nav(db)),
185 } 186 }
186 } 187 }
187} 188}
@@ -376,6 +377,23 @@ impl ToNav for hir::TypeParam {
376 } 377 }
377} 378}
378 379
380impl ToNav for hir::LifetimeParam {
381 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
382 let src = self.source(db);
383 let full_range = src.value.syntax().text_range();
384 NavigationTarget {
385 file_id: src.file_id.original_file(db),
386 name: self.name(db).to_string().into(),
387 kind: LIFETIME_PARAM,
388 full_range,
389 focus_range: Some(full_range),
390 container_name: None,
391 description: None,
392 docs: None,
393 }
394 }
395}
396
379pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<Documentation> { 397pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<Documentation> {
380 let parse = db.parse(symbol.file_id); 398 let parse = db.parse(symbol.file_id);
381 let node = symbol.ptr.to_node(parse.tree().syntax()); 399 let node = symbol.ptr.to_node(parse.tree().syntax());