Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-db/src/helpers.rs')
-rw-r--r--crates/ide-db/src/helpers.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ide-db/src/helpers.rs b/crates/ide-db/src/helpers.rs
index 6e56efe344..8e3b1eef15 100644
--- a/crates/ide-db/src/helpers.rs
+++ b/crates/ide-db/src/helpers.rs
@@ -2,8 +2,8 @@
use std::collections::VecDeque;
-use base_db::FileId;
-use hir::{ItemInNs, ModuleDef, Name, Semantics};
+use base_db::{FileId, SourceDatabaseExt};
+use hir::{Crate, ItemInNs, ModuleDef, Name, Semantics};
use syntax::{
ast::{self, make},
AstToken, SyntaxKind, SyntaxToken, TokenAtOffset,
@@ -103,3 +103,9 @@ pub fn lint_eq_or_in_group(lint: &str, lint_is: &str) -> bool {
false
}
}
+
+pub fn is_editable_crate(krate: Crate, db: &RootDatabase) -> bool {
+ let root_file = krate.root_file(db);
+ let source_root_id = db.file_source_root(root_file);
+ !db.source_root(source_root_id).is_library
+}