import { AbstractWatcher , AutoWire , Logger } from "@vmware/vrdt-common" ; import { Disposable , WorkspaceFoldersChangeEvent } from "vscode-languageserver" ; import { ConnectionLocator } from "./ConnectionLocator" ; import { Initializer } from "./Initializer" ; export type WorkspaceChangeListener = ( event : WorkspaceFoldersChangeEvent ) => void ; @ AutoWire export class WorkspaceFoldersWatcher extends AbstractWatcher < WorkspaceFoldersChangeEvent > { protected readonly logger = Logger . get ( "WorkspaceFoldersWatcher" ) ; constructor ( connectionLocator , initializer ) { super ( ) ; initializer . onInitialized ( ( ) => { connectionLocator . connection . workspace . onDidChangeWorkspaceFolders ( this . watchedFilesChanged , this ) ; } ) ; } onDidChangeWorkspaceFolders ( listener ) { return this . registerListener ( listener ) ; } private watchedFilesChanged ( event ) { this . logger . info ( "The number of opened workspace folders has changed." ) ; this . logger . debug ( "Full list of changes: " , event ) ; this . notifyListeners ( event ) ; } }