feat: allow generate_function to generate in different local crate

This commit is contained in:
Ryo Yoshida 2023-03-02 23:51:12 +09:00
parent 943de55214
commit bda2af71c6
No known key found for this signature in database
GPG key ID: E25698A930586171
4 changed files with 140 additions and 31 deletions

View file

@ -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
}