From f57682c0b3b17a09d728c77134200b4151b2358d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 4 Mar 2020 14:25:22 +0100 Subject: Remove old find refs infra --- crates/ra_hir/src/source_analyzer.rs | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) (limited to 'crates/ra_hir/src/source_analyzer.rs') diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index 015389fb0..73cff17c9 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -7,7 +7,6 @@ //! purely for "IDE needs". use std::{iter::once, sync::Arc}; -use either::Either; use hir_def::{ body::{ scope::{ExprScopes, ScopeId}, @@ -21,7 +20,7 @@ use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile}; use hir_ty::{InEnvironment, InferenceResult, TraitEnvironment}; use ra_syntax::{ ast::{self, AstNode}, - AstPtr, SyntaxNode, SyntaxNodePtr, TextRange, TextUnit, + SyntaxNode, SyntaxNodePtr, TextRange, TextUnit, }; use crate::{ @@ -251,38 +250,6 @@ impl SourceAnalyzer { resolve_hir_path(db, &self.resolver, &hir_path) } - fn resolve_local_name( - &self, - name_ref: &ast::NameRef, - ) -> Option, AstPtr>> { - let name = name_ref.as_name(); - let source_map = self.body_source_map.as_ref()?; - let scopes = self.scopes.as_ref()?; - let scope = scope_for(scopes, source_map, InFile::new(self.file_id, name_ref.syntax()))?; - let entry = scopes.resolve_name_in_scope(scope, &name)?; - Some(source_map.pat_syntax(entry.pat())?.value) - } - - // FIXME: we only use this in `inline_local_variable` assist, ideally, we - // should switch to general reference search infra there. - pub(crate) fn find_all_refs(&self, pat: &ast::BindPat) -> Vec { - let fn_def = pat.syntax().ancestors().find_map(ast::FnDef::cast).unwrap(); - let ptr = Either::Left(AstPtr::new(&ast::Pat::from(pat.clone()))); - fn_def - .syntax() - .descendants() - .filter_map(ast::NameRef::cast) - .filter(|name_ref| match self.resolve_local_name(&name_ref) { - None => false, - Some(d_ptr) => d_ptr == ptr, - }) - .map(|name_ref| ReferenceDescriptor { - name: name_ref.text().to_string(), - range: name_ref.syntax().text_range(), - }) - .collect() - } - pub(crate) fn expand( &self, db: &impl HirDatabase, -- cgit v1.2.3