diff options
Diffstat (limited to 'crates/libanalysis/src/symbol_index.rs')
-rw-r--r-- | crates/libanalysis/src/symbol_index.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/crates/libanalysis/src/symbol_index.rs b/crates/libanalysis/src/symbol_index.rs index 2cad3f6eb..54952cb94 100644 --- a/crates/libanalysis/src/symbol_index.rs +++ b/crates/libanalysis/src/symbol_index.rs | |||
@@ -8,12 +8,12 @@ use {Query, FileId, JobToken}; | |||
8 | 8 | ||
9 | #[derive(Debug)] | 9 | #[derive(Debug)] |
10 | pub(crate) struct FileSymbols { | 10 | pub(crate) struct FileSymbols { |
11 | symbols: Vec<FileSymbol>, | 11 | symbols: Vec<(FileId, FileSymbol)>, |
12 | map: fst::Map, | 12 | map: fst::Map, |
13 | } | 13 | } |
14 | 14 | ||
15 | impl FileSymbols { | 15 | impl FileSymbols { |
16 | pub(crate) fn new(file: &File) -> FileSymbols { | 16 | pub(crate) fn new(file_id: FileId, file: &File) -> FileSymbols { |
17 | let mut symbols = file_symbols(file) | 17 | let mut symbols = file_symbols(file) |
18 | .into_iter() | 18 | .into_iter() |
19 | .map(|s| (s.name.as_str().to_lowercase(), s)) | 19 | .map(|s| (s.name.as_str().to_lowercase(), s)) |
@@ -21,8 +21,10 @@ impl FileSymbols { | |||
21 | 21 | ||
22 | symbols.sort_by(|s1, s2| s1.0.cmp(&s2.0)); | 22 | symbols.sort_by(|s1, s2| s1.0.cmp(&s2.0)); |
23 | symbols.dedup_by(|s1, s2| s1.0 == s2.0); | 23 | symbols.dedup_by(|s1, s2| s1.0 == s2.0); |
24 | let (names, symbols): (Vec<String>, Vec<FileSymbol>) = | 24 | let (names, symbols): (Vec<String>, Vec<(FileId, FileSymbol)>) = |
25 | symbols.into_iter().unzip(); | 25 | symbols.into_iter() |
26 | .map(|(name, symbol)| (name, (file_id, symbol))) | ||
27 | .unzip(); | ||
26 | 28 | ||
27 | let map = fst::Map::from_iter( | 29 | let map = fst::Map::from_iter( |
28 | names.into_iter().zip(0u64..) | 30 | names.into_iter().zip(0u64..) |
@@ -34,12 +36,12 @@ impl FileSymbols { | |||
34 | impl Query { | 36 | impl Query { |
35 | pub(crate) fn search( | 37 | pub(crate) fn search( |
36 | mut self, | 38 | mut self, |
37 | indices: &[(FileId, &FileSymbols)], | 39 | indices: &[&FileSymbols], |
38 | token: &JobToken, | 40 | token: &JobToken, |
39 | ) -> Vec<(FileId, FileSymbol)> { | 41 | ) -> Vec<(FileId, FileSymbol)> { |
40 | 42 | ||
41 | let mut op = fst::map::OpBuilder::new(); | 43 | let mut op = fst::map::OpBuilder::new(); |
42 | for (_, file_symbols) in indices.iter() { | 44 | for file_symbols in indices.iter() { |
43 | let automaton = fst::automaton::Subsequence::new(&self.lowercased); | 45 | let automaton = fst::automaton::Subsequence::new(&self.lowercased); |
44 | op = op.add(file_symbols.map.search(automaton)) | 46 | op = op.add(file_symbols.map.search(automaton)) |
45 | } | 47 | } |
@@ -50,10 +52,10 @@ impl Query { | |||
50 | break; | 52 | break; |
51 | } | 53 | } |
52 | for indexed_value in indexed_values { | 54 | for indexed_value in indexed_values { |
53 | let (file_id, file_symbols) = &indices[indexed_value.index]; | 55 | let file_symbols = &indices[indexed_value.index]; |
54 | let idx = indexed_value.value as usize; | 56 | let idx = indexed_value.value as usize; |
55 | 57 | ||
56 | let symbol = &file_symbols.symbols[idx]; | 58 | let (file_id, symbol) = &file_symbols.symbols[idx]; |
57 | if self.only_types && !is_type(symbol.kind) { | 59 | if self.only_types && !is_type(symbol.kind) { |
58 | continue; | 60 | continue; |
59 | } | 61 | } |