diff options
author | Lukas Wirth <[email protected]> | 2021-04-16 16:31:47 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-04-18 11:44:00 +0100 |
commit | c447a795abecbf9a4138778bab44197250b2dc4a (patch) | |
tree | c35a00f004f09c01f41714ca44e3a0a045a19ea1 /crates/ide | |
parent | 75371eb0fa015ba8834ae2b66cda68eba5d83874 (diff) |
Prevent being able to rename items that are not part of the workspace
Diffstat (limited to 'crates/ide')
-rw-r--r-- | crates/ide/src/lib.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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 { | |||
244 | self.with_db(|db| db.parse(file_id).tree()) | 244 | self.with_db(|db| db.parse(file_id).tree()) |
245 | } | 245 | } |
246 | 246 | ||
247 | /// Returns true if this file belongs to an immutable library. | ||
248 | pub fn is_library_file(&self, file_id: FileId) -> Cancelable<bool> { | ||
249 | use ide_db::base_db::SourceDatabaseExt; | ||
250 | self.with_db(|db| db.source_root(db.file_source_root(file_id)).is_library) | ||
251 | } | ||
252 | |||
247 | /// Gets the file's `LineIndex`: data structure to convert between absolute | 253 | /// Gets the file's `LineIndex`: data structure to convert between absolute |
248 | /// offsets and line/column representation. | 254 | /// offsets and line/column representation. |
249 | pub fn file_line_index(&self, file_id: FileId) -> Cancelable<Arc<LineIndex>> { | 255 | pub fn file_line_index(&self, file_id: FileId) -> Cancelable<Arc<LineIndex>> { |