diff options
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/mock_analysis.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/parent_module.rs | 3 |
3 files changed, 11 insertions, 4 deletions
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 44d1ec77b..24f1b91f6 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -49,6 +49,7 @@ mod test_utils; | |||
49 | 49 | ||
50 | use std::sync::Arc; | 50 | use std::sync::Arc; |
51 | 51 | ||
52 | use ra_cfg::CfgOptions; | ||
52 | use ra_db::{ | 53 | use ra_db::{ |
53 | salsa::{self, ParallelDatabase}, | 54 | salsa::{self, ParallelDatabase}, |
54 | CheckCanceled, SourceDatabase, | 55 | CheckCanceled, SourceDatabase, |
@@ -322,7 +323,10 @@ impl Analysis { | |||
322 | change.add_root(source_root, true); | 323 | change.add_root(source_root, true); |
323 | let mut crate_graph = CrateGraph::default(); | 324 | let mut crate_graph = CrateGraph::default(); |
324 | let file_id = FileId(0); | 325 | let file_id = FileId(0); |
325 | crate_graph.add_crate_root(file_id, Edition::Edition2018); | 326 | // FIXME: cfg options |
327 | // Default to enable test for single file. | ||
328 | let cfg_options = CfgOptions::default().atom("test".into()); | ||
329 | crate_graph.add_crate_root(file_id, Edition::Edition2018, cfg_options); | ||
326 | change.add_file(source_root, file_id, "main.rs".into(), Arc::new(text)); | 330 | change.add_file(source_root, file_id, "main.rs".into(), Arc::new(text)); |
327 | change.set_crate_graph(crate_graph); | 331 | change.set_crate_graph(crate_graph); |
328 | host.apply_change(change); | 332 | host.apply_change(change); |
diff --git a/crates/ra_ide_api/src/mock_analysis.rs b/crates/ra_ide_api/src/mock_analysis.rs index 16870c7ae..80b71894c 100644 --- a/crates/ra_ide_api/src/mock_analysis.rs +++ b/crates/ra_ide_api/src/mock_analysis.rs | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use ra_cfg::CfgOptions; | ||
5 | use relative_path::RelativePathBuf; | 6 | use relative_path::RelativePathBuf; |
6 | use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER}; | 7 | use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER}; |
7 | 8 | ||
@@ -93,10 +94,11 @@ impl MockAnalysis { | |||
93 | assert!(path.starts_with('/')); | 94 | assert!(path.starts_with('/')); |
94 | let path = RelativePathBuf::from_path(&path[1..]).unwrap(); | 95 | let path = RelativePathBuf::from_path(&path[1..]).unwrap(); |
95 | let file_id = FileId(i as u32 + 1); | 96 | let file_id = FileId(i as u32 + 1); |
97 | let cfg_options = CfgOptions::default(); | ||
96 | if path == "/lib.rs" || path == "/main.rs" { | 98 | if path == "/lib.rs" || path == "/main.rs" { |
97 | root_crate = Some(crate_graph.add_crate_root(file_id, Edition2018)); | 99 | root_crate = Some(crate_graph.add_crate_root(file_id, Edition2018, cfg_options)); |
98 | } else if path.ends_with("/lib.rs") { | 100 | } else if path.ends_with("/lib.rs") { |
99 | let other_crate = crate_graph.add_crate_root(file_id, Edition2018); | 101 | let other_crate = crate_graph.add_crate_root(file_id, Edition2018, cfg_options); |
100 | let crate_name = path.parent().unwrap().file_name().unwrap(); | 102 | let crate_name = path.parent().unwrap().file_name().unwrap(); |
101 | if let Some(root_crate) = root_crate { | 103 | if let Some(root_crate) = root_crate { |
102 | crate_graph.add_dep(root_crate, crate_name.into(), other_crate).unwrap(); | 104 | crate_graph.add_dep(root_crate, crate_name.into(), other_crate).unwrap(); |
diff --git a/crates/ra_ide_api/src/parent_module.rs b/crates/ra_ide_api/src/parent_module.rs index c85f1d0d0..566509849 100644 --- a/crates/ra_ide_api/src/parent_module.rs +++ b/crates/ra_ide_api/src/parent_module.rs | |||
@@ -41,6 +41,7 @@ mod tests { | |||
41 | AnalysisChange, CrateGraph, | 41 | AnalysisChange, CrateGraph, |
42 | Edition::Edition2018, | 42 | Edition::Edition2018, |
43 | }; | 43 | }; |
44 | use ra_cfg::CfgOptions; | ||
44 | 45 | ||
45 | #[test] | 46 | #[test] |
46 | fn test_resolve_parent_module() { | 47 | fn test_resolve_parent_module() { |
@@ -88,7 +89,7 @@ mod tests { | |||
88 | assert!(host.analysis().crate_for(mod_file).unwrap().is_empty()); | 89 | assert!(host.analysis().crate_for(mod_file).unwrap().is_empty()); |
89 | 90 | ||
90 | let mut crate_graph = CrateGraph::default(); | 91 | let mut crate_graph = CrateGraph::default(); |
91 | let crate_id = crate_graph.add_crate_root(root_file, Edition2018); | 92 | let crate_id = crate_graph.add_crate_root(root_file, Edition2018, CfgOptions::default()); |
92 | let mut change = AnalysisChange::new(); | 93 | let mut change = AnalysisChange::new(); |
93 | change.set_crate_graph(crate_graph); | 94 | change.set_crate_graph(crate_graph); |
94 | host.apply_change(change); | 95 | host.apply_change(change); |