diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-19 08:57:40 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-19 08:57:40 +0100 |
commit | 75bf8328994e0966d381061647ac7dbbce374b39 (patch) | |
tree | 1fadb1bc57f4d666a427137dee8da7922b46f304 /crates/ide/src | |
parent | 0308fd6dabfce2d13e7e9c5b2a779be73579fa31 (diff) | |
parent | 493aaa140325f3b8fa40de3de58b34e4b96c5d13 (diff) |
Merge #8540
8540: Prevent being able to rename items that are not part of the workspace r=Veykril a=Veykril
This change causes renames that happen on items coming from crates outside the workspace to fail. I believe this should be the right approach, but usage of cargo's workspace might not be entirely correct for preventing these kinds of refactoring from touching things they shouldn't. I'm not entirely sure?
cc #6623, this is one of the bigger footguns when it comes to refactoring, especially in combination with import aliases people tend to rename items coming from a crates dependency which this prevents.
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide/src')
-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>> { |