aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_db/src')
-rw-r--r--crates/ra_db/src/fixture.rs4
-rw-r--r--crates/ra_db/src/input.rs15
-rw-r--r--crates/ra_db/src/lib.rs3
3 files changed, 21 insertions, 1 deletions
diff --git a/crates/ra_db/src/fixture.rs b/crates/ra_db/src/fixture.rs
index 3464f43df..9d992886e 100644
--- a/crates/ra_db/src/fixture.rs
+++ b/crates/ra_db/src/fixture.rs
@@ -70,6 +70,7 @@ fn with_single_file(db: &mut dyn SourceDatabaseExt, ra_fixture: &str) -> FileId
70 meta.cfg, 70 meta.cfg,
71 meta.env, 71 meta.env,
72 Default::default(), 72 Default::default(),
73 Default::default(),
73 ); 74 );
74 crate_graph 75 crate_graph
75 } else { 76 } else {
@@ -81,6 +82,7 @@ fn with_single_file(db: &mut dyn SourceDatabaseExt, ra_fixture: &str) -> FileId
81 CfgOptions::default(), 82 CfgOptions::default(),
82 Env::default(), 83 Env::default(),
83 Default::default(), 84 Default::default(),
85 Default::default(),
84 ); 86 );
85 crate_graph 87 crate_graph
86 }; 88 };
@@ -130,6 +132,7 @@ fn with_files(db: &mut dyn SourceDatabaseExt, fixture: &str) -> Option<FilePosit
130 meta.cfg, 132 meta.cfg,
131 meta.env, 133 meta.env,
132 Default::default(), 134 Default::default(),
135 Default::default(),
133 ); 136 );
134 let prev = crates.insert(krate.clone(), crate_id); 137 let prev = crates.insert(krate.clone(), crate_id);
135 assert!(prev.is_none()); 138 assert!(prev.is_none());
@@ -167,6 +170,7 @@ fn with_files(db: &mut dyn SourceDatabaseExt, fixture: &str) -> Option<FilePosit
167 CfgOptions::default(), 170 CfgOptions::default(),
168 Env::default(), 171 Env::default(),
169 Default::default(), 172 Default::default(),
173 Default::default(),
170 ); 174 );
171 } else { 175 } else {
172 for (from, to) in crate_deps { 176 for (from, to) in crate_deps {
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index e371f849d..65b553a9f 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -19,6 +19,7 @@ use rustc_hash::FxHashSet;
19 19
20use crate::{RelativePath, RelativePathBuf}; 20use crate::{RelativePath, RelativePathBuf};
21use fmt::Display; 21use fmt::Display;
22use ra_proc_macro::ProcMacro;
22 23
23/// `FileId` is an integer which uniquely identifies a file. File paths are 24/// `FileId` is an integer which uniquely identifies a file. File paths are
24/// messy and system-dependent, so most of the code should work directly with 25/// messy and system-dependent, so most of the code should work directly with
@@ -115,6 +116,9 @@ impl Display for CrateName {
115 } 116 }
116} 117}
117 118
119#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
120pub struct ProcMacroId(pub usize);
121
118#[derive(Debug, Clone, PartialEq, Eq)] 122#[derive(Debug, Clone, PartialEq, Eq)]
119pub struct CrateData { 123pub struct CrateData {
120 pub root_file_id: FileId, 124 pub root_file_id: FileId,
@@ -127,6 +131,7 @@ pub struct CrateData {
127 pub env: Env, 131 pub env: Env,
128 pub extern_source: ExternSource, 132 pub extern_source: ExternSource,
129 pub dependencies: Vec<Dependency>, 133 pub dependencies: Vec<Dependency>,
134 pub proc_macro: Vec<ProcMacro>,
130} 135}
131 136
132#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 137#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -166,6 +171,7 @@ impl CrateGraph {
166 cfg_options: CfgOptions, 171 cfg_options: CfgOptions,
167 env: Env, 172 env: Env,
168 extern_source: ExternSource, 173 extern_source: ExternSource,
174 proc_macro: Vec<ProcMacro>,
169 ) -> CrateId { 175 ) -> CrateId {
170 let data = CrateData { 176 let data = CrateData {
171 root_file_id: file_id, 177 root_file_id: file_id,
@@ -174,6 +180,7 @@ impl CrateGraph {
174 cfg_options, 180 cfg_options,
175 env, 181 env,
176 extern_source, 182 extern_source,
183 proc_macro,
177 dependencies: Vec::new(), 184 dependencies: Vec::new(),
178 }; 185 };
179 let crate_id = CrateId(self.arena.len() as u32); 186 let crate_id = CrateId(self.arena.len() as u32);
@@ -345,6 +352,7 @@ mod tests {
345 CfgOptions::default(), 352 CfgOptions::default(),
346 Env::default(), 353 Env::default(),
347 Default::default(), 354 Default::default(),
355 Default::default(),
348 ); 356 );
349 let crate2 = graph.add_crate_root( 357 let crate2 = graph.add_crate_root(
350 FileId(2u32), 358 FileId(2u32),
@@ -353,6 +361,7 @@ mod tests {
353 CfgOptions::default(), 361 CfgOptions::default(),
354 Env::default(), 362 Env::default(),
355 Default::default(), 363 Default::default(),
364 Default::default(),
356 ); 365 );
357 let crate3 = graph.add_crate_root( 366 let crate3 = graph.add_crate_root(
358 FileId(3u32), 367 FileId(3u32),
@@ -361,6 +370,7 @@ mod tests {
361 CfgOptions::default(), 370 CfgOptions::default(),
362 Env::default(), 371 Env::default(),
363 Default::default(), 372 Default::default(),
373 Default::default(),
364 ); 374 );
365 assert!(graph.add_dep(crate1, CrateName::new("crate2").unwrap(), crate2).is_ok()); 375 assert!(graph.add_dep(crate1, CrateName::new("crate2").unwrap(), crate2).is_ok());
366 assert!(graph.add_dep(crate2, CrateName::new("crate3").unwrap(), crate3).is_ok()); 376 assert!(graph.add_dep(crate2, CrateName::new("crate3").unwrap(), crate3).is_ok());
@@ -377,6 +387,7 @@ mod tests {
377 CfgOptions::default(), 387 CfgOptions::default(),
378 Env::default(), 388 Env::default(),
379 Default::default(), 389 Default::default(),
390 Default::default(),
380 ); 391 );
381 let crate2 = graph.add_crate_root( 392 let crate2 = graph.add_crate_root(
382 FileId(2u32), 393 FileId(2u32),
@@ -385,6 +396,7 @@ mod tests {
385 CfgOptions::default(), 396 CfgOptions::default(),
386 Env::default(), 397 Env::default(),
387 Default::default(), 398 Default::default(),
399 Default::default(),
388 ); 400 );
389 let crate3 = graph.add_crate_root( 401 let crate3 = graph.add_crate_root(
390 FileId(3u32), 402 FileId(3u32),
@@ -393,6 +405,7 @@ mod tests {
393 CfgOptions::default(), 405 CfgOptions::default(),
394 Env::default(), 406 Env::default(),
395 Default::default(), 407 Default::default(),
408 Default::default(),
396 ); 409 );
397 assert!(graph.add_dep(crate1, CrateName::new("crate2").unwrap(), crate2).is_ok()); 410 assert!(graph.add_dep(crate1, CrateName::new("crate2").unwrap(), crate2).is_ok());
398 assert!(graph.add_dep(crate2, CrateName::new("crate3").unwrap(), crate3).is_ok()); 411 assert!(graph.add_dep(crate2, CrateName::new("crate3").unwrap(), crate3).is_ok());
@@ -408,6 +421,7 @@ mod tests {
408 CfgOptions::default(), 421 CfgOptions::default(),
409 Env::default(), 422 Env::default(),
410 Default::default(), 423 Default::default(),
424 Default::default(),
411 ); 425 );
412 let crate2 = graph.add_crate_root( 426 let crate2 = graph.add_crate_root(
413 FileId(2u32), 427 FileId(2u32),
@@ -416,6 +430,7 @@ mod tests {
416 CfgOptions::default(), 430 CfgOptions::default(),
417 Env::default(), 431 Env::default(),
418 Default::default(), 432 Default::default(),
433 Default::default(),
419 ); 434 );
420 assert!(graph 435 assert!(graph
421 .add_dep(crate1, CrateName::normalize_dashes("crate-name-with-dashes"), crate2) 436 .add_dep(crate1, CrateName::normalize_dashes("crate-name-with-dashes"), crate2)
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index bac24e218..5829ae465 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -12,9 +12,10 @@ pub use crate::{
12 cancellation::Canceled, 12 cancellation::Canceled,
13 input::{ 13 input::{
14 CrateGraph, CrateId, CrateName, Dependency, Edition, Env, ExternSource, ExternSourceId, 14 CrateGraph, CrateId, CrateName, Dependency, Edition, Env, ExternSource, ExternSourceId,
15 FileId, SourceRoot, SourceRootId, 15 FileId, ProcMacroId, SourceRoot, SourceRootId,
16 }, 16 },
17}; 17};
18pub use ra_proc_macro::ProcMacro;
18pub use relative_path::{RelativePath, RelativePathBuf}; 19pub use relative_path::{RelativePath, RelativePathBuf};
19pub use salsa; 20pub use salsa;
20 21