未验证 提交 d175b2de 编写于 作者: B Benjamin Pasero 提交者: GitHub

Reduce host service dependencies #108522 (#109295)

上级 bc34921b
...@@ -23,8 +23,7 @@ import { IUserDataSyncAccountService } from 'vs/platform/userDataSync/common/use ...@@ -23,8 +23,7 @@ import { IUserDataSyncAccountService } from 'vs/platform/userDataSync/common/use
import { IUserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync'; import { IUserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync';
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IHostService } from 'vs/workbench/services/host/browser/host';
import { ReloadWindowAction } from 'vs/workbench/browser/actions/windowActions';
const SOURCE = 'IWorkbenchExtensionEnablementService'; const SOURCE = 'IWorkbenchExtensionEnablementService';
...@@ -50,7 +49,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench ...@@ -50,7 +49,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
@IUserDataSyncAccountService private readonly userDataSyncAccountService: IUserDataSyncAccountService, @IUserDataSyncAccountService private readonly userDataSyncAccountService: IUserDataSyncAccountService,
@ILifecycleService private readonly lifecycleService: ILifecycleService, @ILifecycleService private readonly lifecycleService: ILifecycleService,
@INotificationService private readonly notificationService: INotificationService, @INotificationService private readonly notificationService: INotificationService,
@IInstantiationService instantiationService: IInstantiationService, @IHostService hostService: IHostService,
) { ) {
super(); super();
this.storageManger = this._register(new StorageManager(storageService)); this.storageManger = this._register(new StorageManager(storageService));
...@@ -62,8 +61,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench ...@@ -62,8 +61,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
this.lifecycleService.when(LifecyclePhase.Restored).then(() => { this.lifecycleService.when(LifecyclePhase.Restored).then(() => {
this.notificationService.prompt(Severity.Info, localize('extensionsDisabled', "All installed extensions are temporarily disabled. Reload the window to return to the previous state."), [{ this.notificationService.prompt(Severity.Info, localize('extensionsDisabled', "All installed extensions are temporarily disabled. Reload the window to return to the previous state."), [{
label: localize('Reload', "Reload"), label: localize('Reload', "Reload"),
// Using ReloadWindowAction because depending on IHostService causes cyclic dependency - #108522 run: () => hostService.reload()
run: () => instantiationService.createInstance(ReloadWindowAction, ReloadWindowAction.ID, ReloadWindowAction.LABEL).run()
}]); }]);
}); });
} }
......
...@@ -27,6 +27,7 @@ import { IUserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/com ...@@ -27,6 +27,7 @@ import { IUserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/com
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { INotificationService } from 'vs/platform/notification/common/notification'; import { INotificationService } from 'vs/platform/notification/common/notification';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService'; import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
import { IHostService } from 'vs/workbench/services/host/browser/host';
function createStorageService(instantiationService: TestInstantiationService): IStorageService { function createStorageService(instantiationService: TestInstantiationService): IStorageService {
let service = instantiationService.get(IStorageService); let service = instantiationService.get(IStorageService);
...@@ -60,7 +61,7 @@ export class TestExtensionEnablementService extends ExtensionEnablementService { ...@@ -60,7 +61,7 @@ export class TestExtensionEnablementService extends ExtensionEnablementService {
instantiationService.get(IUserDataSyncAccountService) || instantiationService.stub(IUserDataSyncAccountService, UserDataSyncAccountService), instantiationService.get(IUserDataSyncAccountService) || instantiationService.stub(IUserDataSyncAccountService, UserDataSyncAccountService),
instantiationService.get(ILifecycleService) || instantiationService.stub(ILifecycleService, new TestLifecycleService()), instantiationService.get(ILifecycleService) || instantiationService.stub(ILifecycleService, new TestLifecycleService()),
instantiationService.get(INotificationService) || instantiationService.stub(INotificationService, new TestNotificationService()), instantiationService.get(INotificationService) || instantiationService.stub(INotificationService, new TestNotificationService()),
instantiationService, instantiationService.get(IHostService)
); );
} }
......
...@@ -86,7 +86,6 @@ export class BrowserHostService extends Disposable implements IHostService { ...@@ -86,7 +86,6 @@ export class BrowserHostService extends Disposable implements IHostService {
constructor( constructor(
@ILayoutService private readonly layoutService: ILayoutService, @ILayoutService private readonly layoutService: ILayoutService,
@IEditorService private readonly editorService: IEditorService,
@IConfigurationService private readonly configurationService: IConfigurationService, @IConfigurationService private readonly configurationService: IConfigurationService,
@IFileService private readonly fileService: IFileService, @IFileService private readonly fileService: IFileService,
@ILabelService private readonly labelService: ILabelService, @ILabelService private readonly labelService: ILabelService,
...@@ -213,13 +212,15 @@ export class BrowserHostService extends Disposable implements IHostService { ...@@ -213,13 +212,15 @@ export class BrowserHostService extends Disposable implements IHostService {
// Handle Folders to Add // Handle Folders to Add
if (foldersToAdd.length > 0) { if (foldersToAdd.length > 0) {
this.instantiationService.invokeFunction(accessor => { this.instantiationService.invokeFunction(accessor => {
const workspaceEditingService: IWorkspaceEditingService = accessor.get(IWorkspaceEditingService); const workspaceEditingService: IWorkspaceEditingService = accessor.get(IWorkspaceEditingService); // avoid heavy dependencies (https://github.com/microsoft/vscode/issues/108522)
workspaceEditingService.addFolders(foldersToAdd); workspaceEditingService.addFolders(foldersToAdd);
}); });
} }
// Handle Files // Handle Files
if (fileOpenables.length > 0) { if (fileOpenables.length > 0) {
this.instantiationService.invokeFunction(async accessor => {
const editorService = accessor.get(IEditorService); // avoid heavy dependencies (https://github.com/microsoft/vscode/issues/108522)
// Support diffMode // Support diffMode
if (options?.diffMode && fileOpenables.length === 2) { if (options?.diffMode && fileOpenables.length === 2) {
...@@ -230,7 +231,7 @@ export class BrowserHostService extends Disposable implements IHostService { ...@@ -230,7 +231,7 @@ export class BrowserHostService extends Disposable implements IHostService {
// Same Window: open via editor service in current window // Same Window: open via editor service in current window
if (this.shouldReuse(options, true /* file */)) { if (this.shouldReuse(options, true /* file */)) {
this.editorService.openEditor({ editorService.openEditor({
leftResource: editors[0].resource, leftResource: editors[0].resource,
rightResource: editors[1].resource rightResource: editors[1].resource
}); });
...@@ -266,7 +267,7 @@ export class BrowserHostService extends Disposable implements IHostService { ...@@ -266,7 +267,7 @@ export class BrowserHostService extends Disposable implements IHostService {
openables = [openable]; openables = [openable];
} }
this.editorService.openEditors(await pathsToEditors(openables, this.fileService)); editorService.openEditors(await pathsToEditors(openables, this.fileService));
} }
// New Window: open into empty window // New Window: open into empty window
...@@ -289,12 +290,13 @@ export class BrowserHostService extends Disposable implements IHostService { ...@@ -289,12 +290,13 @@ export class BrowserHostService extends Disposable implements IHostService {
(async () => { (async () => {
// Wait for the resources to be closed in the editor... // Wait for the resources to be closed in the editor...
await this.editorService.whenClosed(fileOpenables.map(openable => ({ resource: openable.fileUri })), { waitForSaved: true }); await editorService.whenClosed(fileOpenables.map(openable => ({ resource: openable.fileUri })), { waitForSaved: true });
// ...before deleting the wait marker file // ...before deleting the wait marker file
await this.fileService.del(waitMarkerFileURI); await this.fileService.del(waitMarkerFileURI);
})(); })();
} }
});
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册