Skip to main content

php_lsp/db/
mod.rs

1//! Salsa-based incremental computation layer.
2//!
3//! After the mir-analyzer 0.22 migration, semantic analysis (Pass 2, class
4//! issues, references) is owned by `AnalysisSession` in `DocumentStore`.
5//! Salsa here is now responsible for the LSP-side compact representations
6//! only: parsed AST cache (`parse`), per-file declaration index (`index`),
7//! workspace aggregation (`workspace_index`). These power cross-file LSP
8//! features (workspace symbols, document symbols, find-implementations, hover
9//! from index) that don't require the analyzer's full type system.
10
11pub mod index;
12pub mod mir_queries;
13pub mod parse;
14pub mod symbol_map;
15pub mod workspace_index;
16
17#[cfg(test)]
18mod gc_gate_test;
19
20#[cfg(test)]
21mod convergence_spike;
22
23/// Implement the `salsa::Update` trait for Arc-wrapped types using pointer equality.
24/// This reduces boilerplate for types that wrap a single Arc field and should only
25/// invalidate when the pointer changes (not the contents).
26#[macro_export]
27macro_rules! impl_arc_update {
28    ($ty:ty) => {
29        unsafe impl salsa::Update for $ty {
30            unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool {
31                let old_ref = unsafe { &mut *old_pointer };
32                if std::sync::Arc::ptr_eq(&old_ref.0, &new_value.0) {
33                    false
34                } else {
35                    *old_ref = new_value;
36                    true
37                }
38            }
39        }
40    };
41}