mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Cleanup
This commit is contained in:
parent
88267c86c0
commit
8a39519e1c
5 changed files with 81 additions and 79 deletions
|
@ -369,78 +369,3 @@ fn to_file_symbol(node: &SyntaxNode, file_id: FileId) -> Option<FileSymbol> {
|
|||
container_name: None,
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: fix this
|
||||
#[cfg(never)]
|
||||
mod tests {
|
||||
use crate::{display::NavigationTarget, mock_analysis::single_file, Query};
|
||||
use ra_syntax::{
|
||||
SmolStr,
|
||||
SyntaxKind::{FN_DEF, STRUCT_DEF},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_world_symbols_with_no_container() {
|
||||
let code = r#"
|
||||
enum FooInner { }
|
||||
"#;
|
||||
|
||||
let mut symbols = get_symbols_matching(code, "FooInner");
|
||||
|
||||
let s = symbols.pop().unwrap();
|
||||
|
||||
assert_eq!(s.name(), "FooInner");
|
||||
assert!(s.container_name().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_world_symbols_include_container_name() {
|
||||
let code = r#"
|
||||
fn foo() {
|
||||
enum FooInner { }
|
||||
}
|
||||
"#;
|
||||
|
||||
let mut symbols = get_symbols_matching(code, "FooInner");
|
||||
|
||||
let s = symbols.pop().unwrap();
|
||||
|
||||
assert_eq!(s.name(), "FooInner");
|
||||
assert_eq!(s.container_name(), Some(&SmolStr::new("foo")));
|
||||
|
||||
let code = r#"
|
||||
mod foo {
|
||||
struct FooInner;
|
||||
}
|
||||
"#;
|
||||
|
||||
let mut symbols = get_symbols_matching(code, "FooInner");
|
||||
|
||||
let s = symbols.pop().unwrap();
|
||||
|
||||
assert_eq!(s.name(), "FooInner");
|
||||
assert_eq!(s.container_name(), Some(&SmolStr::new("foo")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_world_symbols_are_case_sensitive() {
|
||||
let code = r#"
|
||||
fn foo() {}
|
||||
|
||||
struct Foo;
|
||||
"#;
|
||||
|
||||
let symbols = get_symbols_matching(code, "Foo");
|
||||
|
||||
let fn_match = symbols.iter().find(|s| s.name() == "foo").map(|s| s.kind());
|
||||
let struct_match = symbols.iter().find(|s| s.name() == "Foo").map(|s| s.kind());
|
||||
|
||||
assert_eq!(fn_match, Some(FN_DEF));
|
||||
assert_eq!(struct_match, Some(STRUCT_DEF));
|
||||
}
|
||||
|
||||
fn get_symbols_matching(text: &str, query: &str) -> Vec<NavigationTarget> {
|
||||
let (analysis, _) = single_file(text);
|
||||
analysis.symbol_search(Query::new(query.into())).unwrap()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue