diff options
Diffstat (limited to 'crates/libanalysis/src/roots.rs')
-rw-r--r-- | crates/libanalysis/src/roots.rs | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/crates/libanalysis/src/roots.rs b/crates/libanalysis/src/roots.rs index eb14e7567..01de3e128 100644 --- a/crates/libanalysis/src/roots.rs +++ b/crates/libanalysis/src/roots.rs | |||
@@ -59,18 +59,18 @@ impl SourceRoot { | |||
59 | } | 59 | } |
60 | } | 60 | } |
61 | } | 61 | } |
62 | pub(crate) fn symbols(&self) -> Vec<(FileId, &FileSymbols)> { | 62 | pub(crate) fn symbols(&self) -> Vec<&FileSymbols> { |
63 | self.file_map | 63 | self.file_map |
64 | .iter() | 64 | .iter() |
65 | .map(|(&file_id, data)| (file_id, symbols(data))) | 65 | .map(|(&file_id, data)| symbols(file_id, data)) |
66 | .collect() | 66 | .collect() |
67 | } | 67 | } |
68 | pub fn reindex(&self) { | 68 | pub fn reindex(&self) { |
69 | let now = Instant::now(); | 69 | let now = Instant::now(); |
70 | self.file_map | 70 | self.file_map |
71 | .par_iter() | 71 | .par_iter() |
72 | .for_each(|(_, data)| { | 72 | .for_each(|(&file_id, data)| { |
73 | symbols(data); | 73 | symbols(file_id, data); |
74 | }); | 74 | }); |
75 | info!("parallel indexing took {:?}", now.elapsed()); | 75 | info!("parallel indexing took {:?}", now.elapsed()); |
76 | 76 | ||
@@ -83,9 +83,9 @@ impl SourceRoot { | |||
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | fn symbols((data, symbols): &(FileData, OnceCell<FileSymbols>)) -> &FileSymbols { | 86 | fn symbols(file_id: FileId, (data, symbols): &(FileData, OnceCell<FileSymbols>)) -> &FileSymbols { |
87 | let syntax = data.syntax_transient(); | 87 | let syntax = data.syntax_transient(); |
88 | symbols.get_or_init(|| FileSymbols::new(&syntax)) | 88 | symbols.get_or_init(|| FileSymbols::new(file_id, &syntax)) |
89 | } | 89 | } |
90 | 90 | ||
91 | #[derive(Debug)] | 91 | #[derive(Debug)] |
@@ -108,3 +108,14 @@ impl FileData { | |||
108 | .unwrap_or_else(|| File::parse(&self.text)) | 108 | .unwrap_or_else(|| File::parse(&self.text)) |
109 | } | 109 | } |
110 | } | 110 | } |
111 | |||
112 | // #[derive(Clone, Default, Debug)] | ||
113 | // pub(crate) struct ReadonlySourceRoot { | ||
114 | // data: Arc<ReadonlySourceRoot> | ||
115 | // } | ||
116 | |||
117 | // #[derive(Clone, Default, Debug)] | ||
118 | // pub(crate) struct ReadonlySourceRootInner { | ||
119 | // file_map: HashMap<FileId, FileData>, | ||
120 | // module_map: ModuleMap, | ||
121 | // } | ||