aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/code_model.rs7
-rw-r--r--crates/ra_ide/src/display/navigation_target.rs22
2 files changed, 28 insertions, 1 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 29ace8479..8833750c8 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -860,6 +860,13 @@ pub struct GenericParam {
860 pub(crate) id: GenericParamId, 860 pub(crate) id: GenericParamId,
861} 861}
862 862
863impl GenericParam {
864 pub fn name(self, db: &impl HirDatabase) -> Name {
865 let params = db.generic_params(self.id.parent);
866 params.params[self.id.local_id].name.clone()
867 }
868}
869
863#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 870#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
864pub struct ImplBlock { 871pub struct ImplBlock {
865 pub(crate) id: ImplId, 872 pub(crate) id: ImplId,
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs
index add11fbc3..e8c3d980f 100644
--- a/crates/ra_ide/src/display/navigation_target.rs
+++ b/crates/ra_ide/src/display/navigation_target.rs
@@ -6,7 +6,7 @@ use ra_db::{FileId, SourceDatabase};
6use ra_syntax::{ 6use ra_syntax::{
7 ast::{self, DocCommentsOwner, NameOwner}, 7 ast::{self, DocCommentsOwner, NameOwner},
8 match_ast, AstNode, SmolStr, 8 match_ast, AstNode, SmolStr,
9 SyntaxKind::{self, BIND_PAT}, 9 SyntaxKind::{self, BIND_PAT, TYPE_PARAM},
10 TextRange, 10 TextRange,
11}; 11};
12 12
@@ -351,6 +351,26 @@ impl ToNav for hir::Local {
351 } 351 }
352} 352}
353 353
354impl ToNav for hir::GenericParam {
355 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
356 let src = self.source(db);
357 let range = match src.value {
358 Either::Left(it) => it.syntax().text_range(),
359 Either::Right(it) => it.syntax().text_range(),
360 };
361 NavigationTarget {
362 file_id: src.file_id.original_file(db),
363 name: self.name(db).to_string().into(),
364 kind: TYPE_PARAM,
365 full_range: range,
366 focus_range: None,
367 container_name: None,
368 description: None,
369 docs: None,
370 }
371 }
372}
373
354pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> { 374pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> {
355 let parse = db.parse(symbol.file_id); 375 let parse = db.parse(symbol.file_id);
356 let node = symbol.ptr.to_node(parse.tree().syntax()); 376 let node = symbol.ptr.to_node(parse.tree().syntax());