diff options
Diffstat (limited to 'crates/ide/src/display')
-rw-r--r-- | crates/ide/src/display/navigation_target.rs | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index e24c78301..00e601244 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs | |||
@@ -215,10 +215,8 @@ impl TryToNav for Definition { | |||
215 | Definition::ModuleDef(it) => it.try_to_nav(db), | 215 | Definition::ModuleDef(it) => it.try_to_nav(db), |
216 | Definition::SelfType(it) => it.try_to_nav(db), | 216 | Definition::SelfType(it) => it.try_to_nav(db), |
217 | Definition::Local(it) => Some(it.to_nav(db)), | 217 | Definition::Local(it) => Some(it.to_nav(db)), |
218 | Definition::TypeParam(it) => it.try_to_nav(db), | 218 | Definition::GenericParam(it) => it.try_to_nav(db), |
219 | Definition::LifetimeParam(it) => it.try_to_nav(db), | ||
220 | Definition::Label(it) => Some(it.to_nav(db)), | 219 | Definition::Label(it) => Some(it.to_nav(db)), |
221 | Definition::ConstParam(it) => it.try_to_nav(db), | ||
222 | } | 220 | } |
223 | } | 221 | } |
224 | } | 222 | } |
@@ -389,27 +387,44 @@ impl TryToNav for hir::AssocItem { | |||
389 | } | 387 | } |
390 | } | 388 | } |
391 | 389 | ||
390 | impl TryToNav for hir::GenericParam { | ||
391 | fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> { | ||
392 | match self { | ||
393 | hir::GenericParam::TypeParam(it) => it.try_to_nav(db), | ||
394 | hir::GenericParam::ConstParam(it) => it.try_to_nav(db), | ||
395 | hir::GenericParam::LifetimeParam(it) => it.try_to_nav(db), | ||
396 | } | ||
397 | } | ||
398 | } | ||
399 | |||
392 | impl ToNav for hir::Local { | 400 | impl ToNav for hir::Local { |
393 | fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { | 401 | fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { |
394 | let src = self.source(db); | 402 | let src = self.source(db); |
395 | let node = match &src.value { | 403 | let (node, name) = match &src.value { |
396 | Either::Left(bind_pat) => { | 404 | Either::Left(bind_pat) => (bind_pat.syntax().clone(), bind_pat.name()), |
397 | bind_pat.name().map_or_else(|| bind_pat.syntax().clone(), |it| it.syntax().clone()) | 405 | Either::Right(it) => (it.syntax().clone(), it.name()), |
398 | } | ||
399 | Either::Right(it) => it.syntax().clone(), | ||
400 | }; | 406 | }; |
407 | let focus_range = | ||
408 | name.map(|it| src.with_value(&it.syntax().clone()).original_file_range(db).range); | ||
409 | |||
401 | let full_range = src.with_value(&node).original_file_range(db); | 410 | let full_range = src.with_value(&node).original_file_range(db); |
402 | let name = match self.name(db) { | 411 | let name = match self.name(db) { |
403 | Some(it) => it.to_string().into(), | 412 | Some(it) => it.to_string().into(), |
404 | None => "".into(), | 413 | None => "".into(), |
405 | }; | 414 | }; |
406 | let kind = if self.is_param(db) { SymbolKind::ValueParam } else { SymbolKind::Local }; | 415 | let kind = if self.is_self(db) { |
416 | SymbolKind::SelfParam | ||
417 | } else if self.is_param(db) { | ||
418 | SymbolKind::ValueParam | ||
419 | } else { | ||
420 | SymbolKind::Local | ||
421 | }; | ||
407 | NavigationTarget { | 422 | NavigationTarget { |
408 | file_id: full_range.file_id, | 423 | file_id: full_range.file_id, |
409 | name, | 424 | name, |
410 | kind: Some(kind), | 425 | kind: Some(kind), |
411 | full_range: full_range.range, | 426 | full_range: full_range.range, |
412 | focus_range: None, | 427 | focus_range, |
413 | container_name: None, | 428 | container_name: None, |
414 | description: None, | 429 | description: None, |
415 | docs: None, | 430 | docs: None, |