From 4344264024d374bb9cdc6f388f13c90b48c6c22e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 5 Dec 2018 13:16:20 +0300 Subject: move fuzzy source binding to a separete mode --- crates/ra_hir/src/function/mod.rs | 52 ++------------------------------------- 1 file changed, 2 insertions(+), 50 deletions(-) (limited to 'crates/ra_hir/src/function/mod.rs') diff --git a/crates/ra_hir/src/function/mod.rs b/crates/ra_hir/src/function/mod.rs index e00bca6e3..5187dc051 100644 --- a/crates/ra_hir/src/function/mod.rs +++ b/crates/ra_hir/src/function/mod.rs @@ -6,16 +6,11 @@ use std::{ }; use ra_syntax::{ - TextRange, TextUnit, SyntaxNodeRef, + TextRange, TextUnit, ast::{self, AstNode, DocCommentsOwner, NameOwner}, }; -use ra_db::FileId; -use crate::{ - Cancelable, - DefLoc, DefKind, DefId, HirDatabase, SourceItemId, - Module, -}; +use crate::{ DefId, HirDatabase }; pub use self::scope::FnScopes; @@ -32,49 +27,6 @@ impl Function { Function { fn_id } } - pub fn guess_from_source( - db: &impl HirDatabase, - file_id: FileId, - fn_def: ast::FnDef, - ) -> Cancelable> { - let module = ctry!(Module::guess_from_child_node(db, file_id, fn_def.syntax())?); - let file_items = db.file_items(file_id); - let item_id = file_items.id_of(fn_def.syntax()); - let source_item_id = SourceItemId { file_id, item_id }; - let def_loc = DefLoc { - kind: DefKind::Function, - source_root_id: module.source_root_id, - module_id: module.module_id, - source_item_id, - }; - Ok(Some(Function::new(def_loc.id(db)))) - } - - pub fn guess_for_name_ref( - db: &impl HirDatabase, - file_id: FileId, - name_ref: ast::NameRef, - ) -> Cancelable> { - Function::guess_for_node(db, file_id, name_ref.syntax()) - } - - pub fn guess_for_bind_pat( - db: &impl HirDatabase, - file_id: FileId, - bind_pat: ast::BindPat, - ) -> Cancelable> { - Function::guess_for_node(db, file_id, bind_pat.syntax()) - } - - fn guess_for_node( - db: &impl HirDatabase, - file_id: FileId, - node: SyntaxNodeRef, - ) -> Cancelable> { - let fn_def = ctry!(node.ancestors().find_map(ast::FnDef::cast)); - Function::guess_from_source(db, file_id, fn_def) - } - pub fn scope(&self, db: &impl HirDatabase) -> Arc { db.fn_scopes(self.fn_id) } -- cgit v1.2.3