Respond with JSON-RPC error if we failed to deserialize request
Historically, we intentinally violated JSON-RPC spec here by hard crashing. The idea was to poke both the clients and servers to fix stuff. However, this is confusing for server implementors, and falls down in one important place -- protocol extension are not always backwards compatible, which causes crashes simply due to version mismatch. We had once such case with our own extension, and one for semantic tokens. So let's be less adventerous and just err on the err side!
This commit is contained in:
@@ -403,53 +403,49 @@ impl GlobalState {
|
||||
handlers::handle_matching_brace(s.snapshot(), p)
|
||||
})?
|
||||
.on_sync::<lsp_ext::MemoryUsage>(|s, p| handlers::handle_memory_usage(s, p))?
|
||||
.on::<lsp_ext::AnalyzerStatus>(handlers::handle_analyzer_status)?
|
||||
.on::<lsp_ext::SyntaxTree>(handlers::handle_syntax_tree)?
|
||||
.on::<lsp_ext::ExpandMacro>(handlers::handle_expand_macro)?
|
||||
.on::<lsp_ext::ParentModule>(handlers::handle_parent_module)?
|
||||
.on::<lsp_ext::Runnables>(handlers::handle_runnables)?
|
||||
.on::<lsp_ext::InlayHints>(handlers::handle_inlay_hints)?
|
||||
.on::<lsp_ext::CodeActionRequest>(handlers::handle_code_action)?
|
||||
.on::<lsp_ext::ResolveCodeActionRequest>(handlers::handle_resolve_code_action)?
|
||||
.on::<lsp_ext::HoverRequest>(handlers::handle_hover)?
|
||||
.on::<lsp_ext::ExternalDocs>(handlers::handle_open_docs)?
|
||||
.on::<lsp_types::request::OnTypeFormatting>(handlers::handle_on_type_formatting)?
|
||||
.on::<lsp_types::request::DocumentSymbolRequest>(handlers::handle_document_symbol)?
|
||||
.on::<lsp_types::request::WorkspaceSymbol>(handlers::handle_workspace_symbol)?
|
||||
.on::<lsp_types::request::GotoDefinition>(handlers::handle_goto_definition)?
|
||||
.on::<lsp_types::request::GotoImplementation>(handlers::handle_goto_implementation)?
|
||||
.on::<lsp_types::request::GotoTypeDefinition>(handlers::handle_goto_type_definition)?
|
||||
.on::<lsp_types::request::Completion>(handlers::handle_completion)?
|
||||
.on::<lsp_types::request::CodeLensRequest>(handlers::handle_code_lens)?
|
||||
.on::<lsp_types::request::CodeLensResolve>(handlers::handle_code_lens_resolve)?
|
||||
.on::<lsp_types::request::FoldingRangeRequest>(handlers::handle_folding_range)?
|
||||
.on::<lsp_types::request::SignatureHelpRequest>(handlers::handle_signature_help)?
|
||||
.on::<lsp_types::request::PrepareRenameRequest>(handlers::handle_prepare_rename)?
|
||||
.on::<lsp_types::request::Rename>(handlers::handle_rename)?
|
||||
.on::<lsp_types::request::References>(handlers::handle_references)?
|
||||
.on::<lsp_types::request::Formatting>(handlers::handle_formatting)?
|
||||
.on::<lsp_types::request::DocumentHighlightRequest>(
|
||||
handlers::handle_document_highlight,
|
||||
)?
|
||||
.on::<lsp_types::request::CallHierarchyPrepare>(
|
||||
handlers::handle_call_hierarchy_prepare,
|
||||
)?
|
||||
.on::<lsp_ext::AnalyzerStatus>(handlers::handle_analyzer_status)
|
||||
.on::<lsp_ext::SyntaxTree>(handlers::handle_syntax_tree)
|
||||
.on::<lsp_ext::ExpandMacro>(handlers::handle_expand_macro)
|
||||
.on::<lsp_ext::ParentModule>(handlers::handle_parent_module)
|
||||
.on::<lsp_ext::Runnables>(handlers::handle_runnables)
|
||||
.on::<lsp_ext::InlayHints>(handlers::handle_inlay_hints)
|
||||
.on::<lsp_ext::CodeActionRequest>(handlers::handle_code_action)
|
||||
.on::<lsp_ext::ResolveCodeActionRequest>(handlers::handle_resolve_code_action)
|
||||
.on::<lsp_ext::HoverRequest>(handlers::handle_hover)
|
||||
.on::<lsp_ext::ExternalDocs>(handlers::handle_open_docs)
|
||||
.on::<lsp_types::request::OnTypeFormatting>(handlers::handle_on_type_formatting)
|
||||
.on::<lsp_types::request::DocumentSymbolRequest>(handlers::handle_document_symbol)
|
||||
.on::<lsp_types::request::WorkspaceSymbol>(handlers::handle_workspace_symbol)
|
||||
.on::<lsp_types::request::GotoDefinition>(handlers::handle_goto_definition)
|
||||
.on::<lsp_types::request::GotoImplementation>(handlers::handle_goto_implementation)
|
||||
.on::<lsp_types::request::GotoTypeDefinition>(handlers::handle_goto_type_definition)
|
||||
.on::<lsp_types::request::Completion>(handlers::handle_completion)
|
||||
.on::<lsp_types::request::CodeLensRequest>(handlers::handle_code_lens)
|
||||
.on::<lsp_types::request::CodeLensResolve>(handlers::handle_code_lens_resolve)
|
||||
.on::<lsp_types::request::FoldingRangeRequest>(handlers::handle_folding_range)
|
||||
.on::<lsp_types::request::SignatureHelpRequest>(handlers::handle_signature_help)
|
||||
.on::<lsp_types::request::PrepareRenameRequest>(handlers::handle_prepare_rename)
|
||||
.on::<lsp_types::request::Rename>(handlers::handle_rename)
|
||||
.on::<lsp_types::request::References>(handlers::handle_references)
|
||||
.on::<lsp_types::request::Formatting>(handlers::handle_formatting)
|
||||
.on::<lsp_types::request::DocumentHighlightRequest>(handlers::handle_document_highlight)
|
||||
.on::<lsp_types::request::CallHierarchyPrepare>(handlers::handle_call_hierarchy_prepare)
|
||||
.on::<lsp_types::request::CallHierarchyIncomingCalls>(
|
||||
handlers::handle_call_hierarchy_incoming,
|
||||
)?
|
||||
)
|
||||
.on::<lsp_types::request::CallHierarchyOutgoingCalls>(
|
||||
handlers::handle_call_hierarchy_outgoing,
|
||||
)?
|
||||
)
|
||||
.on::<lsp_types::request::SemanticTokensFullRequest>(
|
||||
handlers::handle_semantic_tokens_full,
|
||||
)?
|
||||
)
|
||||
.on::<lsp_types::request::SemanticTokensFullDeltaRequest>(
|
||||
handlers::handle_semantic_tokens_full_delta,
|
||||
)?
|
||||
)
|
||||
.on::<lsp_types::request::SemanticTokensRangeRequest>(
|
||||
handlers::handle_semantic_tokens_range,
|
||||
)?
|
||||
.on::<lsp_ext::Ssr>(handlers::handle_ssr)?
|
||||
)
|
||||
.on::<lsp_ext::Ssr>(handlers::handle_ssr)
|
||||
.finish();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user