mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-07-09 21:54:59 +00:00
refactor some small session fields
Some checks are pending
lint / cargo-check (push) Waiting to run
lint / clippy (push) Waiting to run
lint / pre-commit (push) Waiting to run
lint / rustfmt (push) Waiting to run
release / build (push) Waiting to run
release / test (push) Waiting to run
release / release (push) Blocked by required conditions
test / generate-matrix (push) Waiting to run
test / Python , Django () (push) Blocked by required conditions
test / tests (push) Blocked by required conditions
zizmor 🌈 / zizmor latest via PyPI (push) Waiting to run
Some checks are pending
lint / cargo-check (push) Waiting to run
lint / clippy (push) Waiting to run
lint / pre-commit (push) Waiting to run
lint / rustfmt (push) Waiting to run
release / build (push) Waiting to run
release / test (push) Waiting to run
release / release (push) Blocked by required conditions
test / generate-matrix (push) Waiting to run
test / Python , Django () (push) Blocked by required conditions
test / tests (push) Blocked by required conditions
zizmor 🌈 / zizmor latest via PyPI (push) Waiting to run
This commit is contained in:
parent
9e13422245
commit
de5e65c10d
2 changed files with 13 additions and 8 deletions
|
@ -61,7 +61,7 @@ impl LanguageServer for DjangoLanguageServer {
|
|||
client::log_message(MessageType::INFO, "Initializing server...");
|
||||
|
||||
self.with_session_mut(|session| {
|
||||
*session.client_capabilities_mut() = Some(params.capabilities);
|
||||
session.set_client_capabilities(params.capabilities);
|
||||
})
|
||||
.await;
|
||||
|
||||
|
@ -121,9 +121,11 @@ impl LanguageServer for DjangoLanguageServer {
|
|||
self.with_session_mut(|session| {
|
||||
let settings = djls_conf::Settings::new(&project_path)
|
||||
.unwrap_or_else(|_| djls_conf::Settings::default());
|
||||
*session.settings_mut() = settings;
|
||||
session.set_settings(settings);
|
||||
|
||||
let project = djls_project::DjangoProject::new(project_path);
|
||||
session.set_project(project);
|
||||
|
||||
*session.project_mut() = Some(djls_project::DjangoProject::new(project_path));
|
||||
true
|
||||
})
|
||||
.await
|
||||
|
@ -298,7 +300,7 @@ impl LanguageServer for DjangoLanguageServer {
|
|||
if let Some(path) = project_path {
|
||||
self.with_session_mut(|session| match djls_conf::Settings::new(path.as_path()) {
|
||||
Ok(new_settings) => {
|
||||
*session.settings_mut() = new_settings;
|
||||
session.set_settings(new_settings);
|
||||
}
|
||||
Err(e) => {
|
||||
client::log_message(MessageType::ERROR, format!("Error loading settings: {e}"));
|
||||
|
|
|
@ -45,8 +45,8 @@ pub struct Session {
|
|||
}
|
||||
|
||||
impl Session {
|
||||
pub fn client_capabilities_mut(&mut self) -> &mut Option<ClientCapabilities> {
|
||||
&mut self.client_capabilities
|
||||
pub fn set_client_capabilities(&mut self, client_capabilities: ClientCapabilities) {
|
||||
self.client_capabilities = Some(client_capabilities);
|
||||
}
|
||||
|
||||
pub fn project(&self) -> Option<&DjangoProject> {
|
||||
|
@ -56,6 +56,9 @@ impl Session {
|
|||
pub fn project_mut(&mut self) -> &mut Option<DjangoProject> {
|
||||
&mut self.project
|
||||
}
|
||||
pub fn set_project(&mut self, project: DjangoProject) {
|
||||
self.project = Some(project);
|
||||
}
|
||||
|
||||
pub fn documents(&self) -> &Store {
|
||||
&self.documents
|
||||
|
@ -69,8 +72,8 @@ impl Session {
|
|||
&self.settings
|
||||
}
|
||||
|
||||
pub fn settings_mut(&mut self) -> &mut Settings {
|
||||
&mut self.settings
|
||||
pub fn set_settings(&mut self, settings: Settings) {
|
||||
self.settings = settings;
|
||||
}
|
||||
|
||||
/// Get a database instance directly from the session
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue