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

@@ -8,35 +8,20 @@ import Severity from 'vs/base/common/severity';
import { URI } from 'vs/base/common/uri';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IExtensionPoint } from 'vs/workbench/services/extensions/common/extensionsRegistry';
import { ExtensionIdentifier, IExtensionManifest, IExtension, ExtensionType } from 'vs/platform/extensions/common/extensions';
import { getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
export interface IExtensionDescription {
readonly id: string;
readonly name: string;
export interface IExtensionDescription extends IExtensionManifest {
readonly identifier: ExtensionIdentifier;
readonly uuid?: string;
readonly displayName?: string;
readonly version: string;
readonly publisher: string;
readonly isBuiltin: boolean;
readonly isUnderDevelopment: boolean;
readonly extensionLocation: URI;
readonly extensionDependencies?: string[];
readonly activationEvents?: string[];
readonly engines: {
vscode: string;
// {{SQL CARBON EDIT}}
azdata?: string;
};
readonly main?: string;
readonly contributes?: { [point: string]: any; };
readonly keywords?: string[];
readonly repository?: {
url: string;
};
enableProposedApi?: boolean;
}
export const nullExtensionDescription = Object.freeze(<IExtensionDescription>{
id: 'nullExtensionDescription',
identifier: new ExtensionIdentifier('nullExtensionDescription'),
name: 'Null Extension Description',
version: '0.0.0',
publisher: 'vscode',
@@ -51,7 +36,7 @@ export const IExtensionService = createDecorator<IExtensionService>('extensionSe
export interface IMessage {
type: Severity;
message: string;
extensionId: string;
extensionId: ExtensionIdentifier;
extensionPointId: string;
}
@@ -104,7 +89,7 @@ export interface IExtensionHostProfile {
/**
* Extension id or one of the four known program states.
*/
export type ProfileSegmentId = string | 'idle' | 'program' | 'gc' | 'self';
export type ProfileSegmentId = string | 'idle' | 'program' | 'gc' | 'self' | null;
export class ActivationTimes {
constructor(
@@ -131,7 +116,7 @@ export const ExtensionHostLogFileName = 'exthost';
export interface IWillActivateEvent {
readonly event: string;
readonly activation: Thenable<void>;
readonly activation: Promise<void>;
}
export interface IResponsiveStateChangeEvent {
@@ -156,7 +141,12 @@ export interface IExtensionService extends ICpuProfilerTarget {
* Fired when extensions status changes.
* The event contains the ids of the extensions that have changed.
*/
onDidChangeExtensionsStatus: Event<string[]>;
onDidChangeExtensionsStatus: Event<ExtensionIdentifier[]>;
/**
* Fired when the available extensions change (i.e. when extensions are added or removed).
*/
onDidChangeExtensions: Event<void>;
/**
* An event that is fired when activation happens.
@@ -172,7 +162,7 @@ export interface IExtensionService extends ICpuProfilerTarget {
/**
* Send an activation event and activate interested extensions.
*/
activateByEvent(activationEvent: string): Thenable<void>;
activateByEvent(activationEvent: string): Promise<void>;
/**
* An promise that resolves when the installed extensions are registered after
@@ -191,6 +181,18 @@ export interface IExtensionService extends ICpuProfilerTarget {
*/
getExtension(id: string): Promise<IExtensionDescription | undefined>;
/**
* Returns `true` if the given extension can be added. Otherwise `false`.
* @param extension An extension
*/
canAddExtension(extension: IExtensionDescription): boolean;
/**
* Returns `true` if the given extension can be removed. Otherwise `false`.
* @param extension An extension
*/
canRemoveExtension(extension: IExtensionDescription): boolean;
/**
* Read all contributions to an extension point.
*/
@@ -246,5 +248,14 @@ export function checkProposedApiEnabled(extension: IExtensionDescription): void
}
export function throwProposedApiError(extension: IExtensionDescription): never {
throw new Error(`[${extension.id}]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ${extension.id}`);
throw new Error(`[${extension.identifier.value}]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ${extension.identifier.value}`);
}
export function toExtension(extensionDescription: IExtensionDescription): IExtension {
return {
type: extensionDescription.isBuiltin ? ExtensionType.System : ExtensionType.User,
identifier: { id: getGalleryExtensionId(extensionDescription.publisher, extensionDescription.name), uuid: extensionDescription.uuid },
manifest: extensionDescription,
location: extensionDescription.extensionLocation,
};
}

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 = {