Commit c9d1c7d
authored
Migrate the workspace indexer to
Branched from #1264
Progress towards #1212
With this PR the Ark indexer that currently powers legacy workspace
symbols, completions, and diagnostics is migrated to sources from the
Oak DB, instead of walking the disk and watching.
Benefits:
- Single source of truth
- Less memory consumption
- Reactivity to changes for workspace files that are not opened in the
editor
This last property is quite nice when changing git branches or editing
files with an agent. The changes used to be ignored until the file was
opened, but now the IDE reacts instantly.
https://github.com/user-attachments/assets/0b99be22-54a8-4522-b233-164b02be979f
- Building a file index is now a Salsa query over `oak_db::File`. Making
it a query per file is especially nice during initial workspace scans
where Salsa cancellations don't invalidate finished work per file, they
remain cached across edits without having to finish building the entire
index. This replaces the old global mutable index.
- New `workspace_files()` helper that collects, as the name says, all
workspace files. Unlike `all_files()`, library roots are excluded. This
is what `indexer::find()` and `map()` use to walk over files.
- Dropped the combined indexer + diagnostics queue. Now diagnostics
query the index, so the ordering we used to enforce by hand (finish
indexing, then run diagnostics) just falls out of the pull model. I've
kept diagnostics batching and deduping as these are still useful.
- Now that the indexer is a query, it's fully lazy. That's a good
property in principle but can lead to user-visible delays when
requesting workspace symbols in an empty workspace on startup. If a file
is opened, diagnostics will query the index and warm it up, but if none
are opened, nothing drives that.
To fix this issue, we now warm up the index manually after the initial
workspace scan has settled. This mirrors how Rust-Analyser warms up its
own general-purpose queries after the language server reaches
"quiescence" (after the initial scan, after a workspace refresh caused
by changing Cargo.toml, etc). There is no such mechanism in ty, it's
fully on-demand. I opted to go the r-a way as it's closer to what we had
before.
- Diagnostics triggering is now simplified by looking at
`salsa::plumbing::current_revision()` from the main loop. Rust-Analyser
uses it too, ty doesn't (they have a different pull model for
diagnostics that I didn't investigate much yet, our push model is closer
to R-A's).
- The indexer was the only consumer of the rename events. We now watch
files purely through `DidChangeWatchedFiles`, which is consistent which
is also what ty and r-a do.
The one event we might want to subscribe later on is `WillRename`. This
would be useful to e.g. update `source()` paths when a file is renamed.ArkFile and make it a query (#1266)17 files changed
Lines changed: 498 additions & 857 deletions
File tree
- crates
- ark/src
- lsp
- completions/sources/composite
- snapshots
- oak_db/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | 139 | | |
143 | 140 | | |
144 | 141 | | |
| |||
297 | 294 | | |
298 | 295 | | |
299 | 296 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | 297 | | |
313 | 298 | | |
314 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
96 | | - | |
| 97 | + | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| |||
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| 160 | + | |
159 | 161 | | |
160 | 162 | | |
161 | 163 | | |
| |||
168 | 170 | | |
169 | 171 | | |
170 | 172 | | |
171 | | - | |
| 173 | + | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
| |||
234 | 236 | | |
235 | 237 | | |
236 | 238 | | |
237 | | - | |
| 239 | + | |
238 | 240 | | |
| 241 | + | |
239 | 242 | | |
240 | 243 | | |
241 | 244 | | |
242 | 245 | | |
243 | 246 | | |
244 | | - | |
| 247 | + | |
245 | 248 | | |
246 | 249 | | |
247 | 250 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| |||
0 commit comments