Implement basic inherent method resolution
This commit is contained in:
@@ -43,6 +43,7 @@ impl FnSignature {
|
||||
.map(|n| n.as_name())
|
||||
.unwrap_or_else(Name::missing);
|
||||
let mut args = Vec::new();
|
||||
let mut has_self_arg = false;
|
||||
if let Some(param_list) = node.param_list() {
|
||||
if let Some(self_param) = param_list.self_param() {
|
||||
let self_type = if let Some(type_ref) = self_param.type_ref() {
|
||||
@@ -60,6 +61,7 @@ impl FnSignature {
|
||||
}
|
||||
};
|
||||
args.push(self_type);
|
||||
has_self_arg = true;
|
||||
}
|
||||
for param in param_list.params() {
|
||||
let type_ref = TypeRef::from_ast_opt(param.type_ref());
|
||||
@@ -75,6 +77,7 @@ impl FnSignature {
|
||||
name,
|
||||
args,
|
||||
ret_type,
|
||||
has_self_arg,
|
||||
};
|
||||
Arc::new(sig)
|
||||
}
|
||||
|
||||
@@ -95,6 +95,21 @@ impl Module {
|
||||
Module::from_module_id(db, loc.source_root_id, child_id).map(Some)
|
||||
}
|
||||
|
||||
/// Iterates over all child modules.
|
||||
pub fn children_impl(&self, db: &impl HirDatabase) -> Cancelable<impl Iterator<Item = Module>> {
|
||||
// FIXME this should be implementable without collecting into a vec, but
|
||||
// it's kind of hard since the iterator needs to keep a reference to the
|
||||
// module tree.
|
||||
let loc = self.def_id.loc(db);
|
||||
let module_tree = db.module_tree(loc.source_root_id)?;
|
||||
let children = loc
|
||||
.module_id
|
||||
.children(&module_tree)
|
||||
.map(|(_, module_id)| Module::from_module_id(db, loc.source_root_id, module_id))
|
||||
.collect::<Cancelable<Vec<_>>>()?;
|
||||
Ok(children.into_iter())
|
||||
}
|
||||
|
||||
pub fn parent_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> {
|
||||
let loc = self.def_id.loc(db);
|
||||
let module_tree = db.module_tree(loc.source_root_id)?;
|
||||
|
||||
Reference in New Issue
Block a user