diff options
Diffstat (limited to 'crates/ra_ide/src/display/navigation_target.rs')
-rw-r--r-- | crates/ra_ide/src/display/navigation_target.rs | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 6dcb9415a..fd245705c 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -418,3 +418,74 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> | |||
418 | } | 418 | } |
419 | } | 419 | } |
420 | } | 420 | } |
421 | |||
422 | #[cfg(test)] | ||
423 | mod tests { | ||
424 | use expect::expect; | ||
425 | |||
426 | use crate::{mock_analysis::single_file, Query}; | ||
427 | |||
428 | #[test] | ||
429 | fn test_nav_for_symbol() { | ||
430 | let (analysis, _) = single_file( | ||
431 | r#" | ||
432 | enum FooInner { } | ||
433 | fn foo() { enum FooInner { } } | ||
434 | "#, | ||
435 | ); | ||
436 | |||
437 | let navs = analysis.symbol_search(Query::new("FooInner".to_string())).unwrap(); | ||
438 | expect![[r#" | ||
439 | [ | ||
440 | NavigationTarget { | ||
441 | file_id: FileId( | ||
442 | 1, | ||
443 | ), | ||
444 | full_range: 0..17, | ||
445 | focus_range: Some( | ||
446 | 5..13, | ||
447 | ), | ||
448 | name: "FooInner", | ||
449 | kind: ENUM_DEF, | ||
450 | container_name: None, | ||
451 | description: Some( | ||
452 | "enum FooInner", | ||
453 | ), | ||
454 | docs: None, | ||
455 | }, | ||
456 | NavigationTarget { | ||
457 | file_id: FileId( | ||
458 | 1, | ||
459 | ), | ||
460 | full_range: 29..46, | ||
461 | focus_range: Some( | ||
462 | 34..42, | ||
463 | ), | ||
464 | name: "FooInner", | ||
465 | kind: ENUM_DEF, | ||
466 | container_name: Some( | ||
467 | "foo", | ||
468 | ), | ||
469 | description: Some( | ||
470 | "enum FooInner", | ||
471 | ), | ||
472 | docs: None, | ||
473 | }, | ||
474 | ] | ||
475 | "#]] | ||
476 | .assert_debug_eq(&navs); | ||
477 | } | ||
478 | |||
479 | #[test] | ||
480 | fn test_world_symbols_are_case_sensitive() { | ||
481 | let (analysis, _) = single_file( | ||
482 | r#" | ||
483 | fn foo() {} | ||
484 | struct Foo; | ||
485 | "#, | ||
486 | ); | ||
487 | |||
488 | let navs = analysis.symbol_search(Query::new("foo".to_string())).unwrap(); | ||
489 | assert_eq!(navs.len(), 2) | ||
490 | } | ||
491 | } | ||