From c447a795abecbf9a4138778bab44197250b2dc4a Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 16 Apr 2021 17:31:47 +0200 Subject: Prevent being able to rename items that are not part of the workspace --- crates/ide/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/ide') diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index b24c664ba..99e45633e 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs @@ -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 { + 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> { -- cgit v1.2.3