From ced1335a0eb79623338322c04f8c36ec970e1264 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 2 Sep 2019 11:08:37 +0200 Subject: [PATCH] debt - less null --- src/vs/base/browser/dnd.ts | 2 +- src/vs/base/common/labels.ts | 2 +- src/vs/workbench/browser/composite.ts | 4 ++-- src/vs/workbench/browser/parts/compositePart.ts | 3 +-- .../workbench/browser/parts/editor/textDiffEditor.ts | 2 +- .../browser/parts/editor/textResourceEditor.ts | 2 +- src/vs/workbench/browser/parts/editor/titleControl.ts | 2 +- src/vs/workbench/common/composite.ts | 2 +- src/vs/workbench/common/editor.ts | 10 +++++----- src/vs/workbench/common/editor/dataUriEditorInput.ts | 5 ++--- src/vs/workbench/common/editor/untitledEditorInput.ts | 4 ++-- .../contrib/files/browser/editors/binaryFileEditor.ts | 2 +- .../workbench/services/editor/browser/editorService.ts | 4 ++-- .../preferences/common/preferencesEditorInput.ts | 2 +- 14 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/vs/base/browser/dnd.ts b/src/vs/base/browser/dnd.ts index 1a5d28e802e..642b0827420 100644 --- a/src/vs/base/browser/dnd.ts +++ b/src/vs/base/browser/dnd.ts @@ -111,4 +111,4 @@ export interface IStaticDND { export const StaticDND: IStaticDND = { CurrentDragAndDropData: undefined -}; \ No newline at end of file +}; diff --git a/src/vs/base/common/labels.ts b/src/vs/base/common/labels.ts index 39effeb6fdf..e866c720bc1 100644 --- a/src/vs/base/common/labels.ts +++ b/src/vs/base/common/labels.ts @@ -283,7 +283,7 @@ interface ISegment { * @param value string to which templating is applied * @param values the values of the templates to use */ -export function template(template: string, values: { [key: string]: string | ISeparator | null } = Object.create(null)): string { +export function template(template: string, values: { [key: string]: string | ISeparator | undefined | null } = Object.create(null)): string { const segments: ISegment[] = []; let inVariable = false; diff --git a/src/vs/workbench/browser/composite.ts b/src/vs/workbench/browser/composite.ts index bab3dcfb849..1c8f30a8f20 100644 --- a/src/vs/workbench/browser/composite.ts +++ b/src/vs/workbench/browser/composite.ts @@ -84,8 +84,8 @@ export abstract class Composite extends Component implements IComposite { this.visible = false; } - getTitle(): string | null { - return null; + getTitle(): string | undefined { + return undefined; } protected get telemetryService(): ITelemetryService { diff --git a/src/vs/workbench/browser/parts/compositePart.ts b/src/vs/workbench/browser/parts/compositePart.ts index 95c15731550..adac882f1d3 100644 --- a/src/vs/workbench/browser/parts/compositePart.ts +++ b/src/vs/workbench/browser/parts/compositePart.ts @@ -32,7 +32,6 @@ import { attachProgressBarStyler } from 'vs/platform/theme/common/styler'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { Dimension, append, $, addClass, hide, show, addClasses } from 'vs/base/browser/dom'; import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview'; -import { withNullAsUndefined } from 'vs/base/common/types'; export interface ICompositeTitleLabel { @@ -240,7 +239,7 @@ export abstract class CompositePart extends Part { // Update title with composite title if it differs from descriptor const descriptor = this.registry.getComposite(composite.getId()); if (descriptor && descriptor.name !== composite.getTitle()) { - this.updateTitle(composite.getId(), withNullAsUndefined(composite.getTitle())); + this.updateTitle(composite.getId(), composite.getTitle()); } // Handle Composite Actions diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts index e1c0ac76525..0fb181af83a 100644 --- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts @@ -61,7 +61,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor { return new EditorMemento(this.getId(), key, Object.create(null), limit, editorGroupService); // do not persist in storage as diff editors are never persisted } - getTitle(): string | null { + getTitle(): string | undefined { if (this.input) { return this.input.getName(); } diff --git a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts index 719a4345953..7f7035c56c6 100644 --- a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts @@ -46,7 +46,7 @@ export class AbstractTextResourceEditor extends BaseTextEditor { super(id, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService, windowService); } - getTitle(): string | null { + getTitle(): string | undefined { if (this.input) { return this.input.getName(); } diff --git a/src/vs/workbench/browser/parts/editor/titleControl.ts b/src/vs/workbench/browser/parts/editor/titleControl.ts index 97d9bb6aee1..089bbbc8875 100644 --- a/src/vs/workbench/browser/parts/editor/titleControl.ts +++ b/src/vs/workbench/browser/parts/editor/titleControl.ts @@ -274,7 +274,7 @@ export abstract class TitleControl extends Themable { label = localize('draggedEditorGroup', "{0} (+{1})", label, this.group.count - 1); } - applyDragImage(e, label, 'monaco-editor-group-drag-image'); + applyDragImage(e, withUndefinedAsNull(label), 'monaco-editor-group-drag-image'); } })); diff --git a/src/vs/workbench/common/composite.ts b/src/vs/workbench/common/composite.ts index 21499990aa2..b6ea6f2ca73 100644 --- a/src/vs/workbench/common/composite.ts +++ b/src/vs/workbench/common/composite.ts @@ -15,7 +15,7 @@ export interface IComposite { /** * Returns the name of this composite to show in the title area. */ - getTitle(): string | null; + getTitle(): string | undefined; /** * Returns the primary actions of the composite. diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index 024a9fe49c0..0a4df5dc9b3 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -292,7 +292,7 @@ export interface IEditorInput extends IDisposable { /** * Returns the display name of this input. */ - getName(): string | null; + getName(): string | undefined; /** * Returns the display description of this input. @@ -302,7 +302,7 @@ export interface IEditorInput extends IDisposable { /** * Returns the display title of this input. */ - getTitle(verbosity?: Verbosity): string | null; + getTitle(verbosity?: Verbosity): string | undefined; /** * Resolves the input. @@ -358,8 +358,8 @@ export abstract class EditorInput extends Disposable implements IEditorInput { * Returns the name of this input that can be shown to the user. Examples include showing the name of the input * above the editor area when the input is shown. */ - getName(): string | null { - return null; + getName(): string | undefined { + return undefined; } /** @@ -374,7 +374,7 @@ export abstract class EditorInput extends Disposable implements IEditorInput { * Returns the title of this input that can be shown to the user. Examples include showing the title of * the input above the editor area as hover over the input label. */ - getTitle(verbosity?: Verbosity): string | null { + getTitle(verbosity?: Verbosity): string | undefined { return this.getName(); } diff --git a/src/vs/workbench/common/editor/dataUriEditorInput.ts b/src/vs/workbench/common/editor/dataUriEditorInput.ts index f75c3d04103..da07bb83608 100644 --- a/src/vs/workbench/common/editor/dataUriEditorInput.ts +++ b/src/vs/workbench/common/editor/dataUriEditorInput.ts @@ -8,7 +8,6 @@ import { URI } from 'vs/base/common/uri'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel'; import { DataUri } from 'vs/base/common/resources'; -import { withUndefinedAsNull } from 'vs/base/common/types'; /** * An editor input to present data URIs in a binary editor. Data URIs have the form of: @@ -51,8 +50,8 @@ export class DataUriEditorInput extends EditorInput { return DataUriEditorInput.ID; } - getName(): string | null { - return withUndefinedAsNull(this.name); + getName(): string | undefined { + return this.name; } getDescription(): string | undefined { diff --git a/src/vs/workbench/common/editor/untitledEditorInput.ts b/src/vs/workbench/common/editor/untitledEditorInput.ts index adae5eddbd3..1c021309268 100644 --- a/src/vs/workbench/common/editor/untitledEditorInput.ts +++ b/src/vs/workbench/common/editor/untitledEditorInput.ts @@ -107,7 +107,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport return this.labelService.getUriLabel(this.resource); } - getTitle(verbosity: Verbosity): string | null { + getTitle(verbosity: Verbosity): string | undefined { if (!this.hasAssociatedFilePath) { return this.getName(); } @@ -121,7 +121,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport return this.longTitle; } - return null; + return undefined; } isDirty(): boolean { diff --git a/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts b/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts index 8b18b21b1d4..8a9bb08108a 100644 --- a/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts +++ b/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts @@ -57,7 +57,7 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor { } } - getTitle(): string | null { + getTitle(): string | undefined { return this.input ? this.input.getName() : nls.localize('binaryFileEditor', "Binary File Viewer"); } } diff --git a/src/vs/workbench/services/editor/browser/editorService.ts b/src/vs/workbench/services/editor/browser/editorService.ts index 9c443dbd313..f36b9f96a4f 100644 --- a/src/vs/workbench/services/editor/browser/editorService.ts +++ b/src/vs/workbench/services/editor/browser/editorService.ts @@ -635,10 +635,10 @@ export class EditorService extends Disposable implements EditorServiceImpl { return input; } - private toDiffLabel(input: EditorInput): string | null { + private toDiffLabel(input: EditorInput): string | undefined { const res = input.getResource(); if (!res) { - return null; + return undefined; } // Do not try to extract any paths from simple untitled editors diff --git a/src/vs/workbench/services/preferences/common/preferencesEditorInput.ts b/src/vs/workbench/services/preferences/common/preferencesEditorInput.ts index 41edfc30a95..edcb4902f76 100644 --- a/src/vs/workbench/services/preferences/common/preferencesEditorInput.ts +++ b/src/vs/workbench/services/preferences/common/preferencesEditorInput.ts @@ -21,7 +21,7 @@ export class PreferencesEditorInput extends SideBySideEditorInput { return PreferencesEditorInput.ID; } - getTitle(verbosity: Verbosity): string | null { + getTitle(verbosity: Verbosity): string | undefined { return this.master.getTitle(verbosity); } } -- GitLab