aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/Cargo.toml1
-rw-r--r--crates/ra_ide_api/src/lib.rs6
-rw-r--r--crates/ra_ide_api/src/mock_analysis.rs7
-rw-r--r--crates/ra_ide_api/src/parent_module.rs3
4 files changed, 13 insertions, 4 deletions
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml
index 6bbf9d5dd..f919a2d61 100644
--- a/crates/ra_ide_api/Cargo.toml
+++ b/crates/ra_ide_api/Cargo.toml
@@ -23,6 +23,7 @@ rand = { version = "0.7.0", features = ["small_rng"] }
23ra_syntax = { path = "../ra_syntax" } 23ra_syntax = { path = "../ra_syntax" }
24ra_text_edit = { path = "../ra_text_edit" } 24ra_text_edit = { path = "../ra_text_edit" }
25ra_db = { path = "../ra_db" } 25ra_db = { path = "../ra_db" }
26ra_cfg = { path = "../ra_cfg" }
26ra_fmt = { path = "../ra_fmt" } 27ra_fmt = { path = "../ra_fmt" }
27ra_prof = { path = "../ra_prof" } 28ra_prof = { path = "../ra_prof" }
28hir = { path = "../ra_hir", package = "ra_hir" } 29hir = { path = "../ra_hir", package = "ra_hir" }
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
50use std::sync::Arc; 50use std::sync::Arc;
51 51
52use ra_cfg::CfgOptions;
52use ra_db::{ 53use 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..13258b63d 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
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use ra_cfg::CfgOptions;
5use relative_path::RelativePathBuf; 6use relative_path::RelativePathBuf;
6use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER}; 7use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER};
7 8
@@ -93,10 +94,12 @@ 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 // FIXME: cfg options
98 let cfg_options = CfgOptions::default();
96 if path == "/lib.rs" || path == "/main.rs" { 99 if path == "/lib.rs" || path == "/main.rs" {
97 root_crate = Some(crate_graph.add_crate_root(file_id, Edition2018)); 100 root_crate = Some(crate_graph.add_crate_root(file_id, Edition2018, cfg_options));
98 } else if path.ends_with("/lib.rs") { 101 } else if path.ends_with("/lib.rs") {
99 let other_crate = crate_graph.add_crate_root(file_id, Edition2018); 102 let other_crate = crate_graph.add_crate_root(file_id, Edition2018, cfg_options);
100 let crate_name = path.parent().unwrap().file_name().unwrap(); 103 let crate_name = path.parent().unwrap().file_name().unwrap();
101 if let Some(root_crate) = root_crate { 104 if let Some(root_crate) = root_crate {
102 crate_graph.add_dep(root_crate, crate_name.into(), other_crate).unwrap(); 105 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);