Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/base-db/src/input.rs')
-rw-r--r--crates/base-db/src/input.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/crates/base-db/src/input.rs b/crates/base-db/src/input.rs
index e8d521b42f..64b026f4da 100644
--- a/crates/base-db/src/input.rs
+++ b/crates/base-db/src/input.rs
@@ -151,6 +151,12 @@ pub enum CrateOrigin {
Lang(LangCrateOrigin),
}
+impl CrateOrigin {
+ pub fn is_local(&self) -> bool {
+ matches!(self, CrateOrigin::Local { .. })
+ }
+}
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum LangCrateOrigin {
Alloc,
@@ -333,6 +339,17 @@ pub struct Env {
entries: FxHashMap<String, String>,
}
+impl Env {
+ pub fn new_for_test_fixture() -> Self {
+ Env {
+ entries: FxHashMap::from_iter([(
+ String::from("__ra_is_test_fixture"),
+ String::from("__ra_is_test_fixture"),
+ )]),
+ }
+ }
+}
+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Dependency {
pub crate_id: CrateId,
@@ -456,6 +473,10 @@ impl CrateGraph {
self.arena.iter().map(|(idx, _)| idx)
}
+ pub fn iter_mut(&mut self) -> impl Iterator<Item = (CrateId, &mut CrateData)> + '_ {
+ self.arena.iter_mut()
+ }
+
/// Returns an iterator over all transitive dependencies of the given crate,
/// including the crate itself.
pub fn transitive_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> {