diff options
author | Aleksey Kladov <[email protected]> | 2019-01-11 11:00:54 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-11 13:01:57 +0000 |
commit | f9ed8d4d23cd210f24ca303c72b436bfbe84741f (patch) | |
tree | 0fc1e57980421ff42e68f5ee8dc699a38dc0fbb4 /crates/ra_ide_api/src/goto_definition.rs | |
parent | 1d3d05d5d70943d8b1356a7e2c8d8b63a1ec470d (diff) |
envapsulate navigation target better
Diffstat (limited to 'crates/ra_ide_api/src/goto_definition.rs')
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index eaddd5083..4706dc733 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_db::{FileId, Cancelable, SyntaxDatabase}; | 1 | use ra_db::{FileId, Cancelable, SyntaxDatabase}; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | TextRange, AstNode, ast, SyntaxKind::{NAME, MODULE}, | 3 | AstNode, ast, |
4 | algo::find_node_at_offset, | 4 | algo::find_node_at_offset, |
5 | }; | 5 | }; |
6 | 6 | ||
@@ -32,13 +32,7 @@ pub(crate) fn reference_definition( | |||
32 | let scope = fn_descr.scopes(db)?; | 32 | let scope = fn_descr.scopes(db)?; |
33 | // First try to resolve the symbol locally | 33 | // First try to resolve the symbol locally |
34 | if let Some(entry) = scope.resolve_local_name(name_ref) { | 34 | if let Some(entry) = scope.resolve_local_name(name_ref) { |
35 | let nav = NavigationTarget { | 35 | let nav = NavigationTarget::from_scope_entry(file_id, &entry); |
36 | file_id, | ||
37 | name: entry.name().to_string().into(), | ||
38 | range: entry.ptr().range(), | ||
39 | kind: NAME, | ||
40 | ptr: None, | ||
41 | }; | ||
42 | return Ok(vec![nav]); | 36 | return Ok(vec![nav]); |
43 | }; | 37 | }; |
44 | } | 38 | } |
@@ -79,18 +73,7 @@ fn name_definition( | |||
79 | if let Some(child_module) = | 73 | if let Some(child_module) = |
80 | hir::source_binder::module_from_declaration(db, file_id, module)? | 74 | hir::source_binder::module_from_declaration(db, file_id, module)? |
81 | { | 75 | { |
82 | let (file_id, _) = child_module.definition_source(db)?; | 76 | let nav = NavigationTarget::from_module(db, child_module)?; |
83 | let name = match child_module.name(db)? { | ||
84 | Some(name) => name.to_string().into(), | ||
85 | None => "".into(), | ||
86 | }; | ||
87 | let nav = NavigationTarget { | ||
88 | file_id, | ||
89 | name, | ||
90 | range: TextRange::offset_len(0.into(), 0.into()), | ||
91 | kind: MODULE, | ||
92 | ptr: None, | ||
93 | }; | ||
94 | return Ok(Some(vec![nav])); | 77 | return Ok(Some(vec![nav])); |
95 | } | 78 | } |
96 | } | 79 | } |