This commit is contained in:
Aleksey Kladov 2020-02-06 16:00:39 +01:00
parent aa571e378b
commit f8dde21fe9

View File

@ -11,7 +11,7 @@
use ra_syntax::{ast, AstNode, SyntaxKind::NAME}; use ra_syntax::{ast, AstNode, SyntaxKind::NAME};
use crate::{ use crate::{
references::{classify_name, NameDefinition, NameKind}, references::{classify_name, NameKind},
Query, Query,
}; };
@ -28,7 +28,7 @@ fn get_name_definition(
&mut self, &mut self,
db: &impl HirDatabase, db: &impl HirDatabase,
import_candidate: &FileSymbol, import_candidate: &FileSymbol,
) -> Option<NameDefinition> { ) -> Option<NameKind> {
let _p = profile("get_name_definition"); let _p = profile("get_name_definition");
let file_id = import_candidate.file_id.into(); let file_id = import_candidate.file_id.into();
let candidate_node = import_candidate.ptr.to_node(&db.parse_or_expand(file_id)?); let candidate_node = import_candidate.ptr.to_node(&db.parse_or_expand(file_id)?);
@ -41,6 +41,7 @@ fn get_name_definition(
&mut self.source_binder, &mut self.source_binder,
hir::InFile { file_id, value: &ast::Name::cast(candidate_name_node)? }, hir::InFile { file_id, value: &ast::Name::cast(candidate_name_node)? },
) )
.map(|it| it.kind)
} }
} }
@ -67,7 +68,7 @@ fn find_imports(&mut self, name_to_import: &str) -> Vec<ModuleDef> {
.into_iter() .into_iter()
.chain(lib_results.into_iter()) .chain(lib_results.into_iter())
.filter_map(|import_candidate| self.get_name_definition(db, &import_candidate)) .filter_map(|import_candidate| self.get_name_definition(db, &import_candidate))
.filter_map(|name_definition_to_import| match name_definition_to_import.kind { .filter_map(|name_definition_to_import| match name_definition_to_import {
NameKind::Def(module_def) => Some(module_def), NameKind::Def(module_def) => Some(module_def),
_ => None, _ => None,
}) })