1 import { NotificationHandler, RequestHandler } from 'vscode-jsonrpc';
2 import { WorkspaceEdit } from 'vscode-languageserver-types';
3 import { ProtocolNotificationType, ProtocolRequestType } from './messages';
5 * Options for notifications/requests for user operations on files.
9 export interface FileOperationOptions {
11 * The server is interested in didCreateFiles notifications.
13 didCreate?: FileOperationRegistrationOptions;
15 * The server is interested in willCreateFiles requests.
17 willCreate?: FileOperationRegistrationOptions;
19 * The server is interested in didRenameFiles notifications.
21 didRename?: FileOperationRegistrationOptions;
23 * The server is interested in willRenameFiles requests.
25 willRename?: FileOperationRegistrationOptions;
27 * The server is interested in didDeleteFiles file notifications.
29 didDelete?: FileOperationRegistrationOptions;
31 * The server is interested in willDeleteFiles file requests.
33 willDelete?: FileOperationRegistrationOptions;
36 * The options to register for file operations.
40 export interface FileOperationRegistrationOptions {
44 filters: FileOperationFilter[];
47 * A pattern kind describing if a glob pattern matches a file a folder or
52 export declare namespace FileOperationPatternKind {
54 * The pattern matches a file only.
58 * The pattern matches a folder only.
60 const folder: 'folder';
62 export declare type FileOperationPatternKind = 'file' | 'folder';
64 * Matching options for the file operation pattern.
68 export interface FileOperationPatternOptions {
70 * The pattern should be matched ignoring casing.
75 * A pattern to describe in which file operation requests or notifications
76 * the server is interested in.
80 interface FileOperationPattern {
82 * The glob pattern to match. Glob patterns can have the following syntax:
83 * - `*` to match one or more characters in a path segment
84 * - `?` to match on one character in a path segment
85 * - `**` to match any number of path segments, including none
86 * - `{}` to group conditions (e.g. `**/*.{ts,js}` matches all TypeScript and JavaScript files)
87 * - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
88 * - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
92 * Whether to match files or folders with this pattern.
94 * Matches both if undefined.
96 matches?: FileOperationPatternKind;
98 * Additional options used during matching.
100 options?: FileOperationPatternOptions;
103 * A filter to describe in which file operation requests or notifications
104 * the server is interested in.
108 export interface FileOperationFilter {
110 * A Uri like `file` or `untitled`.
114 * The actual file operation pattern.
116 pattern: FileOperationPattern;
119 * Capabilities relating to events from file operations by the user in the client.
121 * These events do not come from the file system, they come from user operations
122 * like renaming a file in the UI.
126 export interface FileOperationClientCapabilities {
128 * Whether the client supports dynamic registration for file requests/notifications.
130 dynamicRegistration?: boolean;
132 * The client has support for sending didCreateFiles notifications.
136 * The client has support for willCreateFiles requests.
138 willCreate?: boolean;
140 * The client has support for sending didRenameFiles notifications.
144 * The client has support for willRenameFiles requests.
146 willRename?: boolean;
148 * The client has support for sending didDeleteFiles notifications.
152 * The client has support for willDeleteFiles requests.
154 willDelete?: boolean;
157 * The parameters sent in file create requests/notifications.
161 export interface CreateFilesParams {
163 * An array of all files/folders created in this operation.
168 * Represents information on a file/folder create.
172 export interface FileCreate {
174 * A file:// URI for the location of the file/folder being created.
179 * The parameters sent in file rename requests/notifications.
183 export interface RenameFilesParams {
185 * An array of all files/folders renamed in this operation. When a folder is renamed, only
186 * the folder will be included, and not its children.
191 * Represents information on a file/folder rename.
195 export interface FileRename {
197 * A file:// URI for the original location of the file/folder being renamed.
201 * A file:// URI for the new location of the file/folder being renamed.
206 * The parameters sent in file delete requests/notifications.
210 export interface DeleteFilesParams {
212 * An array of all files/folders deleted in this operation.
217 * Represents information on a file/folder delete.
221 export interface FileDelete {
223 * A file:// URI for the location of the file/folder being deleted.
228 * The will create files request is sent from the client to the server before files are actually
229 * created as long as the creation is triggered from within the client.
233 export declare namespace WillCreateFilesRequest {
234 const method: 'workspace/willCreateFiles';
235 const type: ProtocolRequestType<CreateFilesParams, WorkspaceEdit | null, never, void, FileOperationRegistrationOptions>;
236 type HandlerSignature = RequestHandler<CreateFilesParams, WorkspaceEdit | undefined | null, void>;
239 * The did create files notification is sent from the client to the server when
240 * files were created from within the client.
244 export declare namespace DidCreateFilesNotification {
245 const method: 'workspace/didCreateFiles';
246 const type: ProtocolNotificationType<CreateFilesParams, FileOperationRegistrationOptions>;
247 type HandlerSignature = NotificationHandler<CreateFilesParams>;
250 * The will rename files request is sent from the client to the server before files are actually
251 * renamed as long as the rename is triggered from within the client.
255 export declare namespace WillRenameFilesRequest {
256 const method: 'workspace/willRenameFiles';
257 const type: ProtocolRequestType<RenameFilesParams, WorkspaceEdit | null, never, void, FileOperationRegistrationOptions>;
258 type HandlerSignature = RequestHandler<RenameFilesParams, WorkspaceEdit | undefined | null, void>;
261 * The did rename files notification is sent from the client to the server when
262 * files were renamed from within the client.
266 export declare namespace DidRenameFilesNotification {
267 const method: 'workspace/didRenameFiles';
268 const type: ProtocolNotificationType<RenameFilesParams, FileOperationRegistrationOptions>;
269 type HandlerSignature = NotificationHandler<RenameFilesParams>;
272 * The will delete files request is sent from the client to the server before files are actually
273 * deleted as long as the deletion is triggered from within the client.
277 export declare namespace DidDeleteFilesNotification {
278 const method: 'workspace/didDeleteFiles';
279 const type: ProtocolNotificationType<DeleteFilesParams, FileOperationRegistrationOptions>;
280 type HandlerSignature = NotificationHandler<DeleteFilesParams>;
283 * The did delete files notification is sent from the client to the server when
284 * files were deleted from within the client.
288 export declare namespace WillDeleteFilesRequest {
289 const method: 'workspace/willDeleteFiles';
290 const type: ProtocolRequestType<DeleteFilesParams, WorkspaceEdit | null, never, void, FileOperationRegistrationOptions>;
291 type HandlerSignature = RequestHandler<DeleteFilesParams, WorkspaceEdit | undefined | null, void>;