aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/nameres.rs')
-rw-r--r--crates/ra_hir/src/nameres.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index 20adc9ec4..6bf949654 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -1,18 +1,18 @@
1//! Name resolution algorithm. The end result of the algorithm is `ItemMap`: a 1//! Name resolution algorithm. The end result of the algorithm is an `ItemMap`:
2//! map with maps each module to it's scope: the set of items, visible in the 2//! a map which maps each module to its scope: the set of items visible in the
3//! module. That is, we only resolve imports here, name resolution of item 3//! module. That is, we only resolve imports here, name resolution of item
4//! bodies will be done in a separate step. 4//! bodies will be done in a separate step.
5//! 5//!
6//! Like Rustc, we use an interative per-crate algorithm: we start with scopes 6//! Like Rustc, we use an interactive per-crate algorithm: we start with scopes
7//! containing only directly defined items, and then iteratively resolve 7//! containing only directly defined items, and then iteratively resolve
8//! imports. 8//! imports.
9//! 9//!
10//! To make this work nicely in the IDE scenarios, we place `InputModuleItems` 10//! To make this work nicely in the IDE scenario, we place `InputModuleItems`
11//! in between raw syntax and name resolution. `InputModuleItems` are computed 11//! in between raw syntax and name resolution. `InputModuleItems` are computed
12//! using only the module's syntax, and it is all directly defined items plus 12//! using only the module's syntax, and it is all directly defined items plus
13//! imports. The plain is to make `InputModuleItems` independent of local 13//! imports. The plan is to make `InputModuleItems` independent of local
14//! modifications (that is, typing inside a function shold not change IMIs), 14//! modifications (that is, typing inside a function should not change IMIs),
15//! such that the results of name resolution can be preserved unless the module 15//! so that the results of name resolution can be preserved unless the module
16//! structure itself is modified. 16//! structure itself is modified.
17use std::sync::Arc; 17use std::sync::Arc;
18 18
@@ -34,7 +34,7 @@ use crate::{
34 module_tree::{ModuleId, ModuleTree}, 34 module_tree::{ModuleId, ModuleTree},
35}; 35};
36 36
37/// Item map is the result of the name resolution. Item map contains, for each 37/// `ItemMap` is the result of name resolution. It contains, for each
38/// module, the set of visible items. 38/// module, the set of visible items.
39// FIXME: currenty we compute item map per source-root. We should do it per crate instead. 39// FIXME: currenty we compute item map per source-root. We should do it per crate instead.
40#[derive(Default, Debug, PartialEq, Eq)] 40#[derive(Default, Debug, PartialEq, Eq)]
@@ -59,9 +59,9 @@ impl ModuleScope {
59/// A set of items and imports declared inside a module, without relation to 59/// A set of items and imports declared inside a module, without relation to
60/// other modules. 60/// other modules.
61/// 61///
62/// This stands in-between raw syntax and name resolution and alow us to avoid 62/// This sits in-between raw syntax and name resolution and allows us to avoid
63/// recomputing name res: if `InputModuleItems` are the same, we can avoid 63/// recomputing name res: if two instance of `InputModuleItems` are the same, we
64/// running name resolution. 64/// can avoid redoing name resolution.
65#[derive(Debug, Default, PartialEq, Eq)] 65#[derive(Debug, Default, PartialEq, Eq)]
66pub struct InputModuleItems { 66pub struct InputModuleItems {
67 pub(crate) items: Vec<ModuleItem>, 67 pub(crate) items: Vec<ModuleItem>,
@@ -114,7 +114,7 @@ enum ImportKind {
114 Named(NamedImport), 114 Named(NamedImport),
115} 115}
116 116
117/// Resolution is basically `DefId` atm, but it should account for stuff like 117/// `Resolution` is basically `DefId` atm, but it should account for stuff like
118/// multiple namespaces, ambiguity and errors. 118/// multiple namespaces, ambiguity and errors.
119#[derive(Debug, Clone, PartialEq, Eq)] 119#[derive(Debug, Clone, PartialEq, Eq)]
120pub struct Resolution { 120pub struct Resolution {