Skip to content

Commit cb1223c

Browse files
committed
Renamed WindowComponent to WindowAdaptor
1 parent 96b0193 commit cb1223c

8 files changed

+32
-32
lines changed

src/lib/adaptors/window.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as vscode from 'vscode';
22
import TextEditor from './text-editor';
33
import {QuickPickItem} from 'vscode';
44

5-
export default class WindowComponent {
5+
export default class WindowAdaptor {
66
private window: typeof vscode.window;
77

88
constructor(window: typeof vscode.window) {

src/lib/bootstrapper-factory.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ import NormalisationRuleStore from './normalisation-rule-store';
66
import SelectionInfoRegistry from './selection-info-registry';
77
import * as vscode from 'vscode';
88
import CommandAdaptor from './adaptors/command';
9-
import WindowComponent from './adaptors/window';
9+
import WindowAdaptor from './adaptors/window';
1010

1111
export default class BootstrapperFactory {
1212
create() {
1313
const logger = console;
1414
const selectionInfoRegistry = new SelectionInfoRegistry();
1515
const normalisationRuleStore = this.createNormalisationRuleStore();
1616
const commandAdaptor = new CommandAdaptor(vscode.commands, vscode.Uri.parse);
17-
const windowComponent = new WindowComponent(vscode.window);
17+
const windowAdaptor = new WindowAdaptor(vscode.window);
1818
const commandFactory = new CommandFactory(
1919
selectionInfoRegistry,
2020
normalisationRuleStore,
2121
commandAdaptor,
22-
windowComponent,
22+
windowAdaptor,
2323
vscode,
2424
() => new Date()
2525
);

src/lib/command-factory.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import NormalisationRuleStore from './normalisation-rule-store';
1212
import SelectionInfoRegistry from './selection-info-registry';
1313
import * as clipboardy from 'clipboardy';
1414
import CommandAdaptor from './adaptors/command';
15-
import WindowComponent from './adaptors/window';
15+
import WindowAdaptor from './adaptors/window';
1616

1717
export default class CommandFactory {
1818
private readonly normalisationRuleStore: NormalisationRuleStore;
1919
private readonly selectionInfoRegistry: SelectionInfoRegistry;
2020
private readonly commandAdaptor: CommandAdaptor;
21-
private readonly windowComponent: WindowComponent;
21+
private readonly windowAdaptor: WindowAdaptor;
2222
private readonly vscode: any;
2323
private readonly getCurrentDate: () => Date;
2424
private clipboard?: Clipboard;
@@ -28,13 +28,13 @@ export default class CommandFactory {
2828
constructor(selectionInfoRegistry: SelectionInfoRegistry,
2929
normalisationRuleStore: NormalisationRuleStore,
3030
commandAdaptor: CommandAdaptor,
31-
windowComponent: WindowComponent,
31+
windowAdaptor: WindowAdaptor,
3232
vscode: any,
3333
getCurrentDate: () => Date) {
3434
this.normalisationRuleStore = normalisationRuleStore;
3535
this.selectionInfoRegistry = selectionInfoRegistry;
3636
this.commandAdaptor = commandAdaptor;
37-
this.windowComponent = windowComponent;
37+
this.windowAdaptor = windowAdaptor;
3838
this.getCurrentDate = getCurrentDate;
3939
this.vscode = vscode;
4040
}
@@ -63,14 +63,14 @@ export default class CommandFactory {
6363
this.getDiffPresenter(),
6464
this.selectionInfoRegistry,
6565
this.getMessageBar(),
66-
this.windowComponent
66+
this.windowAdaptor
6767
);
6868
}
6969

7070
createToggleNormalisationRulesCommand() {
7171
return new ToggleNormalisationRulesCommand(
7272
this.normalisationRuleStore,
73-
new NormalisationRulePicker(this.windowComponent),
73+
new NormalisationRulePicker(this.windowAdaptor),
7474
this.getMessageBar()
7575
);
7676
}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ import SelectionInfoRegistry from '../selection-info-registry';
44
import {TextKey} from '../const';
55
import {SelectionInfo} from '../entities/selection-info';
66
import {Command} from './command';
7-
import WindowComponent from '../adaptors/window';
7+
import WindowAdaptor from '../adaptors/window';
88

99
export default class CompareVisibleEditorsCommand implements Command {
10-
private readonly windowComponent: WindowComponent;
10+
private readonly windowAdaptor: WindowAdaptor;
1111
private readonly diffPresenter: DiffPresenter;
1212
private readonly messageBar: MessageBar;
1313
private readonly selectionInfoRegistry: SelectionInfoRegistry;
1414

1515
constructor(diffPresenter: DiffPresenter,
1616
selectionInfoRegistry: SelectionInfoRegistry,
1717
messageBar: MessageBar,
18-
windowComponent: WindowComponent) {
19-
this.windowComponent = windowComponent;
18+
windowAdaptor: WindowAdaptor) {
19+
this.windowAdaptor = windowAdaptor;
2020
this.diffPresenter = diffPresenter;
2121
this.messageBar = messageBar;
2222
this.selectionInfoRegistry = selectionInfoRegistry;
2323
}
2424

2525
async execute() {
26-
const editors = this.windowComponent.visibleTextEditors;
26+
const editors = this.windowAdaptor.visibleTextEditors;
2727
if (editors.length !== 2) {
2828
this.messageBar.showInfo('Please first open 2 documents to compare.');
2929
return;

src/lib/normalisation-rule-picker.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import {QuickPickItem} from 'vscode';
22
import {LoadedNormalisationRule} from './entities/normalisation-rule';
3-
import WindowComponent from './adaptors/window';
3+
import WindowAdaptor from './adaptors/window';
44

55
interface NormalisationRuleQuickPickItem extends QuickPickItem {
66
picked: boolean;
77
ruleIndex: number;
88
}
99

1010
export default class NormalisationRulePicker {
11-
private windowComponent: WindowComponent;
11+
private windowAdaptor: WindowAdaptor;
1212

13-
constructor(windowComponent: WindowComponent) {
14-
this.windowComponent = windowComponent;
13+
constructor(windowAdaptor: WindowAdaptor) {
14+
this.windowAdaptor = windowAdaptor;
1515
}
1616

1717
async show(rules: LoadedNormalisationRule[]) {
1818
const items = this.convertToQuickPickItems(rules);
19-
const userSelection = await this.windowComponent.showQuickPick(items);
19+
const userSelection = await this.windowAdaptor.showQuickPick(items);
2020
const activeItems = userSelection || items.filter(item => item.picked);
2121
return this.convertToRules(activeItems);
2222
}

src/test/lib/commands/compare-selection-with-text1.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import CommandFactory from '../../../lib/command-factory';
55
import NormalisationRuleStore from '../../../lib/normalisation-rule-store';
66
import CommandAdaptor from '../../../lib/adaptors/command';
77
import TextEditor from '../../../lib/adaptors/text-editor';
8-
import WindowComponent from '../../../lib/adaptors/window';
8+
import WindowAdaptor from '../../../lib/adaptors/window';
99

1010
suite('CompareSelectionWithText1', () => {
1111

@@ -23,13 +23,13 @@ suite('CompareSelectionWithText1', () => {
2323
});
2424

2525
const fakeVscode = {window: mockType<typeof vscode.window>()};
26-
const windowComponent = mock(WindowComponent);
26+
const windowAdaptor = mock(WindowAdaptor);
2727
const normalisationRuleStore = mock(NormalisationRuleStore);
2828

2929
test('it saves selected text and takes a diff of 2 texts', async () => {
3030

3131
const commandAdaptor = mock(CommandAdaptor);
32-
const commandFactory = new CommandFactory(selectionInfoRegistry, normalisationRuleStore, commandAdaptor, windowComponent, fakeVscode, () => new Date('2016-06-15T11:43:00Z'));
32+
const commandFactory = new CommandFactory(selectionInfoRegistry, normalisationRuleStore, commandAdaptor, windowAdaptor, fakeVscode, () => new Date('2016-06-15T11:43:00Z'));
3333
const command = commandFactory.createCompareSelectionWithText1Command();
3434

3535
await command.execute(editor);

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import DiffPresenter from '../../../lib/diff-presenter';
44
import SelectionInfoRegistry from '../../../lib/selection-info-registry';
55
import MessageBar from '../../../lib/message-bar';
66
import TextEditor from '../../../lib/adaptors/text-editor';
7-
import WindowComponent from '../../../lib/adaptors/window';
7+
import WindowAdaptor from '../../../lib/adaptors/window';
88

99
suite('CompareVisibleEditorsCommand', () => {
1010
const editor1 = mockType<TextEditor>({
@@ -64,7 +64,7 @@ suite('CompareVisibleEditorsCommand', () => {
6464

6565
function createCommand(visibleTextEditors: TextEditor[]) {
6666
const dependencies = {
67-
windowComponent: mockType<WindowComponent>({visibleTextEditors}),
67+
windowAdaptor: mockType<WindowAdaptor>({visibleTextEditors}),
6868
diffPresenter: mockMethods<DiffPresenter>(['takeDiff']),
6969
messageBar: mockMethods<MessageBar>(['showInfo']),
7070
selectionInfoRegistry: mockMethods<SelectionInfoRegistry>(['set'])
@@ -73,7 +73,7 @@ suite('CompareVisibleEditorsCommand', () => {
7373
dependencies.diffPresenter,
7474
dependencies.selectionInfoRegistry,
7575
dependencies.messageBar,
76-
dependencies.windowComponent
76+
dependencies.windowAdaptor
7777
);
7878
return {command, deps: dependencies} as any;
7979
}

src/test/lib/normalisation-rule-picker.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import NormalisationRulePicker from '../../lib/normalisation-rule-picker';
22
import * as assert from 'assert';
33
import {mock, when} from '../helpers';
4-
import WindowComponent from '../../lib/adaptors/window';
4+
import WindowAdaptor from '../../lib/adaptors/window';
55

66
suite('NormalisationRulePicker', () => {
7-
const windowComponent = mock(WindowComponent);
7+
const windowAdaptor = mock(WindowAdaptor);
88
when(
9-
windowComponent.showQuickPick(
9+
windowAdaptor.showQuickPick(
1010
[
1111
{label: 'RULE_NAME_1', picked: true, ruleIndex: 0, description: ''},
1212
{label: 'RULE_NAME_2', picked: false, ruleIndex: 1, description: ''}
@@ -15,7 +15,7 @@ suite('NormalisationRulePicker', () => {
1515
)
1616
.thenResolve([{label: 'RULE_NAME_2', picked: true, ruleIndex: 1}]);
1717
when(
18-
windowComponent.showQuickPick(
18+
windowAdaptor.showQuickPick(
1919
[
2020
{label: 'RULE_NAME_3', picked: false, ruleIndex: 0, description: ''},
2121
{label: 'RULE_NAME_4', picked: true, ruleIndex: 1, description: ''}
@@ -24,15 +24,15 @@ suite('NormalisationRulePicker', () => {
2424
)
2525
.thenResolve();
2626
when(
27-
windowComponent.showQuickPick(
27+
windowAdaptor.showQuickPick(
2828
[
2929
{label: '(no "name" set for this rule)', picked: true, ruleIndex: 0, description: ''}
3030
]
3131
)
3232
)
3333
.thenResolve([]);
3434

35-
const rulePicker = new NormalisationRulePicker(windowComponent);
35+
const rulePicker = new NormalisationRulePicker(windowAdaptor);
3636

3737
test('it returns the index of active rules that user chose', async () => {
3838
const activeRuleIndices = await rulePicker.show([

0 commit comments

Comments
 (0)