aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_impl
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r--crates/ra_hir/src/code_model_impl/function.rs3
-rw-r--r--crates/ra_hir/src/code_model_impl/module.rs15
2 files changed, 18 insertions, 0 deletions
diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs
index 1ce939e05..77dddff79 100644
--- a/crates/ra_hir/src/code_model_impl/function.rs
+++ b/crates/ra_hir/src/code_model_impl/function.rs
@@ -43,6 +43,7 @@ impl FnSignature {
43 .map(|n| n.as_name()) 43 .map(|n| n.as_name())
44 .unwrap_or_else(Name::missing); 44 .unwrap_or_else(Name::missing);
45 let mut args = Vec::new(); 45 let mut args = Vec::new();
46 let mut has_self_arg = false;
46 if let Some(param_list) = node.param_list() { 47 if let Some(param_list) = node.param_list() {
47 if let Some(self_param) = param_list.self_param() { 48 if let Some(self_param) = param_list.self_param() {
48 let self_type = if let Some(type_ref) = self_param.type_ref() { 49 let self_type = if let Some(type_ref) = self_param.type_ref() {
@@ -60,6 +61,7 @@ impl FnSignature {
60 } 61 }
61 }; 62 };
62 args.push(self_type); 63 args.push(self_type);
64 has_self_arg = true;
63 } 65 }
64 for param in param_list.params() { 66 for param in param_list.params() {
65 let type_ref = TypeRef::from_ast_opt(param.type_ref()); 67 let type_ref = TypeRef::from_ast_opt(param.type_ref());
@@ -75,6 +77,7 @@ impl FnSignature {
75 name, 77 name,
76 args, 78 args,
77 ret_type, 79 ret_type,
80 has_self_arg,
78 }; 81 };
79 Arc::new(sig) 82 Arc::new(sig)
80 } 83 }
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs
index e9ff06dc8..775dd6709 100644
--- a/crates/ra_hir/src/code_model_impl/module.rs
+++ b/crates/ra_hir/src/code_model_impl/module.rs
@@ -95,6 +95,21 @@ impl Module {
95 Module::from_module_id(db, loc.source_root_id, child_id).map(Some) 95 Module::from_module_id(db, loc.source_root_id, child_id).map(Some)
96 } 96 }
97 97
98 /// Iterates over all child modules.
99 pub fn children_impl(&self, db: &impl HirDatabase) -> Cancelable<impl Iterator<Item = Module>> {
100 // FIXME this should be implementable without collecting into a vec, but
101 // it's kind of hard since the iterator needs to keep a reference to the
102 // module tree.
103 let loc = self.def_id.loc(db);
104 let module_tree = db.module_tree(loc.source_root_id)?;
105 let children = loc
106 .module_id
107 .children(&module_tree)
108 .map(|(_, module_id)| Module::from_module_id(db, loc.source_root_id, module_id))
109 .collect::<Cancelable<Vec<_>>>()?;
110 Ok(children.into_iter())
111 }
112
98 pub fn parent_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> { 113 pub fn parent_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> {
99 let loc = self.def_id.loc(db); 114 let loc = self.def_id.loc(db);
100 let module_tree = db.module_tree(loc.source_root_id)?; 115 let module_tree = db.module_tree(loc.source_root_id)?;