From 19136cde000c2c227e79bf44febde990fe265cb7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 11 Jan 2019 20:43:10 +0300 Subject: uncopypaste def sources --- crates/ra_hir/src/code_model_impl/function.rs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'crates/ra_hir/src/code_model_impl') diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs index daf49e791..1ce939e05 100644 --- a/crates/ra_hir/src/code_model_impl/function.rs +++ b/crates/ra_hir/src/code_model_impl/function.rs @@ -3,16 +3,14 @@ mod scope; use std::sync::Arc; use ra_db::Cancelable; -use ra_syntax::{ - TreeArc, - ast::{self, AstNode, NameOwner}, -}; +use ra_syntax::{TreeArc, ast::{self, NameOwner}}; use crate::{ - DefId, DefKind, HirDatabase, Name, AsName, Function, FnSignature, Module, HirFileId, + DefId, HirDatabase, Name, AsName, Function, FnSignature, Module, type_ref::{TypeRef, Mutability}, expr::Body, impl_block::ImplBlock, + code_model_impl::def_id_to_ast, }; pub use self::scope::{FnScopes, ScopesWithSyntaxMapping, ScopeEntryWithSyntax}; @@ -22,16 +20,6 @@ impl Function { Function { def_id } } - pub(crate) fn source_impl(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc) { - let def_loc = self.def_id.loc(db); - assert!(def_loc.kind == DefKind::Function); - let syntax = db.file_item(def_loc.source_item_id); - ( - def_loc.source_item_id.file_id, - ast::FnDef::cast(&syntax).unwrap().to_owned(), - ) - } - pub(crate) fn body(&self, db: &impl HirDatabase) -> Cancelable> { db.body_hir(self.def_id) } @@ -48,8 +36,8 @@ impl Function { impl FnSignature { pub(crate) fn fn_signature_query(db: &impl HirDatabase, def_id: DefId) -> Arc { - let func = Function::new(def_id); - let node = func.source_impl(db).1; // TODO we're using source_impl here to avoid returning Cancelable... this is a bit hacky + // FIXME: we're using def_id_to_ast here to avoid returning Cancelable... this is a bit hacky + let node: TreeArc = def_id_to_ast(db, def_id).1; let name = node .name() .map(|n| n.as_name()) -- cgit v1.2.3