aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db
diff options
context:
space:
mode:
authoruHOOCCOOHu <[email protected]>2019-09-29 23:52:15 +0100
committeruHOOCCOOHu <[email protected]>2019-10-02 19:28:02 +0100
commitb1ed887d813bf5775a16624694939fdf836f97b1 (patch)
treeb69daa2ca7d29a3362e9608ad0596de18caffa18 /crates/ra_db
parentffe179a73663b111e4b3ee8a3f525fb3e461c78e (diff)
Introduce ra_cfg to parse and evaluate CfgExpr
Diffstat (limited to 'crates/ra_db')
-rw-r--r--crates/ra_db/Cargo.toml1
-rw-r--r--crates/ra_db/src/input.rs9
2 files changed, 9 insertions, 1 deletions
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"
10rustc-hash = "1.0" 10rustc-hash = "1.0"
11 11
12ra_syntax = { path = "../ra_syntax" } 12ra_syntax = { path = "../ra_syntax" }
13ra_cfg = { path = "../ra_cfg" }
13ra_prof = { path = "../ra_prof" } 14ra_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 @@
9use relative_path::{RelativePath, RelativePathBuf}; 9use relative_path::{RelativePath, RelativePathBuf};
10use rustc_hash::FxHashMap; 10use rustc_hash::FxHashMap;
11 11
12use ra_cfg::CfgOptions;
12use ra_syntax::SmolStr; 13use ra_syntax::SmolStr;
13use rustc_hash::FxHashSet; 14use rustc_hash::FxHashSet;
14 15
@@ -109,11 +110,13 @@ struct CrateData {
109 file_id: FileId, 110 file_id: FileId,
110 edition: Edition, 111 edition: Edition,
111 dependencies: Vec<Dependency>, 112 dependencies: Vec<Dependency>,
113 cfg_options: CfgOptions,
112} 114}
113 115
114impl CrateData { 116impl CrateData {
115 fn new(file_id: FileId, edition: Edition) -> CrateData { 117 fn new(file_id: FileId, edition: Edition) -> CrateData {
116 CrateData { file_id, edition, dependencies: Vec::new() } 118 // FIXME: cfg options
119 CrateData { file_id, edition, dependencies: Vec::new(), cfg_options: CfgOptions::default() }
117 } 120 }
118 121
119 fn add_dep(&mut self, name: SmolStr, crate_id: CrateId) { 122 fn add_dep(&mut self, name: SmolStr, crate_id: CrateId) {
@@ -141,6 +144,10 @@ impl CrateGraph {
141 crate_id 144 crate_id
142 } 145 }
143 146
147 pub fn cfg_options(&self, crate_id: CrateId) -> &CfgOptions {
148 &self.arena[&crate_id].cfg_options
149 }
150
144 pub fn add_dep( 151 pub fn add_dep(
145 &mut self, 152 &mut self,
146 from: CrateId, 153 from: CrateId,