internal/lsp: support lazy code action edit resolution
In LSP, the client asks the server for a list of code actions based on
where the client's cursor is. A lot of clients (editors) will make this
request after almost every key-stroke. Consquently we need it to be
fast.
The reply from the server, by default, includes the edits necessary to
apply each available code action. This means that the editor can apply
an code action the user chooses without a furth round-trip to the
server, but the downside is that the server has to calculate all the
edits ahead of time.
Clients can advertise to the server that they support lazy resolution of
the edits. This allows the server to reply to the initial request for
code actions with the edits elided. Once the user has then chosen a code
action, the client will make a subsequent round-trip to the server to
get the edits for the chosen code action only. This means we can delay
calculating edits ahead of time.
Because this is an optional client capability, we have to support both
approaches.
Signed-off-by: Matthew Sackman <matthew@cue.works>
Change-Id: I8d96b5786e0bfc72b5122d714287f3342efdb42a
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1235165
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>