mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Introduce ra_cfg to parse and evaluate CfgExpr
This commit is contained in:
parent
ffe179a736
commit
b1ed887d81
11 changed files with 315 additions and 27 deletions
|
@ -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<Dependency>,
|
||||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue