aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorBrandon <[email protected]>2021-03-24 07:47:55 +0000
committerBrandon <[email protected]>2021-03-24 07:47:55 +0000
commit903a2e98f93df87af19375e951c56e7c285989d4 (patch)
treeffa9471abcf322034a52b6a952d44b3d93a525fd /crates/ide
parent0d063b8d212dd6c54da0aa8608154c980107bd07 (diff)
Clean up implementation
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/annotations.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/ide/src/annotations.rs b/crates/ide/src/annotations.rs
index 9e78ed6a0..64bc926f1 100644
--- a/crates/ide/src/annotations.rs
+++ b/crates/ide/src/annotations.rs
@@ -80,19 +80,19 @@ pub(crate) fn annotations(
80 Either::Left(def) => { 80 Either::Left(def) => {
81 let node = match def { 81 let node = match def {
82 hir::ModuleDef::Const(konst) => { 82 hir::ModuleDef::Const(konst) => {
83 konst.source(db).and_then(|node| range_and_position_of(&node)) 83 konst.source(db).and_then(|node| range_and_position_of(&node, file_id))
84 } 84 }
85 hir::ModuleDef::Trait(trait_) => { 85 hir::ModuleDef::Trait(trait_) => {
86 trait_.source(db).and_then(|node| range_and_position_of(&node)) 86 trait_.source(db).and_then(|node| range_and_position_of(&node, file_id))
87 } 87 }
88 hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => { 88 hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => {
89 strukt.source(db).and_then(|node| range_and_position_of(&node)) 89 strukt.source(db).and_then(|node| range_and_position_of(&node, file_id))
90 } 90 }
91 hir::ModuleDef::Adt(hir::Adt::Enum(enum_)) => { 91 hir::ModuleDef::Adt(hir::Adt::Enum(enum_)) => {
92 enum_.source(db).and_then(|node| range_and_position_of(&node)) 92 enum_.source(db).and_then(|node| range_and_position_of(&node, file_id))
93 } 93 }
94 hir::ModuleDef::Adt(hir::Adt::Union(union)) => { 94 hir::ModuleDef::Adt(hir::Adt::Union(union)) => {
95 union.source(db).and_then(|node| range_and_position_of(&node)) 95 union.source(db).and_then(|node| range_and_position_of(&node, file_id))
96 } 96 }
97 _ => None, 97 _ => None,
98 }; 98 };
@@ -122,9 +122,10 @@ pub(crate) fn annotations(
122 122
123 fn range_and_position_of<T: NameOwner>( 123 fn range_and_position_of<T: NameOwner>(
124 node: &InFile<T>, 124 node: &InFile<T>,
125 file_id: FileId,
125 ) -> Option<(TextSize, TextRange)> { 126 ) -> Option<(TextSize, TextRange)> {
126 if node.file_id.is_macro_file() { 127 if node.file_id != file_id.into() {
127 // Macro generated files should not contain annotations. 128 // Node is outside the file we are adding annotations to (e.g. macros).
128 None 129 None
129 } else { 130 } else {
130 Some(( 131 Some((