Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add debug console accessible view #221398

Merged
merged 15 commits into from
Jul 11, 2024
Merged
36 changes: 11 additions & 25 deletions src/vs/editor/contrib/hover/browser/hoverAccessibleViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { localize } from 'vs/nls';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
import { AccessibleViewType, AccessibleViewProviderId, AdvancedContentProvider, IAccessibleViewContentProvider, IAccessibleViewOptions } from 'vs/platform/accessibility/browser/accessibleView';
import { AccessibleViewType, AccessibleViewProviderId, AccessibleContentProvider, IAccessibleViewContentProvider, IAccessibleViewOptions } from 'vs/platform/accessibility/browser/accessibleView';
import { IAccessibleViewImplentation } from 'vs/platform/accessibility/browser/accessibleViewRegistry';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
Expand Down Expand Up @@ -38,7 +38,7 @@ export class HoverAccessibleView implements IAccessibleViewImplentation {

private _provider: HoverAccessibleViewProvider | undefined;

getProvider(accessor: ServicesAccessor): AdvancedContentProvider | undefined {
getProvider(accessor: ServicesAccessor): AccessibleContentProvider | undefined {
const codeEditorService = accessor.get(ICodeEditorService);
const codeEditor = codeEditorService.getActiveCodeEditor() || codeEditorService.getFocusedCodeEditor();
if (!codeEditor) {
Expand All @@ -52,10 +52,6 @@ export class HoverAccessibleView implements IAccessibleViewImplentation {
this._provider = accessor.get(IInstantiationService).createInstance(HoverAccessibleViewProvider, keybindingService, codeEditor, hoverController);
return this._provider;
}

dispose(): void {
this._provider?.dispose();
}
}

export class HoverAccessibilityHelp implements IAccessibleViewImplentation {
Expand All @@ -65,9 +61,7 @@ export class HoverAccessibilityHelp implements IAccessibleViewImplentation {
public readonly type = AccessibleViewType.Help;
public readonly when = EditorContextKeys.hoverVisible;

private _provider: HoverAccessibleViewProvider | undefined;

getProvider(accessor: ServicesAccessor): AdvancedContentProvider | undefined {
getProvider(accessor: ServicesAccessor): AccessibleContentProvider | undefined {
const codeEditorService = accessor.get(ICodeEditorService);
const codeEditor = codeEditorService.getActiveCodeEditor() || codeEditorService.getFocusedCodeEditor();
if (!codeEditor) {
Expand All @@ -79,10 +73,6 @@ export class HoverAccessibilityHelp implements IAccessibleViewImplentation {
}
return accessor.get(IInstantiationService).createInstance(HoverAccessibilityHelpProvider, hoverController);
}

dispose(): void {
this._provider?.dispose();
}
}

abstract class BaseHoverAccessibleViewProvider extends Disposable implements IAccessibleViewContentProvider {
Expand Down Expand Up @@ -124,7 +114,6 @@ abstract class BaseHoverAccessibleViewProvider extends Disposable implements IAc
}
this._focusedHoverPartIndex = -1;
this._hoverController.shouldKeepOpenOnEditorMouseMoveOrLeave = false;
this.dispose();
}

provideContentAtIndex(focusedHoverIndex: number, includeVerbosityActions: boolean): string {
Expand Down Expand Up @@ -247,12 +236,11 @@ export class HoverAccessibleViewProvider extends BaseHoverAccessibleViewProvider
}

export class ExtHoverAccessibleView implements IAccessibleViewImplentation {

public readonly type = AccessibleViewType.View;
public readonly priority = 90;
public readonly name = 'extension-hover';

getProvider(accessor: ServicesAccessor): AdvancedContentProvider | undefined {
getProvider(accessor: ServicesAccessor): AccessibleContentProvider | undefined {
const contextViewService = accessor.get(IContextViewService);
const contextViewElement = contextViewService.getContextViewElement();
const extensionHoverContent = contextViewElement?.textContent ?? undefined;
Expand All @@ -262,16 +250,14 @@ export class ExtHoverAccessibleView implements IAccessibleViewImplentation {
// The accessible view, itself, uses the context view service to display the text. We don't want to read that.
return;
}
return {
id: AccessibleViewProviderId.Hover,
verbositySettingKey: 'accessibility.verbosity.hover',
provideContent() { return extensionHoverContent; },
onClose() {
return new AccessibleContentProvider(
AccessibleViewProviderId.Hover,
{ language: 'typescript', type: AccessibleViewType.View },
() => { return extensionHoverContent; },
() => {
hoverService.showAndFocusLastHover();
},
options: { language: 'typescript', type: AccessibleViewType.View }
};
'accessibility.verbosity.hover',
);
}

dispose() { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { InlineCompletionContextKeys } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionContextKeys';
import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionsController';
import { AccessibleViewType, AccessibleViewProviderId } from 'vs/platform/accessibility/browser/accessibleView';
import { AccessibleViewType, AccessibleViewProviderId, AccessibleContentProvider } from 'vs/platform/accessibility/browser/accessibleView';
import { IAccessibleViewImplentation } from 'vs/platform/accessibility/browser/accessibleViewRegistry';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
Expand All @@ -17,6 +17,7 @@ export class InlineCompletionsAccessibleView extends Disposable implements IAcce
readonly priority = 95;
readonly name = 'inline-completions';
readonly when = ContextKeyExpr.and(InlineCompletionContextKeys.inlineSuggestionVisible);
private _provider: AccessibleContentProvider | undefined;
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
getProvider(accessor: ServicesAccessor) {
const codeEditorService = accessor.get(ICodeEditorService);
function resolveProvider() {
Expand All @@ -35,26 +36,33 @@ export class InlineCompletionsAccessibleView extends Disposable implements IAcce
return;
}
const language = editor.getModel()?.getLanguageId() ?? undefined;
return {
id: AccessibleViewProviderId.InlineCompletions,
verbositySettingKey: 'accessibility.verbosity.inlineCompletions',
provideContent() { return lineText + ghostText; },
onClose() {
return new AccessibleContentProvider(
AccessibleViewProviderId.InlineCompletions,
{ language, type: AccessibleViewType.View },
() => lineText + ghostText,

() => {
model.stop();
editor.focus();
},
next() {
'accessibility.verbosity.inlineCompletions',
undefined,
undefined,
() => {
model.next();
setTimeout(() => resolveProvider(), 50);
},
previous() {
() => {
model.previous();
setTimeout(() => resolveProvider(), 50);
},
options: { language, type: AccessibleViewType.View }
};
);
}
this._provider = resolveProvider();
if (this._provider) {
this._register(this._provider);
}
return resolveProvider();
return this._provider;
}
constructor() {
super();
Expand Down
23 changes: 15 additions & 8 deletions src/vs/platform/accessibility/browser/accessibleView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IPickerQuickAccessItem } from 'vs/platform/quickinput/browser/pickerQui
import { Event } from 'vs/base/common/event';
import { IAction } from 'vs/base/common/actions';
import { IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';

export const IAccessibleViewService = createDecorator<IAccessibleViewService>('accessibleViewService');

Expand All @@ -26,7 +27,8 @@ export const enum AccessibleViewProviderId {
Hover = 'hover',
Notification = 'notification',
EmptyEditorHint = 'emptyEditorHint',
Comments = 'comments'
Comments = 'comments',
DebugConsole = 'debugConsole',
}

export const enum AccessibleViewType {
Expand Down Expand Up @@ -69,7 +71,7 @@ export interface IAccessibleViewOptions {
}


export interface IAccessibleViewContentProvider extends IBasicContentProvider {
export interface IAccessibleViewContentProvider extends IBasicContentProvider, IDisposable {
id: AccessibleViewProviderId;
verbositySettingKey: string;
/**
Expand Down Expand Up @@ -102,6 +104,7 @@ export interface IPosition {

export interface IAccessibleViewService {
readonly _serviceBrand: undefined;
// The provider will be disposed when the view is closed
show(provider: AccesibleViewContentProvider, position?: IPosition): void;
showLastProvider(id: AccessibleViewProviderId): void;
showAccessibleViewHelp(): void;
Expand Down Expand Up @@ -131,9 +134,9 @@ export interface ICodeBlockActionContext {
element: unknown;
}

export type AccesibleViewContentProvider = AdvancedContentProvider | ExtensionContentProvider;
export type AccesibleViewContentProvider = AccessibleContentProvider | ExtensionContentProvider;

export class AdvancedContentProvider implements IAccessibleViewContentProvider {
export class AccessibleContentProvider extends Disposable implements IAccessibleViewContentProvider {

constructor(
public id: AccessibleViewProviderId,
Expand All @@ -149,10 +152,12 @@ export class AdvancedContentProvider implements IAccessibleViewContentProvider {
public onKeyDown?: (e: IKeyboardEvent) => void,
public getSymbols?: () => IAccessibleViewSymbol[],
public onDidRequestClearLastProvider?: Event<AccessibleViewProviderId>,
) { }
) {
super();
}
}

export class ExtensionContentProvider implements IBasicContentProvider {
export class ExtensionContentProvider extends Disposable implements IBasicContentProvider {

constructor(
public readonly id: string,
Expand All @@ -164,10 +169,12 @@ export class ExtensionContentProvider implements IBasicContentProvider {
public previous?: () => void,
public actions?: IAction[],
public onDidChangeContent?: Event<void>,
) { }
) {
super();
}
}

export interface IBasicContentProvider {
export interface IBasicContentProvider extends IDisposable {
id: string;
options: IAccessibleViewOptions;
onClose(): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
*--------------------------------------------------------------------------------------------*/

import { IDisposable } from 'vs/base/common/lifecycle';
import { AccessibleViewType, AdvancedContentProvider, ExtensionContentProvider } from 'vs/platform/accessibility/browser/accessibleView';
import { AccessibleViewType, AccessibleContentProvider, ExtensionContentProvider } from 'vs/platform/accessibility/browser/accessibleView';
import { ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { alert } from 'vs/base/browser/ui/aria/aria';

export interface IAccessibleViewImplentation extends IDisposable {
export interface IAccessibleViewImplentation {
type: AccessibleViewType;
priority: number;
name: string;
/**
* @returns the provider or undefined if the view should not be shown
*/
getProvider: (accessor: ServicesAccessor) => AdvancedContentProvider | ExtensionContentProvider | undefined;
getProvider: (accessor: ServicesAccessor) => AccessibleContentProvider | ExtensionContentProvider | undefined;
when?: ContextKeyExpression | undefined;
}

Expand All @@ -31,7 +31,6 @@ export const AccessibleViewRegistry = new class AccessibleViewRegistry {
if (idx !== -1) {
this._implementations.splice(idx, 1);
}
implementation.dispose();
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { IAction } from 'vs/base/common/actions';
import { Codicon } from 'vs/base/common/codicons';
import { ThemeIcon } from 'vs/base/common/themables';
import { localize } from 'vs/nls';
import { IAccessibleViewService, AccessibleViewProviderId, AccessibleViewType } from 'vs/platform/accessibility/browser/accessibleView';
import { IAccessibleViewImplentation, alertAccessibleViewFocusChange } from 'vs/platform/accessibility/browser/accessibleViewRegistry';
import { IAccessibleViewService, AccessibleViewProviderId, AccessibleViewType, AccessibleContentProvider } from 'vs/platform/accessibility/browser/accessibleView';
import { alertAccessibleViewFocusChange, IAccessibleViewImplentation } from 'vs/platform/accessibility/browser/accessibleViewRegistry';
import { IAccessibilitySignalService, AccessibilitySignal } from 'vs/platform/accessibilitySignal/browser/accessibilitySignalService';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
Expand Down Expand Up @@ -59,15 +59,17 @@ export class NotificationAccessibleView implements IAccessibleViewImplentation {
return;
}
notification.onDidClose(() => accessibleViewService.next());
return {
id: AccessibleViewProviderId.Notification,
provideContent: () => {
return new AccessibleContentProvider(
AccessibleViewProviderId.Notification,
{ type: AccessibleViewType.View },
() => {
return notification.source ? localize('notification.accessibleViewSrc', '{0} Source: {1}', message, notification.source) : localize('notification.accessibleView', '{0}', message);
},
onClose(): void {
focusList();
},
next(): void {
() => focusList(),
'accessibility.verbosity.notification',
undefined,
getActionsFromNotification(notification, accessibilitySignalService),
() => {
if (!list) {
return;
}
Expand All @@ -76,7 +78,7 @@ export class NotificationAccessibleView implements IAccessibleViewImplentation {
alertAccessibleViewFocusChange(notificationIndex, length, 'next');
getProvider();
},
previous(): void {
() => {
if (!list) {
return;
}
Expand All @@ -85,14 +87,10 @@ export class NotificationAccessibleView implements IAccessibleViewImplentation {
alertAccessibleViewFocusChange(notificationIndex, length, 'previous');
getProvider();
},
verbositySettingKey: 'accessibility.verbosity.notification',
options: { type: AccessibleViewType.View },
actions: getActionsFromNotification(notification, accessibilitySignalService)
};
);
}
return getProvider();
}
dispose() { }
}


Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/views/viewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export abstract class ViewPane extends Pane implements IView {
@IThemeService protected themeService: IThemeService,
@ITelemetryService protected telemetryService: ITelemetryService,
@IHoverService protected readonly hoverService: IHoverService,
protected readonly accessibleViewService?: IAccessibleViewInformationService
protected readonly accessibleViewInformationService?: IAccessibleViewInformationService
) {
super({ ...options, ...{ orientation: viewDescriptorService.getViewLocationById(options.id) === ViewContainerLocation.Panel ? Orientation.HORIZONTAL : Orientation.VERTICAL } });

Expand Down Expand Up @@ -553,7 +553,7 @@ export abstract class ViewPane extends Pane implements IView {

private _getAriaLabel(title: string): string {
const viewHasAccessibilityHelpContent = this.viewDescriptorService.getViewDescriptorById(this.id)?.accessibilityHelpContent;
const accessibleViewHasShownForView = this.accessibleViewService?.hasShownAccessibleView(this.id);
const accessibleViewHasShownForView = this.accessibleViewInformationService?.hasShownAccessibleView(this.id);
if (!viewHasAccessibilityHelpContent || accessibleViewHasShownForView) {
return title;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export const enum AccessibilityVerbositySettingId {
EmptyEditorHint = 'accessibility.verbosity.emptyEditorHint',
ReplInputHint = 'accessibility.verbosity.replInputHint',
Comments = 'accessibility.verbosity.comments',
DiffEditorActive = 'accessibility.verbosity.diffEditorActive'
DiffEditorActive = 'accessibility.verbosity.diffEditorActive',
DebugConsole = 'accessibility.verbosity.debugConsole',
}

const baseVerbosityProperty: IConfigurationPropertySchema = {
Expand Down
Loading
Loading