extract auth#session into its own proposal file, make isProposedApiEnabled and checkProposedApiEnabled more strict by forcing them to be called with undefined or a proposal name, https://github.com/microsoft/vscode/issues/131165

This commit is contained in:
Johannes Rieken
2021-11-12 10:03:53 +01:00
parent 20382c5743
commit 8d3536c7f7
15 changed files with 64 additions and 56 deletions

View File

@@ -228,13 +228,13 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const authentication: typeof vscode.authentication = {
getSession(providerId: string, scopes: readonly string[], options?: vscode.AuthenticationGetSessionOptions) {
if (options?.forceNewSession) {
checkProposedApiEnabled(extension);
checkProposedApiEnabled(extension, 'authSession');
}
return extHostAuthentication.getSession(extension, providerId, scopes, options as any);
},
// TODO: remove this after GHPR and Codespaces move off of it
async hasSession(providerId: string, scopes: readonly string[]) {
checkProposedApiEnabled(extension);
checkProposedApiEnabled(extension, 'authSession');
return !!(await extHostAuthentication.getSession(extension, providerId, scopes, { silent: true } as any));
},
get onDidChangeSessions(): Event<vscode.AuthenticationSessionsChangeEvent> {
@@ -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), options, token);
return extHostQuickOpen.showQuickPick(items, isProposedApiEnabled(extension, undefined), 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));
return extHostQuickOpen.createQuickPick(extension.identifier, isProposedApiEnabled(extension, undefined));
},
createInputBox(): vscode.InputBox {
return extHostQuickOpen.createInputBox(extension.identifier);
@@ -1102,7 +1102,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostNotebook.registerNotebookCellStatusBarItemProvider(extension, notebookType, provider);
},
get onDidSaveNotebookDocument(): Event<vscode.NotebookDocument> {
checkProposedApiEnabled(extension);
checkProposedApiEnabled(extension, 'notebookEditor');
return extHostNotebookDocuments.onDidSaveNotebookDocument;
},
createNotebookEditorDecorationType(options: vscode.NotebookDecorationRenderOptions): vscode.NotebookEditorDecorationType {
@@ -1113,11 +1113,11 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostNotebookRenderers.createRendererMessaging(extension, rendererId);
},
onDidChangeNotebookDocumentMetadata(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
checkProposedApiEnabled(extension, 'notebookEditor');
return extHostNotebookDocuments.onDidChangeNotebookDocumentMetadata(listener, thisArgs, disposables);
},
onDidChangeNotebookCells(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
checkProposedApiEnabled(extension, 'notebookEditor');
return extHostNotebook.onDidChangeNotebookCells(listener, thisArgs, disposables);
},
onDidChangeNotebookCellExecutionState(listener, thisArgs?, disposables?) {
@@ -1125,11 +1125,11 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostNotebook.onDidChangeNotebookCellExecutionState(listener, thisArgs, disposables);
},
onDidChangeCellOutputs(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
checkProposedApiEnabled(extension, 'notebookEditor');
return extHostNotebook.onDidChangeCellOutputs(listener, thisArgs, disposables);
},
onDidChangeCellMetadata(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
checkProposedApiEnabled(extension, 'notebookEditor');
return extHostNotebook.onDidChangeCellMetadata(listener, thisArgs, disposables);
},
createConcatTextDocument(notebook, selector) {

View File

@@ -44,7 +44,7 @@ export class ExtHostMessageService {
}
if (options.useCustom) {
checkProposedApiEnabled(extension);
checkProposedApiEnabled(extension, 'resolvers');
}
const commands: { title: string; isCloseAffordance: boolean; handle: number; }[] = [];

View File

@@ -32,7 +32,7 @@ export class ExtHostNotebookRenderers implements ExtHostNotebookRenderersShape {
// In the stable API, the editor is given as an empty object, and this map
// is used to maintain references. This can be removed after editor finalization.
const notebookEditorVisible = isProposedApiEnabled(manifest);
const notebookEditorVisible = isProposedApiEnabled(manifest, 'notebookEditor');
const notebookEditorAliases = new WeakMap<{}, vscode.NotebookEditor>();
const messaging: vscode.NotebookRendererMessaging = {

View File

@@ -502,7 +502,7 @@ class ExtHostSourceControl implements vscode.SourceControl {
private _actionButtonDisposables = new MutableDisposable<DisposableStore>();
private _actionButton: vscode.Command | undefined;
get actionButton(): vscode.Command | undefined {
checkProposedApiEnabled(this._extension);
checkProposedApiEnabled(this._extension, 'scmActionButton');
return this._actionButton;
}
set actionButton(actionButton: vscode.Command | undefined) {

View File

@@ -634,7 +634,7 @@ commandsExtensionPoint.setHandler(extensions => {
title,
source: extension.description.displayName ?? extension.description.name,
shortTitle,
tooltip: isProposedApiEnabled(extension.description) ? title : undefined,
tooltip: isProposedApiEnabled(extension.description, undefined) ? title : undefined,
category,
precondition: ContextKeyExpr.deserialize(enablement),
icon: absoluteIcon
@@ -764,7 +764,7 @@ menusExtensionPoint.setHandler(extensions => {
return;
}
if (menu.proposed && !isProposedApiEnabled(extension.description)) {
if (menu.proposed && !isProposedApiEnabled(extension.description, undefined)) {
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;
}