提交 30d11145 编写于 作者: M Matt Bierner

Replacing a few instances of IDisposable[]

上级 95924674
...@@ -12,7 +12,7 @@ import { ResolvedKeybinding, KeyCode } from 'vs/base/common/keyCodes'; ...@@ -12,7 +12,7 @@ import { ResolvedKeybinding, KeyCode } from 'vs/base/common/keyCodes';
import { addClass, EventType, EventHelper, EventLike, removeTabIndexAndUpdateFocus, isAncestor, hasClass, addDisposableListener, removeClass, append, $, addClasses, removeClasses } from 'vs/base/browser/dom'; import { addClass, EventType, EventHelper, EventLike, removeTabIndexAndUpdateFocus, isAncestor, hasClass, addDisposableListener, removeClass, append, $, addClasses, removeClasses } from 'vs/base/browser/dom';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { RunOnceScheduler } from 'vs/base/common/async'; import { RunOnceScheduler } from 'vs/base/common/async';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { DisposableStore } from 'vs/base/common/lifecycle';
import { Color } from 'vs/base/common/color'; import { Color } from 'vs/base/common/color';
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
import { ScrollbarVisibility, ScrollEvent } from 'vs/base/common/scrollable'; import { ScrollbarVisibility, ScrollEvent } from 'vs/base/common/scrollable';
...@@ -71,7 +71,7 @@ interface ISubMenuData { ...@@ -71,7 +71,7 @@ interface ISubMenuData {
export class Menu extends ActionBar { export class Menu extends ActionBar {
private mnemonics: Map<string, Array<BaseMenuActionViewItem>>; private mnemonics: Map<string, Array<BaseMenuActionViewItem>>;
private menuDisposables: IDisposable[]; private readonly menuDisposables: DisposableStore;
private scrollableElement: DomScrollableElement; private scrollableElement: DomScrollableElement;
private menuElement: HTMLElement; private menuElement: HTMLElement;
private scrollTopHold: number | undefined; private scrollTopHold: number | undefined;
...@@ -79,7 +79,6 @@ export class Menu extends ActionBar { ...@@ -79,7 +79,6 @@ export class Menu extends ActionBar {
private readonly _onScroll: Emitter<void>; private readonly _onScroll: Emitter<void>;
constructor(container: HTMLElement, actions: IAction[], options: IMenuOptions = {}) { constructor(container: HTMLElement, actions: IAction[], options: IMenuOptions = {}) {
addClass(container, 'monaco-menu-container'); addClass(container, 'monaco-menu-container');
container.setAttribute('role', 'presentation'); container.setAttribute('role', 'presentation');
const menuElement = document.createElement('div'); const menuElement = document.createElement('div');
...@@ -103,7 +102,7 @@ export class Menu extends ActionBar { ...@@ -103,7 +102,7 @@ export class Menu extends ActionBar {
this.actionsList.tabIndex = 0; this.actionsList.tabIndex = 0;
this.menuDisposables = []; this.menuDisposables = this._register(new DisposableStore());
addDisposableListener(menuElement, EventType.KEY_DOWN, (e) => { addDisposableListener(menuElement, EventType.KEY_DOWN, (e) => {
const event = new StandardKeyboardEvent(e); const event = new StandardKeyboardEvent(e);
...@@ -217,9 +216,9 @@ export class Menu extends ActionBar { ...@@ -217,9 +216,9 @@ export class Menu extends ActionBar {
menuElement.style.maxHeight = `${Math.max(10, window.innerHeight - container.getBoundingClientRect().top - 30)}px`; menuElement.style.maxHeight = `${Math.max(10, window.innerHeight - container.getBoundingClientRect().top - 30)}px`;
this.scrollableElement.onScroll(() => { this.menuDisposables.push(this.scrollableElement.onScroll(() => {
this._onScroll.fire(); this._onScroll.fire();
}, this, this.menuDisposables); }, this));
this._register(addDisposableListener(this.menuElement, EventType.SCROLL, (e: ScrollEvent) => { this._register(addDisposableListener(this.menuElement, EventType.SCROLL, (e: ScrollEvent) => {
if (this.scrollTopHold !== undefined) { if (this.scrollTopHold !== undefined) {
...@@ -575,7 +574,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem { ...@@ -575,7 +574,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
private mysubmenu: Menu | null; private mysubmenu: Menu | null;
private submenuContainer: HTMLElement | undefined; private submenuContainer: HTMLElement | undefined;
private submenuIndicator: HTMLElement; private submenuIndicator: HTMLElement;
private submenuDisposables: IDisposable[] = []; private readonly submenuDisposables = this._register(new DisposableStore());
private mouseOver: boolean; private mouseOver: boolean;
private showScheduler: RunOnceScheduler; private showScheduler: RunOnceScheduler;
private hideScheduler: RunOnceScheduler; private hideScheduler: RunOnceScheduler;
...@@ -675,7 +674,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem { ...@@ -675,7 +674,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
this.parentData.submenu = undefined; this.parentData.submenu = undefined;
if (this.submenuContainer) { if (this.submenuContainer) {
this.submenuDisposables = dispose(this.submenuDisposables); this.submenuDisposables.clear();
this.submenuContainer = undefined; this.submenuContainer = undefined;
} }
} }
...@@ -720,7 +719,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem { ...@@ -720,7 +719,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
this.parentData.submenu = undefined; this.parentData.submenu = undefined;
} }
this.submenuDisposables = dispose(this.submenuDisposables); this.submenuDisposables.clear();
this.submenuContainer = undefined; this.submenuContainer = undefined;
} }
})); }));
...@@ -741,7 +740,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem { ...@@ -741,7 +740,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
this.parentData.submenu = undefined; this.parentData.submenu = undefined;
} }
this.submenuDisposables = dispose(this.submenuDisposables); this.submenuDisposables.clear();
this.submenuContainer = undefined; this.submenuContainer = undefined;
})); }));
...@@ -781,7 +780,6 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem { ...@@ -781,7 +780,6 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
} }
if (this.submenuContainer) { if (this.submenuContainer) {
this.submenuDisposables = dispose(this.submenuDisposables);
this.submenuContainer = undefined; this.submenuContainer = undefined;
} }
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import 'vs/css!./sash'; import 'vs/css!./sash';
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle'; import { IDisposable, dispose, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { isIPad } from 'vs/base/browser/browser'; import { isIPad } from 'vs/base/browser/browser';
import { isMacintosh } from 'vs/base/common/platform'; import { isMacintosh } from 'vs/base/common/platform';
import * as types from 'vs/base/common/types'; import * as types from 'vs/base/common/types';
...@@ -95,14 +95,14 @@ export class Sash extends Disposable { ...@@ -95,14 +95,14 @@ export class Sash extends Disposable {
linkedSash: Sash | undefined = undefined; linkedSash: Sash | undefined = undefined;
private orthogonalStartSashDisposables: IDisposable[] = []; private readonly orthogonalStartSashDisposables = this._register(new DisposableStore());
private _orthogonalStartSash: Sash | undefined; private _orthogonalStartSash: Sash | undefined;
get orthogonalStartSash(): Sash | undefined { return this._orthogonalStartSash; } get orthogonalStartSash(): Sash | undefined { return this._orthogonalStartSash; }
set orthogonalStartSash(sash: Sash | undefined) { set orthogonalStartSash(sash: Sash | undefined) {
this.orthogonalStartSashDisposables = dispose(this.orthogonalStartSashDisposables); this.orthogonalStartSashDisposables.clear();
if (sash) { if (sash) {
sash.onDidEnablementChange(this.onOrthogonalStartSashEnablementChange, this, this.orthogonalStartSashDisposables); this.orthogonalStartSashDisposables.push(sash.onDidEnablementChange(this.onOrthogonalStartSashEnablementChange, this));
this.onOrthogonalStartSashEnablementChange(sash.state); this.onOrthogonalStartSashEnablementChange(sash.state);
} else { } else {
this.onOrthogonalStartSashEnablementChange(SashState.Disabled); this.onOrthogonalStartSashEnablementChange(SashState.Disabled);
...@@ -111,14 +111,14 @@ export class Sash extends Disposable { ...@@ -111,14 +111,14 @@ export class Sash extends Disposable {
this._orthogonalStartSash = sash; this._orthogonalStartSash = sash;
} }
private orthogonalEndSashDisposables: IDisposable[] = []; private readonly orthogonalEndSashDisposables = this._register(new DisposableStore());
private _orthogonalEndSash: Sash | undefined; private _orthogonalEndSash: Sash | undefined;
get orthogonalEndSash(): Sash | undefined { return this._orthogonalEndSash; } get orthogonalEndSash(): Sash | undefined { return this._orthogonalEndSash; }
set orthogonalEndSash(sash: Sash | undefined) { set orthogonalEndSash(sash: Sash | undefined) {
this.orthogonalEndSashDisposables = dispose(this.orthogonalEndSashDisposables); this.orthogonalEndSashDisposables.clear();
if (sash) { if (sash) {
sash.onDidEnablementChange(this.onOrthogonalEndSashEnablementChange, this, this.orthogonalEndSashDisposables); this.orthogonalEndSashDisposables.push(sash.onDidEnablementChange(this.onOrthogonalEndSashEnablementChange, this));
this.onOrthogonalEndSashEnablementChange(sash.state); this.onOrthogonalEndSashEnablementChange(sash.state);
} else { } else {
this.onOrthogonalEndSashEnablementChange(SashState.Disabled); this.onOrthogonalEndSashEnablementChange(SashState.Disabled);
...@@ -384,9 +384,6 @@ export class Sash extends Disposable { ...@@ -384,9 +384,6 @@ export class Sash extends Disposable {
dispose(): void { dispose(): void {
super.dispose(); super.dispose();
this.orthogonalStartSashDisposables = dispose(this.orthogonalStartSashDisposables);
this.orthogonalEndSashDisposables = dispose(this.orthogonalEndSashDisposables);
if (this.el && this.el.parentElement) { if (this.el && this.el.parentElement) {
this.el.parentElement.removeChild(this.el); this.el.parentElement.removeChild(this.el);
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert'; import * as assert from 'assert';
import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import { DisposableStore } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { Range } from 'vs/editor/common/core/range'; import { Range } from 'vs/editor/common/core/range';
import { TextModel } from 'vs/editor/common/model/textModel'; import { TextModel } from 'vs/editor/common/model/textModel';
...@@ -18,7 +18,7 @@ suite('CodeAction', () => { ...@@ -18,7 +18,7 @@ suite('CodeAction', () => {
let langId = new LanguageIdentifier('fooLang', 17); let langId = new LanguageIdentifier('fooLang', 17);
let uri = URI.parse('untitled:path'); let uri = URI.parse('untitled:path');
let model: TextModel; let model: TextModel;
let disposables: IDisposable[] = []; const disposables = new DisposableStore();
let testData = { let testData = {
diagnostics: { diagnostics: {
abc: { abc: {
...@@ -79,12 +79,13 @@ suite('CodeAction', () => { ...@@ -79,12 +79,13 @@ suite('CodeAction', () => {
}; };
setup(function () { setup(function () {
disposables.clear();
model = TextModel.createFromString('test1\ntest2\ntest3', undefined, langId, uri); model = TextModel.createFromString('test1\ntest2\ntest3', undefined, langId, uri);
disposables = [model]; disposables.push(model);
}); });
teardown(function () { teardown(function () {
dispose(disposables); disposables.clear();
}); });
test('CodeActions are sorted by type, #38623', async function () { test('CodeActions are sorted by type, #38623', async function () {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert'; import * as assert from 'assert';
import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import { DisposableStore } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { Selection } from 'vs/editor/common/core/selection'; import { Selection } from 'vs/editor/common/core/selection';
...@@ -26,10 +26,10 @@ suite('CodeAction', () => { ...@@ -26,10 +26,10 @@ suite('CodeAction', () => {
let model: TextModel; let model: TextModel;
let markerService: MarkerService; let markerService: MarkerService;
let editor: ICodeEditor; let editor: ICodeEditor;
let disposables: IDisposable[]; const disposables = new DisposableStore();
setup(() => { setup(() => {
disposables = []; disposables.clear();
markerService = new MarkerService(); markerService = new MarkerService();
model = TextModel.createFromString('foobar foo bar\nfarboo far boo', undefined, languageIdentifier, uri); model = TextModel.createFromString('foobar foo bar\nfarboo far boo', undefined, languageIdentifier, uri);
editor = createTestCodeEditor({ model: model }); editor = createTestCodeEditor({ model: model });
...@@ -37,7 +37,7 @@ suite('CodeAction', () => { ...@@ -37,7 +37,7 @@ suite('CodeAction', () => {
}); });
teardown(() => { teardown(() => {
dispose(disposables); disposables.clear();
editor.dispose(); editor.dispose();
model.dispose(); model.dispose();
markerService.dispose(); markerService.dispose();
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import 'vs/css!./dnd'; import 'vs/css!./dnd';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
import { isMacintosh } from 'vs/base/common/platform'; import { isMacintosh } from 'vs/base/common/platform';
import { KeyCode } from 'vs/base/common/keyCodes'; import { KeyCode } from 'vs/base/common/keyCodes';
import { ICodeEditor, IEditorMouseEvent, IMouseTarget, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor, IEditorMouseEvent, IMouseTarget, MouseTargetType } from 'vs/editor/browser/editorBrowser';
...@@ -28,12 +28,11 @@ function hasTriggerModifier(e: IKeyboardEvent | IMouseEvent): boolean { ...@@ -28,12 +28,11 @@ function hasTriggerModifier(e: IKeyboardEvent | IMouseEvent): boolean {
} }
} }
export class DragAndDropController implements editorCommon.IEditorContribution { export class DragAndDropController extends Disposable implements editorCommon.IEditorContribution {
private static readonly ID = 'editor.contrib.dragAndDrop'; private static readonly ID = 'editor.contrib.dragAndDrop';
private readonly _editor: ICodeEditor; private readonly _editor: ICodeEditor;
private _toUnhook: IDisposable[];
private _dragSelection: Selection | null; private _dragSelection: Selection | null;
private _dndDecorationIds: string[]; private _dndDecorationIds: string[];
private _mouseDown: boolean; private _mouseDown: boolean;
...@@ -45,15 +44,15 @@ export class DragAndDropController implements editorCommon.IEditorContribution { ...@@ -45,15 +44,15 @@ export class DragAndDropController implements editorCommon.IEditorContribution {
} }
constructor(editor: ICodeEditor) { constructor(editor: ICodeEditor) {
super();
this._editor = editor; this._editor = editor;
this._toUnhook = []; this._register(this._editor.onMouseDown((e: IEditorMouseEvent) => this._onEditorMouseDown(e)));
this._toUnhook.push(this._editor.onMouseDown((e: IEditorMouseEvent) => this._onEditorMouseDown(e))); this._register(this._editor.onMouseUp((e: IEditorMouseEvent) => this._onEditorMouseUp(e)));
this._toUnhook.push(this._editor.onMouseUp((e: IEditorMouseEvent) => this._onEditorMouseUp(e))); this._register(this._editor.onMouseDrag((e: IEditorMouseEvent) => this._onEditorMouseDrag(e)));
this._toUnhook.push(this._editor.onMouseDrag((e: IEditorMouseEvent) => this._onEditorMouseDrag(e))); this._register(this._editor.onMouseDrop((e: IEditorMouseEvent) => this._onEditorMouseDrop(e)));
this._toUnhook.push(this._editor.onMouseDrop((e: IEditorMouseEvent) => this._onEditorMouseDrop(e))); this._register(this._editor.onKeyDown((e: IKeyboardEvent) => this.onEditorKeyDown(e)));
this._toUnhook.push(this._editor.onKeyDown((e: IKeyboardEvent) => this.onEditorKeyDown(e))); this._register(this._editor.onKeyUp((e: IKeyboardEvent) => this.onEditorKeyUp(e)));
this._toUnhook.push(this._editor.onKeyUp((e: IKeyboardEvent) => this.onEditorKeyUp(e))); this._register(this._editor.onDidBlurEditorWidget(() => this.onEditorBlur()));
this._toUnhook.push(this._editor.onDidBlurEditorWidget(() => this.onEditorBlur()));
this._dndDecorationIds = []; this._dndDecorationIds = [];
this._mouseDown = false; this._mouseDown = false;
this._modifierPressed = false; this._modifierPressed = false;
...@@ -228,7 +227,7 @@ export class DragAndDropController implements editorCommon.IEditorContribution { ...@@ -228,7 +227,7 @@ export class DragAndDropController implements editorCommon.IEditorContribution {
this._dragSelection = null; this._dragSelection = null;
this._mouseDown = false; this._mouseDown = false;
this._modifierPressed = false; this._modifierPressed = false;
this._toUnhook = dispose(this._toUnhook); super.dispose();
} }
} }
......
...@@ -7,7 +7,7 @@ import * as arrays from 'vs/base/common/arrays'; ...@@ -7,7 +7,7 @@ import * as arrays from 'vs/base/common/arrays';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { Event } from 'vs/base/common/event'; import { Event } from 'vs/base/common/event';
import { onUnexpectedError } from 'vs/base/common/errors'; import { onUnexpectedError } from 'vs/base/common/errors';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IExtensionManagementService, ILocalExtension, IExtensionEnablementService, IExtensionTipsService, IExtensionIdentifier, EnablementState, InstallOperation } from 'vs/platform/extensionManagement/common/extensionManagement'; import { IExtensionManagementService, ILocalExtension, IExtensionEnablementService, IExtensionTipsService, IExtensionIdentifier, EnablementState, InstallOperation } from 'vs/platform/extensionManagement/common/extensionManagement';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
...@@ -22,9 +22,7 @@ export interface IExtensionStatus { ...@@ -22,9 +22,7 @@ export interface IExtensionStatus {
globallyEnabled: boolean; globallyEnabled: boolean;
} }
export class KeymapExtensions implements IWorkbenchContribution { export class KeymapExtensions extends Disposable implements IWorkbenchContribution {
private disposables: IDisposable[] = [];
constructor( constructor(
@IInstantiationService private readonly instantiationService: IInstantiationService, @IInstantiationService private readonly instantiationService: IInstantiationService,
...@@ -34,13 +32,12 @@ export class KeymapExtensions implements IWorkbenchContribution { ...@@ -34,13 +32,12 @@ export class KeymapExtensions implements IWorkbenchContribution {
@INotificationService private readonly notificationService: INotificationService, @INotificationService private readonly notificationService: INotificationService,
@ITelemetryService private readonly telemetryService: ITelemetryService, @ITelemetryService private readonly telemetryService: ITelemetryService,
) { ) {
this.disposables.push( super();
lifecycleService.onShutdown(() => this.dispose()), this._register(lifecycleService.onShutdown(() => this.dispose()));
instantiationService.invokeFunction(onExtensionChanged)((identifiers => { this._register(instantiationService.invokeFunction(onExtensionChanged)((identifiers => {
Promise.all(identifiers.map(identifier => this.checkForOtherKeymaps(identifier))) Promise.all(identifiers.map(identifier => this.checkForOtherKeymaps(identifier)))
.then(undefined, onUnexpectedError); .then(undefined, onUnexpectedError);
})) })));
);
} }
private checkForOtherKeymaps(extensionIdentifier: IExtensionIdentifier): Promise<void> { private checkForOtherKeymaps(extensionIdentifier: IExtensionIdentifier): Promise<void> {
...@@ -87,10 +84,6 @@ export class KeymapExtensions implements IWorkbenchContribution { ...@@ -87,10 +84,6 @@ export class KeymapExtensions implements IWorkbenchContribution {
}] }]
); );
} }
dispose(): void {
this.disposables = dispose(this.disposables);
}
} }
export function onExtensionChanged(accessor: ServicesAccessor): Event<IExtensionIdentifier[]> { export function onExtensionChanged(accessor: ServicesAccessor): Event<IExtensionIdentifier[]> {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import { dispose, IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { getIconClasses } from 'vs/editor/common/services/getIconClasses'; import { getIconClasses } from 'vs/editor/common/services/getIconClasses';
import { IModelService } from 'vs/editor/common/services/modelService'; import { IModelService } from 'vs/editor/common/services/modelService';
...@@ -164,7 +164,7 @@ export class OpenWorkspaceSettingsAction extends Action { ...@@ -164,7 +164,7 @@ export class OpenWorkspaceSettingsAction extends Action {
static readonly ID = 'workbench.action.openWorkspaceSettings'; static readonly ID = 'workbench.action.openWorkspaceSettings';
static readonly LABEL = nls.localize('openWorkspaceSettings', "Open Workspace Settings"); static readonly LABEL = nls.localize('openWorkspaceSettings', "Open Workspace Settings");
private disposables: IDisposable[] = []; private readonly disposables = new DisposableStore();
constructor( constructor(
id: string, id: string,
...@@ -174,7 +174,7 @@ export class OpenWorkspaceSettingsAction extends Action { ...@@ -174,7 +174,7 @@ export class OpenWorkspaceSettingsAction extends Action {
) { ) {
super(id, label); super(id, label);
this.update(); this.update();
this.workspaceContextService.onDidChangeWorkbenchState(() => this.update(), this, this.disposables); this.disposables.push(this.workspaceContextService.onDidChangeWorkbenchState(() => this.update(), this));
} }
private update(): void { private update(): void {
...@@ -186,7 +186,7 @@ export class OpenWorkspaceSettingsAction extends Action { ...@@ -186,7 +186,7 @@ export class OpenWorkspaceSettingsAction extends Action {
} }
dispose(): void { dispose(): void {
this.disposables = dispose(this.disposables); this.disposables.dispose();
super.dispose(); super.dispose();
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import { dispose, IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { isLinux } from 'vs/base/common/platform'; import { isLinux } from 'vs/base/common/platform';
import { isEqual } from 'vs/base/common/resources'; import { isEqual } from 'vs/base/common/resources';
import { endsWith } from 'vs/base/common/strings'; import { endsWith } from 'vs/base/common/strings';
...@@ -129,14 +129,14 @@ export class PreferencesContribution implements IWorkbenchContribution { ...@@ -129,14 +129,14 @@ export class PreferencesContribution implements IWorkbenchContribution {
const modelContent = JSON.stringify(schema); const modelContent = JSON.stringify(schema);
const languageSelection = this.modeService.create('jsonc'); const languageSelection = this.modeService.create('jsonc');
const model = this.modelService.createModel(modelContent, languageSelection, uri); const model = this.modelService.createModel(modelContent, languageSelection, uri);
const disposables: IDisposable[] = []; const disposables = new DisposableStore();
disposables.push(schemaRegistry.onDidChangeSchema(schemaUri => { disposables.push(schemaRegistry.onDidChangeSchema(schemaUri => {
if (schemaUri === uri.toString()) { if (schemaUri === uri.toString()) {
schema = schemaRegistry.getSchemaContributions().schemas[uri.toString()]; schema = schemaRegistry.getSchemaContributions().schemas[uri.toString()];
model.setValue(JSON.stringify(schema)); model.setValue(JSON.stringify(schema));
} }
})); }));
disposables.push(model.onWillDispose(() => dispose(disposables))); disposables.push(model.onWillDispose(() => disposables.dispose()));
return model; return model;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import * as platform from 'vs/base/common/platform'; import * as platform from 'vs/base/common/platform';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import { dispose, IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { IOpenerService } from 'vs/platform/opener/common/opener'; import { IOpenerService } from 'vs/platform/opener/common/opener';
import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/terminalWidgetManager'; import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/terminalWidgetManager';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
...@@ -64,7 +64,7 @@ interface IPath { ...@@ -64,7 +64,7 @@ interface IPath {
} }
export class TerminalLinkHandler { export class TerminalLinkHandler {
private _hoverDisposables: IDisposable[] = []; private readonly _hoverDisposables = new DisposableStore();
private _mouseMoveDisposable: IDisposable; private _mouseMoveDisposable: IDisposable;
private _widgetManager: TerminalWidgetManager; private _widgetManager: TerminalWidgetManager;
private _processCwd: string; private _processCwd: string;
...@@ -177,7 +177,8 @@ export class TerminalLinkHandler { ...@@ -177,7 +177,8 @@ export class TerminalLinkHandler {
public dispose(): void { public dispose(): void {
this._xterm = null; this._xterm = null;
this._hoverDisposables = dispose(this._hoverDisposables);
this._hoverDisposables.dispose();
this._mouseMoveDisposable = dispose(this._mouseMoveDisposable); this._mouseMoveDisposable = dispose(this._mouseMoveDisposable);
} }
......
...@@ -17,7 +17,7 @@ import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl'; ...@@ -17,7 +17,7 @@ import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import { Schemas } from 'vs/base/common/network'; import { Schemas } from 'vs/base/common/network';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { rimraf, RimRafMode, copy, readFile, exists } from 'vs/base/node/pfs'; import { rimraf, RimRafMode, copy, readFile, exists } from 'vs/base/node/pfs';
import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import { DisposableStore } from 'vs/base/common/lifecycle';
import { FileService } from 'vs/workbench/services/files/common/fileService'; import { FileService } from 'vs/workbench/services/files/common/fileService';
import { NullLogService } from 'vs/platform/log/common/log'; import { NullLogService } from 'vs/platform/log/common/log';
import { getRandomTestPath } from 'vs/base/test/node/testUtils'; import { getRandomTestPath } from 'vs/base/test/node/testUtils';
...@@ -76,7 +76,7 @@ suite('Files - TextFileService i/o', () => { ...@@ -76,7 +76,7 @@ suite('Files - TextFileService i/o', () => {
const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'textfileservice'); const parentDir = getRandomTestPath(tmpdir(), 'vsctests', 'textfileservice');
let accessor: ServiceAccessor; let accessor: ServiceAccessor;
let disposables: IDisposable[] = []; const disposables = new DisposableStore();
let service: ITextFileService; let service: ITextFileService;
let testDir: string; let testDir: string;
...@@ -108,7 +108,7 @@ suite('Files - TextFileService i/o', () => { ...@@ -108,7 +108,7 @@ suite('Files - TextFileService i/o', () => {
(<TextFileEditorModelManager>accessor.textFileService.models).dispose(); (<TextFileEditorModelManager>accessor.textFileService.models).dispose();
accessor.untitledEditorService.revertAll(); accessor.untitledEditorService.revertAll();
disposables = dispose(disposables); disposables.clear();
await rimraf(parentDir, RimRafMode.MOVE); await rimraf(parentDir, RimRafMode.MOVE);
}); });
......
...@@ -7,7 +7,7 @@ import * as assert from 'assert'; ...@@ -7,7 +7,7 @@ import * as assert from 'assert';
import { mapArrayOrNot } from 'vs/base/common/arrays'; import { mapArrayOrNot } from 'vs/base/common/arrays';
import { CancellationTokenSource } from 'vs/base/common/cancellation'; import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { isPromiseCanceledError } from 'vs/base/common/errors'; import { isPromiseCanceledError } from 'vs/base/common/errors';
import { dispose } from 'vs/base/common/lifecycle'; import { DisposableStore } from 'vs/base/common/lifecycle';
import { joinPath } from 'vs/base/common/resources'; import { joinPath } from 'vs/base/common/resources';
import { URI, UriComponents } from 'vs/base/common/uri'; import { URI, UriComponents } from 'vs/base/common/uri';
import * as pfs from 'vs/base/node/pfs'; import * as pfs from 'vs/base/node/pfs';
...@@ -21,7 +21,7 @@ import * as vscode from 'vscode'; ...@@ -21,7 +21,7 @@ import * as vscode from 'vscode';
let rpcProtocol: TestRPCProtocol; let rpcProtocol: TestRPCProtocol;
let extHostSearch: ExtHostSearch; let extHostSearch: ExtHostSearch;
let disposables: vscode.Disposable[] = []; const disposables = new DisposableStore();
let mockMainThreadSearch: MockMainThreadSearch; let mockMainThreadSearch: MockMainThreadSearch;
class MockMainThreadSearch implements MainThreadSearchShape { class MockMainThreadSearch implements MainThreadSearchShape {
...@@ -139,7 +139,7 @@ suite('ExtHostSearch', () => { ...@@ -139,7 +139,7 @@ suite('ExtHostSearch', () => {
}); });
teardown(() => { teardown(() => {
dispose(disposables); disposables.clear();
return rpcProtocol.sync(); return rpcProtocol.sync();
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册