Fix logic for determining macro calls

I believe this currently goes back all the way to the initial
user-written call, but that seems better than the current broken
behavior.
This commit is contained in:
Jonas Schievink 2020-12-08 19:11:12 +01:00
parent 306c6cbaac
commit da5027138d

View file

@ -457,17 +457,15 @@ impl<'a> InFile<&'a SyntaxNode> {
return FileRange { file_id: range.file_id.original_file(db), range: range.value };
}
// Fall back to whole macro call
if let Some(expansion) = self.file_id.expansion_info(db) {
if let Some(call_node) = expansion.call_node() {
return FileRange {
file_id: call_node.file_id.original_file(db),
range: call_node.value.text_range(),
};
}
// Fall back to whole macro call.
let mut node = self.cloned();
while let Some(call_node) = node.file_id.call_node(db) {
node = call_node;
}
FileRange { file_id: self.file_id.original_file(db), range: self.value.text_range() }
let orig_file = node.file_id.original_file(db);
assert_eq!(node.file_id, orig_file.into());
FileRange { file_id: orig_file, range: node.value.text_range() }
}
}