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