mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
source_to_def: skip items with no def
This commit is contained in:
parent
16e142cd39
commit
8482329d65
1 changed files with 56 additions and 50 deletions
|
@ -211,7 +211,17 @@ impl SourceToDefCtx<'_, '_> {
|
|||
|
||||
pub(super) fn find_container(&mut self, src: InFile<&SyntaxNode>) -> Option<ChildContainer> {
|
||||
for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) {
|
||||
let res: ChildContainer = match_ast! {
|
||||
if let Some(res) = self.container_to_def(container) {
|
||||
return Some(res);
|
||||
}
|
||||
}
|
||||
|
||||
let def = self.file_to_def(src.file_id.original_file(self.db.upcast())).get(0).copied()?;
|
||||
Some(def.into())
|
||||
}
|
||||
|
||||
fn container_to_def(&mut self, container: InFile<SyntaxNode>) -> Option<ChildContainer> {
|
||||
let cont = match_ast! {
|
||||
match (container.value) {
|
||||
ast::Module(it) => {
|
||||
let def = self.module_to_def(container.with_value(it))?;
|
||||
|
@ -257,14 +267,10 @@ impl SourceToDefCtx<'_, '_> {
|
|||
let def = self.enum_variant_to_def(container.with_value(it))?;
|
||||
VariantId::from(def).into()
|
||||
},
|
||||
_ => continue,
|
||||
_ => return None,
|
||||
}
|
||||
};
|
||||
return Some(res);
|
||||
}
|
||||
|
||||
let def = self.file_to_def(src.file_id.original_file(self.db.upcast())).get(0).copied()?;
|
||||
Some(def.into())
|
||||
Some(cont)
|
||||
}
|
||||
|
||||
fn find_generic_param_container(&mut self, src: InFile<&SyntaxNode>) -> Option<GenericDefId> {
|
||||
|
|
Loading…
Reference in a new issue