mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
⬆️ rust-analyzer
This commit is contained in:
parent
3e0e51c108
commit
bc45c7659a
321 changed files with 11210 additions and 9720 deletions
|
@ -75,6 +75,7 @@ pub struct Vfs {
|
|||
}
|
||||
|
||||
/// Changed file in the [`Vfs`].
|
||||
#[derive(Debug)]
|
||||
pub struct ChangedFile {
|
||||
/// Id of the changed file
|
||||
pub file_id: FileId,
|
||||
|
@ -161,9 +162,9 @@ impl Vfs {
|
|||
let file_id = self.alloc_file_id(path);
|
||||
let change_kind = match (&self.get(file_id), &contents) {
|
||||
(None, None) => return false,
|
||||
(Some(old), Some(new)) if old == new => return false,
|
||||
(None, Some(_)) => ChangeKind::Create,
|
||||
(Some(_), None) => ChangeKind::Delete,
|
||||
(Some(old), Some(new)) if old == new => return false,
|
||||
(Some(_), Some(_)) => ChangeKind::Modify,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Abstract-ish representation of paths for VFS.
|
||||
use std::fmt;
|
||||
|
||||
use paths::{AbsPath, AbsPathBuf};
|
||||
use paths::{AbsPath, AbsPathBuf, RelPath};
|
||||
|
||||
/// Path in [`Vfs`].
|
||||
///
|
||||
|
@ -84,6 +84,14 @@ impl VfsPath {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn strip_prefix(&self, other: &VfsPath) -> Option<&RelPath> {
|
||||
match (&self.0, &other.0) {
|
||||
(VfsPathRepr::PathBuf(lhs), VfsPathRepr::PathBuf(rhs)) => lhs.strip_prefix(rhs),
|
||||
(VfsPathRepr::VirtualPath(lhs), VfsPathRepr::VirtualPath(rhs)) => lhs.strip_prefix(rhs),
|
||||
(VfsPathRepr::PathBuf(_) | VfsPathRepr::VirtualPath(_), _) => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the `VfsPath` without its final component, if there is one.
|
||||
///
|
||||
/// Returns [`None`] if the path is a root or prefix.
|
||||
|
@ -320,6 +328,13 @@ impl VirtualPath {
|
|||
self.0.starts_with(&other.0)
|
||||
}
|
||||
|
||||
fn strip_prefix(&self, base: &VirtualPath) -> Option<&RelPath> {
|
||||
<_ as AsRef<std::path::Path>>::as_ref(&self.0)
|
||||
.strip_prefix(&base.0)
|
||||
.ok()
|
||||
.map(RelPath::new_unchecked)
|
||||
}
|
||||
|
||||
/// Remove the last component of `self`.
|
||||
///
|
||||
/// This will find the last `'/'` in `self`, and remove everything after it,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue