Skip to content

Commit 5651fa0

Browse files
author
Benjamin Pasero
committed
debt - some 💄
* add a few more readonly to properties * move IVisibleEditor closer to IEditor * remove options accessor from IEditor
1 parent c5dd0e5 commit 5651fa0

14 files changed

Lines changed: 60 additions & 72 deletions

File tree

src/vs/platform/editor/common/editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export interface IResourceInput extends IBaseResourceInput {
6565
/**
6666
* The resource URI of the resource to open.
6767
*/
68-
resource: URI;
68+
readonly resource: URI;
6969

7070
/**
7171
* The encoding of the text input if known.

src/vs/platform/notification/common/notification.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ export interface INotificationProperties {
2121
* Sticky notifications are not automatically removed after a certain timeout. By
2222
* default, notifications with primary actions and severity error are always sticky.
2323
*/
24-
sticky?: boolean;
24+
readonly sticky?: boolean;
2525

2626
/**
2727
* Silent notifications are not shown to the user unless the notification center
2828
* is opened. The status bar will still indicate all number of notifications to
2929
* catch some attention.
3030
*/
31-
silent?: boolean;
31+
readonly silent?: boolean;
3232

3333
/**
3434
* Adds an action to never show the notification again. The choice will be persisted
3535
* such as future requests will not cause the notification to show again.
3636
*/
37-
neverShowAgain?: INeverShowAgainOptions;
37+
readonly neverShowAgain?: INeverShowAgainOptions;
3838
}
3939

4040
export enum NeverShowAgainScope {
@@ -55,38 +55,38 @@ export interface INeverShowAgainOptions {
5555
/**
5656
* The id is used to persist the selection of not showing the notification again.
5757
*/
58-
id: string;
58+
readonly id: string;
5959

6060
/**
6161
* By default the action will show up as primary action. Setting this to true will
6262
* make it a secondary action instead.
6363
*/
64-
isSecondary?: boolean;
64+
readonly isSecondary?: boolean;
6565

6666
/**
6767
* Whether to persist the choice in the current workspace or for all workspaces. By
6868
* default it will be persisted for all workspaces.
6969
*/
70-
scope?: NeverShowAgainScope;
70+
readonly scope?: NeverShowAgainScope;
7171
}
7272

7373
export interface INotification extends INotificationProperties {
7474

7575
/**
7676
* The severity of the notification. Either `Info`, `Warning` or `Error`.
7777
*/
78-
severity: Severity;
78+
readonly severity: Severity;
7979

8080
/**
8181
* The message of the notification. This can either be a `string` or `Error`. Messages
8282
* can optionally include links in the format: `[text](link)`
8383
*/
84-
message: NotificationMessage;
84+
readonly message: NotificationMessage;
8585

8686
/**
8787
* The source of the notification appears as additional information.
8888
*/
89-
source?: string;
89+
readonly source?: string;
9090

9191
/**
9292
* Actions to show as part of the notification. Primary actions show up as
@@ -106,7 +106,7 @@ export interface INotification extends INotificationProperties {
106106
* The initial set of progress properties for the notification. To update progress
107107
* later on, access the `INotificationHandle.progress` property.
108108
*/
109-
progress?: INotificationProgressProperties;
109+
readonly progress?: INotificationProgressProperties;
110110
}
111111

112112
export interface INotificationActions {
@@ -115,32 +115,32 @@ export interface INotificationActions {
115115
* Primary actions show up as buttons as part of the message and will close
116116
* the notification once clicked.
117117
*/
118-
primary?: ReadonlyArray<IAction>;
118+
readonly primary?: ReadonlyArray<IAction>;
119119

120120
/**
121121
* Secondary actions are meant to provide additional configuration or context
122122
* for the notification and will show up less prominent. A notification does not
123123
* close automatically when invoking a secondary action.
124124
*/
125-
secondary?: ReadonlyArray<IAction>;
125+
readonly secondary?: ReadonlyArray<IAction>;
126126
}
127127

128128
export interface INotificationProgressProperties {
129129

130130
/**
131131
* Causes the progress bar to spin infinitley.
132132
*/
133-
infinite?: boolean;
133+
readonly infinite?: boolean;
134134

135135
/**
136136
* Indicate the total amount of work.
137137
*/
138-
total?: number;
138+
readonly total?: number;
139139

140140
/**
141141
* Indicate that a specific chunk of work is done.
142142
*/
143-
worked?: number;
143+
readonly worked?: number;
144144
}
145145

146146
export interface INotificationProgress {
@@ -176,7 +176,7 @@ export interface INotificationHandle {
176176
/**
177177
* Will be fired whenever the visibility of the notification changes.
178178
* A notification can either be visible as toast or inside the notification
179-
* center if it is visible.
179+
* center if it is visible.
180180
*/
181181
readonly onDidChangeVisibility: Event<boolean>;
182182

@@ -214,19 +214,19 @@ export interface IPromptChoice {
214214
/**
215215
* Label to show for the choice to the user.
216216
*/
217-
label: string;
217+
readonly label: string;
218218

219219
/**
220220
* Primary choices show up as buttons in the notification below the message.
221221
* Secondary choices show up under the gear icon in the header of the notification.
222222
*/
223-
isSecondary?: boolean;
223+
readonly isSecondary?: boolean;
224224

225225
/**
226226
* Whether to keep the notification open after the choice was selected
227227
* by the user. By default, will close the notification upon click.
228228
*/
229-
keepOpen?: boolean;
229+
readonly keepOpen?: boolean;
230230

231231
/**
232232
* Triggered when the user selects the choice.
@@ -249,13 +249,13 @@ export interface IStatusMessageOptions {
249249
* An optional timeout after which the status message should show. By default
250250
* the status message will show immediately.
251251
*/
252-
showAfter?: number;
252+
readonly showAfter?: number;
253253

254254
/**
255255
* An optional timeout after which the status message is to be hidden. By default
256256
* the status message will not hide until another status message is displayed.
257257
*/
258-
hideAfter?: number;
258+
readonly hideAfter?: number;
259259
}
260260

261261
export enum NotificationsFilter {

src/vs/workbench/browser/parts/editor/baseEditor.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ export abstract class BaseEditor extends Panel implements IEditor {
6262
return this._input;
6363
}
6464

65-
get options(): EditorOptions | undefined {
66-
return this._options;
67-
}
68-
6965
get group(): IEditorGroup | undefined {
7066
return this._group;
7167
}

src/vs/workbench/browser/parts/editor/editorCommands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import * as nls from 'vs/nls';
77
import * as types from 'vs/base/common/types';
88
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
99
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
10-
import { TextCompareEditorVisibleContext, EditorInput, IEditorIdentifier, IEditorCommandsContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, CloseDirection, IEditor, IEditorInput } from 'vs/workbench/common/editor';
11-
import { IEditorService, IVisibleEditor } from 'vs/workbench/services/editor/common/editorService';
10+
import { TextCompareEditorVisibleContext, EditorInput, IEditorIdentifier, IEditorCommandsContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, CloseDirection, IEditor, IEditorInput, IVisibleEditor } from 'vs/workbench/common/editor';
11+
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
1212
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
1313
import { TextDiffEditor } from 'vs/workbench/browser/parts/editor/textDiffEditor';
1414
import { KeyMod, KeyCode, KeyChord } from 'vs/base/common/keyCodes';

src/vs/workbench/browser/parts/editor/editorControl.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
7-
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
7+
import { EditorInput, EditorOptions, IVisibleEditor } from 'vs/workbench/common/editor';
88
import { Dimension, show, hide, addClass } from 'vs/base/browser/dom';
99
import { Registry } from 'vs/platform/registry/common/platform';
1010
import { IEditorRegistry, Extensions as EditorExtensions, IEditorDescriptor } from 'vs/workbench/browser/editor';
@@ -14,7 +14,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
1414
import { IEditorProgressService, LongRunningOperation } from 'vs/platform/progress/common/progress';
1515
import { IEditorGroupView, DEFAULT_EDITOR_MIN_DIMENSIONS, DEFAULT_EDITOR_MAX_DIMENSIONS } from 'vs/workbench/browser/parts/editor/editor';
1616
import { Emitter } from 'vs/base/common/event';
17-
import { IVisibleEditor } from 'vs/workbench/services/editor/common/editorService';
1817
import { assertIsDefined } from 'vs/base/common/types';
1918

2019
export interface IOpenEditorResult {

src/vs/workbench/browser/parts/editor/editorGroupView.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import 'vs/css!./media/editorgroupview';
77

88
import { EditorGroup, IEditorOpenOptions, EditorCloseEvent, ISerializedEditorGroup, isSerializedEditorGroup } from 'vs/workbench/common/editor/editorGroup';
9-
import { EditorInput, EditorOptions, GroupIdentifier, SideBySideEditorInput, CloseDirection, IEditorCloseEvent, EditorGroupActiveEditorDirtyContext, IEditor, EditorGroupEditorsCountContext, SaveReason, IEditorPartOptionsChangeEvent, EditorsOrder } from 'vs/workbench/common/editor';
9+
import { EditorInput, EditorOptions, GroupIdentifier, SideBySideEditorInput, CloseDirection, IEditorCloseEvent, EditorGroupActiveEditorDirtyContext, IEditor, EditorGroupEditorsCountContext, SaveReason, IEditorPartOptionsChangeEvent, EditorsOrder, IVisibleEditor } from 'vs/workbench/common/editor';
1010
import { Event, Emitter, Relay } from 'vs/base/common/event';
1111
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
1212
import { addClass, addClasses, Dimension, trackFocus, toggleClass, removeClass, addDisposableListener, EventType, EventHelper, findParentWithClass, clearNode, isAncestor } from 'vs/base/browser/dom';
@@ -25,7 +25,7 @@ import { EditorProgressIndicator } from 'vs/workbench/services/progress/browser/
2525
import { localize } from 'vs/nls';
2626
import { isPromiseCanceledError } from 'vs/base/common/errors';
2727
import { dispose, MutableDisposable } from 'vs/base/common/lifecycle';
28-
import { Severity, INotificationService, INotificationActions } from 'vs/platform/notification/common/notification';
28+
import { Severity, INotificationService } from 'vs/platform/notification/common/notification';
2929
import { toErrorMessage } from 'vs/base/common/errorMessage';
3030
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
3131
import { RunOnceWorker } from 'vs/base/common/async';
@@ -42,7 +42,7 @@ import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
4242
import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
4343
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
4444
import { isErrorWithActions, IErrorWithActions } from 'vs/base/common/errorsWithActions';
45-
import { IVisibleEditor, IEditorService } from 'vs/workbench/services/editor/common/editorService';
45+
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
4646
import { withNullAsUndefined, withUndefinedAsNull } from 'vs/base/common/types';
4747
import { hash } from 'vs/base/common/hash';
4848
import { guessMimeTypes } from 'vs/base/common/mime';
@@ -980,7 +980,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
980980

981981
// Otherwise, show a background notification.
982982
else {
983-
const actions: INotificationActions = { primary: [] };
983+
const actions = { primary: [] as readonly IAction[] };
984984
if (Array.isArray(errorActions)) {
985985
actions.primary = errorActions;
986986
}

src/vs/workbench/common/editor.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,12 @@ export interface IEditor extends IPanel {
6666
/**
6767
* The assigned input of this editor.
6868
*/
69-
input: IEditorInput | undefined;
70-
71-
/**
72-
* The assigned options of this editor.
73-
*/
74-
options: IEditorOptions | undefined;
69+
readonly input: IEditorInput | undefined;
7570

7671
/**
7772
* The assigned group this editor is showing in.
7873
*/
79-
group: IEditorGroup | undefined;
74+
readonly group: IEditorGroup | undefined;
8075

8176
/**
8277
* The minimum width of this editor.
@@ -114,6 +109,14 @@ export interface IEditor extends IPanel {
114109
isVisible(): boolean;
115110
}
116111

112+
/**
113+
* Overrides `IEditor` where `input` and `group` are known to be set.
114+
*/
115+
export interface IVisibleEditor extends IEditor {
116+
readonly input: IEditorInput;
117+
readonly group: IEditorGroup;
118+
}
119+
117120
export interface ITextEditor extends IEditor {
118121

119122
/**

src/vs/workbench/common/notifications.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -529,16 +529,12 @@ export class NotificationViewItem extends Disposable implements INotificationVie
529529
}
530530

531531
private setActions(actions: INotificationActions = { primary: [], secondary: [] }): void {
532-
if (!Array.isArray(actions.primary)) {
533-
actions.primary = [];
534-
}
535-
536-
if (!Array.isArray(actions.secondary)) {
537-
actions.secondary = [];
538-
}
532+
this._actions = {
533+
primary: Array.isArray(actions.primary) ? actions.primary : [],
534+
secondary: Array.isArray(actions.secondary) ? actions.secondary : []
535+
};
539536

540-
this._actions = actions;
541-
this._expanded = actions.primary.length > 0;
537+
this._expanded = actions.primary && actions.primary.length > 0;
542538
}
543539

544540
get canCollapse(): boolean {

src/vs/workbench/services/editor/browser/editorService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
77
import { IResourceInput, ITextEditorOptions, IEditorOptions, EditorActivation } from 'vs/platform/editor/common/editor';
8-
import { SideBySideEditor as SideBySideEditorChoice, IEditorInput, IEditor, GroupIdentifier, IFileEditorInput, IUntitledTextResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInputFactoryRegistry, Extensions as EditorExtensions, EditorInput, SideBySideEditorInput, IEditorInputWithOptions, isEditorInputWithOptions, EditorOptions, TextEditorOptions, IEditorIdentifier, IEditorCloseEvent, ITextEditor, ITextDiffEditor, ITextSideBySideEditor, IRevertOptions, SaveReason, EditorsOrder, isTextEditor, IWorkbenchEditorConfiguration, toResource } from 'vs/workbench/common/editor';
8+
import { SideBySideEditor as SideBySideEditorChoice, IEditorInput, IEditor, GroupIdentifier, IFileEditorInput, IUntitledTextResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInputFactoryRegistry, Extensions as EditorExtensions, EditorInput, SideBySideEditorInput, IEditorInputWithOptions, isEditorInputWithOptions, EditorOptions, TextEditorOptions, IEditorIdentifier, IEditorCloseEvent, ITextEditor, ITextDiffEditor, ITextSideBySideEditor, IRevertOptions, SaveReason, EditorsOrder, isTextEditor, IWorkbenchEditorConfiguration, toResource, IVisibleEditor } from 'vs/workbench/common/editor';
99
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
1010
import { Registry } from 'vs/platform/registry/common/platform';
1111
import { ResourceMap } from 'vs/base/common/map';
@@ -17,7 +17,7 @@ import { URI } from 'vs/base/common/uri';
1717
import { basename, isEqualOrParent, joinPath } from 'vs/base/common/resources';
1818
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
1919
import { IEditorGroupsService, IEditorGroup, GroupsOrder, IEditorReplacement, GroupChangeKind, preferredSideBySideGroupDirection } from 'vs/workbench/services/editor/common/editorGroupsService';
20-
import { IResourceEditor, SIDE_GROUP, IResourceEditorReplacement, IOpenEditorOverrideHandler, IVisibleEditor, IEditorService, SIDE_GROUP_TYPE, ACTIVE_GROUP_TYPE, ISaveEditorsOptions, ISaveAllEditorsOptions, IRevertAllEditorsOptions, IBaseSaveRevertAllEditorOptions } from 'vs/workbench/services/editor/common/editorService';
20+
import { IResourceEditor, SIDE_GROUP, IResourceEditorReplacement, IOpenEditorOverrideHandler, IEditorService, SIDE_GROUP_TYPE, ACTIVE_GROUP_TYPE, ISaveEditorsOptions, ISaveAllEditorsOptions, IRevertAllEditorsOptions, IBaseSaveRevertAllEditorOptions } from 'vs/workbench/services/editor/common/editorService';
2121
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
2222
import { Disposable, IDisposable, dispose, toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
2323
import { coalesce, distinct } from 'vs/base/common/arrays';

src/vs/workbench/services/editor/common/editorGroupsService.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
import { Event } from 'vs/base/common/event';
77
import { createDecorator, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
8-
import { IEditorInput, IEditor, GroupIdentifier, IEditorInputWithOptions, CloseDirection, IEditorPartOptions, IEditorPartOptionsChangeEvent, EditorsOrder } from 'vs/workbench/common/editor';
8+
import { IEditorInput, IEditor, GroupIdentifier, IEditorInputWithOptions, CloseDirection, IEditorPartOptions, IEditorPartOptionsChangeEvent, EditorsOrder, IVisibleEditor } from 'vs/workbench/common/editor';
99
import { IEditorOptions, ITextEditorOptions } from 'vs/platform/editor/common/editor';
1010
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
11-
import { IVisibleEditor } from 'vs/workbench/services/editor/common/editorService';
1211
import { IDimension } from 'vs/editor/common/editorCommon';
1312
import { IDisposable } from 'vs/base/common/lifecycle';
1413

0 commit comments

Comments
 (0)