mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-31 12:16:22 +01:00
Merge pull request #187941 from microsoft/merogge/symbol-icon
provide symbol info to screen reader users in documentSymbolsTree
This commit is contained in:
@@ -21,6 +21,7 @@ import { LanguageId } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import * as model from 'vs/editor/common/model';
|
||||
import { TokenizationRegistry as TokenizationRegistryImpl } from 'vs/editor/common/tokenizationRegistry';
|
||||
import { ContiguousMultilineTokens } from 'vs/editor/common/tokens/contiguousMultilineTokens';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { IMarkerData } from 'vs/platform/markers/common/markers';
|
||||
|
||||
@@ -1142,6 +1143,45 @@ export const enum SymbolKind {
|
||||
TypeParameter = 25
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const symbolKindNames: { [symbol: number]: string } = {
|
||||
[SymbolKind.Array]: localize('Array', "array"),
|
||||
[SymbolKind.Boolean]: localize('Boolean', "boolean"),
|
||||
[SymbolKind.Class]: localize('Class', "class"),
|
||||
[SymbolKind.Constant]: localize('Constant', "constant"),
|
||||
[SymbolKind.Constructor]: localize('Constructor', "constructor"),
|
||||
[SymbolKind.Enum]: localize('Enum', "enumeration"),
|
||||
[SymbolKind.EnumMember]: localize('EnumMember', "enumeration member"),
|
||||
[SymbolKind.Event]: localize('Event', "event"),
|
||||
[SymbolKind.Field]: localize('Field', "field"),
|
||||
[SymbolKind.File]: localize('File', "file"),
|
||||
[SymbolKind.Function]: localize('Function', "function"),
|
||||
[SymbolKind.Interface]: localize('Interface', "interface"),
|
||||
[SymbolKind.Key]: localize('Key', "key"),
|
||||
[SymbolKind.Method]: localize('Method', "method"),
|
||||
[SymbolKind.Module]: localize('Module', "module"),
|
||||
[SymbolKind.Namespace]: localize('Namespace', "namespace"),
|
||||
[SymbolKind.Null]: localize('Null', "null"),
|
||||
[SymbolKind.Number]: localize('Number', "number"),
|
||||
[SymbolKind.Object]: localize('Object', "object"),
|
||||
[SymbolKind.Operator]: localize('Operator', "operator"),
|
||||
[SymbolKind.Package]: localize('Package', "package"),
|
||||
[SymbolKind.Property]: localize('Property', "property"),
|
||||
[SymbolKind.String]: localize('String', "string"),
|
||||
[SymbolKind.Struct]: localize('Struct', "struct"),
|
||||
[SymbolKind.TypeParameter]: localize('TypeParameter', "type parameter"),
|
||||
[SymbolKind.Variable]: localize('Variable', "variable"),
|
||||
};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function getAriaLabelForSymbol(symbolName: string, kind: SymbolKind): string {
|
||||
return localize('symbolAriaLabel', '{0} Symbol: {1}', symbolName, symbolKindNames[kind]);
|
||||
}
|
||||
|
||||
export const enum SymbolTag {
|
||||
Deprecated = 1,
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import { format, trim } from 'vs/base/common/strings';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { ScrollType } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { DocumentSymbol, SymbolKind, SymbolKinds, SymbolTag } from 'vs/editor/common/languages';
|
||||
import { DocumentSymbol, SymbolKind, SymbolKinds, SymbolTag, getAriaLabelForSymbol } from 'vs/editor/common/languages';
|
||||
import { IOutlineModelService } from 'vs/editor/contrib/documentSymbols/browser/outlineModel';
|
||||
import { AbstractEditorNavigationQuickAccessProvider, IEditorNavigationQuickAccessOptions, IQuickAccessTextEditorContext } from 'vs/editor/contrib/quickAccess/browser/editorNavigationQuickAccess';
|
||||
import { localize } from 'vs/nls';
|
||||
@@ -316,7 +316,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
|
||||
kind: symbol.kind,
|
||||
score: symbolScore,
|
||||
label: symbolLabelWithIcon,
|
||||
ariaLabel: symbolLabel,
|
||||
ariaLabel: getAriaLabelForSymbol(symbol.name, symbol.kind),
|
||||
description: containerLabel,
|
||||
highlights: deprecated ? undefined : {
|
||||
label: symbolMatches,
|
||||
|
||||
@@ -11,7 +11,7 @@ import { IIdentityProvider, IKeyboardNavigationLabelProvider, IListVirtualDelega
|
||||
import { ITreeNode, ITreeRenderer, ITreeFilter } from 'vs/base/browser/ui/tree/tree';
|
||||
import { createMatches, FuzzyScore } from 'vs/base/common/filters';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { SymbolKind, SymbolKinds, SymbolTag } from 'vs/editor/common/languages';
|
||||
import { SymbolKind, SymbolKinds, SymbolTag, getAriaLabelForSymbol, symbolKindNames } from 'vs/editor/common/languages';
|
||||
import { OutlineElement, OutlineGroup, OutlineModel } from 'vs/editor/contrib/documentSymbols/browser/outlineModel';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IconLabel, IIconLabelValueOptions } from 'vs/base/browser/ui/iconLabel/iconLabel';
|
||||
@@ -49,7 +49,7 @@ export class DocumentSymbolAccessibilityProvider implements IListAccessibilityPr
|
||||
if (element instanceof OutlineGroup) {
|
||||
return element.label;
|
||||
} else {
|
||||
return element.symbol.name;
|
||||
return getAriaLabelForSymbol(element.symbol.name, element.symbol.kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ export class DocumentSymbolRenderer implements ITreeRenderer<OutlineElement, Fuz
|
||||
matches: createMatches(node.filterData),
|
||||
labelEscapeNewLines: true,
|
||||
extraClasses,
|
||||
title: localize('title.template', "{0} ({1})", element.symbol.name, DocumentSymbolRenderer._symbolKindNames[element.symbol.kind])
|
||||
title: localize('title.template', "{0} ({1})", element.symbol.name, symbolKindNames[element.symbol.kind])
|
||||
};
|
||||
if (this._configurationService.getValue(OutlineConfigKeys.icons)) {
|
||||
// add styles for the icons
|
||||
@@ -195,34 +195,7 @@ export class DocumentSymbolRenderer implements ITreeRenderer<OutlineElement, Fuz
|
||||
}
|
||||
}
|
||||
|
||||
private static _symbolKindNames: { [symbol: number]: string } = {
|
||||
[SymbolKind.Array]: localize('Array', "array"),
|
||||
[SymbolKind.Boolean]: localize('Boolean', "boolean"),
|
||||
[SymbolKind.Class]: localize('Class', "class"),
|
||||
[SymbolKind.Constant]: localize('Constant', "constant"),
|
||||
[SymbolKind.Constructor]: localize('Constructor', "constructor"),
|
||||
[SymbolKind.Enum]: localize('Enum', "enumeration"),
|
||||
[SymbolKind.EnumMember]: localize('EnumMember', "enumeration member"),
|
||||
[SymbolKind.Event]: localize('Event', "event"),
|
||||
[SymbolKind.Field]: localize('Field', "field"),
|
||||
[SymbolKind.File]: localize('File', "file"),
|
||||
[SymbolKind.Function]: localize('Function', "function"),
|
||||
[SymbolKind.Interface]: localize('Interface', "interface"),
|
||||
[SymbolKind.Key]: localize('Key', "key"),
|
||||
[SymbolKind.Method]: localize('Method', "method"),
|
||||
[SymbolKind.Module]: localize('Module', "module"),
|
||||
[SymbolKind.Namespace]: localize('Namespace', "namespace"),
|
||||
[SymbolKind.Null]: localize('Null', "null"),
|
||||
[SymbolKind.Number]: localize('Number', "number"),
|
||||
[SymbolKind.Object]: localize('Object', "object"),
|
||||
[SymbolKind.Operator]: localize('Operator', "operator"),
|
||||
[SymbolKind.Package]: localize('Package', "package"),
|
||||
[SymbolKind.Property]: localize('Property', "property"),
|
||||
[SymbolKind.String]: localize('String', "string"),
|
||||
[SymbolKind.Struct]: localize('Struct', "struct"),
|
||||
[SymbolKind.TypeParameter]: localize('TypeParameter', "type parameter"),
|
||||
[SymbolKind.Variable]: localize('Variable', "variable"),
|
||||
};
|
||||
|
||||
|
||||
disposeTemplate(_template: DocumentSymbolTemplate): void {
|
||||
_template.iconLabel.dispose();
|
||||
|
||||
Reference in New Issue
Block a user