Skip to content

Commit c4cff80

Browse files
committed
use nodes from actual file
1 parent 784379e commit c4cff80

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

crates/ide-completion/src/context/analysis.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -883,18 +883,25 @@ fn classify_name_ref(
883883
}
884884
};
885885
let make_path_kind_type = |ty: ast::Type| {
886-
let location = type_location(ty.syntax());
887-
if let Some(p) = ty.syntax().parent() {
888-
if ast::GenericArg::can_cast(p.kind()) || ast::GenericArgList::can_cast(p.kind()) {
889-
if let Some(p) = p.parent().and_then(|p| p.parent()) {
890-
if let Some(segment) = ast::PathSegment::cast(p) {
891-
let path = segment.parent_path().top_path();
892-
dbg!(sema.resolve_path(&path));
893-
}
886+
let location = type_location(ty.syntax()).unwrap_or(TypeLocation::Other);
887+
match &location {
888+
TypeLocation::TupleField => (),
889+
TypeLocation::TypeAscription(_) => (),
890+
TypeLocation::GenericArgList(args) => {
891+
dbg!(&args);
892+
if let Some(segment) =
893+
args.as_ref().and_then(|args| ast::PathSegment::cast(args.syntax().parent()?))
894+
{
895+
let path = dbg!(segment.parent_path().top_path());
896+
dbg!(sema.resolve_path(&path));
894897
}
895898
}
899+
TypeLocation::TypeBound => (),
900+
TypeLocation::ImplTarget => (),
901+
TypeLocation::ImplTrait => (),
902+
TypeLocation::Other => (),
896903
}
897-
PathKind::Type { location: location.unwrap_or(TypeLocation::Other) }
904+
PathKind::Type { location }
898905
};
899906

900907
let mut kind_macro_call = |it: ast::MacroCall| {

0 commit comments

Comments
 (0)