Add test for invalidation of inferred types when typing inside function

This currently fails, but should work once we have hir::Expr.
This commit is contained in:
Florian Diebold 2019-01-05 13:42:47 +01:00
parent 3e42a15878
commit a6f33b4ca5
2 changed files with 58 additions and 0 deletions

View file

@ -87,6 +87,20 @@ fn module_from_source(
Ok(Some(Module::new(db, source_root_id, module_id)?))
}
pub fn function_from_position(
db: &impl HirDatabase,
position: FilePosition,
) -> Cancelable<Option<Function>> {
let file = db.source_file(position.file_id);
let fn_def = if let Some(f) = find_node_at_offset::<ast::FnDef>(file.syntax(), position.offset)
{
f
} else {
return Ok(None);
};
function_from_source(db, position.file_id, fn_def)
}
pub fn function_from_source(
db: &impl HirDatabase,
file_id: FileId,