Merge from vscode fc10e26ea50f82cdd84e9141491357922e6f5fba (#4639)

This commit is contained in:
Anthony Dresser
2019-03-21 10:58:16 -07:00
committed by GitHub
parent 8298db7d13
commit b65ee5b42e
149 changed files with 1408 additions and 814 deletions

View File

@@ -94,6 +94,7 @@ export const enum MenuId {
SCMSourceControl,
SCMTitle,
SearchContext,
StatusBarWindowIndicatorMenu,
TouchBarContext,
ViewItemContext,
ViewTitle,

View File

@@ -12,11 +12,11 @@ export class DialogChannel implements IServerChannel {
constructor(@IDialogService private readonly dialogService: IDialogService) { }
listen<T>(_, event: string): Event<T> {
listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, args?: any[]): Promise<any> {
call(_: unknown, command: string, args?: any[]): Promise<any> {
switch (command) {
case 'show': return this.dialogService.show(args![0], args![1], args![2]);
case 'confirm': return this.dialogService.confirm(args![0]);

View File

@@ -29,7 +29,7 @@ export class DownloadServiceChannel implements IServerChannel {
constructor() { }
listen(_, event: string, arg?: any): Event<any> {
listen(_: unknown, event: string, arg?: any): Event<any> {
switch (event) {
case 'upload': return Event.buffer(upload(URI.revive(arg)));
}
@@ -37,7 +37,7 @@ export class DownloadServiceChannel implements IServerChannel {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string): Promise<any> {
call(_: unknown, command: string): Promise<any> {
throw new Error(`Call not found: ${command}`);
}
}

View File

@@ -48,11 +48,11 @@ export class DriverChannel implements IServerChannel {
constructor(private driver: IDriver) { }
listen<T>(_, event: string): Event<T> {
listen<T>(_: unknown, event: string): Event<T> {
throw new Error('No event found');
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'getWindowIds': return this.driver.getWindowIds();
case 'capturePage': return this.driver.capturePage(arg);
@@ -150,11 +150,11 @@ export class WindowDriverRegistryChannel implements IServerChannel {
constructor(private registry: IWindowDriverRegistry) { }
listen<T>(_, event: string): Event<T> {
listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'registerWindowDriver': return this.registry.registerWindowDriver(arg);
case 'reloadWindowDriver': return this.registry.reloadWindowDriver(arg);
@@ -195,11 +195,11 @@ export class WindowDriverChannel implements IServerChannel {
constructor(private driver: IWindowDriver) { }
listen<T>(_, event: string): Event<T> {
listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`No event found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'click': return this.driver.click(arg[0], arg[1], arg[2]);
case 'doubleClick': return this.driver.doubleClick(arg);

View File

@@ -153,7 +153,8 @@ export interface ITranslation {
export interface IExtensionGalleryService {
_serviceBrand: any;
isEnabled(): boolean;
query(options?: IQueryOptions): Promise<IPager<IGalleryExtension>>;
query(token: CancellationToken): Promise<IPager<IGalleryExtension>>;
query(options: IQueryOptions, token: CancellationToken): Promise<IPager<IGalleryExtension>>;
download(extension: IGalleryExtension, operation: InstallOperation): Promise<string>;
reportStatistic(publisher: string, name: string, version: string, type: StatisticType): Promise<void>;
getReadme(extension: IGalleryExtension, token: CancellationToken): Promise<string>;

View File

@@ -451,7 +451,12 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
});
}
query(options: IQueryOptions = {}): Promise<IPager<IGalleryExtension>> {
query(token: CancellationToken): Promise<IPager<IGalleryExtension>>;
query(options: IQueryOptions, token: CancellationToken): Promise<IPager<IGalleryExtension>>;
query(arg1: any, arg2?: any): Promise<IPager<IGalleryExtension>> {
const options: IQueryOptions = CancellationToken.isCancellationToken(arg1) ? {} : arg1;
const token: CancellationToken = CancellationToken.isCancellationToken(arg1) ? arg1 : arg2;
if (!this.isEnabled()) {
return Promise.reject(new Error('No extension gallery service configured.'));
}
@@ -511,7 +516,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
query = query.withSortOrder(options.sortOrder);
}
return this.queryGallery(query, CancellationToken.None).then(({ galleryExtensions, total }) => {
return this.queryGallery(query, token).then(({ galleryExtensions, total }) => {
const extensions = galleryExtensions.map((e, index) => toExtension(e, e.versions[0], index, query, options.source));
// {{SQL CARBON EDIT}}
const pageSize = extensions.length;

View File

@@ -318,9 +318,6 @@ export class ExtensionManagementService extends Disposable implements IExtension
const existingExtension = installed.filter(i => areSameExtensions(i.identifier, extension.identifier))[0];
if (existingExtension) {
operation = InstallOperation.Update;
if (semver.gt(existingExtension.manifest.version, extension.version)) {
await this.uninstall(existingExtension, true);
}
}
this.downloadInstallableExtension(extension, operation)
@@ -329,7 +326,10 @@ export class ExtensionManagementService extends Disposable implements IExtension
.then(local => this.installDependenciesAndPackExtensions(local, existingExtension)
.then(() => local, error => this.uninstall(local, true).then(() => Promise.reject(error), () => Promise.reject(error))))
.then(
local => {
async local => {
if (existingExtension && semver.neq(existingExtension.manifest.version, extension.version)) {
await this.setUninstalled(existingExtension);
}
this.installingExtensions.delete(key);
onDidInstallExtensionSuccess(extension, operation, local);
successCallback(null);
@@ -529,7 +529,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
// filter out installed extensions
const names = dependenciesAndPackExtensions.filter(id => installed.every(({ identifier: galleryIdentifier }) => !areSameExtensions(galleryIdentifier, { id })));
if (names.length) {
return this.galleryService.query({ names, pageSize: dependenciesAndPackExtensions.length })
return this.galleryService.query({ names, pageSize: dependenciesAndPackExtensions.length }, CancellationToken.None)
.then(galleryResult => {
const extensionsToInstall = galleryResult.firstPage;
return Promise.all(extensionsToInstall.map(async e => {
@@ -609,11 +609,11 @@ export class ExtensionManagementService extends Disposable implements IExtension
}
private findGalleryExtensionById(uuid: string): Promise<IGalleryExtension> {
return this.galleryService.query({ ids: [uuid], pageSize: 1 }).then(galleryResult => galleryResult.firstPage[0]);
return this.galleryService.query({ ids: [uuid], pageSize: 1 }, CancellationToken.None).then(galleryResult => galleryResult.firstPage[0]);
}
private findGalleryExtensionByName(name: string): Promise<IGalleryExtension> {
return this.galleryService.query({ names: [name], pageSize: 1 }).then(galleryResult => galleryResult.firstPage[0]);
return this.galleryService.query({ names: [name], pageSize: 1 }, CancellationToken.None).then(galleryResult => galleryResult.firstPage[0]);
}
private joinErrors(errorOrErrors: (Error | string) | (Array<Error | string>)): Error {

View File

@@ -701,7 +701,16 @@ export interface IUpdateContentOptions {
}
export interface IResolveFileOptions {
/**
* Automatically continue resolving children of a directory until the provided resources
* are found.
*/
resolveTo?: URI[];
/**
* Automatically continue resolving children of a directory if the number of children is 1.
*/
resolveSingleChildDescendants?: boolean;
}
@@ -1034,12 +1043,6 @@ export interface ILegacyFileService {
onFileChanges: Event<FileChangesEvent>;
onAfterOperation: Event<FileOperationEvent>;
resolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat>;
resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]>;
existsFile(resource: URI): Promise<boolean>;
resolveContent(resource: URI, options?: IResolveContentOptions): Promise<IContent>;
resolveStreamContent(resource: URI, options?: IResolveContentOptions): Promise<IStreamContent>;
@@ -1057,4 +1060,4 @@ export interface ILegacyFileService {
watchFileChanges(resource: URI): void;
unwatchFileChanges(resource: URI): void;
}
}

View File

@@ -42,7 +42,7 @@ suite('Files', () => {
assert.strictEqual(true, r1.gotDeleted());
});
function testIsEqual(testMethod: (pA: string | null | undefined, pB: string, ignoreCase: boolean) => boolean): void {
function testIsEqual(testMethod: (pA: string | undefined, pB: string, ignoreCase: boolean) => boolean): void {
// corner cases
assert(testMethod('', '', true));

View File

@@ -35,12 +35,12 @@ export class TestInstantiationService extends InstantiationService {
return <T>this._create(service, { mock: true });
}
public stub<T>(service: ServiceIdentifier<T>, ctor?: any): T;
public stub<T>(service: ServiceIdentifier<T>, obj?: any): T;
public stub<T>(service: ServiceIdentifier<T>, ctor?: any, property?: string, value?: any): sinon.SinonStub;
public stub<T>(service: ServiceIdentifier<T>, obj?: any, property?: string, value?: any): sinon.SinonStub;
public stub<T>(service: ServiceIdentifier<T>, property?: string, value?: any): sinon.SinonStub;
public stub<T>(serviceIdentifier: ServiceIdentifier<T>, arg2?: any, arg3?: string, arg4?: any): sinon.SinonStub {
public stub<T>(service: ServiceIdentifier<T>, ctor: Function): T;
public stub<T>(service: ServiceIdentifier<T>, obj: Partial<T>): T;
public stub<T>(service: ServiceIdentifier<T>, ctor: Function, property: string, value: any): sinon.SinonStub;
public stub<T>(service: ServiceIdentifier<T>, obj: Partial<T>, property: string, value: any): sinon.SinonStub;
public stub<T>(service: ServiceIdentifier<T>, property: string, value: any): sinon.SinonStub;
public stub<T>(serviceIdentifier: ServiceIdentifier<T>, arg2: any, arg3?: string, arg4?: any): sinon.SinonStub {
let service = typeof arg2 !== 'string' ? arg2 : undefined;
let serviceMock: IServiceMock<any> = { id: serviceIdentifier, service: service };
let property = typeof arg2 === 'string' ? arg2 : arg3;

View File

@@ -50,7 +50,7 @@ export class IssueService implements IIssueService {
});
});
ipcMain.on('vscode:issueReporterConfirmClose', (_) => {
ipcMain.on('vscode:issueReporterConfirmClose', () => {
const messageOptions = {
message: localize('confirmCloseIssueReporter', "Your input will not be saved. Are you sure you want to close this window?"),
type: 'warning',
@@ -72,7 +72,7 @@ export class IssueService implements IIssueService {
}
});
ipcMain.on('vscode:workbenchCommand', (_, commandInfo) => {
ipcMain.on('vscode:workbenchCommand', (_: unknown, commandInfo) => {
const { id, from, args } = commandInfo;
let parentWindow: BrowserWindow | null;
@@ -92,7 +92,7 @@ export class IssueService implements IIssueService {
}
});
ipcMain.on('vscode:openExternal', (_, arg) => {
ipcMain.on('vscode:openExternal', (_: unknown, arg) => {
this.windowsService.openExternal(arg);
});

View File

@@ -11,11 +11,11 @@ export class IssueChannel implements IServerChannel {
constructor(private service: IIssueService) { }
listen<T>(_, event: string): Event<T> {
listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'openIssueReporter':
return this.service.openReporter(arg);

View File

@@ -70,11 +70,11 @@ export class LaunchChannel implements IServerChannel {
constructor(private service: ILaunchService) { }
listen<T>(_, event: string): Event<T> {
listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg: any): Promise<any> {
call(_: unknown, command: string, arg: any): Promise<any> {
switch (command) {
case 'start':
const { args, userEnv } = arg as IStartArguments;

View File

@@ -15,7 +15,7 @@ export class LocalizationsChannel implements IServerChannel {
this.onDidLanguagesChange = Event.buffer(service.onDidLanguagesChange, true);
}
listen(_, event: string): Event<any> {
listen(_: unknown, event: string): Event<any> {
switch (event) {
case 'onDidLanguagesChange': return this.onDidLanguagesChange;
}
@@ -23,7 +23,7 @@ export class LocalizationsChannel implements IServerChannel {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'getLanguageIds': return this.service.getLanguageIds(arg);
}

View File

@@ -15,7 +15,7 @@ export class LogLevelSetterChannel implements IServerChannel {
this.onDidChangeLogLevel = Event.buffer(service.onDidChangeLogLevel, true);
}
listen(_, event: string): Event<any> {
listen(_: unknown, event: string): Event<any> {
switch (event) {
case 'onDidChangeLogLevel': return this.onDidChangeLogLevel;
}
@@ -23,7 +23,7 @@ export class LogLevelSetterChannel implements IServerChannel {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'setLevel': this.service.setLevel(arg); return Promise.resolve();
}

View File

@@ -11,11 +11,11 @@ export class MenubarChannel implements IServerChannel {
constructor(private service: IMenubarService) { }
listen<T>(_, event: string): Event<T> {
listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'updateMenubar': return this.service.updateMenubar(arg[0], arg[1]);
}

View File

@@ -5,13 +5,21 @@
import { URI } from 'vs/base/common/uri';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IDisposable } from 'vs/base/common/lifecycle';
export const IOpenerService = createDecorator<IOpenerService>('openerService');
export interface IOpener {
open(resource: URI, options?: { openToSide?: boolean }): Promise<boolean>;
}
export interface IOpenerService {
_serviceBrand: any;
registerOpener(opener: IOpener): IDisposable;
/**
* Opens a resource, like a webadress, a document uri, or executes command.
*
@@ -23,5 +31,6 @@ export interface IOpenerService {
export const NullOpenerService: IOpenerService = Object.freeze({
_serviceBrand: undefined,
registerOpener() { return { dispose() { } }; },
open() { return Promise.resolve(false); }
});

View File

@@ -104,7 +104,7 @@ export class GlobalStorageDatabaseChannel extends Disposable implements IServerC
return { items: mapToSerializable(items) } as ISerializableItemsChangeEvent;
}
listen(_, event: string): Event<any> {
listen(_: unknown, event: string): Event<any> {
switch (event) {
case 'onDidChangeItems': return this.onDidChangeItems;
}
@@ -112,7 +112,7 @@ export class GlobalStorageDatabaseChannel extends Disposable implements IServerC
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'getItems': {
return this.whenReady.then(() => mapToSerializable(this.storageMainService.items));

View File

@@ -16,11 +16,11 @@ export class TelemetryAppenderChannel implements IServerChannel {
constructor(private appender: ITelemetryAppender) { }
listen<T>(_, event: string): Event<T> {
listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, { eventName, data }: ITelemetryLog): Promise<any> {
call(_: unknown, command: string, { eventName, data }: ITelemetryLog): Promise<any> {
this.appender.log(eventName, data);
return Promise.resolve(null);
}

View File

@@ -11,7 +11,7 @@ export class UpdateChannel implements IServerChannel {
constructor(private service: IUpdateService) { }
listen(_, event: string): Event<any> {
listen(_: unknown, event: string): Event<any> {
switch (event) {
case 'onStateChange': return this.service.onStateChange;
}
@@ -19,7 +19,7 @@ export class UpdateChannel implements IServerChannel {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'checkForUpdates': return this.service.checkForUpdates(arg);
case 'downloadUpdate': return this.service.downloadUpdate();

View File

@@ -8,16 +8,21 @@ import { URI } from 'vs/base/common/uri';
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import { URLServiceChannelClient, URLHandlerChannel } from 'vs/platform/url/node/urlIpc';
import { URLService } from 'vs/platform/url/common/urlService';
import { IOpenerService } from 'vs/platform/opener/common/opener';
export class RelayURLService extends URLService implements IURLHandler {
private urlService: IURLService;
constructor(@IMainProcessService mainProcessService: IMainProcessService) {
constructor(
@IMainProcessService mainProcessService: IMainProcessService,
@IOpenerService openerService: IOpenerService
) {
super();
this.urlService = new URLServiceChannelClient(mainProcessService.getChannel('url'));
mainProcessService.registerChannel('urlHandler', new URLHandlerChannel(this));
openerService.registerOpener(this);
}
open(uri: URI): Promise<boolean> {

View File

@@ -13,11 +13,11 @@ export class URLServiceChannel implements IServerChannel {
constructor(private service: IURLService) { }
listen<T>(_, event: string): Event<T> {
listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'open': return this.service.open(URI.revive(arg));
}
@@ -45,11 +45,11 @@ export class URLHandlerChannel implements IServerChannel {
constructor(private handler: IURLHandler) { }
listen<T>(_, event: string): Event<T> {
listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'handleURL': return this.handler.handleURL(URI.revive(arg));
}

View File

@@ -28,7 +28,7 @@ export class WindowsChannel implements IServerChannel {
this.onRecentlyOpenedChange = Event.buffer(service.onRecentlyOpenedChange, true);
}
listen(_, event: string): Event<any> {
listen(_: unknown, event: string): Event<any> {
switch (event) {
case 'onWindowOpen': return this.onWindowOpen;
case 'onWindowFocus': return this.onWindowFocus;
@@ -41,7 +41,7 @@ export class WindowsChannel implements IServerChannel {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'pickFileFolderAndOpen': return this.service.pickFileFolderAndOpen(arg);
case 'pickFileAndOpen': return this.service.pickFileAndOpen(arg);

View File

@@ -12,11 +12,11 @@ export class WorkspacesChannel implements IServerChannel {
constructor(private service: IWorkspacesMainService) { }
listen<T>(_, event: string): Event<T> {
listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`Event not found: ${event}`);
}
call(_, command: string, arg?: any): Promise<any> {
call(_: unknown, command: string, arg?: any): Promise<any> {
switch (command) {
case 'createUntitledWorkspace': {
const rawFolders: IWorkspaceFolderCreationData[] = arg[0];