mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
Merge remote-tracking branch 'microsoft/master' into movableViews
This commit is contained in:
@@ -5,14 +5,19 @@
|
||||
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import * as nls from 'vs/nls';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService';
|
||||
import { ExtHostAuthenticationShape, ExtHostContext, IExtHostContext, MainContext, MainThreadAuthenticationShape } from '../common/extHost.protocol';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
|
||||
export class MainThreadAuthenticationProvider {
|
||||
constructor(
|
||||
private readonly _proxy: ExtHostAuthenticationShape,
|
||||
public readonly id: string
|
||||
public readonly id: string,
|
||||
public readonly displayName: string
|
||||
) { }
|
||||
|
||||
getSessions(): Promise<ReadonlyArray<modes.Session>> {
|
||||
@@ -35,13 +40,15 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@IAuthenticationService private readonly authenticationService: IAuthenticationService,
|
||||
@IDialogService private readonly dialogService: IDialogService,
|
||||
@IStorageService private readonly storageService: IStorageService
|
||||
) {
|
||||
super();
|
||||
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostAuthentication);
|
||||
}
|
||||
|
||||
$registerAuthenticationProvider(id: string): void {
|
||||
const provider = new MainThreadAuthenticationProvider(this._proxy, id);
|
||||
$registerAuthenticationProvider(id: string, displayName: string): void {
|
||||
const provider = new MainThreadAuthenticationProvider(this._proxy, id, displayName);
|
||||
this.authenticationService.registerAuthenticationProvider(id, provider);
|
||||
}
|
||||
|
||||
@@ -49,7 +56,55 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
|
||||
this.authenticationService.unregisterAuthenticationProvider(id);
|
||||
}
|
||||
|
||||
$onDidChangeSessions(id: string) {
|
||||
$onDidChangeSessions(id: string): void {
|
||||
this.authenticationService.sessionsUpdate(id);
|
||||
}
|
||||
|
||||
async $getSessionsPrompt(providerId: string, providerName: string, extensionId: string, extensionName: string): Promise<boolean> {
|
||||
const alwaysAllow = this.storageService.get(`${extensionId}-${providerId}`, StorageScope.GLOBAL);
|
||||
if (alwaysAllow) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const { choice } = await this.dialogService.show(
|
||||
Severity.Info,
|
||||
nls.localize('confirmAuthenticationAccess', "The extension '{0}' is trying to access authentication information from {1}.", extensionName, providerName),
|
||||
[nls.localize('cancel', "Cancel"), nls.localize('allow', "Allow"), nls.localize('alwaysAllow', "Always Allow"),],
|
||||
{ cancelId: 0 }
|
||||
);
|
||||
|
||||
switch (choice) {
|
||||
case 1/** Allow */:
|
||||
return true;
|
||||
case 2 /** Always Allow */:
|
||||
this.storageService.store(`${extensionId}-${providerId}`, 'true', StorageScope.GLOBAL);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async $loginPrompt(providerId: string, providerName: string, extensionId: string, extensionName: string): Promise<boolean> {
|
||||
const alwaysAllow = this.storageService.get(`${extensionId}-${providerId}`, StorageScope.GLOBAL);
|
||||
if (alwaysAllow) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const { choice } = await this.dialogService.show(
|
||||
Severity.Info,
|
||||
nls.localize('confirmLogin', "The extension '{0}' wants to sign in using {1}.", extensionName, providerName),
|
||||
[nls.localize('cancel', "Cancel"), nls.localize('continue', "Continue"), nls.localize('neverAgain', "Don't Show Again")],
|
||||
{ cancelId: 0 }
|
||||
);
|
||||
|
||||
switch (choice) {
|
||||
case 1/** Allow */:
|
||||
return true;
|
||||
case 2 /** Always Allow */:
|
||||
this.storageService.store(`${extensionId}-${providerId}`, 'true', StorageScope.GLOBAL);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensio
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { localize } from 'vs/nls';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { IExtensionEnablementService, EnablementState } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { IWorkbenchExtensionEnablementService, EnablementState } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { IExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/common/extensions';
|
||||
@@ -27,7 +27,7 @@ export class MainThreadExtensionService implements MainThreadExtensionServiceSha
|
||||
private readonly _notificationService: INotificationService;
|
||||
private readonly _extensionsWorkbenchService: IExtensionsWorkbenchService;
|
||||
private readonly _hostService: IHostService;
|
||||
private readonly _extensionEnablementService: IExtensionEnablementService;
|
||||
private readonly _extensionEnablementService: IWorkbenchExtensionEnablementService;
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@@ -35,7 +35,7 @@ export class MainThreadExtensionService implements MainThreadExtensionServiceSha
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IExtensionsWorkbenchService extensionsWorkbenchService: IExtensionsWorkbenchService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IExtensionEnablementService extensionEnablementService: IExtensionEnablementService
|
||||
@IWorkbenchExtensionEnablementService extensionEnablementService: IWorkbenchExtensionEnablementService
|
||||
) {
|
||||
this._extensionService = extensionService;
|
||||
this._notificationService = notificationService;
|
||||
|
||||
@@ -183,17 +183,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
registerAuthenticationProvider(provider: vscode.AuthenticationProvider): vscode.Disposable {
|
||||
return extHostAuthentication.registerAuthenticationProvider(provider);
|
||||
},
|
||||
login(providerId: string): Promise<vscode.Session> {
|
||||
return extHostAuthentication.$login(providerId);
|
||||
},
|
||||
logout(providerId: string, accountId: string): Promise<void> {
|
||||
return extHostAuthentication.$logout(providerId, accountId);
|
||||
},
|
||||
getSessions(providerId: string): Promise<ReadonlyArray<vscode.Session>> {
|
||||
return extHostAuthentication.$getSessions(providerId);
|
||||
},
|
||||
get onDidChangeSessions() {
|
||||
return extHostAuthentication.onDidChangeSessions;
|
||||
get providers() {
|
||||
return extHostAuthentication.providers(extension);
|
||||
},
|
||||
get onDidRegisterAuthenticationProvider() {
|
||||
return extHostAuthentication.onDidRegisterAuthenticationProvider;
|
||||
|
||||
@@ -148,9 +148,11 @@ export interface MainThreadCommentsShape extends IDisposable {
|
||||
}
|
||||
|
||||
export interface MainThreadAuthenticationShape extends IDisposable {
|
||||
$registerAuthenticationProvider(id: string): void;
|
||||
$registerAuthenticationProvider(id: string, displayName: string): void;
|
||||
$unregisterAuthenticationProvider(id: string): void;
|
||||
$onDidChangeSessions(id: string): void;
|
||||
$getSessionsPrompt(providerId: string, providerName: string, extensionId: string, extensionName: string): Promise<boolean>;
|
||||
$loginPrompt(providerId: string, providerName: string, extensionId: string, extensionName: string): Promise<boolean>;
|
||||
}
|
||||
|
||||
export interface MainThreadConfigurationShape extends IDisposable {
|
||||
|
||||
@@ -7,69 +7,90 @@ import * as vscode from 'vscode';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IMainContext, MainContext, MainThreadAuthenticationShape, ExtHostAuthenticationShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { IExtensionDescription, ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
const _onDidUnregisterAuthenticationProvider = new Emitter<string>();
|
||||
const _onDidChangeSessions = new Emitter<string>();
|
||||
export class AuthenticationProviderWrapper implements vscode.AuthenticationProvider {
|
||||
onDidChangeSessions: Event<void>;
|
||||
|
||||
export class ExtHostAuthenticationProvider implements IDisposable {
|
||||
constructor(private _provider: vscode.AuthenticationProvider,
|
||||
private _id: string,
|
||||
constructor(private _requestingExtension: IExtensionDescription,
|
||||
private _provider: vscode.AuthenticationProvider,
|
||||
private _proxy: MainThreadAuthenticationShape) {
|
||||
this._provider.onDidChangeSessions(x => {
|
||||
this._proxy.$onDidChangeSessions(this._id);
|
||||
_onDidChangeSessions.fire(this._id);
|
||||
});
|
||||
|
||||
this.onDidChangeSessions = this._provider.onDidChangeSessions;
|
||||
}
|
||||
|
||||
getSessions(): Promise<ReadonlyArray<vscode.Session>> {
|
||||
get id(): string {
|
||||
return this._provider.id;
|
||||
}
|
||||
|
||||
get displayName(): string {
|
||||
return this._provider.displayName;
|
||||
}
|
||||
|
||||
async getSessions(): Promise<ReadonlyArray<vscode.Session>> {
|
||||
const isAllowed = await this._proxy.$getSessionsPrompt(this._provider.id, this.displayName, ExtensionIdentifier.toKey(this._requestingExtension.identifier), this._requestingExtension.displayName || this._requestingExtension.name);
|
||||
if (!isAllowed) {
|
||||
throw new Error('User did not consent to session access.');
|
||||
}
|
||||
|
||||
return this._provider.getSessions();
|
||||
}
|
||||
|
||||
login(): Promise<vscode.Session> {
|
||||
async login(): Promise<vscode.Session> {
|
||||
const isAllowed = await this._proxy.$loginPrompt(this._provider.id, this.displayName, ExtensionIdentifier.toKey(this._requestingExtension.identifier), this._requestingExtension.displayName || this._requestingExtension.name);
|
||||
if (!isAllowed) {
|
||||
throw new Error('User did not consent to login.');
|
||||
}
|
||||
|
||||
return this._provider.login();
|
||||
}
|
||||
|
||||
logout(sessionId: string): Promise<void> {
|
||||
return this._provider.logout(sessionId);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._proxy.$unregisterAuthenticationProvider(this._id);
|
||||
_onDidUnregisterAuthenticationProvider.fire(this._id);
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostAuthentication implements ExtHostAuthenticationShape {
|
||||
private _proxy: MainThreadAuthenticationShape;
|
||||
private _authenticationProviders: Map<string, ExtHostAuthenticationProvider> = new Map<string, ExtHostAuthenticationProvider>();
|
||||
private _authenticationProviders: Map<string, vscode.AuthenticationProvider> = new Map<string, vscode.AuthenticationProvider>();
|
||||
|
||||
private _onDidRegisterAuthenticationProvider = new Emitter<string>();
|
||||
readonly onDidRegisterAuthenticationProvider: Event<string> = this._onDidRegisterAuthenticationProvider.event;
|
||||
|
||||
readonly onDidUnregisterAuthenticationProvider: Event<string> = _onDidUnregisterAuthenticationProvider.event;
|
||||
|
||||
readonly onDidChangeSessions: Event<string> = _onDidChangeSessions.event;
|
||||
private _onDidUnregisterAuthenticationProvider = new Emitter<string>();
|
||||
readonly onDidUnregisterAuthenticationProvider: Event<string> = this._onDidUnregisterAuthenticationProvider.event;
|
||||
|
||||
constructor(mainContext: IMainContext) {
|
||||
this._proxy = mainContext.getProxy(MainContext.MainThreadAuthentication);
|
||||
|
||||
this.onDidUnregisterAuthenticationProvider(providerId => {
|
||||
this._authenticationProviders.delete(providerId);
|
||||
});
|
||||
}
|
||||
|
||||
registerAuthenticationProvider(provider: vscode.AuthenticationProvider) {
|
||||
providers(requestingExtension: IExtensionDescription): vscode.AuthenticationProvider[] {
|
||||
let providers: vscode.AuthenticationProvider[] = [];
|
||||
this._authenticationProviders.forEach(provider => providers.push(new AuthenticationProviderWrapper(requestingExtension, provider, this._proxy)));
|
||||
return providers;
|
||||
}
|
||||
|
||||
registerAuthenticationProvider(provider: vscode.AuthenticationProvider): vscode.Disposable {
|
||||
if (this._authenticationProviders.get(provider.id)) {
|
||||
throw new Error(`An authentication provider with id '${provider.id}' is already registered.`);
|
||||
}
|
||||
|
||||
const authenticationProvider = new ExtHostAuthenticationProvider(provider, provider.id, this._proxy);
|
||||
this._authenticationProviders.set(provider.id, authenticationProvider);
|
||||
this._authenticationProviders.set(provider.id, provider);
|
||||
|
||||
this._proxy.$registerAuthenticationProvider(provider.id);
|
||||
const listener = provider.onDidChangeSessions(_ => {
|
||||
this._proxy.$onDidChangeSessions(provider.id);
|
||||
});
|
||||
|
||||
this._proxy.$registerAuthenticationProvider(provider.id, provider.displayName);
|
||||
this._onDidRegisterAuthenticationProvider.fire(provider.id);
|
||||
return authenticationProvider;
|
||||
|
||||
return new Disposable(() => {
|
||||
listener.dispose();
|
||||
this._authenticationProviders.delete(provider.id);
|
||||
this._proxy.$unregisterAuthenticationProvider(provider.id);
|
||||
this._onDidUnregisterAuthenticationProvider.fire(provider.id);
|
||||
});
|
||||
}
|
||||
|
||||
$login(providerId: string): Promise<modes.Session> {
|
||||
|
||||
@@ -25,6 +25,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import * as Platform from 'vs/base/common/platform';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IExtHostApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService';
|
||||
|
||||
export interface IExtHostTask extends ExtHostTaskShape {
|
||||
|
||||
@@ -376,6 +377,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
|
||||
protected readonly _configurationService: IExtHostConfiguration;
|
||||
protected readonly _terminalService: IExtHostTerminalService;
|
||||
protected readonly _logService: ILogService;
|
||||
protected readonly _deprecationService: IExtHostApiDeprecationService;
|
||||
protected _handleCounter: number;
|
||||
protected _handlers: Map<number, HandlerData>;
|
||||
protected _taskExecutions: Map<string, TaskExecutionImpl>;
|
||||
@@ -396,7 +398,8 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
|
||||
@IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors,
|
||||
@IExtHostConfiguration configurationService: IExtHostConfiguration,
|
||||
@IExtHostTerminalService extHostTerminalService: IExtHostTerminalService,
|
||||
@ILogService logService: ILogService
|
||||
@ILogService logService: ILogService,
|
||||
@IExtHostApiDeprecationService deprecationService: IExtHostApiDeprecationService
|
||||
) {
|
||||
this._proxy = extHostRpc.getProxy(MainContext.MainThreadTask);
|
||||
this._workspaceProvider = workspaceService;
|
||||
@@ -410,6 +413,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
|
||||
this._notProvidedCustomExecutions = new Set<string>();
|
||||
this._activeCustomExecutions2 = new Map<string, types.CustomExecution>();
|
||||
this._logService = logService;
|
||||
this._deprecationService = deprecationService;
|
||||
}
|
||||
|
||||
public registerTaskProvider(extension: IExtensionDescription, type: string, provider: vscode.TaskProvider): vscode.Disposable {
|
||||
@@ -576,6 +580,8 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
|
||||
return;
|
||||
}
|
||||
|
||||
this.checkDeprecation(resolvedTask, handler);
|
||||
|
||||
const resolvedTaskDTO: tasks.TaskDTO | undefined = TaskDTO.from(resolvedTask, handler.extension);
|
||||
if (!resolvedTaskDTO) {
|
||||
throw new Error('Unexpected: Task cannot be resolved.');
|
||||
@@ -630,6 +636,13 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
|
||||
return createdResult;
|
||||
}
|
||||
|
||||
protected checkDeprecation(task: vscode.Task, handler: HandlerData) {
|
||||
const tTask = (task as types.Task);
|
||||
if (tTask._deprecated) {
|
||||
this._deprecationService.report('Task.constructor', handler.extension, 'Use the Task constructor that takes a `scope` instead.');
|
||||
}
|
||||
}
|
||||
|
||||
private customExecutionComplete(execution: tasks.TaskExecutionDTO): void {
|
||||
const extensionCallback2: vscode.CustomExecution | undefined = this._activeCustomExecutions2.get(execution.id);
|
||||
if (extensionCallback2) {
|
||||
@@ -666,9 +679,10 @@ export class WorkerExtHostTask extends ExtHostTaskBase {
|
||||
@IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors,
|
||||
@IExtHostConfiguration configurationService: IExtHostConfiguration,
|
||||
@IExtHostTerminalService extHostTerminalService: IExtHostTerminalService,
|
||||
@ILogService logService: ILogService
|
||||
@ILogService logService: ILogService,
|
||||
@IExtHostApiDeprecationService deprecationService: IExtHostApiDeprecationService
|
||||
) {
|
||||
super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService, logService);
|
||||
super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService, logService, deprecationService);
|
||||
if (initData.remote.isRemote && initData.remote.authority) {
|
||||
this.registerTaskSystem(Schemas.vscodeRemote, {
|
||||
scheme: Schemas.vscodeRemote,
|
||||
@@ -700,6 +714,7 @@ export class WorkerExtHostTask extends ExtHostTaskBase {
|
||||
const taskDTOs: tasks.TaskDTO[] = [];
|
||||
if (value) {
|
||||
for (let task of value) {
|
||||
this.checkDeprecation(task, handler);
|
||||
if (!task.definition || !validTypes[task.definition.type]) {
|
||||
this._logService.warn(`The task [${task.source}, ${task.name}] uses an undefined task type. The task will be ignored in the future.`);
|
||||
}
|
||||
|
||||
@@ -1358,8 +1358,8 @@ export enum CompletionItemTag {
|
||||
|
||||
export interface CompletionItemLabel {
|
||||
name: string;
|
||||
// signature?: string; // parameters
|
||||
// qualifier?: string;
|
||||
signature?: string;
|
||||
qualifier?: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
@@ -1838,6 +1838,7 @@ export class Task implements vscode.Task2 {
|
||||
private static EmptyType: string = '$empty';
|
||||
|
||||
private __id: string | undefined;
|
||||
private __deprecated: boolean = false;
|
||||
|
||||
private _definition: vscode.TaskDefinition;
|
||||
private _scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder | undefined;
|
||||
@@ -1862,6 +1863,7 @@ export class Task implements vscode.Task2 {
|
||||
this._source = this.source = arg3;
|
||||
this.execution = arg4;
|
||||
problemMatchers = arg5;
|
||||
this.__deprecated = true;
|
||||
} else if (arg2 === TaskScope.Global || arg2 === TaskScope.Workspace) {
|
||||
this.target = arg2;
|
||||
this._name = this.name = arg3;
|
||||
@@ -1898,6 +1900,10 @@ export class Task implements vscode.Task2 {
|
||||
this.__id = value;
|
||||
}
|
||||
|
||||
get _deprecated(): boolean {
|
||||
return this.__deprecated;
|
||||
}
|
||||
|
||||
private clear(): void {
|
||||
if (this.__id === undefined) {
|
||||
return;
|
||||
|
||||
@@ -24,6 +24,7 @@ import { ExtHostTaskBase, TaskHandleDTO, TaskDTO, CustomExecutionDTO, HandlerDat
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IProcessEnvironment } from 'vs/base/common/platform';
|
||||
import { IExtHostApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService';
|
||||
|
||||
export class ExtHostTask extends ExtHostTaskBase {
|
||||
private _variableResolver: ExtHostVariableResolverService | undefined;
|
||||
@@ -35,9 +36,10 @@ export class ExtHostTask extends ExtHostTaskBase {
|
||||
@IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors,
|
||||
@IExtHostConfiguration configurationService: IExtHostConfiguration,
|
||||
@IExtHostTerminalService extHostTerminalService: IExtHostTerminalService,
|
||||
@ILogService logService: ILogService
|
||||
@ILogService logService: ILogService,
|
||||
@IExtHostApiDeprecationService deprecationService: IExtHostApiDeprecationService
|
||||
) {
|
||||
super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService, logService);
|
||||
super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService, logService, deprecationService);
|
||||
if (initData.remote.isRemote && initData.remote.authority) {
|
||||
this.registerTaskSystem(Schemas.vscodeRemote, {
|
||||
scheme: Schemas.vscodeRemote,
|
||||
@@ -73,6 +75,8 @@ export class ExtHostTask extends ExtHostTaskBase {
|
||||
const taskDTOs: tasks.TaskDTO[] = [];
|
||||
if (value) {
|
||||
for (let task of value) {
|
||||
this.checkDeprecation(task, handler);
|
||||
|
||||
if (!task.definition || !validTypes[task.definition.type]) {
|
||||
this._logService.warn(`The task [${task.source}, ${task.name}] uses an undefined task type. The task will be ignored in the future.`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user