use {
super::records::SymbolEntry,
crate::core::{
Ident, Symbol, SymbolPath, SymbolVisibility, Value, Visibility,
},
laburnum::{
ContentHash, Ident as LaburnumIdent,
database::{Partition, PartitionKey},
record::{Record, hash_record},
},
std::{hash::Hash, marker::PhantomData},
};
#[derive(Hash)]
pub struct FileSymbols<V, I, P, S = SymbolVisibility>(PhantomData<(V, I, P, S)>);
impl<V, I, P, S> Default for FileSymbols<V, I, P, S> {
fn default() -> Self {
Self(PhantomData)
}
}
impl<V, I, P, S> Clone for FileSymbols<V, I, P, S> {
fn clone(&self) -> Self {
*self
}
}
impl<V, I, P, S> Copy for FileSymbols<V, I, P, S> {}
impl<V, I, P, S> std::fmt::Debug for FileSymbols<V, I, P, S> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FileSymbols").finish()
}
}
impl<V, I, P, S> PartitionKey for FileSymbols<V, I, P, S>
where
V: Value<I>,
I: Ident,
P: SymbolPath,
S: Visibility,
{
const KEY: LaburnumIdent = LaburnumIdent::new("symbolique::file_symbols");
}
impl<V, I, P, S> Partition for FileSymbols<V, I, P, S>
where
V: Value<I>,
I: Ident,
P: SymbolPath,
S: Visibility,
{
type Record = (); type IndexEntry = SymbolEntry<V, I, P, S>;
type SortKey = P;
}
#[derive(Hash)]
pub struct FileSymbolIndex<V, I, P, S = SymbolVisibility>(
PhantomData<(V, I, P, S)>,
);
impl<V, I, P, S> Default for FileSymbolIndex<V, I, P, S> {
fn default() -> Self {
Self(PhantomData)
}
}
impl<V, I, P, S> Clone for FileSymbolIndex<V, I, P, S> {
fn clone(&self) -> Self {
*self
}
}
impl<V, I, P, S> Copy for FileSymbolIndex<V, I, P, S> {}
impl<V, I, P, S> std::fmt::Debug for FileSymbolIndex<V, I, P, S> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FileSymbolIndex").finish()
}
}
impl<V, I, P, S> PartitionKey for FileSymbolIndex<V, I, P, S>
where
V: Value<I>,
I: Ident,
P: SymbolPath,
S: Visibility,
{
const KEY: LaburnumIdent =
LaburnumIdent::new("symbolique::file_symbol_index");
}
impl<V, I, P, S> Partition for FileSymbolIndex<V, I, P, S>
where
V: Value<I>,
I: Ident,
P: SymbolPath,
S: Visibility,
{
type Record = (); type IndexEntry = SymbolEntry<V, I, P, S>;
type SortKey = P;
}
impl<V, I, P, S> Record for Symbol<V, I, P, S>
where
V: Value<I>,
I: Ident,
P: SymbolPath,
S: Visibility,
{
fn content_hash(&self) -> ContentHash {
hash_record(self)
}
}