diff options
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r-- | crates/ide_db/src/search.rs | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index e69f9d141..c4aff3932 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs | |||
@@ -122,9 +122,15 @@ impl Definition { | |||
122 | if let Definition::Local(var) = self { | 122 | if let Definition::Local(var) = self { |
123 | #[allow(deprecated)] | 123 | #[allow(deprecated)] |
124 | let range = match var.parent(db) { | 124 | let range = match var.parent(db) { |
125 | DefWithBody::Function(f) => f.source_old(db).value.syntax().text_range(), | 125 | DefWithBody::Function(f) => { |
126 | DefWithBody::Const(c) => c.source_old(db).value.syntax().text_range(), | 126 | f.source(db).and_then(|src| src.value.syntax().text_range()) |
127 | DefWithBody::Static(s) => s.source_old(db).value.syntax().text_range(), | 127 | } |
128 | DefWithBody::Const(c) => { | ||
129 | c.source(db).and_then(|src| src.value.syntax().text_range()) | ||
130 | } | ||
131 | DefWithBody::Static(s) => { | ||
132 | s.source(db).and_then(|src| src.value.syntax().text_range()) | ||
133 | } | ||
128 | }; | 134 | }; |
129 | let mut res = FxHashMap::default(); | 135 | let mut res = FxHashMap::default(); |
130 | res.insert(file_id, Some(range)); | 136 | res.insert(file_id, Some(range)); |
@@ -134,17 +140,35 @@ impl Definition { | |||
134 | if let Definition::LifetimeParam(param) = self { | 140 | if let Definition::LifetimeParam(param) = self { |
135 | #[allow(deprecated)] | 141 | #[allow(deprecated)] |
136 | let range = match param.parent(db) { | 142 | let range = match param.parent(db) { |
137 | hir::GenericDef::Function(it) => it.source_old(db).value.syntax().text_range(), | 143 | hir::GenericDef::Function(it) => { |
144 | it.source(db).and_then(|src| src.value.syntax().text_range()) | ||
145 | } | ||
138 | hir::GenericDef::Adt(it) => match it { | 146 | hir::GenericDef::Adt(it) => match it { |
139 | hir::Adt::Struct(it) => it.source_old(db).value.syntax().text_range(), | 147 | hir::Adt::Struct(it) => { |
140 | hir::Adt::Union(it) => it.source_old(db).value.syntax().text_range(), | 148 | it.source(db).and_then(|src| src.value.syntax().text_range()) |
141 | hir::Adt::Enum(it) => it.source_old(db).value.syntax().text_range(), | 149 | } |
150 | hir::Adt::Union(it) => { | ||
151 | it.source(db).and_then(|src| src.value.syntax().text_range()) | ||
152 | } | ||
153 | hir::Adt::Enum(it) => { | ||
154 | it.source(db).and_then(|src| src.value.syntax().text_range()) | ||
155 | } | ||
142 | }, | 156 | }, |
143 | hir::GenericDef::Trait(it) => it.source_old(db).value.syntax().text_range(), | 157 | hir::GenericDef::Trait(it) => { |
144 | hir::GenericDef::TypeAlias(it) => it.source_old(db).value.syntax().text_range(), | 158 | it.source(db).and_then(|src| src.value.syntax().text_range()) |
145 | hir::GenericDef::Impl(it) => it.source_old(db).value.syntax().text_range(), | 159 | } |
146 | hir::GenericDef::Variant(it) => it.source_old(db).value.syntax().text_range(), | 160 | hir::GenericDef::TypeAlias(it) => { |
147 | hir::GenericDef::Const(it) => it.source_old(db).value.syntax().text_range(), | 161 | it.source(db).and_then(|src| src.value.syntax().text_range()) |
162 | } | ||
163 | hir::GenericDef::Impl(it) => { | ||
164 | it.source(db).and_then(|src| src.value.syntax().text_range()) | ||
165 | } | ||
166 | hir::GenericDef::Variant(it) => { | ||
167 | it.source(db).and_then(|src| src.value.syntax().text_range()) | ||
168 | } | ||
169 | hir::GenericDef::Const(it) => { | ||
170 | it.source(db).and_then(|src| src.value.syntax().text_range()) | ||
171 | } | ||
148 | }; | 172 | }; |
149 | let mut res = FxHashMap::default(); | 173 | let mut res = FxHashMap::default(); |
150 | res.insert(file_id, Some(range)); | 174 | res.insert(file_id, Some(range)); |