aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/tests
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-03 18:31:41 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-03 18:31:41 +0000
commit2fcc6bdafa1caffd4ddf98968ee967e9fb091cc0 (patch)
tree5a278ad534d2de9f308bbdfef323c3b20bf9a653 /crates/ra_analysis/tests
parent6c0bca5984a6b66d306f9a413b0433c15d450500 (diff)
parentd61707b4e1f0bdfc7f62b1abf78fdc45c0128699 (diff)
Merge #421
421: Index macros r=matklad a=matklad So, this is pretty cool! We now index items which are the result of macro expansion! (of a single currently hard-coded macro). So, workspace symbols can now be used to navigate to `HirDatabase`, for example Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis/tests')
-rw-r--r--crates/ra_analysis/tests/test/main.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/crates/ra_analysis/tests/test/main.rs b/crates/ra_analysis/tests/test/main.rs
index 23a5799b9..bfdf8aef2 100644
--- a/crates/ra_analysis/tests/test/main.rs
+++ b/crates/ra_analysis/tests/test/main.rs
@@ -6,7 +6,7 @@ use test_utils::{assert_eq_dbg, assert_eq_text};
6 6
7use ra_analysis::{ 7use ra_analysis::{
8 mock_analysis::{analysis_and_position, single_file, single_file_with_position, MockAnalysis}, 8 mock_analysis::{analysis_and_position, single_file, single_file_with_position, MockAnalysis},
9 AnalysisChange, CrateGraph, FileId, FnSignatureInfo, 9 AnalysisChange, CrateGraph, FileId, FnSignatureInfo, Query
10}; 10};
11 11
12fn get_signature(text: &str) -> (FnSignatureInfo, Option<usize>) { 12fn get_signature(text: &str) -> (FnSignatureInfo, Option<usize>) {
@@ -531,6 +531,7 @@ fn test_rename_for_mut_param() {
531 }"#, 531 }"#,
532 ); 532 );
533} 533}
534
534fn test_rename(text: &str, new_name: &str, expected: &str) { 535fn test_rename(text: &str, new_name: &str, expected: &str) {
535 let (analysis, position) = single_file_with_position(text); 536 let (analysis, position) = single_file_with_position(text);
536 let edits = analysis.rename(position, new_name).unwrap(); 537 let edits = analysis.rename(position, new_name).unwrap();
@@ -547,3 +548,19 @@ fn test_rename(text: &str, new_name: &str, expected: &str) {
547 .apply(&*analysis.file_text(file_id.unwrap())); 548 .apply(&*analysis.file_text(file_id.unwrap()));
548 assert_eq_text!(expected, &*result); 549 assert_eq_text!(expected, &*result);
549} 550}
551
552#[test]
553fn world_symbols_include_stuff_from_macros() {
554 let (analysis, _) = single_file(
555 "
556salsa::query_group! {
557pub trait HirDatabase: SyntaxDatabase {}
558}
559 ",
560 );
561
562 let mut symbols = analysis.symbol_search(Query::new("Hir".into())).unwrap();
563 let s = symbols.pop().unwrap();
564 assert_eq!(s.name(), "HirDatabase");
565 assert_eq!(s.range(), TextRange::from_to(33.into(), 44.into()));
566}