diff options
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/mock_analysis.rs | 12 | ||||
-rw-r--r-- | crates/ra_ide_api/src/parent_module.rs | 11 |
3 files changed, 20 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 62ad996bc..cb6c24eaa 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -54,7 +54,7 @@ use std::sync::Arc; | |||
54 | use ra_cfg::CfgOptions; | 54 | use ra_cfg::CfgOptions; |
55 | use ra_db::{ | 55 | use ra_db::{ |
56 | salsa::{self, ParallelDatabase}, | 56 | salsa::{self, ParallelDatabase}, |
57 | CheckCanceled, FileLoader, SourceDatabase, | 57 | CheckCanceled, Env, FileLoader, SourceDatabase, |
58 | }; | 58 | }; |
59 | use ra_syntax::{SourceFile, TextRange, TextUnit}; | 59 | use ra_syntax::{SourceFile, TextRange, TextUnit}; |
60 | 60 | ||
@@ -240,7 +240,7 @@ impl Analysis { | |||
240 | // Default to enable test for single file. | 240 | // Default to enable test for single file. |
241 | let mut cfg_options = CfgOptions::default(); | 241 | let mut cfg_options = CfgOptions::default(); |
242 | cfg_options.insert_atom("test".into()); | 242 | cfg_options.insert_atom("test".into()); |
243 | crate_graph.add_crate_root(file_id, Edition::Edition2018, cfg_options); | 243 | crate_graph.add_crate_root(file_id, Edition::Edition2018, cfg_options, Env::default()); |
244 | change.add_file(source_root, file_id, "main.rs".into(), Arc::new(text)); | 244 | change.add_file(source_root, file_id, "main.rs".into(), Arc::new(text)); |
245 | change.set_crate_graph(crate_graph); | 245 | change.set_crate_graph(crate_graph); |
246 | host.apply_change(change); | 246 | 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 2b1c96dbf..bf8a54932 100644 --- a/crates/ra_ide_api/src/mock_analysis.rs +++ b/crates/ra_ide_api/src/mock_analysis.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use ra_cfg::CfgOptions; | 5 | use ra_cfg::CfgOptions; |
6 | use ra_db::RelativePathBuf; | 6 | use ra_db::{Env, RelativePathBuf}; |
7 | use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER}; | 7 | use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER}; |
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
@@ -96,9 +96,15 @@ impl MockAnalysis { | |||
96 | let file_id = FileId(i as u32 + 1); | 96 | let file_id = FileId(i as u32 + 1); |
97 | let cfg_options = CfgOptions::default(); | 97 | let cfg_options = CfgOptions::default(); |
98 | if path == "/lib.rs" || path == "/main.rs" { | 98 | if path == "/lib.rs" || path == "/main.rs" { |
99 | root_crate = Some(crate_graph.add_crate_root(file_id, Edition2018, cfg_options)); | 99 | root_crate = Some(crate_graph.add_crate_root( |
100 | file_id, | ||
101 | Edition2018, | ||
102 | cfg_options, | ||
103 | Env::default(), | ||
104 | )); | ||
100 | } else if path.ends_with("/lib.rs") { | 105 | } else if path.ends_with("/lib.rs") { |
101 | let other_crate = crate_graph.add_crate_root(file_id, Edition2018, cfg_options); | 106 | let other_crate = |
107 | crate_graph.add_crate_root(file_id, Edition2018, cfg_options, Env::default()); | ||
102 | let crate_name = path.parent().unwrap().file_name().unwrap(); | 108 | let crate_name = path.parent().unwrap().file_name().unwrap(); |
103 | if let Some(root_crate) = root_crate { | 109 | if let Some(root_crate) = root_crate { |
104 | crate_graph.add_dep(root_crate, crate_name.into(), other_crate).unwrap(); | 110 | 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 fa232a379..6027e7d54 100644 --- a/crates/ra_ide_api/src/parent_module.rs +++ b/crates/ra_ide_api/src/parent_module.rs | |||
@@ -34,12 +34,14 @@ pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> { | |||
34 | 34 | ||
35 | #[cfg(test)] | 35 | #[cfg(test)] |
36 | mod tests { | 36 | mod tests { |
37 | use ra_cfg::CfgOptions; | ||
38 | use ra_db::Env; | ||
39 | |||
37 | use crate::{ | 40 | use crate::{ |
38 | mock_analysis::{analysis_and_position, MockAnalysis}, | 41 | mock_analysis::{analysis_and_position, MockAnalysis}, |
39 | AnalysisChange, CrateGraph, | 42 | AnalysisChange, CrateGraph, |
40 | Edition::Edition2018, | 43 | Edition::Edition2018, |
41 | }; | 44 | }; |
42 | use ra_cfg::CfgOptions; | ||
43 | 45 | ||
44 | #[test] | 46 | #[test] |
45 | fn test_resolve_parent_module() { | 47 | fn test_resolve_parent_module() { |
@@ -87,7 +89,12 @@ mod tests { | |||
87 | assert!(host.analysis().crate_for(mod_file).unwrap().is_empty()); | 89 | assert!(host.analysis().crate_for(mod_file).unwrap().is_empty()); |
88 | 90 | ||
89 | let mut crate_graph = CrateGraph::default(); | 91 | let mut crate_graph = CrateGraph::default(); |
90 | let crate_id = crate_graph.add_crate_root(root_file, Edition2018, CfgOptions::default()); | 92 | let crate_id = crate_graph.add_crate_root( |
93 | root_file, | ||
94 | Edition2018, | ||
95 | CfgOptions::default(), | ||
96 | Env::default(), | ||
97 | ); | ||
91 | let mut change = AnalysisChange::new(); | 98 | let mut change = AnalysisChange::new(); |
92 | change.set_crate_graph(crate_graph); | 99 | change.set_crate_graph(crate_graph); |
93 | host.apply_change(change); | 100 | host.apply_change(change); |