Remove dead code

This commit is contained in:
Aleksey Kladov 2020-02-26 13:24:46 +01:00
parent 09bc7ca74d
commit ade0176c20
2 changed files with 9 additions and 25 deletions

View file

@ -47,7 +47,7 @@ pub use crate::{
}, },
has_source::HasSource, has_source::HasSource,
semantics::{original_range, Semantics, SemanticsScope}, semantics::{original_range, Semantics, SemanticsScope},
source_analyzer::{PathResolution, ScopeEntryWithSyntax}, source_analyzer::PathResolution,
}; };
pub use hir_def::{ pub use hir_def::{

View file

@ -25,8 +25,8 @@ use ra_syntax::{
}; };
use crate::{ use crate::{
db::HirDatabase, Adt, Const, EnumVariant, Function, Local, MacroDef, Name, Path, Static, db::HirDatabase, Adt, Const, EnumVariant, Function, Local, MacroDef, Path, Static, Struct,
Struct, Trait, Type, TypeAlias, TypeParam, Trait, Type, TypeAlias, TypeParam,
}; };
/// `SourceAnalyzer` is a convenience wrapper which exposes HIR API in terms of /// `SourceAnalyzer` is a convenience wrapper which exposes HIR API in terms of
@ -53,22 +53,6 @@ pub enum PathResolution {
AssocItem(crate::AssocItem), AssocItem(crate::AssocItem),
} }
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ScopeEntryWithSyntax {
pub(crate) name: Name,
pub(crate) ptr: Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>,
}
impl ScopeEntryWithSyntax {
pub fn name(&self) -> &Name {
&self.name
}
pub fn ptr(&self) -> Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>> {
self.ptr
}
}
#[derive(Debug)] #[derive(Debug)]
pub struct ReferenceDescriptor { pub struct ReferenceDescriptor {
pub range: TextRange, pub range: TextRange,
@ -235,16 +219,16 @@ impl SourceAnalyzer {
resolve_hir_path(db, &self.resolver, &hir_path) resolve_hir_path(db, &self.resolver, &hir_path)
} }
fn resolve_local_name(&self, name_ref: &ast::NameRef) -> Option<ScopeEntryWithSyntax> { fn resolve_local_name(
&self,
name_ref: &ast::NameRef,
) -> Option<Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>> {
let name = name_ref.as_name(); let name = name_ref.as_name();
let source_map = self.body_source_map.as_ref()?; let source_map = self.body_source_map.as_ref()?;
let scopes = self.scopes.as_ref()?; let scopes = self.scopes.as_ref()?;
let scope = scope_for(scopes, source_map, InFile::new(self.file_id, name_ref.syntax()))?; let scope = scope_for(scopes, source_map, InFile::new(self.file_id, name_ref.syntax()))?;
let entry = scopes.resolve_name_in_scope(scope, &name)?; let entry = scopes.resolve_name_in_scope(scope, &name)?;
Some(ScopeEntryWithSyntax { Some(source_map.pat_syntax(entry.pat())?.value)
name: entry.name().clone(),
ptr: source_map.pat_syntax(entry.pat())?.value,
})
} }
// FIXME: we only use this in `inline_local_variable` assist, ideally, we // FIXME: we only use this in `inline_local_variable` assist, ideally, we
@ -258,7 +242,7 @@ impl SourceAnalyzer {
.filter_map(ast::NameRef::cast) .filter_map(ast::NameRef::cast)
.filter(|name_ref| match self.resolve_local_name(&name_ref) { .filter(|name_ref| match self.resolve_local_name(&name_ref) {
None => false, None => false,
Some(entry) => entry.ptr() == ptr, Some(d_ptr) => d_ptr == ptr,
}) })
.map(|name_ref| ReferenceDescriptor { .map(|name_ref| ReferenceDescriptor {
name: name_ref.text().to_string(), name: name_ref.text().to_string(),