import { AbstractWatcher , AutoWire , Logger , MavenProfilesMap } from "@vmware/vrdt-common" ; import { Disposable } from "vscode-languageserver" ; import { remote } from "../../public" ; import { ConnectionLocator } from "../core/ConnectionLocator" ; export type ProfilesChangeListener = ( event : MavenProfilesMap ) => void ; @ AutoWire export class MavenProfileWatcher extends AbstractWatcher < MavenProfilesMap > implements Disposable { protected readonly logger = Logger . get ( "MavenProfileWatcher" ) ; private readonly subscriptions : Disposable [ ] = [ ] ; constructor ( connectionLocator ) { super ( ) ; connectionLocator . connection . onNotification ( remote . client . didChangeMavenProfiles , ( profiles ) => this . mavenProfilesChanged ( profiles ) ) ; } onDidChangeMavenProfiles ( listener ) { return this . registerListener ( listener ) ; } dispose ( ) { this . logger . debug ( "Disposing MavenProfileWatcher" ) ; this . subscriptions . forEach ( s => s && s . dispose ( ) ) ; } private mavenProfilesChanged ( profiles ) { this . logger . debug ( `Received notification about changed maven profiles.` , profiles ) ; if ( profiles ) { this . notifyListeners ( profiles ) ; } } }