Skip to content

Commit e8eb39b

Browse files
authored
debt: move or remove NullXYZServices (microsoft#165397)
We have a few NullXYZServices. Those are useful for testing but we should move them to separate files so that we don't end up shipping them with the product
1 parent 98546b2 commit e8eb39b

File tree

10 files changed

+44
-49
lines changed

10 files changed

+44
-49
lines changed

extensions/references-view/yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,3 @@
66
version "16.11.33"
77
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.33.tgz#566713b1b626f781c5c58fe3531307283e00720c"
88
integrity sha512-0PJ0vg+JyU0MIan58IOIFRtSvsb7Ri+7Wltx2qAg94eMOrpg4+uuP3aUHCpxXc1i0jCXiC+zIamSZh3l9AbcQA==
9-
10-
vscode-nls@^5.2.0:
11-
version "5.2.0"
12-
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
13-
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==

src/vs/editor/contrib/hover/browser/marginHover.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/b
1212
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
1313
import { ILanguageService } from 'vs/editor/common/languages/language';
1414
import { HoverOperation, HoverStartMode, IHoverComputer } from 'vs/editor/contrib/hover/browser/hoverOperation';
15-
import { IOpenerService, NullOpenerService } from 'vs/platform/opener/common/opener';
15+
import { IOpenerService } from 'vs/platform/opener/common/opener';
1616
import { HoverWidget } from 'vs/base/browser/ui/hover/hoverWidget';
1717

1818
const $ = dom.$;
@@ -39,7 +39,7 @@ export class MarginHoverWidget extends Disposable implements IOverlayWidget {
3939
constructor(
4040
editor: ICodeEditor,
4141
languageService: ILanguageService,
42-
openerService: IOpenerService = NullOpenerService,
42+
openerService: IOpenerService,
4343
) {
4444
super();
4545
this._editor = editor;

src/vs/editor/test/browser/services/openerService.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { Disposable } from 'vs/base/common/lifecycle';
77
import { URI } from 'vs/base/common/uri';
88
import { OpenerService } from 'vs/editor/browser/services/openerService';
99
import { TestCodeEditorService } from 'vs/editor/test/browser/editorTestServices';
10-
import { CommandsRegistry, ICommandService, NullCommandService } from 'vs/platform/commands/common/commands';
10+
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
11+
import { NullCommandService } from 'vs/platform/commands/test/common/nullCommandService';
1112
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
1213
import { matchesScheme, matchesSomeScheme } from 'vs/platform/opener/common/opener';
1314
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';

src/vs/editor/test/browser/testCodeEditor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKe
4747
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
4848
import { INotificationService } from 'vs/platform/notification/common/notification';
4949
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
50-
import { IOpenerService, NullOpenerService } from 'vs/platform/opener/common/opener';
50+
import { IOpenerService } from 'vs/platform/opener/common/opener';
51+
import { NullOpenerService } from 'vs/platform/opener/test/common/nullOpenerService';
5152
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
5253
import { NullTelemetryServiceShape } from 'vs/platform/telemetry/common/telemetryUtils';
5354
import { IThemeService } from 'vs/platform/theme/common/themeService';

src/vs/platform/actions/test/common/menuService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
88
import { generateUuid } from 'vs/base/common/uuid';
99
import { isIMenuItem, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
1010
import { MenuService } from 'vs/platform/actions/common/menuService';
11-
import { NullCommandService } from 'vs/platform/commands/common/commands';
11+
import { NullCommandService } from 'vs/platform/commands/test/common/nullCommandService';
1212
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
1313
import { InMemoryStorageService } from 'vs/platform/storage/common/storage';
1414

src/vs/platform/commands/common/commands.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { Emitter, Event } from 'vs/base/common/event';
77
import { Iterable } from 'vs/base/common/iterator';
88
import { IJSONSchema } from 'vs/base/common/jsonSchema';
9-
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
9+
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
1010
import { LinkedList } from 'vs/base/common/linkedList';
1111
import { TypeConstraint, validateConstraints } from 'vs/base/common/types';
1212
import { createDecorator, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
@@ -140,13 +140,4 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
140140
}
141141
};
142142

143-
export const NullCommandService: ICommandService = {
144-
_serviceBrand: undefined,
145-
onWillExecuteCommand: () => Disposable.None,
146-
onDidExecuteCommand: () => Disposable.None,
147-
executeCommand() {
148-
return Promise.resolve(undefined);
149-
}
150-
};
151-
152143
CommandsRegistry.registerCommand('noop', () => { });
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { Disposable } from 'vs/base/common/lifecycle';
7+
import { ICommandService } from 'vs/platform/commands/common/commands';
8+
9+
export const NullCommandService: ICommandService = {
10+
_serviceBrand: undefined,
11+
onWillExecuteCommand: () => Disposable.None,
12+
onDidExecuteCommand: () => Disposable.None,
13+
executeCommand() {
14+
return Promise.resolve(undefined);
15+
}
16+
};

src/vs/platform/opener/common/opener.ts

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

66
import { CancellationToken } from 'vs/base/common/cancellation';
7-
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
7+
import { IDisposable } from 'vs/base/common/lifecycle';
88
import { equalsIgnoreCase, startsWithIgnoreCase } from 'vs/base/common/strings';
99
import { URI } from 'vs/base/common/uri';
1010
import { IEditorOptions, ITextEditorSelection } from 'vs/platform/editor/common/editor';
@@ -117,17 +117,6 @@ export interface IOpenerService {
117117
resolveExternalUri(resource: URI, options?: ResolveExternalUriOptions): Promise<IResolvedExternalUri>;
118118
}
119119

120-
export const NullOpenerService = Object.freeze({
121-
_serviceBrand: undefined,
122-
registerOpener() { return Disposable.None; },
123-
registerValidator() { return Disposable.None; },
124-
registerExternalUriResolver() { return Disposable.None; },
125-
setDefaultExternalOpener() { },
126-
registerExternalOpener() { return Disposable.None; },
127-
async open() { return false; },
128-
async resolveExternalUri(uri: URI) { return { resolved: uri, dispose() { } }; },
129-
} as IOpenerService);
130-
131120
export function matchesScheme(target: URI | string, scheme: string): boolean {
132121
if (URI.isUri(target)) {
133122
return equalsIgnoreCase(target.scheme, scheme);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { Disposable } from 'vs/base/common/lifecycle';
7+
import { URI } from 'vs/base/common/uri';
8+
import { IOpenerService } from '../../common/opener';
9+
10+
export const NullOpenerService = Object.freeze({
11+
_serviceBrand: undefined,
12+
registerOpener() { return Disposable.None; },
13+
registerValidator() { return Disposable.None; },
14+
registerExternalUriResolver() { return Disposable.None; },
15+
setDefaultExternalOpener() { },
16+
registerExternalOpener() { return Disposable.None; },
17+
async open() { return false; },
18+
async resolveExternalUri(uri: URI) { return { resolved: uri, dispose() { } }; },
19+
} as IOpenerService);

src/vs/workbench/services/lifecycle/common/lifecycle.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -262,20 +262,3 @@ export interface ILifecycleService {
262262
*/
263263
shutdown(): Promise<void>;
264264
}
265-
266-
export const NullLifecycleService: ILifecycleService = {
267-
268-
_serviceBrand: undefined,
269-
270-
onBeforeShutdown: Event.None,
271-
onBeforeShutdownError: Event.None,
272-
onShutdownVeto: Event.None,
273-
onWillShutdown: Event.None,
274-
onDidShutdown: Event.None,
275-
276-
phase: LifecyclePhase.Restored,
277-
startupKind: StartupKind.NewWindow,
278-
279-
async when() { },
280-
async shutdown() { }
281-
};

0 commit comments

Comments
 (0)