Change shutdown listeners (#4282)

* change shutdown to use proper notification

* change to use storage service

* remove unused imports

* fix test

* change shutdown methods to private

* remove unusde imports

* fix tests

* formatting
This commit is contained in:
Anthony Dresser
2019-03-13 15:15:51 -07:00
committed by GitHub
parent 08d4cc9690
commit b6584c9ddf
16 changed files with 51 additions and 43 deletions

View File

@@ -51,7 +51,7 @@ export class AccountManagementService implements IAccountManagementService {
private _mementoObj: object,
@IInstantiationService private _instantiationService: IInstantiationService,
@IStorageService private _storageService: IStorageService,
@IClipboardService private _clipboardService: IClipboardService,
@IClipboardService private _clipboardService: IClipboardService
) {
// Create the account store
if (!this._mementoObj) {
@@ -65,6 +65,8 @@ export class AccountManagementService implements IAccountManagementService {
this._removeAccountProviderEmitter = new Emitter<azdata.AccountProviderMetadata>();
this._updateAccountListEmitter = new Emitter<UpdateAccountListEventParams>();
_storageService.onWillSaveState(() => this.shutdown());
// Register status bar item
let statusbarDescriptor = new statusbar.StatusbarItemDescriptor(
AccountListStatusbarItem,
@@ -367,7 +369,7 @@ export class AccountManagementService implements IAccountManagementService {
/**
* Handler for when shutdown of the application occurs. Writes out the memento.
*/
public shutdown(): void {
private shutdown(): void {
if (this._mementoContext) {
this._mementoContext.saveMemento();
}

View File

@@ -67,8 +67,6 @@ export interface INotebookService {
listNotebookEditors(): INotebookEditor[];
shutdown(): void;
getMimeRegistry(): RenderMimeRegistry;
renameNotebookEditor(oldUri: URI, newUri: URI, currentEditor: INotebookEditor): void;
@@ -108,4 +106,4 @@ export interface INotebookEditor {
isVisible(): boolean;
executeEdits(edits: ISingleNotebookEditOperation[]): boolean;
runCell(cell: ICellModel): Promise<boolean>;
}
}

View File

@@ -32,10 +32,10 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import { NotebookEditor } from 'sql/parts/notebook/notebookEditor';
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { registerNotebookThemes } from 'sql/parts/notebook/notebookStyles';
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
import { ILanguageMagic, notebookConstants } from 'sql/parts/notebook/models/modelInterfaces';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { SqlNotebookProvider } from 'sql/workbench/services/notebook/sql/sqlNotebookProvider';
export interface NotebookProviderProperties {
@@ -95,6 +95,7 @@ export class NotebookService extends Disposable implements INotebookService {
private _overrideEditorThemeSetting: boolean;
constructor(
@ILifecycleService lifecycleService: ILifecycleService,
@IStorageService private _storageService: IStorageService,
@IExtensionService extensionService: IExtensionService,
@IExtensionManagementService extensionManagementService: IExtensionManagementService,
@@ -103,7 +104,6 @@ export class NotebookService extends Disposable implements INotebookService {
@IEditorService private readonly _editorService: IEditorService,
@IEditorGroupsService private readonly _editorGroupsService: IEditorGroupsService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IThemeService private readonly _themeService: IThemeService,
@IQueryManagementService private readonly _queryManagementService
) {
super();
@@ -128,6 +128,8 @@ export class NotebookService extends Disposable implements INotebookService {
if (extensionManagementService) {
this._register(extensionManagementService.onDidUninstallExtension(({ identifier }) => this.removeContributedProvidersFromCache(identifier, extensionService)));
}
lifecycleService.onWillShutdown(() => this.shutdown());
this.hookContextKeyListeners();
this.hookNotebookThemesAndConfigListener();
}
@@ -284,7 +286,7 @@ export class NotebookService extends Disposable implements INotebookService {
return this._providerToStandardKernels.get(provider.toUpperCase());
}
public shutdown(): void {
private shutdown(): void {
this._managersMap.forEach(manager => {
manager.forEach(m => {
if (m.serverManager) {
@@ -469,4 +471,4 @@ export class NotebookService extends Disposable implements INotebookService {
}
});
}
}
}