From 764ddc0c8506b0d5356681b8b333e387cb0ba6b6 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sat, 29 Dec 2018 22:07:56 +0000 Subject: Fix a switched line in a comment --- crates/ra_vfs/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index 4de07b093..7fccc3088 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs @@ -2,8 +2,8 @@ //! //! When doing analysis, we don't want to do any IO, we want to keep all source //! code in memory. However, the actual source code is stored on disk, so you -//! component which does this. //! need to get it into the memory in the first place somehow. VFS is the +//! component which does this. //! //! It also is responsible for watching the disk for changes, and for merging //! editor state (modified, unsaved files) with disk state. -- cgit v1.2.3 From f18e25f24cef422b07723574d006e38ba6a0f424 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sat, 29 Dec 2018 22:30:54 +0000 Subject: Improve comment contents --- crates/ra_vfs/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index 7fccc3088..0e0edf261 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs @@ -5,8 +5,10 @@ //! need to get it into the memory in the first place somehow. VFS is the //! component which does this. //! -//! It also is responsible for watching the disk for changes, and for merging +//! It is also responsible for watching the disk for changes, and for merging //! editor state (modified, unsaved files) with disk state. +//! TODO: Some LSP clients support watching the disk, so this crate should +//! to support custom watcher events (related to https://github.com/rust-analyzer/rust-analyzer/issues/131) //! //! VFS is based on a concept of roots: a set of directories on the file system //! whihc are watched for changes. Typically, there will be a root for each -- cgit v1.2.3 From c881fc607efafc04fb31ede90623dc6353620b7f Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sat, 29 Dec 2018 22:32:39 +0000 Subject: Fix instance of uneeded brackets in use_statement (thanks to #333) --- crates/ra_vfs/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index 0e0edf261..ced86740b 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs @@ -31,7 +31,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use relative_path::RelativePathBuf; use crossbeam_channel::Receiver; use walkdir::DirEntry; -use thread_worker::{WorkerHandle}; +use thread_worker::WorkerHandle; use crate::{ arena::{ArenaId, Arena}, -- cgit v1.2.3 From 07202f944c556ef71f6d6676189db73ed5980992 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sat, 29 Dec 2018 22:33:28 +0000 Subject: Remove some unnecessary unwraps by using the `Result::ok` combinatoric --- crates/ra_vfs/src/lib.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'crates') diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index ced86740b..90d5e21f4 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs @@ -59,12 +59,8 @@ impl RootFilter { if !(self.file_filter)(path) { return None; } - if !(path.starts_with(&self.root)) { - return None; - } - let path = path.strip_prefix(&self.root).unwrap(); - let path = RelativePathBuf::from_path(path).unwrap(); - Some(path) + let path = path.strip_prefix(&self.root).ok()?; + RelativePathBuf::from_path(path).ok() } } -- cgit v1.2.3 From 5dd602f90162cc3ec89751d76265c761b5aa2797 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sat, 29 Dec 2018 22:45:01 +0000 Subject: Reuse has_rs_extension in io.rs --- crates/ra_vfs/src/io.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/ra_vfs/src/io.rs b/crates/ra_vfs/src/io.rs index be400bae9..4cfdb83da 100644 --- a/crates/ra_vfs/src/io.rs +++ b/crates/ra_vfs/src/io.rs @@ -8,7 +8,7 @@ use walkdir::{DirEntry, WalkDir}; use thread_worker::{WorkerHandle}; use relative_path::RelativePathBuf; -use crate::VfsRoot; +use crate::{VfsRoot, has_rs_extension}; pub(crate) struct Task { pub(crate) root: VfsRoot, @@ -59,7 +59,7 @@ fn load_root(root: &Path, filter: &dyn Fn(&DirEntry) -> bool) -> Vec<(RelativePa continue; } let path = entry.path(); - if path.extension().and_then(|os| os.to_str()) != Some("rs") { + if !has_rs_extension(path) { continue; } let text = match fs::read_to_string(path) { -- cgit v1.2.3