Skip to content

Commit f5ece05

Browse files
committed
Move cancel to Client
1 parent 5bc3aee commit f5ece05

23 files changed

+50
-43
lines changed

crates/ty_server/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub use document::{DocumentKey, NotebookDocument, PositionEncoding, TextDocument
44
pub use session::{ClientSettings, DocumentQuery, DocumentSnapshot, Session};
55
use std::num::NonZeroUsize;
66

7-
mod client;
87
mod document;
98
mod logging;
109
mod server;

crates/ty_server/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod connection;
1919
mod main_loop;
2020
mod schedule;
2121

22-
use crate::client::Client;
22+
use crate::session::client::Client;
2323
pub(crate) use api::Error;
2424
pub(crate) use connection::{ConnectionInitializer, ConnectionSender};
2525
pub(crate) use main_loop::{Action, Event, MainLoopReceiver, MainLoopSender};

crates/ty_server/src/server/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod traits;
1515

1616
use self::traits::{NotificationHandler, RequestHandler};
1717
use super::{Result, schedule::BackgroundSchedule};
18-
use crate::client::Client;
18+
use crate::session::client::Client;
1919
use crate::show_err_msg;
2020
use notifications as notification;
2121
use requests as request;

crates/ty_server/src/server/api/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use lsp_server::ErrorCode;
22
use lsp_types::{PublishDiagnosticsParams, Url, notification::PublishDiagnostics};
33

44
use super::LSPResult;
5-
use crate::client::Client;
65
use crate::server::Result;
6+
use crate::session::client::Client;
77

88
pub(super) fn clear_diagnostics(uri: &Url, client: &Client) -> Result<()> {
99
client

crates/ty_server/src/server/api/notifications/cancel.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use lsp_server::{ErrorCode, RequestId, ResponseError};
1+
use lsp_server::RequestId;
22
use lsp_types::CancelParams;
33
use lsp_types::notification::Cancel;
44

5-
use crate::client::Client;
65
use crate::server::Result;
76
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
87
use crate::session::Session;
8+
use crate::session::client::Client;
99

1010
pub(crate) struct CancelNotificationHandler;
1111

@@ -20,18 +20,7 @@ impl SyncNotificationHandler for CancelNotificationHandler {
2020
lsp_types::NumberOrString::String(id) => id.into(),
2121
};
2222

23-
let method_name = session.request_queue_mut().incoming_mut().cancel(&id);
24-
25-
if let Some(method_name) = method_name {
26-
tracing::debug!("Cancelled request id={id} method={method_name}");
27-
let error = ResponseError {
28-
code: ErrorCode::RequestCanceled as i32,
29-
message: "request was cancelled by client".to_owned(),
30-
data: None,
31-
};
32-
33-
let _ = client.respond_err(id, error);
34-
}
23+
let _ = client.cancel(session, id);
3524

3625
Ok(())
3726
}

crates/ty_server/src/server/api/notifications/did_change.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use lsp_server::ErrorCode;
22
use lsp_types::DidChangeTextDocumentParams;
33
use lsp_types::notification::DidChangeTextDocument;
44

5-
use crate::client::Client;
65
use crate::server::Result;
76
use crate::server::api::LSPResult;
87
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
98
use crate::session::Session;
9+
use crate::session::client::Client;
1010
use crate::system::{AnySystemPath, url_to_any_system_path};
1111
use ty_project::watch::ChangeEvent;
1212

crates/ty_server/src/server/api/notifications/did_change_watched_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::client::Client;
21
use crate::server::Result;
32
use crate::server::api::LSPResult;
43
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
54
use crate::session::Session;
5+
use crate::session::client::Client;
66
use crate::system::{AnySystemPath, url_to_any_system_path};
77
use lsp_types as types;
88
use lsp_types::{FileChangeType, notification as notif};

crates/ty_server/src/server/api/notifications/did_close.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::client::Client;
21
use crate::server::Result;
32
use crate::server::api::LSPResult;
43
use crate::server::api::diagnostics::clear_diagnostics;
54
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
65
use crate::session::Session;
6+
use crate::session::client::Client;
77
use crate::system::{AnySystemPath, url_to_any_system_path};
88
use lsp_server::ErrorCode;
99
use lsp_types::DidCloseTextDocumentParams;

crates/ty_server/src/server/api/notifications/did_close_notebook.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use lsp_types::DidCloseNotebookDocumentParams;
22
use lsp_types::notification::DidCloseNotebookDocument;
33

4-
use crate::client::Client;
54
use crate::server::Result;
65
use crate::server::api::LSPResult;
76
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
87
use crate::session::Session;
8+
use crate::session::client::Client;
99
use crate::system::{AnySystemPath, url_to_any_system_path};
1010
use ty_project::watch::ChangeEvent;
1111

crates/ty_server/src/server/api/notifications/did_open.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use lsp_types::notification::DidOpenTextDocument;
22
use lsp_types::{DidOpenTextDocumentParams, TextDocumentItem};
33

44
use crate::TextDocument;
5-
use crate::client::Client;
65
use crate::server::Result;
76
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
87
use crate::session::Session;
8+
use crate::session::client::Client;
99
use crate::system::{AnySystemPath, url_to_any_system_path};
1010
use ruff_db::Db;
1111
use ty_project::watch::ChangeEvent;

0 commit comments

Comments
 (0)