@@ -6,11 +6,14 @@ import {
6
6
CompletionList ,
7
7
CompletionParams ,
8
8
Diagnostic ,
9
+ DidChangeWatchedFilesNotification ,
9
10
Disposable ,
10
11
DocumentLink ,
11
12
DocumentLinkRequest ,
12
13
DocumentSymbol ,
13
14
DocumentSymbolRequest ,
15
+ FileChangeType ,
16
+ FileEvent ,
14
17
Hover ,
15
18
NotificationHandler ,
16
19
ProtocolConnection ,
@@ -85,6 +88,12 @@ export interface DocumentDescriptor {
85
88
settings ?: Settings
86
89
}
87
90
91
+ export interface ChangedFiles {
92
+ created ?: string [ ]
93
+ changed ?: string [ ]
94
+ deleted ?: string [ ]
95
+ }
96
+
88
97
export interface ClientDocument {
89
98
/**
90
99
* The URI to the document
@@ -203,6 +212,11 @@ export interface Client extends ClientWorkspace {
203
212
*/
204
213
onServerCapabilitiesChanged ( cb : ( ) => void ) : void
205
214
215
+ /**
216
+ * Tell the server that files on disk have changed
217
+ */
218
+ notifyChangedFiles ( changes : ChangedFiles ) : Promise < void >
219
+
206
220
/**
207
221
* Get a workspace by name
208
222
*/
@@ -533,12 +547,33 @@ export async function createClient(opts: ClientOptions): Promise<Client> {
533
547
await initPromise
534
548
}
535
549
550
+ function notifyChangedFiles ( changes : ChangedFiles ) {
551
+ let events : FileEvent [ ] = [ ]
552
+
553
+ for ( const path of changes ?. created ?? [ ] ) {
554
+ events . push ( { uri : URI . file ( path ) . toString ( ) , type : FileChangeType . Created } )
555
+ }
556
+
557
+ for ( const path of changes ?. changed ?? [ ] ) {
558
+ events . push ( { uri : URI . file ( path ) . toString ( ) , type : FileChangeType . Changed } )
559
+ }
560
+
561
+ for ( const path of changes ?. deleted ?? [ ] ) {
562
+ events . push ( { uri : URI . file ( path ) . toString ( ) , type : FileChangeType . Deleted } )
563
+ }
564
+
565
+ return conn . sendNotification ( DidChangeWatchedFilesNotification . type , {
566
+ changes : events ,
567
+ } )
568
+ }
569
+
536
570
return {
537
571
...clientWorkspaces [ 0 ] ,
538
572
get serverCapabilities ( ) {
539
573
return registeredCapabilities
540
574
} ,
541
575
onServerCapabilitiesChanged,
576
+ notifyChangedFiles,
542
577
workspace,
543
578
updateSettings,
544
579
}
0 commit comments