mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
ToNav for GenericParam
This commit is contained in:
parent
dda9587e75
commit
1692f07393
2 changed files with 28 additions and 1 deletions
|
@ -860,6 +860,13 @@ pub struct GenericParam {
|
||||||
pub(crate) id: GenericParamId,
|
pub(crate) id: GenericParamId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GenericParam {
|
||||||
|
pub fn name(self, db: &impl HirDatabase) -> Name {
|
||||||
|
let params = db.generic_params(self.id.parent);
|
||||||
|
params.params[self.id.local_id].name.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
pub struct ImplBlock {
|
pub struct ImplBlock {
|
||||||
pub(crate) id: ImplId,
|
pub(crate) id: ImplId,
|
||||||
|
|
|
@ -6,7 +6,7 @@ use ra_db::{FileId, SourceDatabase};
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
ast::{self, DocCommentsOwner, NameOwner},
|
ast::{self, DocCommentsOwner, NameOwner},
|
||||||
match_ast, AstNode, SmolStr,
|
match_ast, AstNode, SmolStr,
|
||||||
SyntaxKind::{self, BIND_PAT},
|
SyntaxKind::{self, BIND_PAT, TYPE_PARAM},
|
||||||
TextRange,
|
TextRange,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -351,6 +351,26 @@ impl ToNav for hir::Local {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ToNav for hir::GenericParam {
|
||||||
|
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
|
||||||
|
let src = self.source(db);
|
||||||
|
let range = match src.value {
|
||||||
|
Either::Left(it) => it.syntax().text_range(),
|
||||||
|
Either::Right(it) => it.syntax().text_range(),
|
||||||
|
};
|
||||||
|
NavigationTarget {
|
||||||
|
file_id: src.file_id.original_file(db),
|
||||||
|
name: self.name(db).to_string().into(),
|
||||||
|
kind: TYPE_PARAM,
|
||||||
|
full_range: range,
|
||||||
|
focus_range: None,
|
||||||
|
container_name: None,
|
||||||
|
description: None,
|
||||||
|
docs: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> {
|
pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> {
|
||||||
let parse = db.parse(symbol.file_id);
|
let parse = db.parse(symbol.file_id);
|
||||||
let node = symbol.ptr.to_node(parse.tree().syntax());
|
let node = symbol.ptr.to_node(parse.tree().syntax());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue