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/semantics.rs | 8 +------- crates/ra_hir/src/source_analyzer.rs | 35 +---------------------------------- 2 files changed, 2 insertions(+), 41 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index afc7f7ee7..7ce785791 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -19,7 +19,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use crate::{ db::HirDatabase, semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, - source_analyzer::{resolve_hir_path, ReferenceDescriptor, SourceAnalyzer}, + source_analyzer::{resolve_hir_path, SourceAnalyzer}, Function, HirFileId, InFile, Local, MacroDef, Module, ModuleDef, Name, Origin, Path, PathResolution, ScopeDef, StructField, Trait, Type, TypeParam, VariantDef, }; @@ -171,12 +171,6 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { SemanticsScope { db: self.db, resolver } } - // FIXME: we only use this in `inline_local_variable` assist, ideally, we - // should switch to general reference search infra there. - pub fn find_all_refs(&self, pat: &ast::BindPat) -> Vec { - self.analyze(pat.syntax()).find_all_refs(pat) - } - fn analyze(&self, node: &SyntaxNode) -> SourceAnalyzer { let src = self.find_file(node.clone()); self.analyze2(src.as_ref(), None) 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