[analysis_server] Change LSP-over-Legacy to be wrapped with the original protocol

Originally we didn't use the LSP Request/Response classes, and just exposed the handlers through the legacy request/response.

However there were some mismatches (such as legacy protocol always returns Map<String, Object?> but some LSP requests return Lists, LSP using int|String IDs, and LSP having numeric error codes that don't match legacy string error codes).

This change uses LSP's request and Response by wrapping them inside a standard (legacy) handler. The LSP-over-Legacy handler has become a standard handler, and the params contain an "lspMessage" field that holds an LSP message, and the result contains an "lspResponse" field that contains an LSP response.

If an LSP handler returns an error, it will be returned as an error inside the LSP response, which will be in a _successful_ legacy request (since that's how we can return an LSP response - as the result).

Change-Id: I67973590ab32f3543d1a6e1b7279974e5e8832bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315201
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Danny Tuppeny
2023-08-06 14:32:18 +00:00
committed by Commit Queue
parent 678e207a6d
commit 76dc2c4cfa
29 changed files with 684 additions and 195 deletions
@@ -881,6 +881,15 @@ public interface AnalysisServer {
*/
public boolean isSocketOpen();
/**
* {@code lsp.handle}
*
* Call an LSP handler. Message can be requests or notifications.
*
* @param lspMessage The LSP RequestMessage.
*/
public void lsp_handle(Object lspMessage, HandleConsumer consumer);
/**
* Remove the given listener from the list of listeners that will receive notification when new
* analysis results become available.