Take a reference in LSP notify (#23077)
In current code this doesn't have benefit. In preparation for avoiding a clone of workspace configuration. Having the interface this way may make opportunities for efficiency clearer in the future Release Notes: - N/A
This commit is contained in:
parent
c1c767a5bd
commit
2f762955cd
10 changed files with 52 additions and 51 deletions
|
@ -1007,7 +1007,7 @@ async fn test_language_server_statuses(cx_a: &mut TestAppContext, cx_b: &mut Tes
|
||||||
fake_language_server.start_progress("the-token").await;
|
fake_language_server.start_progress("the-token").await;
|
||||||
|
|
||||||
executor.advance_clock(SERVER_PROGRESS_THROTTLE_TIMEOUT);
|
executor.advance_clock(SERVER_PROGRESS_THROTTLE_TIMEOUT);
|
||||||
fake_language_server.notify::<lsp::notification::Progress>(lsp::ProgressParams {
|
fake_language_server.notify::<lsp::notification::Progress>(&lsp::ProgressParams {
|
||||||
token: lsp::NumberOrString::String("the-token".to_string()),
|
token: lsp::NumberOrString::String("the-token".to_string()),
|
||||||
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::Report(
|
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::Report(
|
||||||
lsp::WorkDoneProgressReport {
|
lsp::WorkDoneProgressReport {
|
||||||
|
@ -1041,7 +1041,7 @@ async fn test_language_server_statuses(cx_a: &mut TestAppContext, cx_b: &mut Tes
|
||||||
});
|
});
|
||||||
|
|
||||||
executor.advance_clock(SERVER_PROGRESS_THROTTLE_TIMEOUT);
|
executor.advance_clock(SERVER_PROGRESS_THROTTLE_TIMEOUT);
|
||||||
fake_language_server.notify::<lsp::notification::Progress>(lsp::ProgressParams {
|
fake_language_server.notify::<lsp::notification::Progress>(&lsp::ProgressParams {
|
||||||
token: lsp::NumberOrString::String("the-token".to_string()),
|
token: lsp::NumberOrString::String("the-token".to_string()),
|
||||||
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::Report(
|
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::Report(
|
||||||
lsp::WorkDoneProgressReport {
|
lsp::WorkDoneProgressReport {
|
||||||
|
|
|
@ -3900,7 +3900,7 @@ async fn test_collaborating_with_diagnostics(
|
||||||
.receive_notification::<lsp::notification::DidOpenTextDocument>()
|
.receive_notification::<lsp::notification::DidOpenTextDocument>()
|
||||||
.await;
|
.await;
|
||||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||||
lsp::PublishDiagnosticsParams {
|
&lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
|
@ -3920,7 +3920,7 @@ async fn test_collaborating_with_diagnostics(
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||||
lsp::PublishDiagnosticsParams {
|
&lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
|
@ -3994,7 +3994,7 @@ async fn test_collaborating_with_diagnostics(
|
||||||
|
|
||||||
// Simulate a language server reporting more errors for a file.
|
// Simulate a language server reporting more errors for a file.
|
||||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||||
lsp::PublishDiagnosticsParams {
|
&lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![
|
diagnostics: vec![
|
||||||
|
@ -4088,7 +4088,7 @@ async fn test_collaborating_with_diagnostics(
|
||||||
|
|
||||||
// Simulate a language server reporting no errors for a file.
|
// Simulate a language server reporting no errors for a file.
|
||||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||||
lsp::PublishDiagnosticsParams {
|
&lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![],
|
diagnostics: vec![],
|
||||||
|
@ -4183,7 +4183,7 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
fake_language_server.notify::<lsp::notification::Progress>(lsp::ProgressParams {
|
fake_language_server.notify::<lsp::notification::Progress>(&lsp::ProgressParams {
|
||||||
token: lsp::NumberOrString::String("the-disk-based-token".to_string()),
|
token: lsp::NumberOrString::String("the-disk-based-token".to_string()),
|
||||||
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::Begin(
|
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::Begin(
|
||||||
lsp::WorkDoneProgressBegin {
|
lsp::WorkDoneProgressBegin {
|
||||||
|
@ -4194,7 +4194,7 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
|
||||||
});
|
});
|
||||||
for file_name in file_names {
|
for file_name in file_names {
|
||||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||||
lsp::PublishDiagnosticsParams {
|
&lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Url::from_file_path(Path::new("/test").join(file_name)).unwrap(),
|
uri: lsp::Url::from_file_path(Path::new("/test").join(file_name)).unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
|
@ -4207,7 +4207,7 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
fake_language_server.notify::<lsp::notification::Progress>(lsp::ProgressParams {
|
fake_language_server.notify::<lsp::notification::Progress>(&lsp::ProgressParams {
|
||||||
token: lsp::NumberOrString::String("the-disk-based-token".to_string()),
|
token: lsp::NumberOrString::String("the-disk-based-token".to_string()),
|
||||||
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::End(
|
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::End(
|
||||||
lsp::WorkDoneProgressEnd { message: None },
|
lsp::WorkDoneProgressEnd { message: None },
|
||||||
|
|
|
@ -270,7 +270,7 @@ impl RegisteredBuffer {
|
||||||
server
|
server
|
||||||
.lsp
|
.lsp
|
||||||
.notify::<lsp::notification::DidChangeTextDocument>(
|
.notify::<lsp::notification::DidChangeTextDocument>(
|
||||||
lsp::DidChangeTextDocumentParams {
|
&lsp::DidChangeTextDocumentParams {
|
||||||
text_document: lsp::VersionedTextDocumentIdentifier::new(
|
text_document: lsp::VersionedTextDocumentIdentifier::new(
|
||||||
buffer.uri.clone(),
|
buffer.uri.clone(),
|
||||||
buffer.snapshot_version,
|
buffer.snapshot_version,
|
||||||
|
@ -659,7 +659,7 @@ impl Copilot {
|
||||||
let snapshot = buffer.read(cx).snapshot();
|
let snapshot = buffer.read(cx).snapshot();
|
||||||
server
|
server
|
||||||
.notify::<lsp::notification::DidOpenTextDocument>(
|
.notify::<lsp::notification::DidOpenTextDocument>(
|
||||||
lsp::DidOpenTextDocumentParams {
|
&lsp::DidOpenTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentItem {
|
text_document: lsp::TextDocumentItem {
|
||||||
uri: uri.clone(),
|
uri: uri.clone(),
|
||||||
language_id: language_id.clone(),
|
language_id: language_id.clone(),
|
||||||
|
@ -707,7 +707,7 @@ impl Copilot {
|
||||||
server
|
server
|
||||||
.lsp
|
.lsp
|
||||||
.notify::<lsp::notification::DidSaveTextDocument>(
|
.notify::<lsp::notification::DidSaveTextDocument>(
|
||||||
lsp::DidSaveTextDocumentParams {
|
&lsp::DidSaveTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentIdentifier::new(
|
text_document: lsp::TextDocumentIdentifier::new(
|
||||||
registered_buffer.uri.clone(),
|
registered_buffer.uri.clone(),
|
||||||
),
|
),
|
||||||
|
@ -727,14 +727,14 @@ impl Copilot {
|
||||||
server
|
server
|
||||||
.lsp
|
.lsp
|
||||||
.notify::<lsp::notification::DidCloseTextDocument>(
|
.notify::<lsp::notification::DidCloseTextDocument>(
|
||||||
lsp::DidCloseTextDocumentParams {
|
&lsp::DidCloseTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentIdentifier::new(old_uri),
|
text_document: lsp::TextDocumentIdentifier::new(old_uri),
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
server
|
server
|
||||||
.lsp
|
.lsp
|
||||||
.notify::<lsp::notification::DidOpenTextDocument>(
|
.notify::<lsp::notification::DidOpenTextDocument>(
|
||||||
lsp::DidOpenTextDocumentParams {
|
&lsp::DidOpenTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentItem::new(
|
text_document: lsp::TextDocumentItem::new(
|
||||||
registered_buffer.uri.clone(),
|
registered_buffer.uri.clone(),
|
||||||
registered_buffer.language_id.clone(),
|
registered_buffer.language_id.clone(),
|
||||||
|
@ -759,7 +759,7 @@ impl Copilot {
|
||||||
server
|
server
|
||||||
.lsp
|
.lsp
|
||||||
.notify::<lsp::notification::DidCloseTextDocument>(
|
.notify::<lsp::notification::DidCloseTextDocument>(
|
||||||
lsp::DidCloseTextDocumentParams {
|
&lsp::DidCloseTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentIdentifier::new(buffer.uri),
|
text_document: lsp::TextDocumentIdentifier::new(buffer.uri),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -1479,7 +1479,7 @@ pub mod tests {
|
||||||
.await
|
.await
|
||||||
.expect("work done progress create request failed");
|
.expect("work done progress create request failed");
|
||||||
cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
fake_server.notify::<lsp::notification::Progress>(lsp::ProgressParams {
|
fake_server.notify::<lsp::notification::Progress>(&lsp::ProgressParams {
|
||||||
token: lsp::ProgressToken::String(progress_token.to_string()),
|
token: lsp::ProgressToken::String(progress_token.to_string()),
|
||||||
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::Begin(
|
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::Begin(
|
||||||
lsp::WorkDoneProgressBegin::default(),
|
lsp::WorkDoneProgressBegin::default(),
|
||||||
|
@ -1504,7 +1504,7 @@ pub mod tests {
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
fake_server.notify::<lsp::notification::Progress>(lsp::ProgressParams {
|
fake_server.notify::<lsp::notification::Progress>(&lsp::ProgressParams {
|
||||||
token: lsp::ProgressToken::String(progress_token.to_string()),
|
token: lsp::ProgressToken::String(progress_token.to_string()),
|
||||||
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::End(
|
value: lsp::ProgressParamsValue::WorkDone(lsp::WorkDoneProgress::End(
|
||||||
lsp::WorkDoneProgressEnd::default(),
|
lsp::WorkDoneProgressEnd::default(),
|
||||||
|
|
|
@ -331,7 +331,7 @@ impl EditorLspTestContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn notify<T: notification::Notification>(&self, params: T::Params) {
|
pub fn notify<T: notification::Notification>(&self, params: T::Params) {
|
||||||
self.lsp.notify::<T>(params);
|
self.lsp.notify::<T>(¶ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
|
|
@ -963,7 +963,7 @@ impl LspLogView {
|
||||||
});
|
});
|
||||||
|
|
||||||
server
|
server
|
||||||
.notify::<SetTrace>(SetTraceParams { value: level })
|
.notify::<SetTrace>(&SetTraceParams { value: level })
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ async fn test_lsp_logs(cx: &mut TestAppContext) {
|
||||||
let log_view = window.root(cx).unwrap();
|
let log_view = window.root(cx).unwrap();
|
||||||
let mut cx = VisualTestContext::from_window(*window, cx);
|
let mut cx = VisualTestContext::from_window(*window, cx);
|
||||||
|
|
||||||
language_server.notify::<lsp::notification::LogMessage>(lsp::LogMessageParams {
|
language_server.notify::<lsp::notification::LogMessage>(&lsp::LogMessageParams {
|
||||||
message: "hello from the server".into(),
|
message: "hello from the server".into(),
|
||||||
typ: lsp::MessageType::INFO,
|
typ: lsp::MessageType::INFO,
|
||||||
});
|
});
|
||||||
|
|
|
@ -815,7 +815,7 @@ impl LanguageServer {
|
||||||
}
|
}
|
||||||
self.capabilities = RwLock::new(response.capabilities);
|
self.capabilities = RwLock::new(response.capabilities);
|
||||||
|
|
||||||
self.notify::<notification::Initialized>(InitializedParams {})?;
|
self.notify::<notification::Initialized>(&InitializedParams {})?;
|
||||||
Ok(Arc::new(self))
|
Ok(Arc::new(self))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -835,7 +835,7 @@ impl LanguageServer {
|
||||||
&executor,
|
&executor,
|
||||||
(),
|
(),
|
||||||
);
|
);
|
||||||
let exit = Self::notify_internal::<notification::Exit>(&outbound_tx, ());
|
let exit = Self::notify_internal::<notification::Exit>(&outbound_tx, &());
|
||||||
outbound_tx.close();
|
outbound_tx.close();
|
||||||
|
|
||||||
let server = self.server.clone();
|
let server = self.server.clone();
|
||||||
|
@ -1146,7 +1146,7 @@ impl LanguageServer {
|
||||||
if let Some(outbound_tx) = outbound_tx.upgrade() {
|
if let Some(outbound_tx) = outbound_tx.upgrade() {
|
||||||
Self::notify_internal::<notification::Cancel>(
|
Self::notify_internal::<notification::Cancel>(
|
||||||
&outbound_tx,
|
&outbound_tx,
|
||||||
CancelParams {
|
&CancelParams {
|
||||||
id: NumberOrString::Number(id),
|
id: NumberOrString::Number(id),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -1174,13 +1174,13 @@ impl LanguageServer {
|
||||||
/// Sends a RPC notification to the language server.
|
/// Sends a RPC notification to the language server.
|
||||||
///
|
///
|
||||||
/// [LSP Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage)
|
/// [LSP Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage)
|
||||||
pub fn notify<T: notification::Notification>(&self, params: T::Params) -> Result<()> {
|
pub fn notify<T: notification::Notification>(&self, params: &T::Params) -> Result<()> {
|
||||||
Self::notify_internal::<T>(&self.outbound_tx, params)
|
Self::notify_internal::<T>(&self.outbound_tx, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn notify_internal<T: notification::Notification>(
|
fn notify_internal<T: notification::Notification>(
|
||||||
outbound_tx: &channel::Sender<String>,
|
outbound_tx: &channel::Sender<String>,
|
||||||
params: T::Params,
|
params: &T::Params,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let message = serde_json::to_string(&Notification {
|
let message = serde_json::to_string(&Notification {
|
||||||
jsonrpc: JSON_RPC_VERSION,
|
jsonrpc: JSON_RPC_VERSION,
|
||||||
|
@ -1372,7 +1372,7 @@ impl LanguageServer {
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
impl FakeLanguageServer {
|
impl FakeLanguageServer {
|
||||||
/// See [`LanguageServer::notify`].
|
/// See [`LanguageServer::notify`].
|
||||||
pub fn notify<T: notification::Notification>(&self, params: T::Params) {
|
pub fn notify<T: notification::Notification>(&self, params: &T::Params) {
|
||||||
self.server.notify::<T>(params).ok();
|
self.server.notify::<T>(params).ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1480,7 +1480,7 @@ impl FakeLanguageServer {
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
self.notify::<notification::Progress>(ProgressParams {
|
self.notify::<notification::Progress>(&ProgressParams {
|
||||||
token: NumberOrString::String(token),
|
token: NumberOrString::String(token),
|
||||||
value: ProgressParamsValue::WorkDone(WorkDoneProgress::Begin(progress)),
|
value: ProgressParamsValue::WorkDone(WorkDoneProgress::Begin(progress)),
|
||||||
});
|
});
|
||||||
|
@ -1488,7 +1488,7 @@ impl FakeLanguageServer {
|
||||||
|
|
||||||
/// Simulate that the server has completed work and notifies about that with the specified token.
|
/// Simulate that the server has completed work and notifies about that with the specified token.
|
||||||
pub fn end_progress(&self, token: impl Into<String>) {
|
pub fn end_progress(&self, token: impl Into<String>) {
|
||||||
self.notify::<notification::Progress>(ProgressParams {
|
self.notify::<notification::Progress>(&ProgressParams {
|
||||||
token: NumberOrString::String(token.into()),
|
token: NumberOrString::String(token.into()),
|
||||||
value: ProgressParamsValue::WorkDone(WorkDoneProgress::End(Default::default())),
|
value: ProgressParamsValue::WorkDone(WorkDoneProgress::End(Default::default())),
|
||||||
});
|
});
|
||||||
|
@ -1540,7 +1540,7 @@ mod tests {
|
||||||
|
|
||||||
let server = cx.update(|cx| server.initialize(None, cx)).await.unwrap();
|
let server = cx.update(|cx| server.initialize(None, cx)).await.unwrap();
|
||||||
server
|
server
|
||||||
.notify::<notification::DidOpenTextDocument>(DidOpenTextDocumentParams {
|
.notify::<notification::DidOpenTextDocument>(&DidOpenTextDocumentParams {
|
||||||
text_document: TextDocumentItem::new(
|
text_document: TextDocumentItem::new(
|
||||||
Url::from_str("file://a/b").unwrap(),
|
Url::from_str("file://a/b").unwrap(),
|
||||||
"rust".to_string(),
|
"rust".to_string(),
|
||||||
|
@ -1558,11 +1558,11 @@ mod tests {
|
||||||
"file://a/b"
|
"file://a/b"
|
||||||
);
|
);
|
||||||
|
|
||||||
fake.notify::<notification::ShowMessage>(ShowMessageParams {
|
fake.notify::<notification::ShowMessage>(&ShowMessageParams {
|
||||||
typ: MessageType::ERROR,
|
typ: MessageType::ERROR,
|
||||||
message: "ok".to_string(),
|
message: "ok".to_string(),
|
||||||
});
|
});
|
||||||
fake.notify::<notification::PublishDiagnostics>(PublishDiagnosticsParams {
|
fake.notify::<notification::PublishDiagnostics>(&PublishDiagnosticsParams {
|
||||||
uri: Url::from_str("file://b/c").unwrap(),
|
uri: Url::from_str("file://b/c").unwrap(),
|
||||||
version: Some(5),
|
version: Some(5),
|
||||||
diagnostics: vec![],
|
diagnostics: vec![],
|
||||||
|
|
|
@ -302,7 +302,7 @@ impl LocalLspStore {
|
||||||
|
|
||||||
language_server
|
language_server
|
||||||
.notify::<lsp::notification::DidChangeConfiguration>(
|
.notify::<lsp::notification::DidChangeConfiguration>(
|
||||||
lsp::DidChangeConfigurationParams {
|
&lsp::DidChangeConfigurationParams {
|
||||||
settings: workspace_config,
|
settings: workspace_config,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -1922,7 +1922,7 @@ impl LocalLspStore {
|
||||||
};
|
};
|
||||||
|
|
||||||
server
|
server
|
||||||
.notify::<lsp::notification::DidOpenTextDocument>(lsp::DidOpenTextDocumentParams {
|
.notify::<lsp::notification::DidOpenTextDocument>(&lsp::DidOpenTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentItem::new(
|
text_document: lsp::TextDocumentItem::new(
|
||||||
uri.clone(),
|
uri.clone(),
|
||||||
adapter.language_id(&language.name()),
|
adapter.language_id(&language.name()),
|
||||||
|
@ -1968,7 +1968,7 @@ impl LocalLspStore {
|
||||||
for (_, language_server) in self.language_servers_for_buffer(buffer, cx) {
|
for (_, language_server) in self.language_servers_for_buffer(buffer, cx) {
|
||||||
language_server
|
language_server
|
||||||
.notify::<lsp::notification::DidCloseTextDocument>(
|
.notify::<lsp::notification::DidCloseTextDocument>(
|
||||||
lsp::DidCloseTextDocumentParams {
|
&lsp::DidCloseTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentIdentifier::new(file_url.clone()),
|
text_document: lsp::TextDocumentIdentifier::new(file_url.clone()),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -5068,7 +5068,7 @@ impl LspStore {
|
||||||
|
|
||||||
language_server
|
language_server
|
||||||
.notify::<lsp::notification::DidChangeTextDocument>(
|
.notify::<lsp::notification::DidChangeTextDocument>(
|
||||||
lsp::DidChangeTextDocumentParams {
|
&lsp::DidChangeTextDocumentParams {
|
||||||
text_document: lsp::VersionedTextDocumentIdentifier::new(
|
text_document: lsp::VersionedTextDocumentIdentifier::new(
|
||||||
uri.clone(),
|
uri.clone(),
|
||||||
next_version,
|
next_version,
|
||||||
|
@ -5104,7 +5104,7 @@ impl LspStore {
|
||||||
};
|
};
|
||||||
server
|
server
|
||||||
.notify::<lsp::notification::DidSaveTextDocument>(
|
.notify::<lsp::notification::DidSaveTextDocument>(
|
||||||
lsp::DidSaveTextDocumentParams {
|
&lsp::DidSaveTextDocumentParams {
|
||||||
text_document: text_document.clone(),
|
text_document: text_document.clone(),
|
||||||
text,
|
text,
|
||||||
},
|
},
|
||||||
|
@ -5174,7 +5174,7 @@ impl LspStore {
|
||||||
|
|
||||||
server
|
server
|
||||||
.notify::<lsp::notification::DidChangeConfiguration>(
|
.notify::<lsp::notification::DidChangeConfiguration>(
|
||||||
lsp::DidChangeConfigurationParams { settings },
|
&lsp::DidChangeConfigurationParams { settings },
|
||||||
)
|
)
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
@ -6215,7 +6215,7 @@ impl LspStore {
|
||||||
|
|
||||||
if filter.should_send_did_rename(&old_uri, is_dir) {
|
if filter.should_send_did_rename(&old_uri, is_dir) {
|
||||||
language_server
|
language_server
|
||||||
.notify::<DidRenameFiles>(RenameFilesParams {
|
.notify::<DidRenameFiles>(&RenameFilesParams {
|
||||||
files: vec![FileRename {
|
files: vec![FileRename {
|
||||||
old_uri: old_uri.clone(),
|
old_uri: old_uri.clone(),
|
||||||
new_uri: new_uri.clone(),
|
new_uri: new_uri.clone(),
|
||||||
|
@ -6322,7 +6322,7 @@ impl LspStore {
|
||||||
if !changes.is_empty() {
|
if !changes.is_empty() {
|
||||||
server
|
server
|
||||||
.notify::<lsp::notification::DidChangeWatchedFiles>(
|
.notify::<lsp::notification::DidChangeWatchedFiles>(
|
||||||
lsp::DidChangeWatchedFilesParams { changes },
|
&lsp::DidChangeWatchedFilesParams { changes },
|
||||||
)
|
)
|
||||||
.log_err();
|
.log_err();
|
||||||
}
|
}
|
||||||
|
@ -7534,7 +7534,7 @@ impl LspStore {
|
||||||
let uri = lsp::Url::from_file_path(file.abs_path(cx)).unwrap();
|
let uri = lsp::Url::from_file_path(file.abs_path(cx)).unwrap();
|
||||||
language_server
|
language_server
|
||||||
.notify::<lsp::notification::DidOpenTextDocument>(
|
.notify::<lsp::notification::DidOpenTextDocument>(
|
||||||
lsp::DidOpenTextDocumentParams {
|
&lsp::DidOpenTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentItem::new(
|
text_document: lsp::TextDocumentItem::new(
|
||||||
uri,
|
uri,
|
||||||
adapter.language_id(&language.name()),
|
adapter.language_id(&language.name()),
|
||||||
|
@ -7636,10 +7636,11 @@ impl LspStore {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if progress.is_cancellable {
|
if progress.is_cancellable {
|
||||||
server
|
server
|
||||||
.notify::<lsp::notification::WorkDoneProgressCancel>(
|
.notify::<lsp::notification::WorkDoneProgressCancel>(
|
||||||
WorkDoneProgressCancelParams {
|
&WorkDoneProgressCancelParams {
|
||||||
token: lsp::NumberOrString::String(token.clone()),
|
token: lsp::NumberOrString::String(token.clone()),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -7649,7 +7650,7 @@ impl LspStore {
|
||||||
if progress.is_cancellable {
|
if progress.is_cancellable {
|
||||||
server
|
server
|
||||||
.notify::<lsp::notification::WorkDoneProgressCancel>(
|
.notify::<lsp::notification::WorkDoneProgressCancel>(
|
||||||
WorkDoneProgressCancelParams {
|
&WorkDoneProgressCancelParams {
|
||||||
token: lsp::NumberOrString::String(token.clone()),
|
token: lsp::NumberOrString::String(token.clone()),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -7784,7 +7785,7 @@ impl LspStore {
|
||||||
};
|
};
|
||||||
if !params.changes.is_empty() {
|
if !params.changes.is_empty() {
|
||||||
server
|
server
|
||||||
.notify::<lsp::notification::DidChangeWatchedFiles>(params)
|
.notify::<lsp::notification::DidChangeWatchedFiles>(¶ms)
|
||||||
.log_err();
|
.log_err();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1269,7 +1269,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
fake_server.notify::<lsp::notification::PublishDiagnostics>(&lsp::PublishDiagnosticsParams {
|
||||||
uri: Url::from_file_path("/dir/a.rs").unwrap(),
|
uri: Url::from_file_path("/dir/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
|
@ -1321,7 +1321,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Ensure publishing empty diagnostics twice only results in one update event.
|
// Ensure publishing empty diagnostics twice only results in one update event.
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
fake_server.notify::<lsp::notification::PublishDiagnostics>(&lsp::PublishDiagnosticsParams {
|
||||||
uri: Url::from_file_path("/dir/a.rs").unwrap(),
|
uri: Url::from_file_path("/dir/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: Default::default(),
|
diagnostics: Default::default(),
|
||||||
|
@ -1334,7 +1334,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
fake_server.notify::<lsp::notification::PublishDiagnostics>(&lsp::PublishDiagnosticsParams {
|
||||||
uri: Url::from_file_path("/dir/a.rs").unwrap(),
|
uri: Url::from_file_path("/dir/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: Default::default(),
|
diagnostics: Default::default(),
|
||||||
|
@ -1453,7 +1453,7 @@ async fn test_restarting_server_with_diagnostics_published(cx: &mut gpui::TestAp
|
||||||
|
|
||||||
// Publish diagnostics
|
// Publish diagnostics
|
||||||
let fake_server = fake_servers.next().await.unwrap();
|
let fake_server = fake_servers.next().await.unwrap();
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
fake_server.notify::<lsp::notification::PublishDiagnostics>(&lsp::PublishDiagnosticsParams {
|
||||||
uri: Url::from_file_path("/dir/a.rs").unwrap(),
|
uri: Url::from_file_path("/dir/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
|
@ -1534,7 +1534,7 @@ async fn test_restarted_server_reporting_invalid_buffer_version(cx: &mut gpui::T
|
||||||
|
|
||||||
// Before restarting the server, report diagnostics with an unknown buffer version.
|
// Before restarting the server, report diagnostics with an unknown buffer version.
|
||||||
let fake_server = fake_servers.next().await.unwrap();
|
let fake_server = fake_servers.next().await.unwrap();
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
fake_server.notify::<lsp::notification::PublishDiagnostics>(&lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
|
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
|
||||||
version: Some(10000),
|
version: Some(10000),
|
||||||
diagnostics: Vec::new(),
|
diagnostics: Vec::new(),
|
||||||
|
@ -1784,7 +1784,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
assert!(change_notification_1.text_document.version > open_notification.text_document.version);
|
assert!(change_notification_1.text_document.version > open_notification.text_document.version);
|
||||||
|
|
||||||
// Report some diagnostics for the initial version of the buffer
|
// Report some diagnostics for the initial version of the buffer
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
fake_server.notify::<lsp::notification::PublishDiagnostics>(&lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
|
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
|
||||||
version: Some(open_notification.text_document.version),
|
version: Some(open_notification.text_document.version),
|
||||||
diagnostics: vec![
|
diagnostics: vec![
|
||||||
|
@ -1870,7 +1870,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Ensure overlapping diagnostics are highlighted correctly.
|
// Ensure overlapping diagnostics are highlighted correctly.
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
fake_server.notify::<lsp::notification::PublishDiagnostics>(&lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
|
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
|
||||||
version: Some(open_notification.text_document.version),
|
version: Some(open_notification.text_document.version),
|
||||||
diagnostics: vec![
|
diagnostics: vec![
|
||||||
|
@ -1962,7 +1962,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Handle out-of-order diagnostics
|
// Handle out-of-order diagnostics
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
fake_server.notify::<lsp::notification::PublishDiagnostics>(&lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
|
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
|
||||||
version: Some(change_notification_2.text_document.version),
|
version: Some(change_notification_2.text_document.version),
|
||||||
diagnostics: vec![
|
diagnostics: vec![
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue