aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/navigation_target.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/navigation_target.rs')
-rw-r--r--crates/ra_ide_api/src/navigation_target.rs45
1 files changed, 10 insertions, 35 deletions
diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs
index ae2175dbc..d73d4afa7 100644
--- a/crates/ra_ide_api/src/navigation_target.rs
+++ b/crates/ra_ide_api/src/navigation_target.rs
@@ -112,62 +112,37 @@ impl NavigationTarget {
112 } 112 }
113 } 113 }
114 114
115 // TODO once Def::Item is gone, this should be able to always return a NavigationTarget 115 pub(crate) fn from_def(db: &RootDatabase, module_def: hir::ModuleDef) -> NavigationTarget {
116 pub(crate) fn from_def(
117 db: &RootDatabase,
118 module_def: hir::ModuleDef,
119 ) -> Option<NavigationTarget> {
120 match module_def { 116 match module_def {
121 hir::ModuleDef::Module(module) => Some(NavigationTarget::from_module(db, module)), 117 hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module),
122 hir::ModuleDef::Function(func) => Some(NavigationTarget::from_function(db, func)), 118 hir::ModuleDef::Function(func) => NavigationTarget::from_function(db, func),
123 hir::ModuleDef::Struct(s) => { 119 hir::ModuleDef::Struct(s) => {
124 let (file_id, node) = s.source(db); 120 let (file_id, node) = s.source(db);
125 Some(NavigationTarget::from_named( 121 NavigationTarget::from_named(file_id.original_file(db), &*node)
126 file_id.original_file(db),
127 &*node,
128 ))
129 } 122 }
130 hir::ModuleDef::Const(s) => { 123 hir::ModuleDef::Const(s) => {
131 let (file_id, node) = s.source(db); 124 let (file_id, node) = s.source(db);
132 Some(NavigationTarget::from_named( 125 NavigationTarget::from_named(file_id.original_file(db), &*node)
133 file_id.original_file(db),
134 &*node,
135 ))
136 } 126 }
137 hir::ModuleDef::Static(s) => { 127 hir::ModuleDef::Static(s) => {
138 let (file_id, node) = s.source(db); 128 let (file_id, node) = s.source(db);
139 Some(NavigationTarget::from_named( 129 NavigationTarget::from_named(file_id.original_file(db), &*node)
140 file_id.original_file(db),
141 &*node,
142 ))
143 } 130 }
144 hir::ModuleDef::Enum(e) => { 131 hir::ModuleDef::Enum(e) => {
145 let (file_id, node) = e.source(db); 132 let (file_id, node) = e.source(db);
146 Some(NavigationTarget::from_named( 133 NavigationTarget::from_named(file_id.original_file(db), &*node)
147 file_id.original_file(db),
148 &*node,
149 ))
150 } 134 }
151 hir::ModuleDef::EnumVariant(var) => { 135 hir::ModuleDef::EnumVariant(var) => {
152 let (file_id, node) = var.source(db); 136 let (file_id, node) = var.source(db);
153 Some(NavigationTarget::from_named( 137 NavigationTarget::from_named(file_id.original_file(db), &*node)
154 file_id.original_file(db),
155 &*node,
156 ))
157 } 138 }
158 hir::ModuleDef::Trait(e) => { 139 hir::ModuleDef::Trait(e) => {
159 let (file_id, node) = e.source(db); 140 let (file_id, node) = e.source(db);
160 Some(NavigationTarget::from_named( 141 NavigationTarget::from_named(file_id.original_file(db), &*node)
161 file_id.original_file(db),
162 &*node,
163 ))
164 } 142 }
165 hir::ModuleDef::Type(e) => { 143 hir::ModuleDef::Type(e) => {
166 let (file_id, node) = e.source(db); 144 let (file_id, node) = e.source(db);
167 Some(NavigationTarget::from_named( 145 NavigationTarget::from_named(file_id.original_file(db), &*node)
168 file_id.original_file(db),
169 &*node,
170 ))
171 } 146 }
172 } 147 }
173 } 148 }