Dummy service update (#387)

* +

* +

* +

* +
This commit is contained in:
Andrew Pareles 2025-04-09 21:49:07 -07:00 committed by GitHub
parent bb22aefb6a
commit 6bf79b27c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,6 +6,7 @@
import { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { ServicesAccessor } from '../../../../editor/browser/editorExtensions.js';
import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js';
import { localize2 } from '../../../../nls.js';
import { Action2, registerAction2 } from '../../../../platform/actions/common/actions.js';
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
@ -14,15 +15,16 @@ import { KeybindingWeight } from '../../../../platform/keybinding/common/keybind
import { IWorkbenchContribution, registerWorkbenchContribution2, WorkbenchPhase } from '../../../common/contributions.js';
// to change this, just Cmd+Shift+F and replace DummyService with YourServiceName, and replace
export interface IDummyService {
readonly _serviceBrand: undefined;
readonly _serviceBrand: undefined; // services need this, just leave it undefined
}
export const IDummyService = createDecorator<IDummyService>('DummyService');
// An example of an action (delete if you're not using an action):
registerAction2(class extends Action2 {
constructor() {
super({
@ -42,18 +44,21 @@ registerAction2(class extends Action2 {
}
})
// on mount
class DummyService extends Disposable implements IWorkbenchContribution, IDummyService {
static readonly ID = 'workbench.contrib.void.dummy'
static readonly ID = 'workbench.contrib.void.dummy' // workbenchContributions need this, services do not
_serviceBrand: undefined;
constructor(
@ICodeEditorService codeEditorService: ICodeEditorService,
) {
super()
}
}
// pick one and delete the other:
registerSingleton(IDummyService, DummyService, InstantiationType.Eager);
registerWorkbenchContribution2(DummyService.ID, DummyService, WorkbenchPhase.BlockRestore);