提交 154c4774 编写于 作者: M Matt Bierner

Render code actions contribution point in extension contributions

Fixes #84091
上级 26c4541c
......@@ -96,6 +96,17 @@ export interface IWebviewEditor {
}[];
}
export interface ICodeActionContributionAction {
readonly kind: string;
readonly title: string;
readonly description?: string;
}
export interface ICodeActionContribution {
readonly languages: readonly string[];
readonly actions: readonly ICodeActionContributionAction[];
}
export interface IExtensionContributions {
commands?: ICommand[];
configuration?: IConfiguration | IConfiguration[];
......@@ -113,6 +124,7 @@ export interface IExtensionContributions {
colors?: IColor[];
localizations?: ILocalization[];
readonly webviewEditors?: readonly IWebviewEditor[];
readonly codeActions?: readonly ICodeActionContribution[];
}
export type ExtensionKind = 'ui' | 'workspace' | 'web';
......
......@@ -848,6 +848,7 @@ export class ExtensionEditor extends BaseEditor {
const renders = [
this.renderSettings(content, manifest, layout),
this.renderCommands(content, manifest, layout),
this.renderCodeActions(content, manifest, layout),
this.renderLanguages(content, manifest, layout),
this.renderColorThemes(content, manifest, layout),
this.renderIconThemes(content, manifest, layout),
......@@ -1075,6 +1076,37 @@ export class ExtensionEditor extends BaseEditor {
return true;
}
private renderCodeActions(container: HTMLElement, manifest: IExtensionManifest, onDetailsToggle: Function): boolean {
const codeActions = manifest.contributes?.codeActions || [];
if (!codeActions.length) {
return false;
}
const flatActions = arrays.flatten(
codeActions.map(contribution =>
contribution.actions.map(action => ({ ...action, languages: contribution.languages }))));
const details = $('details', { open: true, ontoggle: onDetailsToggle },
$('summary', { tabindex: '0' }, localize('codeActions', "Code Actions ({0})", flatActions.length)),
$('table', undefined,
$('tr', undefined,
$('th', undefined, localize('codeActions.title', "Title")),
$('th', undefined, localize('codeActions.kind', "Kind")),
$('th', undefined, localize('codeActions.description', "Description")),
$('th', undefined, localize('codeActions.languages', "Languages"))),
...flatActions.map(action =>
$('tr', undefined,
$('td', undefined, action.title),
$('td', undefined, $('code', undefined, action.kind)),
$('td', undefined, action.description ?? ''),
$('td', undefined, ...action.languages.map(language => $('code', undefined, language)))))
)
);
append(container, details);
return true;
}
private renderColorThemes(container: HTMLElement, manifest: IExtensionManifest, onDetailsToggle: Function): boolean {
const contrib = manifest.contributes?.themes || [];
if (!contrib.length) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册