sync_lsp/text_document/
will_save_wait_until.rs1use crate::TypeProvider;
8use crate::{Server, connection::Endpoint};
9use crate::connection::Callback;
10use serde::Deserialize;
11use super::will_save::TextDocumentSaveReason;
12use super::{TextDocumentIdentifer, TextEdit};
13
14#[derive(Default, Clone)]
15pub(crate) struct WillSaveWaitUntilOptions;
16
17#[derive(Deserialize)]
18#[serde(rename_all = "camelCase")]
19struct WillSaveWaitUntilTextDocumentParams {
20 text_document: TextDocumentIdentifer,
21 reason: TextDocumentSaveReason
22}
23
24impl WillSaveWaitUntilOptions {
25
26 pub(crate) const METHOD: &'static str = "textDocument/willSaveWaitUntil";
27
28 pub(super) fn endpoint<T: TypeProvider>() -> Endpoint<T, WillSaveWaitUntilOptions> {
29 Endpoint::new(Callback::request(|_, _: WillSaveWaitUntilTextDocumentParams| Vec::<TextEdit>::new()))
30 }
31}
32
33impl<T: TypeProvider> Server<T> {
34
35 pub fn on_will_save_wait_until(&mut self, callback: fn(&mut Server<T>, TextDocumentIdentifer, TextDocumentSaveReason) -> Vec<TextEdit>) {
45 self.text_document.will_save_wait_until.set_callback(Callback::request(move |server, params: WillSaveWaitUntilTextDocumentParams| {
46 callback(server, params.text_document, params.reason)
47 }))
48 }
49}