From b1ed887d813bf5775a16624694939fdf836f97b1 Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Mon, 30 Sep 2019 06:52:15 +0800 Subject: Introduce ra_cfg to parse and evaluate CfgExpr --- crates/ra_db/Cargo.toml | 1 + crates/ra_db/src/input.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/ra_db') diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 2fac07bc5..c141f1a88 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml @@ -10,4 +10,5 @@ relative-path = "0.4.0" rustc-hash = "1.0" ra_syntax = { path = "../ra_syntax" } +ra_cfg = { path = "../ra_cfg" } ra_prof = { path = "../ra_prof" } diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 52f892891..5fd6edd78 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs @@ -9,6 +9,7 @@ use relative_path::{RelativePath, RelativePathBuf}; use rustc_hash::FxHashMap; +use ra_cfg::CfgOptions; use ra_syntax::SmolStr; use rustc_hash::FxHashSet; @@ -109,11 +110,13 @@ struct CrateData { file_id: FileId, edition: Edition, dependencies: Vec, + cfg_options: CfgOptions, } impl CrateData { fn new(file_id: FileId, edition: Edition) -> CrateData { - CrateData { file_id, edition, dependencies: Vec::new() } + // FIXME: cfg options + CrateData { file_id, edition, dependencies: Vec::new(), cfg_options: CfgOptions::default() } } fn add_dep(&mut self, name: SmolStr, crate_id: CrateId) { @@ -141,6 +144,10 @@ impl CrateGraph { crate_id } + pub fn cfg_options(&self, crate_id: CrateId) -> &CfgOptions { + &self.arena[&crate_id].cfg_options + } + pub fn add_dep( &mut self, from: CrateId, -- cgit v1.2.3