mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
checkProposedApiEnabled and isProposedApiEnabled must be called with proposal name, add proposals for package.json-based API, https://github.com/microsoft/vscode/issues/131165
This commit is contained in:
@@ -600,7 +600,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
return <Thenable<any>>extHostMessageService.showMessage(extension, Severity.Error, message, rest[0], <Array<string | vscode.MessageItem>>rest.slice(1));
|
||||
},
|
||||
showQuickPick(items: any, options?: vscode.QuickPickOptions, token?: vscode.CancellationToken): any {
|
||||
return extHostQuickOpen.showQuickPick(items, isProposedApiEnabled(extension, undefined), options, token);
|
||||
return extHostQuickOpen.showQuickPick(items, options, token);
|
||||
},
|
||||
showWorkspaceFolderPick(options?: vscode.WorkspaceFolderPickOptions) {
|
||||
return extHostQuickOpen.showWorkspaceFolderPick(options);
|
||||
@@ -689,7 +689,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
return extHostUrls.registerUriHandler(extension.identifier, handler);
|
||||
},
|
||||
createQuickPick<T extends vscode.QuickPickItem>(): vscode.QuickPick<T> {
|
||||
return extHostQuickOpen.createQuickPick(extension.identifier, isProposedApiEnabled(extension, undefined));
|
||||
return extHostQuickOpen.createQuickPick(extension.identifier);
|
||||
},
|
||||
createInputBox(): vscode.InputBox {
|
||||
return extHostQuickOpen.createInputBox(extension.identifier);
|
||||
|
||||
@@ -22,16 +22,16 @@ import { ThemeIcon as ThemeIconUtils } from 'vs/platform/theme/common/themeServi
|
||||
export type Item = string | QuickPickItem;
|
||||
|
||||
export interface ExtHostQuickOpen {
|
||||
showQuickPick(itemsOrItemsPromise: QuickPickItem[] | Promise<QuickPickItem[]>, enableProposedApi: boolean, options: QuickPickOptions & { canPickMany: true; }, token?: CancellationToken): Promise<QuickPickItem[] | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: string[] | Promise<string[]>, enableProposedApi: boolean, options?: QuickPickOptions, token?: CancellationToken): Promise<string | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: QuickPickItem[] | Promise<QuickPickItem[]>, enableProposedApi: boolean, options?: QuickPickOptions, token?: CancellationToken): Promise<QuickPickItem | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: Item[] | Promise<Item[]>, enableProposedApi: boolean, options?: QuickPickOptions, token?: CancellationToken): Promise<Item | Item[] | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: QuickPickItem[] | Promise<QuickPickItem[]>, options: QuickPickOptions & { canPickMany: true; }, token?: CancellationToken): Promise<QuickPickItem[] | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: string[] | Promise<string[]>, options?: QuickPickOptions, token?: CancellationToken): Promise<string | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: QuickPickItem[] | Promise<QuickPickItem[]>, options?: QuickPickOptions, token?: CancellationToken): Promise<QuickPickItem | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: Item[] | Promise<Item[]>, options?: QuickPickOptions, token?: CancellationToken): Promise<Item | Item[] | undefined>;
|
||||
|
||||
showInput(options?: InputBoxOptions, token?: CancellationToken): Promise<string | undefined>;
|
||||
|
||||
showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions, token?: CancellationToken): Promise<WorkspaceFolder | undefined>
|
||||
|
||||
createQuickPick<T extends QuickPickItem>(extensionId: ExtensionIdentifier, enableProposedApi: boolean): QuickPick<T>;
|
||||
createQuickPick<T extends QuickPickItem>(extensionId: ExtensionIdentifier): QuickPick<T>;
|
||||
|
||||
createInputBox(extensionId: ExtensionIdentifier): InputBox;
|
||||
}
|
||||
@@ -56,10 +56,10 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
|
||||
this._commands = commands;
|
||||
}
|
||||
|
||||
showQuickPick(itemsOrItemsPromise: QuickPickItem[] | Promise<QuickPickItem[]>, enableProposedApi: boolean, options: QuickPickOptions & { canPickMany: true; }, token?: CancellationToken): Promise<QuickPickItem[] | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: string[] | Promise<string[]>, enableProposedApi: boolean, options?: QuickPickOptions, token?: CancellationToken): Promise<string | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: QuickPickItem[] | Promise<QuickPickItem[]>, enableProposedApi: boolean, options?: QuickPickOptions, token?: CancellationToken): Promise<QuickPickItem | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: Item[] | Promise<Item[]>, enableProposedApi: boolean, options?: QuickPickOptions, token: CancellationToken = CancellationToken.None): Promise<Item | Item[] | undefined> {
|
||||
showQuickPick(itemsOrItemsPromise: QuickPickItem[] | Promise<QuickPickItem[]>, options: QuickPickOptions & { canPickMany: true; }, token?: CancellationToken): Promise<QuickPickItem[] | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: string[] | Promise<string[]>, options?: QuickPickOptions, token?: CancellationToken): Promise<string | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: QuickPickItem[] | Promise<QuickPickItem[]>, options?: QuickPickOptions, token?: CancellationToken): Promise<QuickPickItem | undefined>;
|
||||
showQuickPick(itemsOrItemsPromise: Item[] | Promise<Item[]>, options?: QuickPickOptions, token: CancellationToken = CancellationToken.None): Promise<Item | Item[] | undefined> {
|
||||
|
||||
// clear state from last invocation
|
||||
this._onDidSelectItem = undefined;
|
||||
@@ -192,7 +192,7 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
|
||||
|
||||
// ---- QuickInput
|
||||
|
||||
createQuickPick<T extends QuickPickItem>(extensionId: ExtensionIdentifier, enableProposedApi: boolean): QuickPick<T> {
|
||||
createQuickPick<T extends QuickPickItem>(extensionId: ExtensionIdentifier): QuickPick<T> {
|
||||
const session: ExtHostQuickPick<T> = new ExtHostQuickPick(extensionId, () => this._sessions.delete(session._id));
|
||||
this._sessions.set(session._id, session);
|
||||
return session;
|
||||
|
||||
@@ -17,14 +17,14 @@ import { ThemeIcon } from 'vs/platform/theme/common/themeService';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
import { index } from 'vs/base/common/arrays';
|
||||
import { isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { ApiProposalName } from 'vs/workbench/services/extensions/common/extensionsApiProposals';
|
||||
|
||||
interface IAPIMenu {
|
||||
readonly key: string;
|
||||
readonly id: MenuId;
|
||||
readonly description: string;
|
||||
readonly proposed?: boolean; // defaults to false
|
||||
readonly proposed?: ApiProposalName;
|
||||
readonly supportsSubmenus?: boolean; // defaults to true
|
||||
readonly deprecationMessage?: string;
|
||||
}
|
||||
|
||||
const apiMenus: IAPIMenu[] = [
|
||||
@@ -85,17 +85,11 @@ const apiMenus: IAPIMenu[] = [
|
||||
id: MenuId.DebugToolBar,
|
||||
description: localize('menus.debugToolBar', "The debug toolbar menu")
|
||||
},
|
||||
{
|
||||
key: 'menuBar/file',
|
||||
id: MenuId.MenubarFileMenu,
|
||||
description: localize('menus.file', "The top level file menu"),
|
||||
proposed: true
|
||||
},
|
||||
{
|
||||
key: 'menuBar/home',
|
||||
id: MenuId.MenubarHomeMenu,
|
||||
description: localize('menus.home', "The home indicator context menu (web only)"),
|
||||
proposed: true,
|
||||
proposed: 'contribMenuBarHome',
|
||||
supportsSubmenus: false
|
||||
},
|
||||
{
|
||||
@@ -133,14 +127,6 @@ const apiMenus: IAPIMenu[] = [
|
||||
id: MenuId.SCMChangeContext,
|
||||
description: localize('menus.changeTitle', "The Source Control inline change menu")
|
||||
},
|
||||
{
|
||||
key: 'statusBar/windowIndicator',
|
||||
id: MenuId.StatusBarWindowIndicatorMenu,
|
||||
description: localize('menus.statusBarWindowIndicator', "The window indicator menu in the status bar"),
|
||||
proposed: true,
|
||||
supportsSubmenus: false,
|
||||
deprecationMessage: localize('menus.statusBarWindowIndicator.deprecated', "Use menu 'statusBar/remoteIndicator' instead."),
|
||||
},
|
||||
{
|
||||
key: 'statusBar/remoteIndicator',
|
||||
id: MenuId.StatusBarRemoteIndicatorMenu,
|
||||
@@ -198,19 +184,19 @@ const apiMenus: IAPIMenu[] = [
|
||||
key: 'notebook/cell/executePrimary',
|
||||
id: MenuId.NotebookCellExecutePrimary,
|
||||
description: localize('notebook.cell.executePrimary', "The contributed primary notebook cell execution button"),
|
||||
proposed: true
|
||||
proposed: 'notebookEditor'
|
||||
},
|
||||
{
|
||||
key: 'interactive/toolbar',
|
||||
id: MenuId.InteractiveToolbar,
|
||||
description: localize('interactive.toolbar', "The contributed interactive toolbar menu"),
|
||||
proposed: true
|
||||
proposed: 'notebookEditor'
|
||||
},
|
||||
{
|
||||
key: 'interactive/cell/title',
|
||||
id: MenuId.InteractiveCellTitle,
|
||||
description: localize('interactive.cell.title', "The contributed interactive cell title menu"),
|
||||
proposed: true
|
||||
proposed: 'notebookEditor'
|
||||
},
|
||||
{
|
||||
key: 'testing/item/context',
|
||||
@@ -263,7 +249,7 @@ const apiMenus: IAPIMenu[] = [
|
||||
id: MenuId.InlineCompletionsActions,
|
||||
description: localize('inlineCompletions.actions', "The actions shown when hovering on an inline completion"),
|
||||
supportsSubmenus: false,
|
||||
proposed: true
|
||||
proposed: 'inlineCompletions'
|
||||
},
|
||||
];
|
||||
|
||||
@@ -451,8 +437,7 @@ namespace schema {
|
||||
description: localize('vscode.extension.contributes.menus', "Contributes menu items to the editor"),
|
||||
type: 'object',
|
||||
properties: index(apiMenus, menu => menu.key, menu => ({
|
||||
description: menu.proposed ? `(${localize('proposed', "Proposed API")}) ${menu.description}` : menu.description,
|
||||
deprecationMessage: menu.deprecationMessage,
|
||||
markdownDescription: menu.proposed ? localize('proposed', "Proposed API, requires `enabledApiProposal: [\"{0}\"]` - {1}", menu.proposed, menu.description) : menu.description,
|
||||
type: 'array',
|
||||
items: menu.supportsSubmenus === false ? menuItem : { oneOf: [menuItem, submenuItem] }
|
||||
})),
|
||||
@@ -634,7 +619,7 @@ commandsExtensionPoint.setHandler(extensions => {
|
||||
title,
|
||||
source: extension.description.displayName ?? extension.description.name,
|
||||
shortTitle,
|
||||
tooltip: isProposedApiEnabled(extension.description, undefined) ? title : undefined,
|
||||
tooltip: title,
|
||||
category,
|
||||
precondition: ContextKeyExpr.deserialize(enablement),
|
||||
icon: absoluteIcon
|
||||
@@ -764,7 +749,7 @@ menusExtensionPoint.setHandler(extensions => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (menu.proposed && !isProposedApiEnabled(extension.description, undefined)) {
|
||||
if (menu.proposed && !isProposedApiEnabled(extension.description, menu.proposed)) {
|
||||
collector.error(localize('proposedAPI.invalid', "{0} is a proposed menu identifier and is only available when running out of dev or with the following command line switch: --enable-proposed-api {1}", entry.key, extension.description.identifier.value));
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user