pub(crate) fn on_sync<R>(
        &mut self,
        f: fn(&mut GlobalState, R::Params) -> Result<R::Result>,
    ) -> Result<&mut Self>
    where
        R: lsp_types::request::Request + 'static,
        R::Params: DeserializeOwned + panic::UnwindSafe + fmt::Debug + 'static,
        R::Result: Serialize + 'static,
    {
        let (id, params) = match self.parse::<R>() {
            Some(it) => it,
            None => return Ok(self),
        };
        let global_state = panic::AssertUnwindSafe(&mut *self.global_state);

        let result = panic::catch_unwind(move || {
            // Make sure that the whole AssertUnwindSafe is moved into the
            // closure, and not just its field.
            let panic::AssertUnwindSafe(global_state) = { global_state };

            let _pctx = stdx::panic_context::enter(format!(
                "\nversion: {}\nrequest: {} {:#?}",
                env!("REV"),
                R::METHOD,
                params
            ));
            f(global_state, params)
        });
        let response = result_to_response::<R>(id, result);

        self.global_state.respond(response);
        Ok(self)
    }
/// Dispatches the request onto the current thread
Dispatches the request onto the current thread
Dispatches the request onto the current thread
pub(crate) fn on_sync<R>(
        &mut self,
        f: fn(&mut GlobalState, R::Params) -> Result<R::Result>,
    ) -> Result<&mut Self>
    where
        R: lsp_types::request::Request + 'static,
        R::Params: DeserializeOwned + panic::UnwindSafe + fmt::Debug + 'static,
        R::Result: Serialize + 'static,
    {
        let (id, params) = match self.parse::<R>() {
            Some(it) => it,
            None => return Ok(self),
        };
        let global_state = panic::AssertUnwindSafe(&mut *self.global_state);
        let result = panic::catch_unwind(move || {
            // Make sure that the whole AssertUnwindSafe is moved into the
            // closure, and not just its field.
            let panic::AssertUnwindSafe(global_state) = { global_state };
            let _pctx = stdx::panic_context::enter(format!(
                "\nversion: {}\nrequest: {} {:#?}",
                env!("REV"),
                R::METHOD,
                params
            ));
            f(global_state, params)
        });
        let response = result_to_response::<R>(id, result);
        self.global_state.respond(response);
        Ok(self)
    }
pub ( crate ) fn on_sync < R > ( & mut self , f : fn ( & mut GlobalState , R :: Params ) -> Result < R :: Result > , ) -> Result < & mut Self > where R : lsp_types :: request :: Request + ' static , R :: Params : DeserializeOwned + panic :: UnwindSafe + fmt :: Debug + ' static , R :: Result : Serialize + ' static , { let ( id , params ) = match self . parse :: < R > ( ) { Some ( it ) => it , None => return Ok ( self ) , } ; let global_state = panic :: AssertUnwindSafe ( & mut * self . global_state ) ; let result = panic :: catch_unwind ( move | | { // Make sure that the whole AssertUnwindSafe is moved into the // closure, and not just its field. let panic :: AssertUnwindSafe ( global_state ) = { global_state } ; let _pctx = stdx :: panic_context :: enter ( format ! ( " \n \n " env ( " " ) R METHOD params ) ) ; f ( global_state , params ) } ) ; let response = result_to_response :: < R > ( id , result ) ; self . global_state . respond ( response ) ; Ok ( self ) }
Dispatches the request onto the current thread
Dispatches the request onto the current thread
&mut self
f
fn(&mut GlobalState, R::Params) -> Result<R::Result>