Path: blob/main/src/vs/workbench/contrib/debug/common/debugAccessibilityAnnouncer.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { IDebugService } from './debug.js';6import { Disposable, IDisposable, MutableDisposable } from '../../../../base/common/lifecycle.js';7import { IWorkbenchContribution } from '../../../common/contributions.js';8import { ILogService } from '../../../../platform/log/common/log.js';9import { IAccessibilityService } from '../../../../platform/accessibility/common/accessibility.js';10import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';11import { Expression } from './debugModel.js';1213export class DebugWatchAccessibilityAnnouncer extends Disposable implements IWorkbenchContribution {14static ID = 'workbench.contrib.debugWatchAccessibilityAnnouncer';15private readonly _listener: MutableDisposable<IDisposable> = this._register(new MutableDisposable());16constructor(17@IDebugService private readonly _debugService: IDebugService,18@ILogService private readonly _logService: ILogService,19@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,20@IConfigurationService private readonly _configurationService: IConfigurationService21) {22super();23this._setListener();24this._register(_configurationService.onDidChangeConfiguration(e => {25if (e.affectsConfiguration('accessibility.debugWatchVariableAnnouncements')) {26this._setListener();27}28}));29}3031private _setListener(): void {32const value = this._configurationService.getValue('accessibility.debugWatchVariableAnnouncements');33if (value && !this._listener.value) {34this._listener.value = this._debugService.getModel().onDidChangeWatchExpressionValue((e) => {35if (!e || e.value === Expression.DEFAULT_VALUE) {36return;37}3839// TODO: get user feedback, perhaps setting to configure verbosity + whether value, name, neither, or both are announced40this._accessibilityService.alert(`${e.name} = ${e.value}`);41this._logService.trace(`debugAccessibilityAnnouncerValueChanged ${e.name} ${e.value}`);42});43} else {44this._listener.clear();45}46}47}484950