diff options
author | Aleksey Kladov <[email protected]> | 2019-12-07 17:48:35 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-07 18:44:43 +0000 |
commit | 1692f07393dba4f5c122df1a609d5b18751bf406 (patch) | |
tree | 8df8763aabe4ac55f93edbb3d8eed609826a6243 /crates/ra_ide/src | |
parent | dda9587e75f4fd1740d16531038023ff582ef43f (diff) |
ToNav for GenericParam
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/display/navigation_target.rs | 22 |
1 files changed, 21 insertions, 1 deletions
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}; | |||
6 | use ra_syntax::{ | 6 | use 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 | ||
354 | impl 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 | |||
354 | pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> { | 374 | pub(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()); |