Skip to content

Commit

Permalink
provide aria labels for debug viewers
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Feb 3, 2016
1 parent 6d4245e commit 46db05e
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 8 deletions.
84 changes: 78 additions & 6 deletions src/vs/workbench/parts/debug/browser/debugViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { IContextViewService, IContextMenuService } from 'vs/platform/contextvie
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IMessageService } from 'vs/platform/message/common/message';
import { Source } from 'vs/workbench/parts/debug/common/debugSource';

const $ = dom.emmet;
const booleanRegex = /^true|false$/i;
Expand Down Expand Up @@ -123,6 +124,14 @@ function renderRenameBox(debugService: debug.IDebugService, contextViewService:
}));
}

function getSourceName(source: Source, contextService: IWorkspaceContextService): string {
if (source.inMemory) {
return source.name;
}

return labels.getPathLabel(paths.basename(source.uri.fsPath), contextService);
}

export class BaseDebugController extends treedefaults.DefaultController {

constructor(protected debugService: debug.IDebugService, private contextMenuService: IContextMenuService, private actionProvider: renderer.IActionProvider, private focusOnContextMenu = true) {
Expand Down Expand Up @@ -277,11 +286,7 @@ export class CallStackRenderer implements tree.IRenderer {
stackFrame.source.available ? dom.removeClass(data.stackFrame, 'disabled') : dom.addClass(data.stackFrame, 'disabled');
data.file.title = stackFrame.source.uri.fsPath;
data.label.textContent = stackFrame.name;
if (stackFrame.source.inMemory) {
data.fileName.textContent = stackFrame.source.name;
} else {
data.fileName.textContent = labels.getPathLabel(paths.basename(stackFrame.source.uri.fsPath), this.contextService);
}
data.fileName.textContent = getSourceName(stackFrame.source, this.contextService);
data.lineNumber.textContent = stackFrame.lineNumber !== undefined ? `${ stackFrame.lineNumber }` : '';
}

Expand All @@ -290,6 +295,24 @@ export class CallStackRenderer implements tree.IRenderer {
}
}

export class CallstackAccessibilityProvider implements tree.IAccessibilityProvider {

constructor(@IWorkspaceContextService private contextService: IWorkspaceContextService) {
// noop
}

public getAriaLabel(tree: tree.ITree, element: any): string {
if (element instanceof model.Thread) {
return nls.localize('threadAriaLabel', "Thread {0}, callstack, debug", (<model.Thread>element).name);
}
if (element instanceof model.StackFrame) {
return nls.localize('stackFrameAriaLabel', "Stack Frame {0} on line {1} in {2}, callstack, debug", (<model.StackFrame>element).name, (<model.StackFrame>element).lineNumber, getSourceName((<model.StackFrame>element).source, this.contextService));
}

return null;
}
}

// variables

export class VariablesActionProvider implements renderer.IActionProvider {
Expand Down Expand Up @@ -389,7 +412,7 @@ export class VariablesRenderer implements tree.IRenderer {
if (element instanceof model.Scope) {
return VariablesRenderer.SCOPE_TEMPLATE_ID;
}
if (element instanceof model.Expression) {
if (element instanceof model.Variable) {
return VariablesRenderer.VARIABLE_TEMPLATE_ID;
}

Expand Down Expand Up @@ -429,6 +452,20 @@ export class VariablesRenderer implements tree.IRenderer {
}
}

export class VariablesAccessibilityProvider implements tree.IAccessibilityProvider {

public getAriaLabel(tree: tree.ITree, element: any): string {
if (element instanceof model.Scope) {
return nls.localize('variableScopeAriaLabel', "Scope {0}, variables, debug", (<model.Scope>element).name);
}
if (element instanceof model.Variable) {
return nls.localize('variableAriaLabel', "Variable {0} has value {1}, variables, debug", (<model.Variable>element).name, (<model.Variable>element).value);
}

return null;
}
}

// watch expressions

export class WatchExpressionsActionProvider implements renderer.IActionProvider {
Expand Down Expand Up @@ -597,6 +634,20 @@ export class WatchExpressionsRenderer implements tree.IRenderer {
}
}

export class WatchExpressionsAccessibilityProvider implements tree.IAccessibilityProvider {

public getAriaLabel(tree: tree.ITree, element: any): string {
if (element instanceof model.Expression) {
return nls.localize('watchExpressionAriaLabel', "Expression {0} has value {1}, watch, debug", (<model.Expression>element).name, (<model.Expression>element).value);
}
if (element instanceof model.Variable) {
return nls.localize('watchVariableAriaLabel', "Variable {0} has value {1}, watch, debug", (<model.Variable>element).name, (<model.Variable>element).value);
}

return null;
}
}

export class WatchExpressionsController extends BaseDebugController {

constructor(debugService: debug.IDebugService, contextMenuService: IContextMenuService, actionProvider: renderer.IActionProvider) {
Expand Down Expand Up @@ -858,6 +909,27 @@ export class BreakpointsRenderer implements tree.IRenderer {
}
}

export class BreakpointsAccessibilityProvider implements tree.IAccessibilityProvider {

constructor(@IWorkspaceContextService private contextService: IWorkspaceContextService) {
// noop
}

public getAriaLabel(tree: tree.ITree, element: any): string {
if (element instanceof model.Breakpoint) {
return nls.localize('breakpointAriaLabel', "Breakpoint on line {0} in {1}, breakpoints, debug", (<model.Breakpoint>element).lineNumber, getSourceName((<model.Breakpoint>element).source, this.contextService));
}
if (element instanceof model.FunctionBreakpoint) {
return nls.localize('functionBreakpointAriaLabel', "Funktion breakpoint {0}, breakpoints, debug", (<model.FunctionBreakpoint>element).name);
}
if (element instanceof model.ExceptionBreakpoint) {
return nls.localize('exceptionBreakpointAriaLabel', "Exception breakpoint {0}, breakpoints, debug", (<model.ExceptionBreakpoint>element).name);
}

return null;
}
}

export class BreakpointsController extends BaseDebugController {

/* protected */ public onLeftClick(tree:tree.ITree, element: any, eventish:treedefaults.ICancelableEvent, origin: string = 'mouse'):boolean {
Expand Down
6 changes: 5 additions & 1 deletion src/vs/workbench/parts/debug/browser/debugViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class VariablesView extends viewlet.CollapsibleViewletView {
this.tree = new treeimpl.Tree(this.treeContainer, {
dataSource: new viewer.VariablesDataSource(this.debugService),
renderer: this.instantiationService.createInstance(viewer.VariablesRenderer),
accessibilityProvider: new viewer.VariablesAccessibilityProvider(),
controller: new viewer.BaseDebugController(this.debugService, this.contextMenuService, new viewer.VariablesActionProvider(this.instantiationService))
}, debugTreeOptions(nls.localize('variablesAriaTreeLabel', "Debug Variables")));

Expand Down Expand Up @@ -145,6 +146,7 @@ class WatchExpressionsView extends viewlet.CollapsibleViewletView {
this.tree = new treeimpl.Tree(this.treeContainer, {
dataSource: new viewer.WatchExpressionsDataSource(this.debugService),
renderer: this.instantiationService.createInstance(viewer.WatchExpressionsRenderer, actionProvider, this.actionRunner),
accessibilityProvider: new viewer.WatchExpressionsAccessibilityProvider(),
controller: new viewer.WatchExpressionsController(this.debugService, this.contextMenuService, actionProvider)
}, debugTreeOptions(nls.localize('watchAriaTreeLabel', "Debug Watch Expressions")));

Expand Down Expand Up @@ -215,7 +217,8 @@ class CallStackView extends viewlet.CollapsibleViewletView {

this.tree = new treeimpl.Tree(this.treeContainer, {
dataSource: new viewer.CallStackDataSource(),
renderer: this.instantiationService.createInstance(viewer.CallStackRenderer)
renderer: this.instantiationService.createInstance(viewer.CallStackRenderer),
accessibilityProvider: this.instantiationService.createInstance(viewer.CallstackAccessibilityProvider)
}, debugTreeOptions(nls.localize('callStackAriaLabel', "Debug Call Stack")));

const debugModel = this.debugService.getModel();
Expand Down Expand Up @@ -332,6 +335,7 @@ class BreakpointsView extends viewlet.AdaptiveCollapsibleViewletView {
this.tree = new treeimpl.Tree(this.treeContainer, {
dataSource: new viewer.BreakpointsDataSource(),
renderer: this.instantiationService.createInstance(viewer.BreakpointsRenderer, actionProvider, this.actionRunner),
accessibilityProvider: this.instantiationService.createInstance(viewer.BreakpointsAccessibilityProvider),
controller: new viewer.BreakpointsController(this.debugService, this.contextMenuService, actionProvider),
sorter: {
compare(tree: tree.ITree, element: any, otherElement: any): number {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/parts/output/browser/outputPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class OutputPanel extends StringEditor {
let ariaLabel: string;
let channel = this.outputService.getActiveChannel();

options.ariaLabel = channel ? nls.localize('outputPanelWithInputAriaLabel', "{0}. Output panel.", channel) : nls.localize('outputPanelAriaLabel', "Output panel.");
options.ariaLabel = channel ? nls.localize('outputPanelWithInputAriaLabel', "{0}, Output panel", channel) : nls.localize('outputPanelAriaLabel', "Output panel");

return options;
}
Expand Down

0 comments on commit 46db05e

Please sign in to comment.