diff options
author | Florian Diebold <[email protected]> | 2019-01-27 16:23:49 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-02-01 21:54:21 +0000 |
commit | d3df80dfe41e4e3ab7644ae576119a264ba0e7f1 (patch) | |
tree | 9e19af8285cd2e95aa0ec79e589c3d08fb9047bf /crates/ra_hir | |
parent | afce8e442639fa9ed954b3659a2d1eccb7d80113 (diff) |
Cleanup
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir/src/resolve.rs | 16 | ||||
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 8 |
4 files changed, 12 insertions, 23 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index e78ba889e..f9f702ae2 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -76,11 +76,7 @@ impl Body { | |||
76 | } | 76 | } |
77 | 77 | ||
78 | // needs arbitrary_self_types to be a method... or maybe move to the def? | 78 | // needs arbitrary_self_types to be a method... or maybe move to the def? |
79 | pub fn resolver_for_expr( | 79 | pub fn resolver_for_expr(body: Arc<Body>, db: &impl HirDatabase, expr_id: ExprId) -> Resolver { |
80 | body: Arc<Body>, | ||
81 | db: &impl HirDatabase, | ||
82 | expr_id: ExprId, | ||
83 | ) -> Resolver<'static> { | ||
84 | let scopes = db.expr_scopes(body.owner); | 80 | let scopes = db.expr_scopes(body.owner); |
85 | resolver_for_scope(body, db, scopes.scope_for(expr_id)) | 81 | resolver_for_scope(body, db, scopes.scope_for(expr_id)) |
86 | } | 82 | } |
@@ -89,7 +85,7 @@ pub fn resolver_for_scope( | |||
89 | body: Arc<Body>, | 85 | body: Arc<Body>, |
90 | db: &impl HirDatabase, | 86 | db: &impl HirDatabase, |
91 | scope_id: Option<scope::ScopeId>, | 87 | scope_id: Option<scope::ScopeId>, |
92 | ) -> Resolver<'static> { | 88 | ) -> Resolver { |
93 | let mut r = body.owner.resolver(db); | 89 | let mut r = body.owner.resolver(db); |
94 | let scopes = db.expr_scopes(body.owner); | 90 | let scopes = db.expr_scopes(body.owner); |
95 | let scope_chain = scopes.scope_chain_for(scope_id).collect::<Vec<_>>(); | 91 | let scope_chain = scopes.scope_chain_for(scope_id).collect::<Vec<_>>(); |
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index 9b020db81..7ec6512b6 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -25,8 +25,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; | |||
25 | use crate::{ | 25 | use crate::{ |
26 | Module, ModuleDef, | 26 | Module, ModuleDef, |
27 | Path, PathKind, PersistentHirDatabase, | 27 | Path, PathKind, PersistentHirDatabase, |
28 | Crate, | 28 | Crate, Name, |
29 | Name, | ||
30 | module_tree::{ModuleId, ModuleTree}, | 29 | module_tree::{ModuleId, ModuleTree}, |
31 | nameres::lower::{ImportId, LoweredModule, ImportData}, | 30 | nameres::lower::{ImportId, LoweredModule, ImportData}, |
32 | }; | 31 | }; |
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs index 871f7d8f7..3e0af3a43 100644 --- a/crates/ra_hir/src/resolve.rs +++ b/crates/ra_hir/src/resolve.rs | |||
@@ -109,8 +109,6 @@ impl Resolver { | |||
109 | self.scopes.iter().rev().find_map(|scope| match scope { | 109 | self.scopes.iter().rev().find_map(|scope| match scope { |
110 | Scope::ModuleScope(m) => Some((&*m.item_map, m.module.clone())), | 110 | Scope::ModuleScope(m) => Some((&*m.item_map, m.module.clone())), |
111 | 111 | ||
112 | Scope::ModuleScopeRef(m) => Some((m.item_map, m.module.clone())), | ||
113 | |||
114 | _ => None, | 112 | _ => None, |
115 | }) | 113 | }) |
116 | } | 114 | } |
@@ -197,13 +195,13 @@ impl Scope { | |||
197 | fn collect_names(&self, f: &mut FnMut(Name, PerNs<Resolution>)) { | 195 | fn collect_names(&self, f: &mut FnMut(Name, PerNs<Resolution>)) { |
198 | match self { | 196 | match self { |
199 | Scope::ModuleScope(m) => { | 197 | Scope::ModuleScope(m) => { |
200 | m.item_map[m.module.module_id] | 198 | // TODO: should we provide `self` here? |
201 | .entries() | 199 | // f( |
202 | .for_each(|(name, res)| { | 200 | // Name::self_param(), |
203 | f(name.clone(), res.def.map(|def| Resolution::Def { def })); | 201 | // PerNs::types(Resolution::Def { |
204 | }) | 202 | // def: m.module.into(), |
205 | } | 203 | // }), |
206 | Scope::ModuleScopeRef(m) => { | 204 | // ); |
207 | m.item_map[m.module.module_id] | 205 | m.item_map[m.module.module_id] |
208 | .entries() | 206 | .entries() |
209 | .for_each(|(name, res)| { | 207 | .for_each(|(name, res)| { |
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 621215bfb..ce929cf3e 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -203,7 +203,7 @@ pub fn macro_symbols(db: &impl HirDatabase, file_id: FileId) -> Vec<(SmolStr, Te | |||
203 | res | 203 | res |
204 | } | 204 | } |
205 | 205 | ||
206 | pub fn resolver_for_position(db: &impl HirDatabase, position: FilePosition) -> Resolver<'static> { | 206 | pub fn resolver_for_position(db: &impl HirDatabase, position: FilePosition) -> Resolver { |
207 | let file = db.parse(position.file_id); | 207 | let file = db.parse(position.file_id); |
208 | find_leaf_at_offset(file.syntax(), position.offset) | 208 | find_leaf_at_offset(file.syntax(), position.offset) |
209 | .find_map(|node| { | 209 | .find_map(|node| { |
@@ -230,11 +230,7 @@ pub fn resolver_for_position(db: &impl HirDatabase, position: FilePosition) -> R | |||
230 | .unwrap_or_default() | 230 | .unwrap_or_default() |
231 | } | 231 | } |
232 | 232 | ||
233 | pub fn resolver_for_node( | 233 | pub fn resolver_for_node(db: &impl HirDatabase, file_id: FileId, node: &SyntaxNode) -> Resolver { |
234 | db: &impl HirDatabase, | ||
235 | file_id: FileId, | ||
236 | node: &SyntaxNode, | ||
237 | ) -> Resolver<'static> { | ||
238 | node.ancestors() | 234 | node.ancestors() |
239 | .find_map(|node| { | 235 | .find_map(|node| { |
240 | if ast::Expr::cast(node).is_some() || ast::Block::cast(node).is_some() { | 236 | if ast::Expr::cast(node).is_some() || ast::Block::cast(node).is_some() { |