Skip to content

Commit b82feda

Browse files
committed
Removed no-longer-adding-value MessageBar class
1 parent 389f8c0 commit b82feda

File tree

7 files changed

+14
-60
lines changed

7 files changed

+14
-60
lines changed

src/lib/command-factory.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import CompareVisibleEditorsCommand from './commands/compare-visible-editors';
55
import TextTitleBuilder from './text-title-builder';
66
import Clipboard from './clipboard';
77
import DiffPresenter from './diff-presenter';
8-
import MessageBar from './message-bar';
98
import NormalisationRulePicker from './normalisation-rule-picker';
109
import ToggleNormalisationRulesCommand from './commands/toggle-normalisation-rules';
1110
import NormalisationRuleStore from './normalisation-rule-store';
@@ -22,7 +21,6 @@ export default class CommandFactory {
2221
private readonly getCurrentDate: () => Date;
2322
private clipboard?: Clipboard;
2423
private diffPresenter?: DiffPresenter;
25-
private messageBar?: MessageBar;
2624

2725
constructor(selectionInfoRegistry: SelectionInfoRegistry,
2826
normalisationRuleStore: NormalisationRuleStore,
@@ -59,7 +57,6 @@ export default class CommandFactory {
5957
return new CompareVisibleEditorsCommand(
6058
this.getDiffPresenter(),
6159
this.selectionInfoRegistry,
62-
this.getMessageBar(),
6360
this.windowAdaptor
6461
);
6562
}
@@ -68,7 +65,7 @@ export default class CommandFactory {
6865
return new ToggleNormalisationRulesCommand(
6966
this.normalisationRuleStore,
7067
new NormalisationRulePicker(this.windowAdaptor),
71-
this.getMessageBar()
68+
this.windowAdaptor
7269
);
7370
}
7471

@@ -82,11 +79,6 @@ export default class CommandFactory {
8279
return this.diffPresenter;
8380
}
8481

85-
private getMessageBar() {
86-
this.messageBar = this.messageBar || this.createMessageBar();
87-
return this.messageBar;
88-
}
89-
9082
private createClipboard() {
9183
return new Clipboard(clipboardy, process.platform);
9284
}
@@ -100,8 +92,4 @@ export default class CommandFactory {
10092
this.getCurrentDate
10193
);
10294
}
103-
104-
private createMessageBar() {
105-
return new MessageBar(this.windowAdaptor);
106-
}
10795
}

src/lib/commands/compare-visible-editors.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import DiffPresenter from '../diff-presenter';
2-
import MessageBar from '../message-bar';
32
import SelectionInfoRegistry from '../selection-info-registry';
43
import {TextKey} from '../const';
54
import {SelectionInfo} from '../entities/selection-info';
@@ -9,23 +8,20 @@ import WindowAdaptor from '../adaptors/window';
98
export default class CompareVisibleEditorsCommand implements Command {
109
private readonly windowAdaptor: WindowAdaptor;
1110
private readonly diffPresenter: DiffPresenter;
12-
private readonly messageBar: MessageBar;
1311
private readonly selectionInfoRegistry: SelectionInfoRegistry;
1412

1513
constructor(diffPresenter: DiffPresenter,
1614
selectionInfoRegistry: SelectionInfoRegistry,
17-
messageBar: MessageBar,
1815
windowAdaptor: WindowAdaptor) {
1916
this.windowAdaptor = windowAdaptor;
2017
this.diffPresenter = diffPresenter;
21-
this.messageBar = messageBar;
2218
this.selectionInfoRegistry = selectionInfoRegistry;
2319
}
2420

2521
async execute() {
2622
const editors = this.windowAdaptor.visibleTextEditors;
2723
if (editors.length !== 2) {
28-
this.messageBar.showInfo('Please first open 2 documents to compare.');
24+
this.windowAdaptor.showInformationMessage('Please first open 2 documents to compare.');
2925
return;
3026
}
3127

src/lib/commands/toggle-normalisation-rules.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import MessageBar from '../message-bar';
21
import NormalisationRulePicker from '../normalisation-rule-picker';
32
import NormalisationRuleStore from '../normalisation-rule-store';
43
import {Command} from './command';
4+
import WindowAdaptor from '../adaptors/window';
55

66
export default class ToggleNormalisationRulesCommand implements Command {
7-
private readonly messageBar: MessageBar;
7+
private readonly windowAdaptor: WindowAdaptor;
88
private readonly normalisationRulePicker: NormalisationRulePicker;
99
private readonly normalisationRuleStore: NormalisationRuleStore;
1010

1111
constructor(normalisationRuleStore: NormalisationRuleStore,
1212
normalisationRulePicker: NormalisationRulePicker,
13-
messageBar: MessageBar) {
14-
this.messageBar = messageBar;
13+
windowAdaptor: WindowAdaptor) {
14+
this.windowAdaptor = windowAdaptor;
1515
this.normalisationRulePicker = normalisationRulePicker;
1616
this.normalisationRuleStore = normalisationRuleStore;
1717
}
@@ -22,7 +22,7 @@ export default class ToggleNormalisationRulesCommand implements Command {
2222
const newRules = await this.normalisationRulePicker.show(rules);
2323
this.normalisationRuleStore.specifyActiveRules(newRules);
2424
} else {
25-
await this.messageBar.showInfo(
25+
await this.windowAdaptor.showInformationMessage(
2626
'Please set `partialDiff.preComparisonTextNormalizationRules` first'
2727
);
2828
}

src/lib/message-bar.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/test/lib/commands/compare-visible-editors.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import CompareVisibleEditorsCommand from '../../../lib/commands/compare-visible-
22
import {mockMethods, mockType, verify} from '../../helpers';
33
import DiffPresenter from '../../../lib/diff-presenter';
44
import SelectionInfoRegistry from '../../../lib/selection-info-registry';
5-
import MessageBar from '../../../lib/message-bar';
65
import TextEditor from '../../../lib/adaptors/text-editor';
76
import WindowAdaptor from '../../../lib/adaptors/window';
87

@@ -58,21 +57,19 @@ suite('CompareVisibleEditorsCommand', () => {
5857
await command.execute();
5958

6059
verify(
61-
deps.messageBar.showInfo('Please first open 2 documents to compare.')
60+
deps.windowAdaptor.showInformationMessage('Please first open 2 documents to compare.')
6261
);
6362
});
6463

6564
function createCommand(visibleTextEditors: TextEditor[]) {
6665
const dependencies = {
67-
windowAdaptor: mockType<WindowAdaptor>({visibleTextEditors}),
66+
windowAdaptor: mockMethods<WindowAdaptor>(['showInformationMessage'], {visibleTextEditors}),
6867
diffPresenter: mockMethods<DiffPresenter>(['takeDiff']),
69-
messageBar: mockMethods<MessageBar>(['showInfo']),
7068
selectionInfoRegistry: mockMethods<SelectionInfoRegistry>(['set'])
7169
};
7270
const command = new CompareVisibleEditorsCommand(
7371
dependencies.diffPresenter,
7472
dependencies.selectionInfoRegistry,
75-
dependencies.messageBar,
7673
dependencies.windowAdaptor
7774
);
7875
return {command, deps: dependencies} as any;

src/test/lib/commands/toggle-normalisation-rules.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import ToggleNormalisationRulesCommand from '../../../lib/commands/toggle-normalisation-rules';
2-
import {mockMethods, mockType, verify, when} from '../../helpers';
3-
import MessageBar from '../../../lib/message-bar';
2+
import {mock, mockMethods, mockType, verify, when} from '../../helpers';
43
import NormalisationRuleStore from '../../../lib/normalisation-rule-store';
54
import NormalisationRulePicker from '../../../lib/normalisation-rule-picker';
65
import {LoadedNormalisationRule} from '../../../lib/entities/normalisation-rule';
6+
import WindowAdaptor from '../../../lib/adaptors/window';
77

88
suite('ToggleNormalisationRulesCommand', () => {
99

@@ -23,7 +23,7 @@ suite('ToggleNormalisationRulesCommand', () => {
2323
await command.execute();
2424

2525
verify(
26-
deps.messageBar.showInfo(
26+
deps.windowAdaptor.showInformationMessage(
2727
'Please set `partialDiff.preComparisonTextNormalizationRules` first'
2828
)
2929
);
@@ -37,14 +37,14 @@ suite('ToggleNormalisationRulesCommand', () => {
3737
when(normalisationRulePicker.show(rules)).thenResolve('ACTIVE_RULE_INDICES');
3838

3939
const deps = {
40-
messageBar: mockMethods<MessageBar>(['showInfo']),
40+
windowAdaptor: mock(WindowAdaptor),
4141
normalisationRulePicker,
4242
normalisationRuleStore
4343
};
4444
const command = new ToggleNormalisationRulesCommand(
4545
deps.normalisationRuleStore,
4646
deps.normalisationRulePicker,
47-
deps.messageBar
47+
deps.windowAdaptor
4848
);
4949
return {command, deps} as any;
5050
}

src/test/lib/message-bar.test.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)