aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-01-27 16:23:49 +0000
committerFlorian Diebold <[email protected]>2019-02-01 21:54:21 +0000
commitd3df80dfe41e4e3ab7644ae576119a264ba0e7f1 (patch)
tree9e19af8285cd2e95aa0ec79e589c3d08fb9047bf /crates
parentafce8e442639fa9ed954b3659a2d1eccb7d80113 (diff)
Cleanup
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/expr.rs8
-rw-r--r--crates/ra_hir/src/nameres.rs3
-rw-r--r--crates/ra_hir/src/resolve.rs16
-rw-r--r--crates/ra_hir/src/source_binder.rs8
-rw-r--r--crates/ra_ide_api/src/completion/complete_path.rs6
-rw-r--r--crates/ra_ide_api/src/completion/completion_context.rs2
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs1
7 files changed, 17 insertions, 27 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?
79pub fn resolver_for_expr( 79pub 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};
25use crate::{ 25use 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
206pub fn resolver_for_position(db: &impl HirDatabase, position: FilePosition) -> Resolver<'static> { 206pub 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
233pub fn resolver_for_node( 233pub 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() {
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index 9e61c0212..5b89c64ad 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -1,11 +1,11 @@
1use join_to_string::join; 1use join_to_string::join;
2 2
3use hir::{Docs, Resolution};
4
3use crate::{ 5use crate::{
4 completion::{CompletionItem, CompletionItemKind, Completions, CompletionKind, CompletionContext}, 6 completion::{CompletionItem, CompletionItemKind, Completions, CompletionKind, CompletionContext},
5}; 7};
6 8
7use hir::Docs;
8
9pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { 9pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
10 let path = match &ctx.path_prefix { 10 let path = match &ctx.path_prefix {
11 Some(path) => path.clone(), 11 Some(path) => path.clone(),
@@ -15,7 +15,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
15 Some(Resolution::Def { def }) => def, 15 Some(Resolution::Def { def }) => def,
16 _ => return, 16 _ => return,
17 }; 17 };
18 match def_id { 18 match def {
19 hir::ModuleDef::Module(module) => { 19 hir::ModuleDef::Module(module) => {
20 let module_scope = module.scope(ctx.db); 20 let module_scope = module.scope(ctx.db);
21 for (name, res) in module_scope.entries() { 21 for (name, res) in module_scope.entries() {
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs
index aea32fce3..5d1851da6 100644
--- a/crates/ra_ide_api/src/completion/completion_context.rs
+++ b/crates/ra_ide_api/src/completion/completion_context.rs
@@ -16,7 +16,7 @@ pub(crate) struct CompletionContext<'a> {
16 pub(super) db: &'a db::RootDatabase, 16 pub(super) db: &'a db::RootDatabase,
17 pub(super) offset: TextUnit, 17 pub(super) offset: TextUnit,
18 pub(super) leaf: &'a SyntaxNode, 18 pub(super) leaf: &'a SyntaxNode,
19 pub(super) resolver: Resolver<'static>, 19 pub(super) resolver: Resolver,
20 pub(super) module: Option<hir::Module>, 20 pub(super) module: Option<hir::Module>,
21 pub(super) function: Option<hir::Function>, 21 pub(super) function: Option<hir::Function>,
22 pub(super) function_syntax: Option<&'a ast::FnDef>, 22 pub(super) function_syntax: Option<&'a ast::FnDef>,
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index f7dd28c7c..48080b6e1 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -4,6 +4,7 @@ use ra_syntax::{
4 algo::find_node_at_offset, 4 algo::find_node_at_offset,
5}; 5};
6use test_utils::tested_by; 6use test_utils::tested_by;
7use hir::Resolution;
7 8
8use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; 9use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo};
9 10