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//! method-return-type cache (`method_returns`), workspace aggregation
8//! (`workspace_index`). These power cross-file LSP features
9//! (workspace symbols, document symbols, find-implementations, hover from
10//! index) that don't require the analyzer's full type system.
11
12pub mod analysis;
13pub mod index;
14pub mod input;
15pub mod method_returns;
16pub mod parse;
17pub mod workspace_index;
18
19#[allow(unused_imports)]
20pub use input::{FileId, SourceFile, Workspace};
21
22/// Implement the `salsa::Update` trait for Arc-wrapped types using pointer equality.
23/// This reduces boilerplate for types that wrap a single Arc field and should only
24/// invalidate when the pointer changes (not the contents).
25#[macro_export]
26macro_rules! impl_arc_update {
27    ($ty:ty) => {
28        unsafe impl salsa::Update for $ty {
29            unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool {
30                let old_ref = unsafe { &mut *old_pointer };
31                if std::sync::Arc::ptr_eq(&old_ref.0, &new_value.0) {
32                    false
33                } else {
34                    *old_ref = new_value;
35                    true
36                }
37            }
38        }
39    };
40}