mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-27 04:19:22 +00:00
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
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:
parent
6e4ad7ddf5
commit
00140c58ca
5 changed files with 219 additions and 157 deletions
55
crates/djls-server/src/session.rs
Normal file
55
crates/djls-server/src/session.rs
Normal 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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue