From 9710ad8c488e63fc46ab911e2d0787dafacb87e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Wed, 1 Jul 2020 15:11:34 +0300 Subject: Reuse Semantics instances --- crates/ra_ide/src/references.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide/src/references.rs') diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 3433fdae3..c2b0d5efe 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -86,12 +86,11 @@ impl IntoIterator for ReferenceSearchResult { } pub(crate) fn find_all_refs( - db: &RootDatabase, + sema: &Semantics, position: FilePosition, search_scope: Option, ) -> Option> { let _p = profile("find_all_refs"); - let sema = Semantics::new(db); let syntax = sema.parse(position.file_id).syntax().clone(); let (opt_name, search_kind) = if let Some(name) = @@ -108,15 +107,15 @@ pub(crate) fn find_all_refs( let RangeInfo { range, info: def } = find_name(&sema, &syntax, position, opt_name)?; let references = def - .find_usages(db, search_scope) + .find_usages(sema, search_scope) .into_iter() .filter(|r| search_kind == ReferenceKind::Other || search_kind == r.kind) .collect(); - let decl_range = def.try_to_nav(db)?.range(); + let decl_range = def.try_to_nav(sema.db)?.range(); let declaration = Declaration { - nav: def.try_to_nav(db)?, + nav: def.try_to_nav(sema.db)?, kind: ReferenceKind::Other, access: decl_access(&def, &syntax, decl_range), }; -- cgit v1.2.3