move all state to single field on server struct (#144)
Some checks are pending
test / tests (push) Blocked by required conditions
lint / pre-commit (push) Waiting to run
release / test (push) Waiting to run
release / release (push) Blocked by required conditions
release / build (push) Waiting to run
test / generate-matrix (push) Waiting to run
test / Python , Django () (push) Blocked by required conditions
zizmor 🌈 / zizmor latest via PyPI (push) Waiting to run

This commit is contained in:
Josh Thomas 2025-05-13 23:25:27 -05:00 committed by GitHub
parent 6e4ad7ddf5
commit 00140c58ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 219 additions and 157 deletions

View file

@ -0,0 +1,55 @@
use crate::documents::Store;
use djls_conf::Settings;
use djls_project::DjangoProject;
use tower_lsp_server::lsp_types::ClientCapabilities;
#[derive(Debug, Default)]
pub struct Session {
client_capabilities: Option<ClientCapabilities>,
project: Option<DjangoProject>,
documents: Store,
settings: Settings,
}
impl Session {
pub fn new(client_capabilities: ClientCapabilities) -> Self {
Self {
client_capabilities: Some(client_capabilities),
project: None,
documents: Store::new(),
settings: Settings::default(),
}
}
pub fn client_capabilities(&self) -> &Option<ClientCapabilities> {
&self.client_capabilities
}
pub fn client_capabilities_mut(&mut self) -> &mut Option<ClientCapabilities> {
&mut self.client_capabilities
}
pub fn project(&self) -> Option<&DjangoProject> {
self.project.as_ref()
}
pub fn project_mut(&mut self) -> &mut Option<DjangoProject> {
&mut self.project
}
pub fn documents(&self) -> &Store {
&self.documents
}
pub fn documents_mut(&mut self) -> &mut Store {
&mut self.documents
}
pub fn settings(&self) -> &Settings {
&self.settings
}
pub fn settings_mut(&mut self) -> &mut Settings {
&mut self.settings
}
}