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 analysis;
12pub mod index;
13pub mod input;
14pub mod parse;
15pub mod symbol_map;
16pub mod workspace_index;
17
18#[allow(unused_imports)]
19pub use input::{FileId, SourceFile, Workspace};
20
21/// Implement the `salsa::Update` trait for Arc-wrapped types using pointer equality.
22/// This reduces boilerplate for types that wrap a single Arc field and should only
23/// invalidate when the pointer changes (not the contents).
24#[macro_export]
25macro_rules! impl_arc_update {
26    ($ty:ty) => {
27        unsafe impl salsa::Update for $ty {
28            unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool {
29                let old_ref = unsafe { &mut *old_pointer };
30                if std::sync::Arc::ptr_eq(&old_ref.0, &new_value.0) {
31                    false
32                } else {
33                    *old_ref = new_value;
34                    true
35                }
36            }
37        }
38    };
39}