Skip to content

Commit

Permalink
language server code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
micahscopes committed Jan 26, 2024
1 parent b4c6c01 commit bd1bbd5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 35 deletions.
11 changes: 1 addition & 10 deletions crates/language-server/src/backend.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::sync::Arc;
use std::sync::{Mutex, MutexGuard};
// use tokio::sync::{Mutex, MutexGuard};
use std::sync::Mutex;

use crate::db::LanguageServerDatabase;

Expand All @@ -18,14 +17,6 @@ pub struct Backend {
}

impl Backend {
// pub(crate) fn db(&self) -> MutexGuard<LanguageServerDatabase> {
// self.db.lock().unwrap()
// }

// pub(crate) fn workspace(&self) -> MutexGuard<Workspace> {
// self.workspace.lock().unwrap()
// }

pub fn new(client: Client) -> Self {
let db = Arc::new(Mutex::new(LanguageServerDatabase::default()));
let workspace = Arc::new(Mutex::new(Workspace::default()));
Expand Down
14 changes: 6 additions & 8 deletions crates/language-server/src/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use lsp_types::{
TextDocumentItem,
};

use tokio::sync::MutexGuard;
use tower_lsp::{jsonrpc::Result, Client, LanguageServer};
use tower_lsp::{jsonrpc::Result, LanguageServer};

use crate::{
backend::Backend,
Expand Down Expand Up @@ -188,12 +187,11 @@ async fn on_change(backend: &Backend, params: TextDocumentItem) {
};

let client = backend.client.lock().await;
let diagnostics =
diagnostics
.unwrap()
.into_iter()
.map(|(uri, diags)| client.publish_diagnostics(uri, diags, None))
.collect::<Vec<_>>();
let diagnostics = diagnostics
.unwrap()
.into_iter()
.map(|(uri, diags)| client.publish_diagnostics(uri, diags, None))
.collect::<Vec<_>>();

futures::future::join_all(diagnostics).await;
}
18 changes: 1 addition & 17 deletions crates/language-server/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl log::Log for Logger {
let level = record.level();
let client = self.client.clone();
tokio::spawn(async move {
let mut client = client.lock().await;
let client = client.lock().await;
client
.log_message(
match level {
Expand All @@ -37,22 +37,6 @@ impl log::Log for Logger {
)
.await;
});
// let client = self.client.clone();
// tokio::task::spawn_blocking(async move {
// let client = client.lock().await;
// client
// .log_message(
// match level {
// log::Level::Error => lsp_types::MessageType::ERROR,
// log::Level::Warn => lsp_types::MessageType::WARNING,
// log::Level::Info => lsp_types::MessageType::INFO,
// log::Level::Debug => lsp_types::MessageType::LOG,
// log::Level::Trace => lsp_types::MessageType::LOG,
// },
// message,
// )
// .await;
// });
}
}

Expand Down

0 comments on commit bd1bbd5

Please sign in to comment.