fix(lsp): remove code_action/diagnostics deadlock (#10555)

Landed without test to meet 1.10.0 deadline. See #10587.
This commit is contained in:
Kitson Kelly 2021-05-12 00:43:00 +10:00 committed by GitHub
parent 46f0ac59e0
commit 41a3b17de4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 356 additions and 428 deletions

View file

@ -91,7 +91,7 @@ pub(crate) struct Inner {
/// are part of the TypeScript snapshot and have to be fetched out.
assets: Assets,
/// The LSP client that this LSP server is connected to.
client: Client,
pub(crate) client: Client,
/// Configuration information.
config: Config,
diagnostics_server: diagnostics::DiagnosticsServer,
@ -117,9 +117,9 @@ pub(crate) struct Inner {
/// A memoized version of fixable diagnostic codes retrieved from TypeScript.
ts_fixable_diagnostics: Vec<String>,
/// An abstraction that handles interactions with TypeScript.
ts_server: Arc<TsServer>,
pub(crate) ts_server: Arc<TsServer>,
/// A map of specifiers and URLs used to translate over the LSP.
pub url_map: urls::LspUrlMap,
pub(crate) url_map: urls::LspUrlMap,
}
impl LanguageServer {
@ -959,12 +959,8 @@ impl Inner {
let mut code_actions = CodeActionCollection::default();
let file_diagnostics = self
.diagnostics_server
.get(specifier.clone(), DiagnosticSource::TypeScript)
.await
.map_err(|err| {
error!("Unable to get diagnostics: {}", err);
LspError::internal_error()
})?;
.get(&specifier, DiagnosticSource::TypeScript)
.await;
for diagnostic in &fixable_diagnostics {
match diagnostic.source.as_deref() {
Some("deno-ts") => {
@ -2484,13 +2480,7 @@ impl Inner {
if let Some(source) = self.documents.content(&referrer).unwrap() {
self.analyze_dependencies(&referrer, &source);
}
self
.diagnostics_server
.invalidate(referrer)
.map_err(|err| {
error!("{}", err);
LspError::internal_error()
})?;
self.diagnostics_server.invalidate(&referrer).await;
}
self.diagnostics_server.update().map_err(|err| {
@ -4608,7 +4598,7 @@ mod tests {
LspFixture::Path("did_open_notification_code_action.json"),
LspResponse::None,
),
(LspFixture::None, LspResponse::Delay(500)),
(LspFixture::None, LspResponse::Delay(20000)),
(
LspFixture::Path("code_action_request.json"),
LspResponse::RequestFixture(2, "code_action_response.json".to_string()),