diff options
author | Jonas Schievink <[email protected]> | 2020-12-08 18:11:12 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-12-08 18:11:12 +0000 |
commit | da5027138d93c59aeb25aab5021276969f074992 (patch) | |
tree | 67b9f5e41749a89b85b3f4ce49fec62b4a85da82 | |
parent | 306c6cbaac692bd5fec66173cb7fd9f2d7de9e98 (diff) |
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.
-rw-r--r-- | crates/hir_expand/src/lib.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs index 3edcadf0d..1a9428514 100644 --- a/crates/hir_expand/src/lib.rs +++ b/crates/hir_expand/src/lib.rs | |||
@@ -457,17 +457,15 @@ impl<'a> InFile<&'a SyntaxNode> { | |||
457 | return FileRange { file_id: range.file_id.original_file(db), range: range.value }; | 457 | return FileRange { file_id: range.file_id.original_file(db), range: range.value }; |
458 | } | 458 | } |
459 | 459 | ||
460 | // Fall back to whole macro call | 460 | // Fall back to whole macro call. |
461 | if let Some(expansion) = self.file_id.expansion_info(db) { | 461 | let mut node = self.cloned(); |
462 | if let Some(call_node) = expansion.call_node() { | 462 | while let Some(call_node) = node.file_id.call_node(db) { |
463 | return FileRange { | 463 | node = call_node; |
464 | file_id: call_node.file_id.original_file(db), | ||
465 | range: call_node.value.text_range(), | ||
466 | }; | ||
467 | } | ||
468 | } | 464 | } |
469 | 465 | ||
470 | FileRange { file_id: self.file_id.original_file(db), range: self.value.text_range() } | 466 | let orig_file = node.file_id.original_file(db); |
467 | assert_eq!(node.file_id, orig_file.into()); | ||
468 | FileRange { file_id: orig_file, range: node.value.text_range() } | ||
471 | } | 469 | } |
472 | } | 470 | } |
473 | 471 | ||