1 | import * as code from 'vscode';
|
2 | import * as proto from 'vscode-languageserver-protocol';
|
3 | import { DynamicFeature, RegistrationData, NextSignature, FeatureState, FeatureClient } from './features';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export interface FileOperationsMiddleware {
|
10 | didCreateFiles?: NextSignature<code.FileCreateEvent, Promise<void>>;
|
11 | willCreateFiles?: NextSignature<code.FileWillCreateEvent, Thenable<code.WorkspaceEdit | null | undefined>>;
|
12 | didRenameFiles?: NextSignature<code.FileRenameEvent, Promise<void>>;
|
13 | willRenameFiles?: NextSignature<code.FileWillRenameEvent, Thenable<code.WorkspaceEdit | null | undefined>>;
|
14 | didDeleteFiles?: NextSignature<code.FileDeleteEvent, Promise<void>>;
|
15 | willDeleteFiles?: NextSignature<code.FileWillDeleteEvent, Thenable<code.WorkspaceEdit | null | undefined>>;
|
16 | }
|
17 | interface FileOperationsWorkspaceMiddleware {
|
18 | workspace?: FileOperationsMiddleware;
|
19 | }
|
20 | interface Event<I> {
|
21 | readonly files: ReadonlyArray<I>;
|
22 | }
|
23 | declare abstract class FileOperationFeature<I, E extends Event<I>> implements DynamicFeature<proto.FileOperationRegistrationOptions> {
|
24 | protected readonly _client: FeatureClient<FileOperationsWorkspaceMiddleware>;
|
25 | private readonly _event;
|
26 | private readonly _registrationType;
|
27 | private readonly _clientCapability;
|
28 | private readonly _serverCapability;
|
29 | private _listener;
|
30 | private readonly _filters;
|
31 | constructor(client: FeatureClient<FileOperationsWorkspaceMiddleware>, event: code.Event<E>, registrationType: proto.RegistrationType<proto.FileOperationRegistrationOptions>, clientCapability: keyof proto.FileOperationClientCapabilities, serverCapability: keyof proto.FileOperationOptions);
|
32 | getState(): FeatureState;
|
33 | protected filterSize(): number;
|
34 | get registrationType(): proto.RegistrationType<proto.FileOperationRegistrationOptions>;
|
35 | fillClientCapabilities(capabilities: proto.ClientCapabilities): void;
|
36 | initialize(capabilities: proto.ServerCapabilities): void;
|
37 | register(data: RegistrationData<proto.FileOperationRegistrationOptions>): void;
|
38 | abstract send(data: E): Promise<void>;
|
39 | unregister(id: string): void;
|
40 | clear(): void;
|
41 | protected getFileType(uri: code.Uri): Promise<code.FileType | undefined>;
|
42 | protected filter(event: E, prop: (i: I) => code.Uri): Promise<E>;
|
43 | protected static getFileType(uri: code.Uri): Promise<code.FileType | undefined>;
|
44 | private static asMinimatchOptions;
|
45 | }
|
46 | declare abstract class NotificationFileOperationFeature<I, E extends {
|
47 | readonly files: ReadonlyArray<I>;
|
48 | }, P> extends FileOperationFeature<I, E> {
|
49 | private _notificationType;
|
50 | private _accessUri;
|
51 | private _createParams;
|
52 | constructor(client: FeatureClient<FileOperationsWorkspaceMiddleware>, event: code.Event<E>, notificationType: proto.ProtocolNotificationType<P, proto.FileOperationRegistrationOptions>, clientCapability: keyof proto.FileOperationClientCapabilities, serverCapability: keyof proto.FileOperationOptions, accessUri: (i: I) => code.Uri, createParams: (e: E) => P);
|
53 | send(originalEvent: E): Promise<void>;
|
54 | protected abstract doSend(event: E, next: (event: E) => Promise<void>): Promise<void>;
|
55 | }
|
56 | declare abstract class CachingNotificationFileOperationFeature<I, E extends {
|
57 | readonly files: ReadonlyArray<I>;
|
58 | }, P> extends NotificationFileOperationFeature<I, E, P> {
|
59 | protected _willListener: code.Disposable | undefined;
|
60 | private readonly _fsPathFileTypes;
|
61 | protected getFileType(uri: code.Uri): Promise<code.FileType | undefined>;
|
62 | protected cacheFileTypes(event: E, prop: (i: I) => code.Uri): Promise<void>;
|
63 | protected clearFileTypeCache(): void;
|
64 | unregister(id: string): void;
|
65 | clear(): void;
|
66 | }
|
67 | export declare class DidCreateFilesFeature extends NotificationFileOperationFeature<code.Uri, code.FileCreateEvent, proto.CreateFilesParams> {
|
68 | constructor(client: FeatureClient<FileOperationsWorkspaceMiddleware>);
|
69 | protected doSend(event: code.FileCreateEvent, next: (event: code.FileCreateEvent) => Promise<void>): Promise<void>;
|
70 | }
|
71 | export declare class DidRenameFilesFeature extends CachingNotificationFileOperationFeature<{
|
72 | oldUri: code.Uri;
|
73 | newUri: code.Uri;
|
74 | }, code.FileRenameEvent, proto.RenameFilesParams> {
|
75 | constructor(client: FeatureClient<FileOperationsWorkspaceMiddleware>);
|
76 | register(data: RegistrationData<proto.FileOperationRegistrationOptions>): void;
|
77 | private willRename;
|
78 | protected doSend(event: code.FileRenameEvent, next: (event: code.FileRenameEvent) => Promise<void>): Promise<void>;
|
79 | }
|
80 | export declare class DidDeleteFilesFeature extends CachingNotificationFileOperationFeature<code.Uri, code.FileDeleteEvent, proto.DeleteFilesParams> {
|
81 | constructor(client: FeatureClient<FileOperationsWorkspaceMiddleware>);
|
82 | register(data: RegistrationData<proto.FileOperationRegistrationOptions>): void;
|
83 | private willDelete;
|
84 | protected doSend(event: code.FileCreateEvent, next: (event: code.FileCreateEvent) => Promise<void>): Promise<void>;
|
85 | }
|
86 | interface RequestEvent<I> {
|
87 | readonly token: code.CancellationToken;
|
88 | readonly files: ReadonlyArray<I>;
|
89 | waitUntil(thenable: Thenable<code.WorkspaceEdit>): void;
|
90 | waitUntil(thenable: Thenable<any>): void;
|
91 | }
|
92 | declare abstract class RequestFileOperationFeature<I, E extends RequestEvent<I>, P> extends FileOperationFeature<I, E> {
|
93 | private _requestType;
|
94 | private _accessUri;
|
95 | private _createParams;
|
96 | constructor(client: FeatureClient<FileOperationsWorkspaceMiddleware>, event: code.Event<E>, requestType: proto.ProtocolRequestType<P, proto.WorkspaceEdit | null, never, void, proto.FileOperationRegistrationOptions>, clientCapability: keyof proto.FileOperationClientCapabilities, serverCapability: keyof proto.FileOperationOptions, accessUri: (i: I) => code.Uri, createParams: (e: Event<I>) => P);
|
97 | send(originalEvent: E & RequestEvent<I>): Promise<void>;
|
98 | private waitUntil;
|
99 | protected abstract doSend(event: E, next: (event: RequestEvent<I>) => Thenable<code.WorkspaceEdit> | Thenable<any>): Thenable<code.WorkspaceEdit> | Thenable<any>;
|
100 | }
|
101 | export declare class WillCreateFilesFeature extends RequestFileOperationFeature<code.Uri, code.FileWillCreateEvent, proto.CreateFilesParams> {
|
102 | constructor(client: FeatureClient<FileOperationsWorkspaceMiddleware>);
|
103 | protected doSend(event: code.FileWillCreateEvent, next: (event: code.FileWillCreateEvent) => Thenable<code.WorkspaceEdit> | Thenable<any>): Thenable<code.WorkspaceEdit> | Thenable<any>;
|
104 | }
|
105 | export declare class WillRenameFilesFeature extends RequestFileOperationFeature<{
|
106 | oldUri: code.Uri;
|
107 | newUri: code.Uri;
|
108 | }, code.FileWillRenameEvent, proto.RenameFilesParams> {
|
109 | constructor(client: FeatureClient<FileOperationsWorkspaceMiddleware>);
|
110 | protected doSend(event: code.FileWillRenameEvent, next: (event: code.FileWillRenameEvent) => Thenable<code.WorkspaceEdit> | Thenable<any>): Thenable<code.WorkspaceEdit> | Thenable<any>;
|
111 | }
|
112 | export declare class WillDeleteFilesFeature extends RequestFileOperationFeature<code.Uri, code.FileWillDeleteEvent, proto.DeleteFilesParams> {
|
113 | constructor(client: FeatureClient<FileOperationsWorkspaceMiddleware>);
|
114 | protected doSend(event: code.FileWillDeleteEvent, next: (event: code.FileWillDeleteEvent) => Thenable<code.WorkspaceEdit> | Thenable<any>): Thenable<code.WorkspaceEdit> | Thenable<any>;
|
115 | }
|
116 | export {};
|