diff options
author | Lukas Wirth <[email protected]> | 2020-12-16 20:35:15 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2020-12-16 21:21:01 +0000 |
commit | 55faa2daa3fc8bd213038a012b1c5e9ad5fd3736 (patch) | |
tree | 2d84a7fa9fe93aa7a6bdd4d0f9cda87e6bb4a5da /crates/ide/src/display | |
parent | 067067a6c11bb5afda98f5af14bfdec4744e7812 (diff) |
Lifetime reference search
Diffstat (limited to 'crates/ide/src/display')
-rw-r--r-- | crates/ide/src/display/navigation_target.rs | 20 |
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}; | |||
9 | use syntax::{ | 9 | use 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 | ||
380 | impl 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 | |||
379 | pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<Documentation> { | 397 | pub(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()); |