mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
move auto-imoprter into IDE
auto-import is purely an IDE concern, so it should be done outside of HIR
This commit is contained in:
parent
200032852b
commit
e01052d1f0
7 changed files with 68 additions and 92 deletions
|
@ -14,12 +14,11 @@ use ra_syntax::{
|
|||
ast::{self, AstNode, NameOwner},
|
||||
algo::find_node_at_offset,
|
||||
SyntaxKind::*,
|
||||
SmolStr,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name,
|
||||
AsName, Module, HirFileId, Crate, Trait, Resolver, Ty, ImportResolver,
|
||||
AsName, Module, HirFileId, Crate, Trait, Resolver, Ty,
|
||||
expr::{BodySourceMap, scope::{ScopeId, ExprScopes}},
|
||||
ids::LocationCtx,
|
||||
expr, AstId,
|
||||
|
@ -171,7 +170,6 @@ fn def_with_body_from_child_node(
|
|||
#[derive(Debug)]
|
||||
pub struct SourceAnalyzer {
|
||||
resolver: Resolver,
|
||||
import_resolver: ImportResolver,
|
||||
body_source_map: Option<Arc<BodySourceMap>>,
|
||||
infer: Option<Arc<crate::ty::InferenceResult>>,
|
||||
scopes: Option<Arc<crate::expr::ExprScopes>>,
|
||||
|
@ -219,7 +217,6 @@ impl SourceAnalyzer {
|
|||
offset: Option<TextUnit>,
|
||||
) -> SourceAnalyzer {
|
||||
let def_with_body = def_with_body_from_child_node(db, file_id, node);
|
||||
let import_resolver = ImportResolver::new();
|
||||
if let Some(def) = def_with_body {
|
||||
let source_map = def.body_source_map(db);
|
||||
let scopes = db.expr_scopes(def);
|
||||
|
@ -230,7 +227,6 @@ impl SourceAnalyzer {
|
|||
let resolver = expr::resolver_for_scope(def.body(db), db, scope);
|
||||
SourceAnalyzer {
|
||||
resolver,
|
||||
import_resolver,
|
||||
body_source_map: Some(source_map),
|
||||
infer: Some(def.infer(db)),
|
||||
scopes: Some(scopes),
|
||||
|
@ -241,7 +237,6 @@ impl SourceAnalyzer {
|
|||
.ancestors()
|
||||
.find_map(|node| try_get_resolver_for_node(db, file_id, node))
|
||||
.unwrap_or_default(),
|
||||
import_resolver,
|
||||
body_source_map: None,
|
||||
infer: None,
|
||||
scopes: None,
|
||||
|
@ -328,14 +323,6 @@ impl SourceAnalyzer {
|
|||
self.resolver.all_names(db)
|
||||
}
|
||||
|
||||
pub fn all_import_names(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
name: &Name,
|
||||
) -> FxHashMap<SmolStr, Vec<SmolStr>> {
|
||||
self.import_resolver.all_names(db, name)
|
||||
}
|
||||
|
||||
pub fn find_all_refs(&self, pat: &ast::BindPat) -> Vec<ReferenceDescriptor> {
|
||||
// FIXME: at least, this should work with any DefWithBody, but ideally
|
||||
// this should be hir-based altogether
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue