Resolve paths to defs (functions currently) during type inference
This commit is contained in:
@@ -5,12 +5,13 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use ra_db::Cancelable;
|
||||
use ra_syntax::{
|
||||
TextRange, TextUnit,
|
||||
ast::{self, AstNode, DocCommentsOwner, NameOwner},
|
||||
};
|
||||
|
||||
use crate::{ DefId, HirDatabase, ty::InferenceResult };
|
||||
use crate::{ DefId, HirDatabase, ty::InferenceResult, Module };
|
||||
|
||||
pub use self::scope::FnScopes;
|
||||
|
||||
@@ -18,7 +19,7 @@ pub use self::scope::FnScopes;
|
||||
pub struct FnId(pub(crate) DefId);
|
||||
|
||||
pub struct Function {
|
||||
fn_id: FnId,
|
||||
pub(crate) fn_id: FnId,
|
||||
}
|
||||
|
||||
impl Function {
|
||||
@@ -27,6 +28,10 @@ impl Function {
|
||||
Function { fn_id }
|
||||
}
|
||||
|
||||
pub fn syntax(&self, db: &impl HirDatabase) -> ast::FnDefNode {
|
||||
db.fn_syntax(self.fn_id)
|
||||
}
|
||||
|
||||
pub fn scopes(&self, db: &impl HirDatabase) -> Arc<FnScopes> {
|
||||
db.fn_scopes(self.fn_id)
|
||||
}
|
||||
@@ -36,9 +41,14 @@ impl Function {
|
||||
FnSignatureInfo::new(syntax.borrowed())
|
||||
}
|
||||
|
||||
pub fn infer(&self, db: &impl HirDatabase) -> Arc<InferenceResult> {
|
||||
pub fn infer(&self, db: &impl HirDatabase) -> Cancelable<Arc<InferenceResult>> {
|
||||
db.infer(self.fn_id)
|
||||
}
|
||||
|
||||
pub fn module(&self, db: &impl HirDatabase) -> Cancelable<Module> {
|
||||
let loc = self.fn_id.0.loc(db);
|
||||
Module::new(db, loc.source_root_id, loc.module_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
Reference in New Issue
Block a user