diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-27 18:45:05 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-27 18:45:05 +0000 |
commit | 360f6b7bb32d6280ed787075c4a54f4e5b46fcb6 (patch) | |
tree | 4c059427819ef442c785125f48fe83f81f6d667a /crates/ra_hir_def | |
parent | 4946169a96f3d442f463724af481fdb760381ccb (diff) | |
parent | 27b362b05910c81fd5b28f6cd5d2c075311032f9 (diff) |
Merge #2430
2430: rename ra_ide_api -> ra_ide r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/attr.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/docs.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lang_item.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/path_resolution.rs | 16 | ||||
-rw-r--r-- | crates/ra_hir_def/src/resolver.rs | 6 |
8 files changed, 24 insertions, 25 deletions
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 298608e27..fffb22201 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs | |||
@@ -35,7 +35,7 @@ impl Attrs { | |||
35 | match def { | 35 | match def { |
36 | AttrDefId::ModuleId(module) => { | 36 | AttrDefId::ModuleId(module) => { |
37 | let def_map = db.crate_def_map(module.krate); | 37 | let def_map = db.crate_def_map(module.krate); |
38 | let src = match def_map[module.module_id].declaration_source(db) { | 38 | let src = match def_map[module.local_id].declaration_source(db) { |
39 | Some(it) => it, | 39 | Some(it) => it, |
40 | None => return Attrs::default(), | 40 | None => return Attrs::default(), |
41 | }; | 41 | }; |
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 78a532bdd..a57a0176d 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs | |||
@@ -82,7 +82,7 @@ impl Expander { | |||
82 | } | 82 | } |
83 | 83 | ||
84 | fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> { | 84 | fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> { |
85 | self.crate_def_map.resolve_path(db, self.module.module_id, path).0.take_macros() | 85 | self.crate_def_map.resolve_path(db, self.module.local_id, path).0.take_macros() |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs index 4749b642f..34ed9b7a5 100644 --- a/crates/ra_hir_def/src/docs.rs +++ b/crates/ra_hir_def/src/docs.rs | |||
@@ -36,7 +36,7 @@ impl Documentation { | |||
36 | match def { | 36 | match def { |
37 | AttrDefId::ModuleId(module) => { | 37 | AttrDefId::ModuleId(module) => { |
38 | let def_map = db.crate_def_map(module.krate); | 38 | let def_map = db.crate_def_map(module.krate); |
39 | let src = def_map[module.module_id].declaration_source(db)?; | 39 | let src = def_map[module.local_id].declaration_source(db)?; |
40 | docs_from_ast(&src.value) | 40 | docs_from_ast(&src.value) |
41 | } | 41 | } |
42 | AttrDefId::StructFieldId(it) => { | 42 | AttrDefId::StructFieldId(it) => { |
diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs index f15c23db9..f4fdbdcfc 100644 --- a/crates/ra_hir_def/src/lang_item.rs +++ b/crates/ra_hir_def/src/lang_item.rs | |||
@@ -41,7 +41,7 @@ impl LangItems { | |||
41 | crate_def_map | 41 | crate_def_map |
42 | .modules | 42 | .modules |
43 | .iter() | 43 | .iter() |
44 | .filter_map(|(module_id, _)| db.module_lang_items(ModuleId { krate, module_id })) | 44 | .filter_map(|(local_id, _)| db.module_lang_items(ModuleId { krate, local_id })) |
45 | .for_each(|it| lang_items.items.extend(it.items.iter().map(|(k, v)| (k.clone(), *v)))); | 45 | .for_each(|it| lang_items.items.extend(it.items.iter().map(|(k, v)| (k.clone(), *v)))); |
46 | 46 | ||
47 | Arc::new(lang_items) | 47 | Arc::new(lang_items) |
@@ -80,7 +80,7 @@ impl LangItems { | |||
80 | fn collect_lang_items(&mut self, db: &impl DefDatabase, module: ModuleId) { | 80 | fn collect_lang_items(&mut self, db: &impl DefDatabase, module: ModuleId) { |
81 | // Look for impl targets | 81 | // Look for impl targets |
82 | let def_map = db.crate_def_map(module.krate); | 82 | let def_map = db.crate_def_map(module.krate); |
83 | let module_data = &def_map[module.module_id]; | 83 | let module_data = &def_map[module.local_id]; |
84 | for &impl_block in module_data.impls.iter() { | 84 | for &impl_block in module_data.impls.iter() { |
85 | self.collect_lang_item(db, impl_block, LangItemTarget::ImplBlockId) | 85 | self.collect_lang_item(db, impl_block, LangItemTarget::ImplBlockId) |
86 | } | 86 | } |
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index ddf464c60..bc5530896 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -50,7 +50,7 @@ impl_arena_id!(LocalImportId); | |||
50 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 50 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
51 | pub struct ModuleId { | 51 | pub struct ModuleId { |
52 | pub krate: CrateId, | 52 | pub krate: CrateId, |
53 | pub module_id: LocalModuleId, | 53 | pub local_id: LocalModuleId, |
54 | } | 54 | } |
55 | 55 | ||
56 | /// An ID of a module, **local** to a specific crate | 56 | /// An ID of a module, **local** to a specific crate |
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index ea3abfdae..603b49738 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -37,7 +37,7 @@ pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> C | |||
37 | log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); | 37 | log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); |
38 | def_map.extern_prelude.insert( | 38 | def_map.extern_prelude.insert( |
39 | dep.as_name(), | 39 | dep.as_name(), |
40 | ModuleId { krate: dep.crate_id, module_id: dep_def_map.root }.into(), | 40 | ModuleId { krate: dep.crate_id, local_id: dep_def_map.root }.into(), |
41 | ); | 41 | ); |
42 | 42 | ||
43 | // look for the prelude | 43 | // look for the prelude |
@@ -323,7 +323,7 @@ where | |||
323 | tested_by!(glob_across_crates); | 323 | tested_by!(glob_across_crates); |
324 | // glob import from other crate => we can just import everything once | 324 | // glob import from other crate => we can just import everything once |
325 | let item_map = self.db.crate_def_map(m.krate); | 325 | let item_map = self.db.crate_def_map(m.krate); |
326 | let scope = &item_map[m.module_id].scope; | 326 | let scope = &item_map[m.local_id].scope; |
327 | 327 | ||
328 | // Module scoped macros is included | 328 | // Module scoped macros is included |
329 | let items = scope | 329 | let items = scope |
@@ -337,7 +337,7 @@ where | |||
337 | // glob import from same crate => we do an initial | 337 | // glob import from same crate => we do an initial |
338 | // import, and then need to propagate any further | 338 | // import, and then need to propagate any further |
339 | // additions | 339 | // additions |
340 | let scope = &self.def_map[m.module_id].scope; | 340 | let scope = &self.def_map[m.local_id].scope; |
341 | 341 | ||
342 | // Module scoped macros is included | 342 | // Module scoped macros is included |
343 | let items = scope | 343 | let items = scope |
@@ -349,7 +349,7 @@ where | |||
349 | self.update(module_id, Some(import_id), &items); | 349 | self.update(module_id, Some(import_id), &items); |
350 | // record the glob import in case we add further items | 350 | // record the glob import in case we add further items |
351 | self.glob_imports | 351 | self.glob_imports |
352 | .entry(m.module_id) | 352 | .entry(m.local_id) |
353 | .or_default() | 353 | .or_default() |
354 | .push((module_id, import_id)); | 354 | .push((module_id, import_id)); |
355 | } | 355 | } |
@@ -590,7 +590,7 @@ where | |||
590 | raw::RawItemKind::Impl(imp) => { | 590 | raw::RawItemKind::Impl(imp) => { |
591 | let module = ModuleId { | 591 | let module = ModuleId { |
592 | krate: self.def_collector.def_map.krate, | 592 | krate: self.def_collector.def_map.krate, |
593 | module_id: self.module_id, | 593 | local_id: self.module_id, |
594 | }; | 594 | }; |
595 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); | 595 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); |
596 | let imp_id = ImplId::from_ast_id(ctx, self.raw_items[imp].ast_id); | 596 | let imp_id = ImplId::from_ast_id(ctx, self.raw_items[imp].ast_id); |
@@ -673,7 +673,7 @@ where | |||
673 | modules[self.module_id].children.insert(name.clone(), res); | 673 | modules[self.module_id].children.insert(name.clone(), res); |
674 | let resolution = Resolution { | 674 | let resolution = Resolution { |
675 | def: PerNs::types( | 675 | def: PerNs::types( |
676 | ModuleId { krate: self.def_collector.def_map.krate, module_id: res }.into(), | 676 | ModuleId { krate: self.def_collector.def_map.krate, local_id: res }.into(), |
677 | ), | 677 | ), |
678 | import: None, | 678 | import: None, |
679 | }; | 679 | }; |
@@ -682,8 +682,7 @@ where | |||
682 | } | 682 | } |
683 | 683 | ||
684 | fn define_def(&mut self, def: &raw::DefData) { | 684 | fn define_def(&mut self, def: &raw::DefData) { |
685 | let module = | 685 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: self.module_id }; |
686 | ModuleId { krate: self.def_collector.def_map.krate, module_id: self.module_id }; | ||
687 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); | 686 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); |
688 | 687 | ||
689 | let name = def.name.clone(); | 688 | let name = def.name.clone(); |
diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs index 9455f22bb..b72c55bd1 100644 --- a/crates/ra_hir_def/src/nameres/path_resolution.rs +++ b/crates/ra_hir_def/src/nameres/path_resolution.rs | |||
@@ -74,19 +74,19 @@ impl CrateDefMap { | |||
74 | PathKind::DollarCrate(krate) => { | 74 | PathKind::DollarCrate(krate) => { |
75 | if krate == self.krate { | 75 | if krate == self.krate { |
76 | tested_by!(macro_dollar_crate_self); | 76 | tested_by!(macro_dollar_crate_self); |
77 | PerNs::types(ModuleId { krate: self.krate, module_id: self.root }.into()) | 77 | PerNs::types(ModuleId { krate: self.krate, local_id: self.root }.into()) |
78 | } else { | 78 | } else { |
79 | let def_map = db.crate_def_map(krate); | 79 | let def_map = db.crate_def_map(krate); |
80 | let module = ModuleId { krate, module_id: def_map.root }; | 80 | let module = ModuleId { krate, local_id: def_map.root }; |
81 | tested_by!(macro_dollar_crate_other); | 81 | tested_by!(macro_dollar_crate_other); |
82 | PerNs::types(module.into()) | 82 | PerNs::types(module.into()) |
83 | } | 83 | } |
84 | } | 84 | } |
85 | PathKind::Crate => { | 85 | PathKind::Crate => { |
86 | PerNs::types(ModuleId { krate: self.krate, module_id: self.root }.into()) | 86 | PerNs::types(ModuleId { krate: self.krate, local_id: self.root }.into()) |
87 | } | 87 | } |
88 | PathKind::Self_ => { | 88 | PathKind::Self_ => { |
89 | PerNs::types(ModuleId { krate: self.krate, module_id: original_module }.into()) | 89 | PerNs::types(ModuleId { krate: self.krate, local_id: original_module }.into()) |
90 | } | 90 | } |
91 | // plain import or absolute path in 2015: crate-relative with | 91 | // plain import or absolute path in 2015: crate-relative with |
92 | // fallback to extern prelude (with the simplification in | 92 | // fallback to extern prelude (with the simplification in |
@@ -113,7 +113,7 @@ impl CrateDefMap { | |||
113 | } | 113 | } |
114 | PathKind::Super => { | 114 | PathKind::Super => { |
115 | if let Some(p) = self.modules[original_module].parent { | 115 | if let Some(p) = self.modules[original_module].parent { |
116 | PerNs::types(ModuleId { krate: self.krate, module_id: p }.into()) | 116 | PerNs::types(ModuleId { krate: self.krate, local_id: p }.into()) |
117 | } else { | 117 | } else { |
118 | log::debug!("super path in root module"); | 118 | log::debug!("super path in root module"); |
119 | return ResolvePathResult::empty(ReachedFixedPoint::Yes); | 119 | return ResolvePathResult::empty(ReachedFixedPoint::Yes); |
@@ -160,7 +160,7 @@ impl CrateDefMap { | |||
160 | Path { segments: path.segments[i..].to_vec(), kind: PathKind::Self_ }; | 160 | Path { segments: path.segments[i..].to_vec(), kind: PathKind::Self_ }; |
161 | log::debug!("resolving {:?} in other crate", path); | 161 | log::debug!("resolving {:?} in other crate", path); |
162 | let defp_map = db.crate_def_map(module.krate); | 162 | let defp_map = db.crate_def_map(module.krate); |
163 | let (def, s) = defp_map.resolve_path(db, module.module_id, &path); | 163 | let (def, s) = defp_map.resolve_path(db, module.local_id, &path); |
164 | return ResolvePathResult::with( | 164 | return ResolvePathResult::with( |
165 | def, | 165 | def, |
166 | ReachedFixedPoint::Yes, | 166 | ReachedFixedPoint::Yes, |
@@ -169,7 +169,7 @@ impl CrateDefMap { | |||
169 | } | 169 | } |
170 | 170 | ||
171 | // Since it is a qualified path here, it should not contains legacy macros | 171 | // Since it is a qualified path here, it should not contains legacy macros |
172 | match self[module.module_id].scope.get(&segment.name) { | 172 | match self[module.local_id].scope.get(&segment.name) { |
173 | Some(res) => res.def, | 173 | Some(res) => res.def, |
174 | _ => { | 174 | _ => { |
175 | log::debug!("path segment {:?} not found", segment.name); | 175 | log::debug!("path segment {:?} not found", segment.name); |
@@ -254,7 +254,7 @@ impl CrateDefMap { | |||
254 | keep = db.crate_def_map(prelude.krate); | 254 | keep = db.crate_def_map(prelude.krate); |
255 | &keep | 255 | &keep |
256 | }; | 256 | }; |
257 | def_map[prelude.module_id].scope.get(name).map_or_else(PerNs::none, |res| res.def) | 257 | def_map[prelude.local_id].scope.get(name).map_or_else(PerNs::none, |res| res.def) |
258 | } else { | 258 | } else { |
259 | PerNs::none() | 259 | PerNs::none() |
260 | } | 260 | } |
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 5155365cc..0847f6dcf 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs | |||
@@ -325,7 +325,7 @@ impl Resolver { | |||
325 | if let Scope::ModuleScope(m) = scope { | 325 | if let Scope::ModuleScope(m) = scope { |
326 | if let Some(prelude) = m.crate_def_map.prelude { | 326 | if let Some(prelude) = m.crate_def_map.prelude { |
327 | let prelude_def_map = db.crate_def_map(prelude.krate); | 327 | let prelude_def_map = db.crate_def_map(prelude.krate); |
328 | traits.extend(prelude_def_map[prelude.module_id].scope.traits()); | 328 | traits.extend(prelude_def_map[prelude.local_id].scope.traits()); |
329 | } | 329 | } |
330 | traits.extend(m.crate_def_map[m.module_id].scope.traits()); | 330 | traits.extend(m.crate_def_map[m.module_id].scope.traits()); |
331 | } | 331 | } |
@@ -402,7 +402,7 @@ impl Scope { | |||
402 | }); | 402 | }); |
403 | if let Some(prelude) = m.crate_def_map.prelude { | 403 | if let Some(prelude) = m.crate_def_map.prelude { |
404 | let prelude_def_map = db.crate_def_map(prelude.krate); | 404 | let prelude_def_map = db.crate_def_map(prelude.krate); |
405 | prelude_def_map[prelude.module_id].scope.entries().for_each(|(name, res)| { | 405 | prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, res)| { |
406 | f(name.clone(), ScopeDef::PerNs(res.def)); | 406 | f(name.clone(), ScopeDef::PerNs(res.def)); |
407 | }); | 407 | }); |
408 | } | 408 | } |
@@ -492,7 +492,7 @@ pub trait HasResolver: Copy { | |||
492 | impl HasResolver for ModuleId { | 492 | impl HasResolver for ModuleId { |
493 | fn resolver(self, db: &impl DefDatabase) -> Resolver { | 493 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
494 | let def_map = db.crate_def_map(self.krate); | 494 | let def_map = db.crate_def_map(self.krate); |
495 | Resolver::default().push_module_scope(def_map, self.module_id) | 495 | Resolver::default().push_module_scope(def_map, self.local_id) |
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||