diff options
Diffstat (limited to 'crates/ra_ide_api/src/navigation_target.rs')
-rw-r--r-- | crates/ra_ide_api/src/navigation_target.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index c5be8e01b..ae2175dbc 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs | |||
@@ -3,7 +3,7 @@ use ra_syntax::{ | |||
3 | SyntaxNode, AstNode, SmolStr, TextRange, ast, | 3 | SyntaxNode, AstNode, SmolStr, TextRange, ast, |
4 | SyntaxKind::{self, NAME}, | 4 | SyntaxKind::{self, NAME}, |
5 | }; | 5 | }; |
6 | use hir::{ModuleSource}; | 6 | use hir::{ModuleSource, FieldSource}; |
7 | 7 | ||
8 | use crate::{FileSymbol, db::RootDatabase}; | 8 | use crate::{FileSymbol, db::RootDatabase}; |
9 | 9 | ||
@@ -101,6 +101,17 @@ impl NavigationTarget { | |||
101 | NavigationTarget::from_named(file_id.original_file(db), &*fn_def) | 101 | NavigationTarget::from_named(file_id.original_file(db), &*fn_def) |
102 | } | 102 | } |
103 | 103 | ||
104 | pub(crate) fn from_field(db: &RootDatabase, field: hir::StructField) -> NavigationTarget { | ||
105 | let (file_id, field) = field.source(db); | ||
106 | let file_id = file_id.original_file(db); | ||
107 | match field { | ||
108 | FieldSource::Named(it) => NavigationTarget::from_named(file_id, &*it), | ||
109 | FieldSource::Pos(it) => { | ||
110 | NavigationTarget::from_syntax(file_id, "".into(), None, it.syntax()) | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | |||
104 | // TODO once Def::Item is gone, this should be able to always return a NavigationTarget | 115 | // TODO once Def::Item is gone, this should be able to always return a NavigationTarget |
105 | pub(crate) fn from_def( | 116 | pub(crate) fn from_def( |
106 | db: &RootDatabase, | 117 | db: &RootDatabase, |