From 1d97b7249513f3b02e697d9e79ad5b487b8ece9c Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 21 Mar 2019 11:46:39 -0700 Subject: [PATCH] Convert undefined -> null in IOutputService --- .../api/browser/mainThreadOutputService.ts | 4 ++-- .../contrib/output/browser/outputServices.ts | 13 ++++++------- src/vs/workbench/contrib/output/common/output.ts | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/api/browser/mainThreadOutputService.ts b/src/vs/workbench/api/browser/mainThreadOutputService.ts index be1dad12f03..9eb8abcdfa8 100644 --- a/src/vs/workbench/api/browser/mainThreadOutputService.ts +++ b/src/vs/workbench/api/browser/mainThreadOutputService.ts @@ -38,7 +38,7 @@ export class MainThreadOutputService extends Disposable implements MainThreadOut const setVisibleChannel = () => { const panel = this._panelService.getActivePanel(); - const visibleChannel: IOutputChannel | null = panel && panel.getId() === OUTPUT_PANEL_ID ? this._outputService.getActiveChannel() : null; + const visibleChannel = panel && panel.getId() === OUTPUT_PANEL_ID ? this._outputService.getActiveChannel() : undefined; this._proxy.$setVisibleChannel(visibleChannel ? visibleChannel.id : null); }; this._register(Event.any(this._outputService.onActiveOutputChannel, this._panelService.onDidPanelOpen, this._panelService.onDidPanelClose)(() => setVisibleChannel())); @@ -104,7 +104,7 @@ export class MainThreadOutputService extends Disposable implements MainThreadOut return undefined; } - private _getChannel(channelId: string): IOutputChannel | null { + private _getChannel(channelId: string): IOutputChannel | undefined { return this._outputService.getChannel(channelId); } } diff --git a/src/vs/workbench/contrib/output/browser/outputServices.ts b/src/vs/workbench/contrib/output/browser/outputServices.ts index 64af8aeae43..cb5a3e64108 100644 --- a/src/vs/workbench/contrib/output/browser/outputServices.ts +++ b/src/vs/workbench/contrib/output/browser/outputServices.ts @@ -27,7 +27,6 @@ import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { CancellationToken } from 'vs/base/common/cancellation'; import { IOutputChannelModel, IOutputChannelModelService } from 'vs/workbench/services/output/common/outputChannelModel'; -import { withUndefinedAsNull } from 'vs/base/common/types'; const OUTPUT_ACTIVE_CHANNEL_KEY = 'output.activechannel'; @@ -67,7 +66,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo private channels: Map = new Map(); private activeChannelIdInStorage: string; - private activeChannel: OutputChannel | null; + private activeChannel?: OutputChannel; private readonly _onActiveOutputChannel = new Emitter(); readonly onActiveOutputChannel: Event = this._onActiveOutputChannel.event; @@ -106,7 +105,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo // Set active channel to first channel if not set if (!this.activeChannel) { const channels = this.getChannelDescriptors(); - this.activeChannel = channels && channels.length > 0 ? this.getChannel(channels[0].id) : null; + this.activeChannel = channels && channels.length > 0 ? this.getChannel(channels[0].id) : undefined; } this._register(this.lifecycleService.onShutdown(() => this.dispose())); @@ -141,15 +140,15 @@ export class OutputService extends Disposable implements IOutputService, ITextMo return promise.then(() => this._onActiveOutputChannel.fire(id)); } - getChannel(id: string): OutputChannel | null { - return withUndefinedAsNull(this.channels.get(id)); + getChannel(id: string): OutputChannel | undefined { + return this.channels.get(id); } getChannelDescriptors(): IOutputChannelDescriptor[] { return Registry.as(Extensions.OutputChannels).getChannels(); } - getActiveChannel(): IOutputChannel | null { + getActiveChannel(): IOutputChannel | undefined { return this.activeChannel; } @@ -195,7 +194,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo channel.model.onDispose(() => { if (this.activeChannel === channel) { const channels = this.getChannelDescriptors(); - const channel = channels.length ? this.getChannel(channels[0].id) : null; + const channel = channels.length ? this.getChannel(channels[0].id) : undefined; if (channel && this.isPanelShown()) { this.showChannel(channel.id, true); } else { diff --git a/src/vs/workbench/contrib/output/common/output.ts b/src/vs/workbench/contrib/output/common/output.ts index 08e2a7a363e..ab2b6efe73f 100644 --- a/src/vs/workbench/contrib/output/common/output.ts +++ b/src/vs/workbench/contrib/output/common/output.ts @@ -68,7 +68,7 @@ export interface IOutputService { * Given the channel id returns the output channel instance. * Channel should be first registered via OutputChannelRegistry. */ - getChannel(id: string): IOutputChannel | null; + getChannel(id: string): IOutputChannel | undefined; /** * Returns an array of all known output channels descriptors. @@ -79,7 +79,7 @@ export interface IOutputService { * Returns the currently active channel. * Only one channel can be active at a given moment. */ - getActiveChannel(): IOutputChannel | null; + getActiveChannel(): IOutputChannel | undefined; /** * Show the channel with the passed id. -- GitLab