aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-25 07:16:28 +0000
committerAleksey Kladov <[email protected]>2019-01-25 07:16:28 +0000
commitbc77f91cf6bec95176b32d0794775e5f00c25367 (patch)
tree91a504f18b8f23bc21c105d2deeba1a3d40d5fac /crates/ra_hir/src
parente884ab05c216fc4a4a35d6267d08519dc5dda41d (diff)
rename def_id -> def
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/nameres.rs39
-rw-r--r--crates/ra_hir/src/nameres/tests.rs4
2 files changed, 16 insertions, 27 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index 0046dfebf..bd5fbfadf 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -59,7 +59,7 @@ impl ModuleScope {
59#[derive(Debug, Clone, PartialEq, Eq)] 59#[derive(Debug, Clone, PartialEq, Eq)]
60pub struct Resolution { 60pub struct Resolution {
61 /// None for unresolved 61 /// None for unresolved
62 pub def_id: PerNs<ModuleDef>, 62 pub def: PerNs<ModuleDef>,
63 /// ident by which this is imported into local scope. 63 /// ident by which this is imported into local scope.
64 pub import: Option<ImportId>, 64 pub import: Option<ImportId>,
65} 65}
@@ -211,11 +211,11 @@ where
211 let krate = Crate::new(crate_id); 211 let krate = Crate::new(crate_id);
212 for dep in krate.dependencies(self.db) { 212 for dep in krate.dependencies(self.db) {
213 if let Some(module) = dep.krate.root_module(self.db) { 213 if let Some(module) = dep.krate.root_module(self.db) {
214 let def_id = module.into(); 214 let def = module.into();
215 self.add_module_item( 215 self.add_module_item(
216 &mut module_items, 216 &mut module_items,
217 dep.name.clone(), 217 dep.name.clone(),
218 PerNs::types(def_id), 218 PerNs::types(def),
219 ); 219 );
220 } 220 }
221 } 221 }
@@ -227,7 +227,7 @@ where
227 module_items.items.insert( 227 module_items.items.insert(
228 segment.name.clone(), 228 segment.name.clone(),
229 Resolution { 229 Resolution {
230 def_id: PerNs::none(), 230 def: PerNs::none(),
231 import: Some(import_id), 231 import: Some(import_id),
232 }, 232 },
233 ); 233 );
@@ -235,11 +235,8 @@ where
235 } 235 }
236 } 236 }
237 // Populate explicitly declared items, except modules 237 // Populate explicitly declared items, except modules
238 for (name, &def_id) in input.declarations.iter() { 238 for (name, &def) in input.declarations.iter() {
239 let resolution = Resolution { 239 let resolution = Resolution { def, import: None };
240 def_id,
241 import: None,
242 };
243 module_items.items.insert(name.clone(), resolution); 240 module_items.items.insert(name.clone(), resolution);
244 } 241 }
245 242
@@ -255,16 +252,8 @@ where
255 self.result.per_module.insert(module_id, module_items); 252 self.result.per_module.insert(module_id, module_items);
256 } 253 }
257 254
258 fn add_module_item( 255 fn add_module_item(&self, module_items: &mut ModuleScope, name: Name, def: PerNs<ModuleDef>) {
259 &self, 256 let resolution = Resolution { def, import: None };
260 module_items: &mut ModuleScope,
261 name: Name,
262 def_id: PerNs<ModuleDef>,
263 ) {
264 let resolution = Resolution {
265 def_id,
266 import: None,
267 };
268 module_items.items.insert(name, resolution); 257 module_items.items.insert(name, resolution);
269 } 258 }
270 259
@@ -295,7 +284,7 @@ where
295 krate: self.krate, 284 krate: self.krate,
296 module_id, 285 module_id,
297 }; 286 };
298 let (def_id, reached_fixedpoint) = 287 let (def, reached_fixedpoint) =
299 self.result 288 self.result
300 .resolve_path_fp(self.db, original_module, &import.path); 289 .resolve_path_fp(self.db, original_module, &import.path);
301 290
@@ -303,7 +292,7 @@ where
303 let last_segment = import.path.segments.last().unwrap(); 292 let last_segment = import.path.segments.last().unwrap();
304 self.update(module_id, |items| { 293 self.update(module_id, |items| {
305 let res = Resolution { 294 let res = Resolution {
306 def_id, 295 def,
307 import: Some(import_id), 296 import: Some(import_id),
308 }; 297 };
309 items.items.insert(last_segment.name.clone(), res); 298 items.items.insert(last_segment.name.clone(), res);
@@ -312,7 +301,7 @@ where
312 "resolved import {:?} ({:?}) cross-source root to {:?}", 301 "resolved import {:?} ({:?}) cross-source root to {:?}",
313 last_segment.name, 302 last_segment.name,
314 import, 303 import,
315 def_id, 304 def,
316 ); 305 );
317 } 306 }
318 reached_fixedpoint 307 reached_fixedpoint
@@ -388,12 +377,12 @@ impl ItemMap {
388 kind: PathKind::Crate, 377 kind: PathKind::Crate,
389 }; 378 };
390 log::debug!("resolving {:?} in other crate", path); 379 log::debug!("resolving {:?} in other crate", path);
391 let def_id = module.resolve_path(db, &path); 380 let def = module.resolve_path(db, &path);
392 return (def_id, ReachedFixedPoint::Yes); 381 return (def, ReachedFixedPoint::Yes);
393 } 382 }
394 383
395 match self.per_module[&module.module_id].items.get(&segment.name) { 384 match self.per_module[&module.module_id].items.get(&segment.name) {
396 Some(res) if !res.def_id.is_none() => res.def_id, 385 Some(res) if !res.def.is_none() => res.def,
397 _ => { 386 _ => {
398 log::debug!("path segment {:?} not found", segment.name); 387 log::debug!("path segment {:?} not found", segment.name);
399 return (PerNs::none(), ReachedFixedPoint::No); 388 return (PerNs::none(), ReachedFixedPoint::No);
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs
index 430d16a2e..7e35c016f 100644
--- a/crates/ra_hir/src/nameres/tests.rs
+++ b/crates/ra_hir/src/nameres/tests.rs
@@ -37,8 +37,8 @@ fn check_module_item_map(map: &ItemMap, module_id: ModuleId, expected: &str) {
37 37
38 fn dump_resolution(resolution: &Resolution) -> &'static str { 38 fn dump_resolution(resolution: &Resolution) -> &'static str {
39 match ( 39 match (
40 resolution.def_id.types.is_some(), 40 resolution.def.types.is_some(),
41 resolution.def_id.values.is_some(), 41 resolution.def.values.is_some(),
42 ) { 42 ) {
43 (true, true) => "t v", 43 (true, true) => "t v",
44 (true, false) => "t", 44 (true, false) => "t",