Merge VS Code 1.31.1 (#4283)

This commit is contained in:
Matt Irvine
2019-03-15 13:09:45 -07:00
committed by GitHub
parent 7d31575149
commit 86bac90001
1716 changed files with 53308 additions and 48375 deletions

View File

@@ -11,6 +11,7 @@ import { EXTENSION_IDENTIFIER_PATTERN } from 'vs/platform/extensionManagement/co
import { Extensions, IJSONContributionRegistry } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
import { IExtensionDescription, IMessage } from 'vs/workbench/services/extensions/common/extensions';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
const hasOwnProperty = Object.hasOwnProperty;
const schemaRegistry = Registry.as<IJSONContributionRegistry>(Extensions.JSONContribution);
@@ -35,7 +36,7 @@ export class ExtensionMessageCollector {
this._messageHandler({
type: type,
message: message,
extensionId: this._extension.id,
extensionId: this._extension.identifier,
extensionPointId: this._extensionPointId
});
}
@@ -60,7 +61,7 @@ export interface IExtensionPointUser<T> {
}
export interface IExtensionPointHandler<T> {
(extensions: IExtensionPointUser<T>[]): void;
(extensions: IExtensionPointUser<T>[], delta: ExtensionPointUserDelta<T>): void;
}
export interface IExtensionPoint<T> {
@@ -68,22 +69,60 @@ export interface IExtensionPoint<T> {
setHandler(handler: IExtensionPointHandler<T>): void;
}
export class ExtensionPointUserDelta<T> {
private static _toSet<T>(arr: IExtensionPointUser<T>[]): Set<string> {
const result = new Set<string>();
for (let i = 0, len = arr.length; i < len; i++) {
result.add(ExtensionIdentifier.toKey(arr[i].description.identifier));
}
return result;
}
public static compute<T>(previous: IExtensionPointUser<T>[] | null, current: IExtensionPointUser<T>[]): ExtensionPointUserDelta<T> {
if (!previous || !previous.length) {
return new ExtensionPointUserDelta<T>(current, []);
}
if (!current || !current.length) {
return new ExtensionPointUserDelta<T>([], previous);
}
const previousSet = this._toSet(previous);
const currentSet = this._toSet(current);
let added = current.filter(user => !previousSet.has(ExtensionIdentifier.toKey(user.description.identifier)));
let removed = previous.filter(user => !currentSet.has(ExtensionIdentifier.toKey(user.description.identifier)));
return new ExtensionPointUserDelta<T>(added, removed);
}
constructor(
public readonly added: IExtensionPointUser<T>[],
public readonly removed: IExtensionPointUser<T>[],
) { }
}
export class ExtensionPoint<T> implements IExtensionPoint<T> {
public readonly name: string;
private _handler: IExtensionPointHandler<T> | null;
private _users: IExtensionPointUser<T>[] | null;
private _done: boolean;
public readonly isDynamic: boolean;
constructor(name: string) {
private _handler: IExtensionPointHandler<T> | null;
private _handlerCalled: boolean;
private _users: IExtensionPointUser<T>[] | null;
private _delta: ExtensionPointUserDelta<T> | null;
constructor(name: string, isDynamic: boolean) {
this.name = name;
this.isDynamic = isDynamic;
this._handler = null;
this._handlerCalled = false;
this._users = null;
this._done = false;
this._delta = null;
}
setHandler(handler: IExtensionPointHandler<T>): void {
if (this._handler !== null || this._done) {
if (this._handler !== null) {
throw new Error('Handler already set!');
}
this._handler = handler;
@@ -91,27 +130,23 @@ export class ExtensionPoint<T> implements IExtensionPoint<T> {
}
acceptUsers(users: IExtensionPointUser<T>[]): void {
if (this._users !== null || this._done) {
throw new Error('Users already set!');
}
this._delta = ExtensionPointUserDelta.compute(this._users, users);
this._users = users;
this._handle();
}
private _handle(): void {
if (this._handler === null || this._users === null) {
if (this._handler === null || this._users === null || this._delta === null) {
return;
}
this._done = true;
let handler = this._handler;
this._handler = null;
let users = this._users;
this._users = null;
if (this._handlerCalled && !this.isDynamic) {
throw new Error('The extension point is not dynamic!');
}
try {
handler(users);
this._handlerCalled = true;
this._handler(this._users, this._delta);
} catch (err) {
onUnexpectedError(err);
}
@@ -331,6 +366,13 @@ export const schema = {
}
};
export interface IExtensionPointDescriptor {
isDynamic?: boolean;
extensionPoint: string;
deps?: IExtensionPoint<any>[];
jsonSchema: IJSONSchema;
}
export class ExtensionsRegistryImpl {
private _extensionPoints: { [extPoint: string]: ExtensionPoint<any>; };
@@ -339,14 +381,14 @@ export class ExtensionsRegistryImpl {
this._extensionPoints = {};
}
public registerExtensionPoint<T>(extensionPoint: string, deps: IExtensionPoint<any>[], jsonSchema: IJSONSchema): IExtensionPoint<T> {
if (hasOwnProperty.call(this._extensionPoints, extensionPoint)) {
throw new Error('Duplicate extension point: ' + extensionPoint);
public registerExtensionPoint<T>(desc: IExtensionPointDescriptor): IExtensionPoint<T> {
if (hasOwnProperty.call(this._extensionPoints, desc.extensionPoint)) {
throw new Error('Duplicate extension point: ' + desc.extensionPoint);
}
let result = new ExtensionPoint<T>(extensionPoint);
this._extensionPoints[extensionPoint] = result;
let result = new ExtensionPoint<T>(desc.extensionPoint, desc.isDynamic || false);
this._extensionPoints[desc.extensionPoint] = result;
schema.properties['contributes'].properties[extensionPoint] = jsonSchema;
schema.properties['contributes'].properties[desc.extensionPoint] = desc.jsonSchema;
schemaRegistry.registerSchema(schemaId, schema);
return result;
@@ -355,6 +397,10 @@ export class ExtensionsRegistryImpl {
public getExtensionPoints(): ExtensionPoint<any>[] {
return Object.keys(this._extensionPoints).map(point => this._extensionPoints[point]);
}
public getExtensionPointsMap(): { [extPoint: string]: ExtensionPoint<any>; } {
return this._extensionPoints;
}
}
const PRExtensions = {