Skip to content

Commit

Permalink
Remove support for non-dynamic extension points entirely (microsoft#6…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima authored and sandy081 committed Feb 22, 2019
1 parent f2457d5 commit 7b93ab9
Show file tree
Hide file tree
Showing 17 changed files with 15 additions and 61 deletions.
6 changes: 2 additions & 4 deletions src/vs/workbench/api/browser/viewsExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,14 @@ export interface ICustomViewDescriptor extends ITreeViewDescriptor {
type ViewContainerExtensionPointType = { [loc: string]: IUserFriendlyViewsContainerDescriptor[] };
const viewsContainersExtensionPoint: IExtensionPoint<ViewContainerExtensionPointType> = ExtensionsRegistry.registerExtensionPoint<ViewContainerExtensionPointType>({
extensionPoint: 'viewsContainers',
jsonSchema: viewsContainersContribution,
isDynamic: true
jsonSchema: viewsContainersContribution
});

type ViewExtensionPointType = { [loc: string]: IUserFriendlyViewDescriptor[] };
const viewsExtensionPoint: IExtensionPoint<ViewExtensionPointType> = ExtensionsRegistry.registerExtensionPoint<ViewExtensionPointType>({
extensionPoint: 'views',
deps: [viewsContainersExtensionPoint],
jsonSchema: viewsContribution,
isDynamic: true
jsonSchema: viewsContribution
});

const TEST_VIEW_CONTAINER_ORDER = 6;
Expand Down
6 changes: 2 additions & 4 deletions src/vs/workbench/api/common/configurationExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ const defaultConfigurationExtPoint = ExtensionsRegistry.registerExtensionPoint<I
$ref: editorConfigurationSchemaId,
}
}
},
isDynamic: true
}
});
defaultConfigurationExtPoint.setHandler((extensions, { added, removed }) => {
if (removed.length) {
Expand Down Expand Up @@ -134,8 +133,7 @@ const configurationExtPoint = ExtensionsRegistry.registerExtensionPoint<IConfigu
items: configurationEntrySchema
}
]
},
isDynamic: true
}
});

const extensionConfigurations: Map<string, IConfigurationNode[]> = new Map<string, IConfigurationNode[]>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ interface IJSONValidationExtensionPoint {

const configurationExtPoint = ExtensionsRegistry.registerExtensionPoint<IJSONValidationExtensionPoint[]>({
extensionPoint: 'jsonValidation',
isDynamic: true,
jsonSchema: {
description: nls.localize('contributes.jsonValidation', 'Contributes json schema configuration.'),
type: 'array',
Expand Down
6 changes: 2 additions & 4 deletions src/vs/workbench/api/common/menusExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ let _commandRegistrations: IDisposable[] = [];

ExtensionsRegistry.registerExtensionPoint<schema.IUserFriendlyCommand | schema.IUserFriendlyCommand[]>({
extensionPoint: 'commands',
jsonSchema: schema.commandsContribution,
isDynamic: true
jsonSchema: schema.commandsContribution
}).setHandler(extensions => {

function handleCommand(userFriendlyCommand: schema.IUserFriendlyCommand, extension: IExtensionPointUser<any>, disposables: IDisposable[]) {
Expand Down Expand Up @@ -332,8 +331,7 @@ let _menuRegistrations: IDisposable[] = [];

ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyMenuItem[] }>({
extensionPoint: 'menus',
jsonSchema: schema.menusContribtion,
isDynamic: true
jsonSchema: schema.menusContribtion
}).setHandler(extensions => {

// remove all previous menu registrations
Expand Down
2 changes: 0 additions & 2 deletions src/vs/workbench/contrib/debug/common/debugSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { inputsSchema } from 'vs/workbench/services/configurationResolver/common
// debuggers extension point
export const debuggersExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<IDebuggerContribution[]>({
extensionPoint: 'debuggers',
isDynamic: true,
jsonSchema: {
description: nls.localize('vscode.extension.contributes.debuggers', 'Contributes debug adapters.'),
type: 'array',
Expand Down Expand Up @@ -112,7 +111,6 @@ export interface IRawBreakpointContribution {
// breakpoints extension point #9037
export const breakpointsExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<IRawBreakpointContribution[]>({
extensionPoint: 'breakpoints',
isDynamic: true,
jsonSchema: {
description: nls.localize('vscode.extension.contributes.breakpoints', 'Contributes breakpoints.'),
type: 'array',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ namespace snippetExt {
};

export const point = ExtensionsRegistry.registerExtensionPoint<snippetExt.ISnippetsExtensionPoint[]>({
isDynamic: true,
extensionPoint: 'snippets',
deps: [languagesExtPoint],
jsonSchema: snippetExt.snippetsContribution
Expand Down
6 changes: 2 additions & 4 deletions src/vs/workbench/contrib/tasks/common/problemMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,7 @@ const problemPatternExtPoint = ExtensionsRegistry.registerExtensionPoint<Config.
Schemas.NamedMultiLineProblemPattern
]
}
},
isDynamic: true
}
});

export interface IProblemPatternRegistry {
Expand Down Expand Up @@ -1674,8 +1673,7 @@ const problemMatchersExtPoint = ExtensionsRegistry.registerExtensionPoint<Config
description: localize('ProblemMatcherExtPoint', 'Contributes problem matchers'),
type: 'array',
items: Schemas.NamedProblemMatcher
},
isDynamic: true
}
});

export interface IProblemMatcherRegistry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ const taskDefinitionsExtPoint = ExtensionsRegistry.registerExtensionPoint<Config
description: nls.localize('TaskDefinitionExtPoint', 'Contributes task kinds'),
type: 'array',
items: taskDefinitionSchema
},
isDynamic: true
}
});

export interface ITaskDefinitionRegistry {
Expand Down
14 changes: 2 additions & 12 deletions src/vs/workbench/services/extensions/common/extensionsRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,14 @@ export class ExtensionPointUserDelta<T> {
export class ExtensionPoint<T> implements IExtensionPoint<T> {

public readonly name: string;
public readonly isDynamic: boolean;

private _handler: IExtensionPointHandler<T> | null;
private _handlerCalled: boolean;
private _users: IExtensionPointUser<T>[] | null;
private _delta: ExtensionPointUserDelta<T> | null;

constructor(name: string, isDynamic: boolean) {
constructor(name: string) {
this.name = name;
this.isDynamic = isDynamic;
this._handler = null;
this._handlerCalled = false;
this._users = null;
this._delta = null;
}
Expand All @@ -140,12 +136,7 @@ export class ExtensionPoint<T> implements IExtensionPoint<T> {
return;
}

if (this._handlerCalled && !this.isDynamic) {
throw new Error('The extension point is not dynamic!');
}

try {
this._handlerCalled = true;
this._handler(this._users, this._delta);
} catch (err) {
onUnexpectedError(err);
Expand Down Expand Up @@ -367,7 +358,6 @@ export const schema = {
};

export interface IExtensionPointDescriptor {
isDynamic?: boolean;
extensionPoint: string;
deps?: IExtensionPoint<any>[];
jsonSchema: IJSONSchema;
Expand All @@ -385,7 +375,7 @@ export class ExtensionsRegistryImpl {
if (hasOwnProperty.call(this._extensionPoints, desc.extensionPoint)) {
throw new Error('Duplicate extension point: ' + desc.extensionPoint);
}
let result = new ExtensionPoint<T>(desc.extensionPoint, desc.isDynamic || false);
let result = new ExtensionPoint<T>(desc.extensionPoint);
this._extensionPoints[desc.extensionPoint] = result;

schema.properties['contributes'].properties[desc.extensionPoint] = desc.jsonSchema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ export class ExtensionService extends Disposable implements IExtensionService {
}

const extensionDescription = await this._extensionScanner.scanSingleExtension(extension.location.fsPath, extension.type === ExtensionType.System, this.createLogger());
if (!extensionDescription || !this._usesOnlyDynamicExtensionPoints(extensionDescription)) {
// uses non-dynamic extension point
if (!extensionDescription) {
// could not scan extension...
continue;
}

Expand Down Expand Up @@ -271,22 +271,6 @@ export class ExtensionService extends Disposable implements IExtensionService {
}
}

private _usesOnlyDynamicExtensionPoints(extension: IExtensionDescription): boolean {
const extensionPoints = ExtensionsRegistry.getExtensionPointsMap();
if (extension.contributes) {
for (let extPointName in extension.contributes) {
if (hasOwnProperty.call(extension.contributes, extPointName)) {
const extPoint = extensionPoints[extPointName];
if (extPoint && !extPoint.isDynamic) {
return false;
}
}
}
}

return true;
}

public canAddExtension(extension: IExtensionDescription): boolean {
if (this._windowService.getConfiguration().remoteAuthority) {
return false;
Expand All @@ -304,7 +288,7 @@ export class ExtensionService extends Disposable implements IExtensionService {
}
}

return this._usesOnlyDynamicExtensionPoints(extension);
return true;
}

public canRemoveExtension(extension: IExtensionDescription): boolean {
Expand All @@ -331,7 +315,7 @@ export class ExtensionService extends Disposable implements IExtensionService {
return false;
}

return this._usesOnlyDynamicExtensionPoints(extension);
return true;
}

private async _activateAddedExtensionIfNeeded(extensionDescription: IExtensionDescription): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ let keybindingType: IJSONSchema = {
};

const keybindingsExtPoint = ExtensionsRegistry.registerExtensionPoint<ContributedKeyBinding | ContributedKeyBinding[]>({
isDynamic: true,
extensionPoint: 'keybindings',
jsonSchema: {
description: nls.localize('vscode.extension.contributes.keybindings', "Contributes keybindings."),
Expand Down
1 change: 0 additions & 1 deletion src/vs/workbench/services/label/common/labelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';

const resourceLabelFormattersExtPoint = ExtensionsRegistry.registerExtensionPoint<ResourceLabelFormatter[]>({
extensionPoint: 'resourceLabelFormatters',
isDynamic: true,
jsonSchema: {
description: localize('vscode.extension.contributes.resourceLabelFormatters', 'Contributes resource label formatting rules.'),
type: 'array',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface IRawLanguageExtensionPoint {
}

export const languagesExtPoint: IExtensionPoint<IRawLanguageExtensionPoint[]> = ExtensionsRegistry.registerExtensionPoint<IRawLanguageExtensionPoint[]>({
isDynamic: true,
extensionPoint: 'languages',
jsonSchema: {
description: nls.localize('vscode.extension.contributes.languages', 'Contributes language declarations.'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export interface ITMSyntaxExtensionPoint {
}

export const grammarsExtPoint: IExtensionPoint<ITMSyntaxExtensionPoint[]> = ExtensionsRegistry.registerExtensionPoint<ITMSyntaxExtensionPoint[]>({
isDynamic: true,
extensionPoint: 'grammars',
deps: [languagesExtPoint],
jsonSchema: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { URI } from 'vs/base/common/uri';

const themesExtPoint = ExtensionsRegistry.registerExtensionPoint<IThemeExtensionPoint[]>({
extensionPoint: 'themes',
isDynamic: true,
jsonSchema: {
description: nls.localize('vscode.extension.contributes.themes', 'Contributes textmate color themes.'),
type: 'array',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const colorIdPattern = '^\\w+[.\\w+]*$';

const configurationExtPoint = ExtensionsRegistry.registerExtensionPoint<IColorExtensionPoint[]>({
extensionPoint: 'colors',
isDynamic: true,
jsonSchema: {
description: nls.localize('contributes.color', 'Contributes extension defined themable colors'),
type: 'array',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { URI } from 'vs/base/common/uri';

const iconThemeExtPoint = ExtensionsRegistry.registerExtensionPoint<IThemeExtensionPoint[]>({
extensionPoint: 'iconThemes',
isDynamic: true,
jsonSchema: {
description: nls.localize('vscode.extension.contributes.iconThemes', 'Contributes file icon themes.'),
type: 'array',
Expand Down

0 comments on commit 7b93ab9

Please sign in to comment.