diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-09-11 12:37:04 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-09-11 12:37:04 +0100 |
commit | 4f1167d8ddac9d392f034341e6bc032b51014918 (patch) | |
tree | f26520ae48d4670aaefd2d62f9de37af30ef5bac /crates/vfs/src/file_set.rs | |
parent | eb7136f76d3535fde25dc6f49e3035312f7cc84c (diff) | |
parent | ca698a0b8c78e5ba7738fc0f0f6f77718e70a83e (diff) |
Merge #5969
5969: Propose module name completion options r=jonas-schievink a=SomeoneToIgnore
<img width="539" alt="image" src="https://user-images.githubusercontent.com/2690773/92663009-cb0aec00-f308-11ea-9ef5-1faa91518031.png">
Currently traverses the whole file set every time we try to complete the module, as discussed in https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/mod.3C.7C.3E.20completion
Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/vfs/src/file_set.rs')
-rw-r--r-- | crates/vfs/src/file_set.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs index e9196fcd2..4aa2d6526 100644 --- a/crates/vfs/src/file_set.rs +++ b/crates/vfs/src/file_set.rs | |||
@@ -23,13 +23,22 @@ impl FileSet { | |||
23 | let mut base = self.paths[&anchor].clone(); | 23 | let mut base = self.paths[&anchor].clone(); |
24 | base.pop(); | 24 | base.pop(); |
25 | let path = base.join(path)?; | 25 | let path = base.join(path)?; |
26 | let res = self.files.get(&path).copied(); | 26 | self.files.get(&path).copied() |
27 | res | 27 | } |
28 | |||
29 | pub fn file_for_path(&self, path: &VfsPath) -> Option<&FileId> { | ||
30 | self.files.get(path) | ||
28 | } | 31 | } |
32 | |||
33 | pub fn path_for_file(&self, file: &FileId) -> Option<&VfsPath> { | ||
34 | self.paths.get(file) | ||
35 | } | ||
36 | |||
29 | pub fn insert(&mut self, file_id: FileId, path: VfsPath) { | 37 | pub fn insert(&mut self, file_id: FileId, path: VfsPath) { |
30 | self.files.insert(path.clone(), file_id); | 38 | self.files.insert(path.clone(), file_id); |
31 | self.paths.insert(file_id, path); | 39 | self.paths.insert(file_id, path); |
32 | } | 40 | } |
41 | |||
33 | pub fn iter(&self) -> impl Iterator<Item = FileId> + '_ { | 42 | pub fn iter(&self) -> impl Iterator<Item = FileId> + '_ { |
34 | self.paths.keys().copied() | 43 | self.paths.keys().copied() |
35 | } | 44 | } |