1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Copyright Two Neutron Stars Incorporated and contributors
// SPDX-License-Identifier: BlueOak-1.0.0
//! # Database Partition Definitions
//!
//! This module contains standardized partition definitions for the Laburnum
//! database. Each partition follows a consistent pattern to ensure uniformity
//! across the codebase.
//!
//! # Standard Partitions
//!
//! Laburnum provides standard partitions for common LSP features:
//! - [`Diagnostics`] - Errors, warnings, and info messages
//! - [`DocumentSymbols`] - Symbols for outline view / breadcrumbs
//! - [`WorkspaceSymbols`] - Global symbol search across workspace
//! - [`TextDocumentPosition`] - Position-to-symbol mapping for hover/goto
//! - [`TextDocumentReferences`] - Symbol references for "find all references"
//! - [`DocumentFoldingRange`] - Code folding regions
//! - [`Workspace`] - Workspace-level configuration
//!
//! Writing to these standard partitions enables LSP features to work
//! automatically.
//!
//! # Using Standard Partitions
//!
//! Language crates using Laburnum write to these partitions by:
//!
//! 1. Defining a concrete record type that implements the partition's record
//! trait (e.g., `DiagnosticRecord`)
//! 2. Using [`impl_partition_for_dyn!`] to create a wrapper partition type
//! 3. Writing records via the normal partition write path
//!
//! ## Example
//!
//! ```rust,ignore
//! use laburnum::{
//! impl_partition_for_dyn,
//! partitions::{Diagnostics, diagnostics::DiagnosticRecord},
//! };
//!
//! // 1. Define your concrete record type implementing the required trait
//! #[derive(Debug)]
//! pub struct MyDiagnostic { /* ... */ }
//!
//! impl DiagnosticRecord for MyDiagnostic { /* ... */ }
//! impl laburnum::record::Record for MyDiagnostic { /* ... */ }
//!
//! // 2. Create a wrapper partition using the macro
//! // This enforces at compile time that MyDiagnostic implements DiagnosticRecord
//! impl_partition_for_dyn!(MyDiagnosticsPartition, Diagnostics, MyDiagnostic);
//!
//! // 3. Write records using the wrapper partition
//! use laburnum::partitions::diagnostics::DiagnosticSortKey;
//!
//! let sort_key = DiagnosticSortKey::Diagnostic {
//! source_key,
//! severity: DiagnosticSeverity::ERROR,
//! sequence: 0,
//! };
//! writer.write::<MyDiagnosticsPartition>(sort_key, my_diagnostic.into());
//! ```
//!
//! The [`impl_partition_for_dyn!`] macro:
//! - Creates a new partition type that shares the same `KEY` as the Laburnum
//! partition
//! - Enforces at compile time that your record type implements the required
//! trait via [`DynPartitionRecord`]
//! - Allows you to use the standard partition write path
//!
//! # Partition File Structure
//!
//! Each partition is defined in its own file following this structure:
//!
//! ### 1. Partition Marker Type
//! A zero-sized marker type that implements [`DynPartition`]:
//! ```rust,ignore
//! pub struct MyPartition;
//!
//! impl PartitionKey for MyPartition {
//! const KEY: Ident = Ident::new("laburnum::my_partition");
//! }
//!
//! impl DynPartition for MyPartition {
//! type DynSortKey = MyPartitionSortKey;
//! type RecordConstraint = dyn MyPartitionRecord;
//! }
//!
//! // Blanket impl connecting any type implementing MyPartitionRecord to this
//! // partition
//! impl<R: MyPartitionRecord + crate::record::Record>
//! crate::database::DynPartitionRecord<MyPartition> for R
//! {}
//! ```
//!
//! ### 2. Sort Key Enum
//! An enum representing sort key variants and query prefixes:
//! ```rust,ignore
//! #[derive(Debug, Clone)]
//! pub enum MyPartitionSortKey {
//! Record { field1: Type1, field2: Type2 },
//! All,
//! Prefix { field1: Type1 },
//! }
//! ```
//!
//! ### 3. Display Implementation
//! Formats the enum into sort key strings:
//! ```rust,ignore
//! impl std::fmt::Display for MyPartitionSortKey {
//! fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
//! match self {
//! Self::Record { field1, field2 } => write!(f, "{}|{}", field1, field2),
//! Self::All => Ok(()),
//! Self::Prefix { field1 } => write!(f, "{}|", field1),
//! }
//! }
//! }
//! ```
//!
//! ### 4. Record Trait
//! The trait that concrete record types must implement:
//! ```rust,ignore
//! pub trait MyPartitionRecord: Send + Sync + std::fmt::Debug {
//! fn method1(&self) -> ReturnType;
//! fn method2(&self) -> ReturnType;
//! }
//! ```
//!
//! [`impl_partition_for_dyn!`]: crate::impl_partition_for_dyn
//! [`DynPartition`]: crate::database::DynPartition
//! [`DynPartitionRecord`]: crate::database::DynPartitionRecord
pub use ;