diff options
author | uHOOCCOOHu <[email protected]> | 2019-10-02 19:02:53 +0100 |
---|---|---|
committer | uHOOCCOOHu <[email protected]> | 2019-10-02 19:28:03 +0100 |
commit | 1067a1c5f649cc206e35b427eaa8d6553280cc96 (patch) | |
tree | e55b3e9ad4b2ece335f5660712918b6b97390bd3 /crates/ra_lsp_server | |
parent | e0100e63ae2e873f119b905ac77c3355ffb351b0 (diff) |
Read default cfgs from rustc
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/world.rs | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 677d81835..aedc55a95 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -19,6 +19,7 @@ jod-thread = "0.1.0" | |||
19 | ra_vfs = "0.4.0" | 19 | ra_vfs = "0.4.0" |
20 | ra_syntax = { path = "../ra_syntax" } | 20 | ra_syntax = { path = "../ra_syntax" } |
21 | ra_db = { path = "../ra_db" } | 21 | ra_db = { path = "../ra_db" } |
22 | ra_cfg = { path = "../ra_cfg" } | ||
22 | ra_text_edit = { path = "../ra_text_edit" } | 23 | ra_text_edit = { path = "../ra_text_edit" } |
23 | ra_ide_api = { path = "../ra_ide_api" } | 24 | ra_ide_api = { path = "../ra_ide_api" } |
24 | lsp-server = "0.2.0" | 25 | lsp-server = "0.2.0" |
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index b55046ec9..27da751ab 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs | |||
@@ -13,7 +13,7 @@ use ra_ide_api::{ | |||
13 | Analysis, AnalysisChange, AnalysisHost, CrateGraph, FeatureFlags, FileId, LibraryData, | 13 | Analysis, AnalysisChange, AnalysisHost, CrateGraph, FeatureFlags, FileId, LibraryData, |
14 | SourceRootId, | 14 | SourceRootId, |
15 | }; | 15 | }; |
16 | use ra_project_model::ProjectWorkspace; | 16 | use ra_project_model::{get_rustc_cfg_options, ProjectWorkspace}; |
17 | use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot, VfsTask, Watch}; | 17 | use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot, VfsTask, Watch}; |
18 | use ra_vfs_glob::{Glob, RustPackageFilterBuilder}; | 18 | use ra_vfs_glob::{Glob, RustPackageFilterBuilder}; |
19 | use relative_path::RelativePathBuf; | 19 | use relative_path::RelativePathBuf; |
@@ -97,6 +97,10 @@ impl WorldState { | |||
97 | change.set_debug_root_path(SourceRootId(r.0), vfs_root_path.display().to_string()); | 97 | change.set_debug_root_path(SourceRootId(r.0), vfs_root_path.display().to_string()); |
98 | } | 98 | } |
99 | 99 | ||
100 | // FIXME: Read default cfgs from config | ||
101 | let default_cfg_options = | ||
102 | get_rustc_cfg_options().atom("test".into()).atom("debug_assertion".into()); | ||
103 | |||
100 | // Create crate graph from all the workspaces | 104 | // Create crate graph from all the workspaces |
101 | let mut crate_graph = CrateGraph::default(); | 105 | let mut crate_graph = CrateGraph::default(); |
102 | let mut load = |path: &std::path::Path| { | 106 | let mut load = |path: &std::path::Path| { |
@@ -104,7 +108,7 @@ impl WorldState { | |||
104 | vfs_file.map(|f| FileId(f.0)) | 108 | vfs_file.map(|f| FileId(f.0)) |
105 | }; | 109 | }; |
106 | for ws in workspaces.iter() { | 110 | for ws in workspaces.iter() { |
107 | let (graph, crate_names) = ws.to_crate_graph(&mut load); | 111 | let (graph, crate_names) = ws.to_crate_graph(&default_cfg_options, &mut load); |
108 | let shift = crate_graph.extend(graph); | 112 | let shift = crate_graph.extend(graph); |
109 | for (crate_id, name) in crate_names { | 113 | for (crate_id, name) in crate_names { |
110 | change.set_debug_crate_name(crate_id.shift(shift), name) | 114 | change.set_debug_crate_name(crate_id.shift(shift), name) |