MCPcopy Create free account
hub / github.com/GCWing/BitFun / send_request

Method send_request

src/crates/services/services-core/src/lsp/process.rs:587–618  ·  view source on GitHub ↗

Sends a request and waits for the response.

(
        &self,
        method: impl Into<String>,
        params: Option<serde_json::Value>,
    )

Source from the content-addressed store, hash-verified

585
586 /// Sends a request and waits for the response.
587 pub async fn send_request(
588 &self,
589 method: impl Into<String>,
590 params: Option<serde_json::Value>,
591 ) -> Result<serde_json::Value> {
592 let id = self.request_id.fetch_add(1, Ordering::SeqCst);
593 let method_str = method.into();
594
595 let message = create_request(id, method_str.clone(), params);
596
597 let (tx, rx) = oneshot::channel();
598
599 {
600 let mut pending = self.pending_requests.write().await;
601 pending.insert(id, tx);
602 }
603
604 {
605 let mut stdin = self.stdin.write().await;
606 write_message(&mut stdin, &message).await?;
607 }
608
609 let response = timeout(Duration::from_secs(60), rx).await.map_err(|_| {
610 error!("LSP request timeout after 60s: {}", method_str);
611 anyhow!(
612 "LSP request timeout (60s): {}. The LSP server may not be responding.",
613 method_str
614 )
615 })??;
616
617 extract_result(response)
618 }
619
620 /// Sends a notification (does not wait for a response).
621 pub async fn send_notification(

Callers 15

initializeMethod · 0.45
shutdownMethod · 0.45
get_completionsMethod · 0.45
goto_definitionMethod · 0.45
get_hoverMethod · 0.45
find_referencesMethod · 0.45
get_code_actionsMethod · 0.45
format_documentMethod · 0.45
get_inlay_hintsMethod · 0.45
renameMethod · 0.45
get_document_symbolsMethod · 0.45

Calls 7

create_requestFunction · 0.85
channelFunction · 0.85
write_messageFunction · 0.85
extract_resultFunction · 0.85
cloneMethod · 0.45
writeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected