Skip to content

Commit 55f2a29

Browse files
authored
Enable workspace extensions (microsoft#210466)
* Enable workspace extensions * fix
1 parent 5ccc2db commit 55f2a29

File tree

6 files changed

+13
-58
lines changed

6 files changed

+13
-58
lines changed

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@
168168
"[github-issues]": {
169169
"editor.wordWrap": "on"
170170
},
171-
"extensions.experimental.supportWorkspaceExtensions": true,
172171
"css.format.spaceAroundSelectorSeparator": true,
173172
"inlineChat.mode": "live",
174173
"typescript.enablePromptUseWorkspaceTsdk": true,

src/vs/workbench/contrib/extensions/browser/workspaceRecommendations.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@ export class WorkspaceRecommendations extends ExtensionRecommendations {
5555
this._register(this.fileService.watch(this.uriIdentityService.extUri.joinPath(folder.uri, WORKSPACE_EXTENSIONS_FOLDER)));
5656
}
5757

58-
if (this.workbenchExtensionManagementService.isWorkspaceExtensionsSupported()) {
59-
this._register(this.fileService.onDidFilesChange(e => {
60-
if (this.contextService.getWorkspace().folders.some(folder =>
61-
e.affects(this.uriIdentityService.extUri.joinPath(folder.uri, WORKSPACE_EXTENSIONS_FOLDER), FileChangeType.ADDED, FileChangeType.DELETED))
62-
) {
63-
this.onDidChangeWorkspaceExtensionsScheduler.schedule();
64-
}
65-
}));
66-
}
58+
this._register(this.fileService.onDidFilesChange(e => {
59+
if (this.contextService.getWorkspace().folders.some(folder =>
60+
e.affects(this.uriIdentityService.extUri.joinPath(folder.uri, WORKSPACE_EXTENSIONS_FOLDER), FileChangeType.ADDED, FileChangeType.DELETED))
61+
) {
62+
this.onDidChangeWorkspaceExtensionsScheduler.schedule();
63+
}
64+
}));
6765
}
6866

6967
private async onDidChangeWorkspaceExtensionsFolders(): Promise<void> {
@@ -75,9 +73,6 @@ export class WorkspaceRecommendations extends ExtensionRecommendations {
7573
}
7674

7775
private async fetchWorkspaceExtensions(): Promise<URI[]> {
78-
if (!this.workbenchExtensionManagementService.isWorkspaceExtensionsSupported()) {
79-
return [];
80-
}
8176
const workspaceExtensions: URI[] = [];
8277
for (const workspaceFolder of this.contextService.getWorkspace().folders) {
8378
const extensionsLocaiton = this.uriIdentityService.extUri.joinPath(workspaceFolder.uri, WORKSPACE_EXTENSIONS_FOLDER);

src/vs/workbench/contrib/extensions/test/electron-sandbox/extensionRecommendationsService.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ suite('ExtensionRecommendationsService Test', () => {
232232
async canInstall() { return true; },
233233
async getExtensionsControlManifest() { return { malicious: [], deprecated: {}, search: [] }; },
234234
async getTargetPlatform() { return getTargetPlatform(platform, arch); },
235-
isWorkspaceExtensionsSupported() { return false; },
236235
});
237236
instantiationService.stub(IExtensionService, {
238237
onDidChangeExtensions: Event.None,

src/vs/workbench/services/extensionManagement/common/extensionManagement.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export interface IWorkbenchExtensionManagementService extends IProfileAwareExten
6666
onDidChangeProfile: Event<DidChangeProfileForServerEvent>;
6767
onDidEnableExtensions: Event<IExtension[]>;
6868

69-
isWorkspaceExtensionsSupported(): boolean;
7069
getExtensions(locations: URI[]): Promise<IResourceExtension[]>;
7170
getInstalledWorkspaceExtensions(includeInvalid: boolean): Promise<ILocalExtension[]>;
7271

src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
ILocalExtension, IGalleryExtension, IExtensionIdentifier, IExtensionsControlManifest, IExtensionGalleryService, InstallOptions, UninstallOptions, InstallExtensionResult, ExtensionManagementError, ExtensionManagementErrorCode, Metadata, InstallOperation, EXTENSION_INSTALL_SYNC_CONTEXT, InstallExtensionInfo,
99
IProductVersion
1010
} from 'vs/platform/extensionManagement/common/extensionManagement';
11-
import { DidChangeProfileForServerEvent, DidUninstallExtensionOnServerEvent, extensionsConfigurationNodeBase, IExtensionManagementServer, IExtensionManagementServerService, InstallExtensionOnServerEvent, IResourceExtension, IWorkbenchExtensionManagementService, UninstallExtensionOnServerEvent } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
11+
import { DidChangeProfileForServerEvent, DidUninstallExtensionOnServerEvent, IExtensionManagementServer, IExtensionManagementServerService, InstallExtensionOnServerEvent, IResourceExtension, IWorkbenchExtensionManagementService, UninstallExtensionOnServerEvent } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
1212
import { ExtensionType, isLanguagePackExtension, IExtensionManifest, getWorkspaceSupportTypeMessage, TargetPlatform } from 'vs/platform/extensions/common/extensions';
1313
import { URI } from 'vs/base/common/uri';
1414
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
@@ -38,8 +38,6 @@ import { IExtensionsScannerService, IScannedExtension } from 'vs/platform/extens
3838
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
3939
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
4040
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
41-
import { Registry } from 'vs/platform/registry/common/platform';
42-
import { ConfigurationScope, Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
4341

4442
export class ExtensionManagementService extends Disposable implements IWorkbenchExtensionManagementService {
4543

@@ -64,7 +62,7 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
6462

6563
protected readonly servers: IExtensionManagementServer[] = [];
6664

67-
private readonly workspaceExtensionManagementService?: WorkspaceExtensionsManagementService;
65+
private readonly workspaceExtensionManagementService: WorkspaceExtensionsManagementService;
6866

6967
constructor(
7068
@IExtensionManagementServerService protected readonly extensionManagementServerService: IExtensionManagementServerService,
@@ -85,27 +83,8 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
8583
) {
8684
super();
8785

88-
if (productService.quality !== 'stable') {
89-
Registry.as<IConfigurationRegistry>(Extensions.Configuration)
90-
.registerConfiguration({
91-
...extensionsConfigurationNodeBase,
92-
properties: {
93-
'extensions.experimental.supportWorkspaceExtensions': {
94-
type: 'boolean',
95-
description: localize('extensions.experimental.supportWorkspaceExtensions', "Enables support for workspace specific local extensions."),
96-
default: false,
97-
scope: ConfigurationScope.APPLICATION
98-
}
99-
}
100-
});
101-
}
102-
103-
if (this.productService.quality !== 'stable' && this.configurationService.getValue('extensions.experimental.supportWorkspaceExtensions') === true) {
104-
this.workspaceExtensionManagementService = this._register(this.instantiationService.createInstance(WorkspaceExtensionsManagementService));
105-
this.onDidEnableExtensions = this.workspaceExtensionManagementService.onDidChangeInvalidExtensions;
106-
} else {
107-
this.onDidEnableExtensions = Event.None;
108-
}
86+
this.workspaceExtensionManagementService = this._register(this.instantiationService.createInstance(WorkspaceExtensionsManagementService));
87+
this.onDidEnableExtensions = this.workspaceExtensionManagementService.onDidChangeInvalidExtensions;
10988

11089
if (this.extensionManagementServerService.localExtensionManagementServer) {
11190
this.servers.push(this.extensionManagementServerService.localExtensionManagementServer);
@@ -149,10 +128,6 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
149128
}
150129
}
151130

152-
isWorkspaceExtensionsSupported(): boolean {
153-
return !!this.workspaceExtensionManagementService;
154-
}
155-
156131
async getInstalled(type?: ExtensionType, profileLocation?: URI, productVersion?: IProductVersion): Promise<ILocalExtension[]> {
157132
const result: ILocalExtension[] = [];
158133
await Promise.all(this.servers.map(async server => {
@@ -430,13 +405,10 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
430405
}
431406

432407
async getExtensions(locations: URI[]): Promise<IResourceExtension[]> {
433-
if (!this.workspaceExtensionManagementService) {
434-
return [];
435-
}
436408
const scannedExtensions = await this.extensionsScannerService.scanMultipleExtensions(locations, ExtensionType.User, { includeInvalid: true });
437409
const result: IResourceExtension[] = [];
438410
await Promise.all(scannedExtensions.map(async scannedExtension => {
439-
const workspaceExtension = await this.workspaceExtensionManagementService?.toLocalWorkspaceExtension(scannedExtension);
411+
const workspaceExtension = await this.workspaceExtensionManagementService.toLocalWorkspaceExtension(scannedExtension);
440412
if (workspaceExtension) {
441413
result.push({
442414
identifier: workspaceExtension.identifier,
@@ -451,18 +423,14 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
451423
}
452424

453425
async getInstalledWorkspaceExtensions(includeInvalid: boolean): Promise<ILocalExtension[]> {
454-
return this.workspaceExtensionManagementService?.getInstalled(includeInvalid) ?? [];
426+
return this.workspaceExtensionManagementService.getInstalled(includeInvalid);
455427
}
456428

457429
async installResourceExtension(extension: IResourceExtension, installOptions: InstallOptions): Promise<ILocalExtension> {
458430
if (!installOptions.isWorkspaceScoped) {
459431
return this.installFromLocation(extension.location);
460432
}
461433

462-
if (!this.workspaceExtensionManagementService) {
463-
throw new Error('Workspace Extensions are not supported');
464-
}
465-
466434
this.logService.info(`Installing the extension ${extension.identifier.id} from ${extension.location.toString()} in workspace`);
467435
const server = this.getWorkspaceExtensionsServer();
468436
this._onInstallExtension.fire({
@@ -510,10 +478,6 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
510478
throw new Error('The extension is not a workspace extension');
511479
}
512480

513-
if (!this.workspaceExtensionManagementService) {
514-
throw new Error('Workspace Extensions are not supported');
515-
}
516-
517481
this.logService.info(`Uninstalling the workspace extension ${extension.identifier.id} from ${extension.location.toString()}`);
518482
const server = this.getWorkspaceExtensionsServer();
519483
this._onUninstallExtension.fire({

src/vs/workbench/test/browser/workbenchTestServices.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,6 @@ export class TestWorkbenchExtensionManagementService implements IWorkbenchExtens
21892189
getInstalledWorkspaceExtensions(): Promise<ILocalExtension[]> { throw new Error('Method not implemented.'); }
21902190
installResourceExtension(): Promise<ILocalExtension> { throw new Error('Method not implemented.'); }
21912191
getExtensions(): Promise<IResourceExtension[]> { throw new Error('Method not implemented.'); }
2192-
isWorkspaceExtensionsSupported(): boolean { throw new Error('Method not implemented.'); }
21932192
}
21942193

21952194
export class TestUserDataProfileService implements IUserDataProfileService {

0 commit comments

Comments
 (0)