aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-22 08:01:03 +0000
committerAleksey Kladov <[email protected]>2018-12-22 08:01:03 +0000
commit49e746b010bbba408e9e4b1a40d89642e4cb84c6 (patch)
treed2d46b55e76a7a9af91c6502d70c5523b0a89b1a /crates/ra_hir
parent4e4ca27eabac6a9c97dc07baf9a067efdfc63384 (diff)
completion uses hir scopes
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/function.rs2
-rw-r--r--crates/ra_hir/src/function/scope.rs2
-rw-r--r--crates/ra_hir/src/source_binder.rs12
3 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_hir/src/function.rs b/crates/ra_hir/src/function.rs
index 5187dc051..2925beb16 100644
--- a/crates/ra_hir/src/function.rs
+++ b/crates/ra_hir/src/function.rs
@@ -27,7 +27,7 @@ impl Function {
27 Function { fn_id } 27 Function { fn_id }
28 } 28 }
29 29
30 pub fn scope(&self, db: &impl HirDatabase) -> Arc<FnScopes> { 30 pub fn scopes(&self, db: &impl HirDatabase) -> Arc<FnScopes> {
31 db.fn_scopes(self.fn_id) 31 db.fn_scopes(self.fn_id)
32 } 32 }
33 33
diff --git a/crates/ra_hir/src/function/scope.rs b/crates/ra_hir/src/function/scope.rs
index 77be25f1a..a1a580979 100644
--- a/crates/ra_hir/src/function/scope.rs
+++ b/crates/ra_hir/src/function/scope.rs
@@ -33,7 +33,7 @@ pub struct ScopeData {
33} 33}
34 34
35impl FnScopes { 35impl FnScopes {
36 pub fn new(fn_def: ast::FnDef) -> FnScopes { 36 pub(crate) fn new(fn_def: ast::FnDef) -> FnScopes {
37 let mut scopes = FnScopes { 37 let mut scopes = FnScopes {
38 self_param: fn_def 38 self_param: fn_def
39 .param_list() 39 .param_list()
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index ce2a0f2e8..a0165aef2 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -74,6 +74,16 @@ pub fn function_from_source(
74 fn_def: ast::FnDef, 74 fn_def: ast::FnDef,
75) -> Cancelable<Option<Function>> { 75) -> Cancelable<Option<Function>> {
76 let module = ctry!(module_from_child_node(db, file_id, fn_def.syntax())?); 76 let module = ctry!(module_from_child_node(db, file_id, fn_def.syntax())?);
77 let res = function_from_module(db, &module, fn_def);
78 Ok(Some(res))
79}
80
81pub fn function_from_module(
82 db: &impl HirDatabase,
83 module: &Module,
84 fn_def: ast::FnDef,
85) -> Function {
86 let file_id = module.source().file_id();
77 let file_items = db.file_items(file_id); 87 let file_items = db.file_items(file_id);
78 let item_id = file_items.id_of(file_id, fn_def.syntax()); 88 let item_id = file_items.id_of(file_id, fn_def.syntax());
79 let source_item_id = SourceItemId { 89 let source_item_id = SourceItemId {
@@ -86,7 +96,7 @@ pub fn function_from_source(
86 module_id: module.module_id, 96 module_id: module.module_id,
87 source_item_id, 97 source_item_id,
88 }; 98 };
89 Ok(Some(Function::new(def_loc.id(db)))) 99 Function::new(def_loc.id(db))
90} 100}
91 101
92pub fn function_from_child_node( 102pub fn function_from_child_node(