lsp-types icon indicating copy to clipboard operation
lsp-types copied to clipboard

Returning partial results

Open kjeremy opened this issue 4 years ago • 2 comments

While doing #155 I realized that only semantic tokens can handle a partial result in it's Request::Result. Would it make sense to add a new trait for requests that can return partial results instead of making every result an enum?

pub trait PartialRequest : Request {
    type PartialResult: DeserializeOwned + Serialize;
}

kjeremy avatar Apr 23 '20 14:04 kjeremy

Can any request return a partial result? Not sure how this is supposed to work. Does it make sense to just provide a generic struct to be used if a partial result is accepted

pub struct Partial<T> {
    #[serde(flatten)]
    pub result: T,
    #[serde(flatten)]
    pub work_done_progress_params: WorkDoneProgressParams,
}

Marwes avatar Apr 24 '20 06:04 Marwes

Not all requests can return partial results and some can report progress without returning partial results.

See https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#workDoneProgress and https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#partialResults

I do like the idea of making things generic though.

kjeremy avatar Apr 24 '20 12:04 kjeremy