diff options
author | Aleksey Kladov <[email protected]> | 2019-01-11 10:29:53 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-11 13:01:57 +0000 |
commit | a5dd04078e6be1e3a874a2c9017d824f5a067315 (patch) | |
tree | eaf0e0871c283b5bfdd6524767909c9e702bd3b1 /crates/ra_ide_api/src | |
parent | 7b143779653ac6dfe094f7cf0c9967e1c0a81318 (diff) |
reshuffle nones
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/navigation_target.rs | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index cff11eeab..b2a53e9aa 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs | |||
@@ -24,34 +24,22 @@ impl NavigationTarget { | |||
24 | 24 | ||
25 | // TODO once Def::Item is gone, this should be able to always return a NavigationTarget | 25 | // TODO once Def::Item is gone, this should be able to always return a NavigationTarget |
26 | pub(crate) fn from_def(db: &RootDatabase, def: Def) -> Cancelable<Option<NavigationTarget>> { | 26 | pub(crate) fn from_def(db: &RootDatabase, def: Def) -> Cancelable<Option<NavigationTarget>> { |
27 | Ok(match def { | 27 | let res = match def { |
28 | Def::Struct(s) => { | 28 | Def::Struct(s) => { |
29 | let (file_id, node) = s.source(db)?; | 29 | let (file_id, node) = s.source(db)?; |
30 | Some(NavigationTarget::from_named( | 30 | NavigationTarget::from_named(file_id.original_file(db), &*node) |
31 | file_id.original_file(db), | ||
32 | &*node, | ||
33 | )) | ||
34 | } | 31 | } |
35 | Def::Enum(e) => { | 32 | Def::Enum(e) => { |
36 | let (file_id, node) = e.source(db)?; | 33 | let (file_id, node) = e.source(db)?; |
37 | Some(NavigationTarget::from_named( | 34 | NavigationTarget::from_named(file_id.original_file(db), &*node) |
38 | file_id.original_file(db), | ||
39 | &*node, | ||
40 | )) | ||
41 | } | 35 | } |
42 | Def::EnumVariant(ev) => { | 36 | Def::EnumVariant(ev) => { |
43 | let (file_id, node) = ev.source(db)?; | 37 | let (file_id, node) = ev.source(db)?; |
44 | Some(NavigationTarget::from_named( | 38 | NavigationTarget::from_named(file_id.original_file(db), &*node) |
45 | file_id.original_file(db), | ||
46 | &*node, | ||
47 | )) | ||
48 | } | 39 | } |
49 | Def::Function(f) => { | 40 | Def::Function(f) => { |
50 | let (file_id, node) = f.source(db)?; | 41 | let (file_id, node) = f.source(db)?; |
51 | Some(NavigationTarget::from_named( | 42 | NavigationTarget::from_named(file_id.original_file(db), &*node) |
52 | file_id.original_file(db), | ||
53 | &*node, | ||
54 | )) | ||
55 | } | 43 | } |
56 | Def::Module(m) => { | 44 | Def::Module(m) => { |
57 | let (file_id, source) = m.definition_source(db)?; | 45 | let (file_id, source) = m.definition_source(db)?; |
@@ -61,15 +49,16 @@ impl NavigationTarget { | |||
61 | .unwrap_or_else(|| SmolStr::new("")); | 49 | .unwrap_or_else(|| SmolStr::new("")); |
62 | match source { | 50 | match source { |
63 | ModuleSource::SourceFile(node) => { | 51 | ModuleSource::SourceFile(node) => { |
64 | Some(NavigationTarget::from_syntax(file_id, name, node.syntax())) | 52 | NavigationTarget::from_syntax(file_id, name, node.syntax()) |
65 | } | 53 | } |
66 | ModuleSource::Module(node) => { | 54 | ModuleSource::Module(node) => { |
67 | Some(NavigationTarget::from_syntax(file_id, name, node.syntax())) | 55 | NavigationTarget::from_syntax(file_id, name, node.syntax()) |
68 | } | 56 | } |
69 | } | 57 | } |
70 | } | 58 | } |
71 | Def::Item => None, | 59 | Def::Item => return Ok(None), |
72 | }) | 60 | }; |
61 | Ok(Some(res)) | ||
73 | } | 62 | } |
74 | 63 | ||
75 | fn from_named(file_id: FileId, node: &impl ast::NameOwner) -> NavigationTarget { | 64 | fn from_named(file_id: FileId, node: &impl ast::NameOwner) -> NavigationTarget { |