diff options
Diffstat (limited to 'crates/ra_ide_db/src/symbol_index.rs')
-rw-r--r-- | crates/ra_ide_db/src/symbol_index.rs | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index 436b4497f..ddad03633 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs | |||
@@ -369,78 +369,3 @@ fn to_file_symbol(node: &SyntaxNode, file_id: FileId) -> Option<FileSymbol> { | |||
369 | container_name: None, | 369 | container_name: None, |
370 | }) | 370 | }) |
371 | } | 371 | } |
372 | |||
373 | // TODO: fix this | ||
374 | #[cfg(never)] | ||
375 | mod tests { | ||
376 | use crate::{display::NavigationTarget, mock_analysis::single_file, Query}; | ||
377 | use ra_syntax::{ | ||
378 | SmolStr, | ||
379 | SyntaxKind::{FN_DEF, STRUCT_DEF}, | ||
380 | }; | ||
381 | |||
382 | #[test] | ||
383 | fn test_world_symbols_with_no_container() { | ||
384 | let code = r#" | ||
385 | enum FooInner { } | ||
386 | "#; | ||
387 | |||
388 | let mut symbols = get_symbols_matching(code, "FooInner"); | ||
389 | |||
390 | let s = symbols.pop().unwrap(); | ||
391 | |||
392 | assert_eq!(s.name(), "FooInner"); | ||
393 | assert!(s.container_name().is_none()); | ||
394 | } | ||
395 | |||
396 | #[test] | ||
397 | fn test_world_symbols_include_container_name() { | ||
398 | let code = r#" | ||
399 | fn foo() { | ||
400 | enum FooInner { } | ||
401 | } | ||
402 | "#; | ||
403 | |||
404 | let mut symbols = get_symbols_matching(code, "FooInner"); | ||
405 | |||
406 | let s = symbols.pop().unwrap(); | ||
407 | |||
408 | assert_eq!(s.name(), "FooInner"); | ||
409 | assert_eq!(s.container_name(), Some(&SmolStr::new("foo"))); | ||
410 | |||
411 | let code = r#" | ||
412 | mod foo { | ||
413 | struct FooInner; | ||
414 | } | ||
415 | "#; | ||
416 | |||
417 | let mut symbols = get_symbols_matching(code, "FooInner"); | ||
418 | |||
419 | let s = symbols.pop().unwrap(); | ||
420 | |||
421 | assert_eq!(s.name(), "FooInner"); | ||
422 | assert_eq!(s.container_name(), Some(&SmolStr::new("foo"))); | ||
423 | } | ||
424 | |||
425 | #[test] | ||
426 | fn test_world_symbols_are_case_sensitive() { | ||
427 | let code = r#" | ||
428 | fn foo() {} | ||
429 | |||
430 | struct Foo; | ||
431 | "#; | ||
432 | |||
433 | let symbols = get_symbols_matching(code, "Foo"); | ||
434 | |||
435 | let fn_match = symbols.iter().find(|s| s.name() == "foo").map(|s| s.kind()); | ||
436 | let struct_match = symbols.iter().find(|s| s.name() == "Foo").map(|s| s.kind()); | ||
437 | |||
438 | assert_eq!(fn_match, Some(FN_DEF)); | ||
439 | assert_eq!(struct_match, Some(STRUCT_DEF)); | ||
440 | } | ||
441 | |||
442 | fn get_symbols_matching(text: &str, query: &str) -> Vec<NavigationTarget> { | ||
443 | let (analysis, _) = single_file(text); | ||
444 | analysis.symbol_search(Query::new(query.into())).unwrap() | ||
445 | } | ||
446 | } | ||