Class IncomingDocumentChanges
The changes to documents that the client has sent and the server has not applied yet: a request about a document one of them changes is answered
ContentModified (-32801) at once, instead of keeping the change, and every request the client sends after it, waiting until it ends.
public sealed class IncomingDocumentChanges
- Inheritance
-
IncomingDocumentChanges
- Inherited Members
Remarks
OmniSharp runs a notification that changes a document (textDocument/didOpen, didChange, didClose) in order, after the requests already
running, which it runs in parallel. An RDCore server answers every request (WithEveryRequestAnswered(LanguageServerOptions)), so a keystroke
that arrives while the document's diagnostics are being pulled waits for the pull, and so does the completion the client sends after it: on a module of
2,100 lines, about five seconds (HexIDE's findings desk #31).
The server knows of a change as it arrives (Tap(Stream)), long before its turn comes. A request made of what the document was says so with
WhileCurrentAsync<T>(Uri, CancellationToken, Func<CancellationToken, Task<T>>): when a change to its document arrives while it runs, or has arrived and is not applied yet when it starts, the request
stops and is answered ContentModified, which LSP 3.17 §Response Message has a server answer "if it detects a content change in its unprocessed
messages". The client asks again for the document as it is now. A change to another document changes nothing for it.
Methods
Applied(Uri)
A change to a document has been applied: the server's handler of the notification has run.
public void Applied(Uri document)
Parameters
documentUriThe document the change was to.
Arrived(Uri)
A change to a document has arrived from the client, and is waiting for its turn: the requests about the document that are running are answered
ContentModified, and so is each that starts before the change is applied. A change to a document the server does not serve
(Serve(Func<Uri, bool>)) is nothing.
public void Arrived(Uri document)
Parameters
documentUriThe document the change is to.
ContentModified()
The error a request about a document is answered with when the document changed while the answer was made: ContentModified (-32801), which the
client asks again after.
public static RpcErrorException ContentModified()
Returns
Remarks
OmniSharp answers an OperationCanceledException RequestCancelled, its own ContentModifiedException included: an
RpcErrorException is answered its code.
Serve(TextDocumentSelector)
Says that the server's handlers apply a change to the documents a selector matches, which is what they are registered for: the client names a document's language its own way, so a filter of the selector is matched by the document's path alone.
public void Serve(TextDocumentSelector selector)
Parameters
selectorTextDocumentSelectorWhat the handlers of a document's notifications are registered for.
Serve(Func<Uri, bool>)
Says which documents the server's handlers apply a change to (Applied(Uri)). A change to any other is no change of the server's: OmniSharp hands it to no handler, so it is never applied, and is not waited for.
public void Serve(Func<Uri, bool> serves)
Parameters
Tap(Stream)
Wraps the stream the server reads its client's messages from, so that a change to a document is known as it arrives (Arrived(Uri)). What is read is passed on unchanged.
public Stream Tap(Stream input)
Parameters
inputStreamThe stream the client's messages arrive on.
Returns
- Stream
The stream to read them from.
WhileCurrentAsync<T>(Uri, CancellationToken, Func<CancellationToken, Task<T>>)
Answers a request about a document with what answer makes of it, unless a change to the document arrives first: then the request
stops, and is answered ContentModified (-32801).
public Task<T> WhileCurrentAsync<T>(Uri document, CancellationToken token, Func<CancellationToken, Task<T>> answer)
Parameters
documentUriThe document the request is about.
tokenCancellationTokenThe request's own token, which the client cancels.
answerFunc<CancellationToken, Task<T>>Makes the answer, with a token that is cancelled when the client cancels the request or a change to the document arrives.
Returns
- Task<T>
The answer.
Type Parameters
TWhat the request answers.
Exceptions
- RpcErrorException
A change to the document arrived before the answer was made: the error is ContentModified.
WhileWorkspaceCurrentAsync<T>(CancellationToken, Func<CancellationToken, Task<T>>)
Answers a request about every document of the workspace with what answer makes of them, unless a change to any document arrives
first: then the request stops, and is answered ContentModified (-32801).
public Task<T> WhileWorkspaceCurrentAsync<T>(CancellationToken token, Func<CancellationToken, Task<T>> answer)
Parameters
tokenCancellationTokenThe request's own token, which the client cancels.
answerFunc<CancellationToken, Task<T>>Makes the answer, with a token that is cancelled when the client cancels the request or a change to any document arrives.
Returns
- Task<T>
The answer.
Type Parameters
TWhat the request answers.
Remarks
A request such as workspace/diagnostic is made of every module; a keystroke in any of them would wait for all of them, and the completion the
client sends after it too. The client asks again for the workspace as it is now.
Exceptions
- RpcErrorException
A change to a document arrived before the answer was made: the error is ContentModified.