Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/lib.rs')
-rw-r--r--crates/hir-expand/src/lib.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/crates/hir-expand/src/lib.rs b/crates/hir-expand/src/lib.rs
index d844d8f41e..6ecac1463f 100644
--- a/crates/hir-expand/src/lib.rs
+++ b/crates/hir-expand/src/lib.rs
@@ -392,6 +392,10 @@ impl HirFileId {
}
}
+ pub fn call_node(self, db: &dyn ExpandDatabase) -> Option<InFile<SyntaxNode>> {
+ Some(db.lookup_intern_macro_call(self.macro_file()?).to_node(db))
+ }
+
pub fn as_builtin_derive_attr_node(
&self,
db: &dyn ExpandDatabase,
@@ -848,7 +852,10 @@ impl ExpansionInfo {
map_node_range_up(db, &self.exp_map, range)
}
- /// Maps up the text range out of the expansion into is macro call.
+ /// Maps up the text range out of the expansion into its macro call.
+ ///
+ /// Note that this may return multiple ranges as we lose the precise association between input to output
+ /// and as such we may consider inputs that are unrelated.
pub fn map_range_up_once(
&self,
db: &dyn ExpandDatabase,
@@ -864,11 +871,10 @@ impl ExpansionInfo {
InFile { file_id, value: smallvec::smallvec![span.range + anchor_offset] }
}
SpanMap::ExpansionSpanMap(arg_map) => {
- let arg_range = self
- .arg
- .value
- .as_ref()
- .map_or_else(|| TextRange::empty(TextSize::from(0)), |it| it.text_range());
+ let Some(arg_node) = &self.arg.value else {
+ return InFile::new(self.arg.file_id, smallvec::smallvec![]);
+ };
+ let arg_range = arg_node.text_range();
InFile::new(
self.arg.file_id,
arg_map