Prevent being able to rename items that are not part of the workspace

This commit is contained in:
Lukas Wirth 2021-04-16 17:31:47 +02:00
parent 75371eb0fa
commit c447a795ab
10 changed files with 92 additions and 15 deletions

View file

@ -244,6 +244,12 @@ impl Analysis {
self.with_db(|db| db.parse(file_id).tree())
}
/// Returns true if this file belongs to an immutable library.
pub fn is_library_file(&self, file_id: FileId) -> Cancelable<bool> {
use ide_db::base_db::SourceDatabaseExt;
self.with_db(|db| db.source_root(db.file_source_root(file_id)).is_library)
}
/// Gets the file's `LineIndex`: data structure to convert between absolute
/// offsets and line/column representation.
pub fn file_line_index(&self, file_id: FileId) -> Cancelable<Arc<LineIndex>> {