Table of Contents

Class WorkspaceEditFiles

Namespace
RDCore.SDK.Client
Assembly
RDCore.SDK.dll

Applies a workspace edit (LSP 3.17 §WorkspaceEdit) to the files on disk, for a client that keeps no document open: each file is read in its encoding, edited, and written back in it (ModuleFileText).

public sealed class WorkspaceEditFiles
Inheritance
WorkspaceEditFiles
Inherited Members

Remarks

The edit is applied whole or not at all, as far as a file system allows: every change is made in memory first, and a change that cannot be made (a document whose version is not the client's, a file that does not exist, a text its encoding cannot write, an edit that does not fit the text) refuses the edit before any file is written. Then each file is written atomically; a write that fails stops there, and the result says which files were written before it.

Text edits only: creating, renaming and deleting files (resource operations) are refused, and a client that uses this says none in its workspace.workspaceEdit.resourceOperations capability. Several changes of one document are made in the order the edit lists them.

Constructors

WorkspaceEditFiles(IFileSystem, int)

Applies a workspace edit (LSP 3.17 §WorkspaceEdit) to the files on disk, for a client that keeps no document open: each file is read in its encoding, edited, and written back in it (ModuleFileText).

public WorkspaceEditFiles(IFileSystem fileSystem, int ansiCodePage)

Parameters

fileSystem IFileSystem

The file system the files are on.

ansiCodePage int

The code page a file without a byte order mark that is not valid UTF-8 is read and written in: the environment's (Environment.AnsiCodePage), or DefaultAnsiCodePage.

Remarks

The edit is applied whole or not at all, as far as a file system allows: every change is made in memory first, and a change that cannot be made (a document whose version is not the client's, a file that does not exist, a text its encoding cannot write, an edit that does not fit the text) refuses the edit before any file is written. Then each file is written atomically; a write that fails stops there, and the result says which files were written before it.

Text edits only: creating, renaming and deleting files (resource operations) are refused, and a client that uses this says none in its workspace.workspaceEdit.resourceOperations capability. Several changes of one document are made in the order the edit lists them.

Methods

ApplyAsync(WorkspaceEdit, Func<DocumentUri, int?>, CancellationToken)

Applies a workspace edit to the files it changes.

public Task<WorkspaceEditFilesResult> ApplyAsync(WorkspaceEdit edit, Func<DocumentUri, int?> versionOf, CancellationToken token)

Parameters

edit WorkspaceEdit

The edit: its document changes, or else its changes.

versionOf Func<DocumentUri, int?>

The version the client has of a document, null for one it has not opened. A change that names a version applies only to that version.

token CancellationToken

A token that cancels the edit; a file being written is written whole.

Returns

Task<WorkspaceEditFilesResult>

Whether the edit was applied, and the files written.