mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Lifetime reference search
This commit is contained in:
parent
067067a6c1
commit
55faa2daa3
12 changed files with 373 additions and 41 deletions
|
@ -9,7 +9,7 @@ use ide_db::{defs::Definition, RootDatabase};
|
|||
use syntax::{
|
||||
ast::{self, NameOwner},
|
||||
match_ast, AstNode, SmolStr,
|
||||
SyntaxKind::{self, IDENT_PAT, TYPE_PARAM},
|
||||
SyntaxKind::{self, IDENT_PAT, LIFETIME_PARAM, TYPE_PARAM},
|
||||
TextRange,
|
||||
};
|
||||
|
||||
|
@ -182,6 +182,7 @@ impl TryToNav for Definition {
|
|||
Definition::SelfType(it) => Some(it.to_nav(db)),
|
||||
Definition::Local(it) => Some(it.to_nav(db)),
|
||||
Definition::TypeParam(it) => Some(it.to_nav(db)),
|
||||
Definition::LifetimeParam(it) => Some(it.to_nav(db)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -376,6 +377,23 @@ impl ToNav for hir::TypeParam {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToNav for hir::LifetimeParam {
|
||||
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
|
||||
let src = self.source(db);
|
||||
let full_range = src.value.syntax().text_range();
|
||||
NavigationTarget {
|
||||
file_id: src.file_id.original_file(db),
|
||||
name: self.name(db).to_string().into(),
|
||||
kind: LIFETIME_PARAM,
|
||||
full_range,
|
||||
focus_range: Some(full_range),
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<Documentation> {
|
||||
let parse = db.parse(symbol.file_id);
|
||||
let node = symbol.ptr.to_node(parse.tree().syntax());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue