Path: blob/main/src/vs/workbench/contrib/debug/common/nullDebugService.ts
13401 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Event } from '../../../../base/common/event.js';6import { Disposable, IDisposable, IReference } from '../../../../base/common/lifecycle.js';7import { URI } from '../../../../base/common/uri.js';8import { IAdapterManager, IBreakpoint, IConfig, IConfigurationManager, IDebugModel, IDebugService, IDebugSession, IDebugSessionOptions, IEnablement, IExceptionBreakpoint, IExpression, IExpressionContainer, ILaunch, IStackFrame, IThread, IViewModel, State } from './debug.js';9import type { IDataBreakpointOptions, IFunctionBreakpointOptions, IInstructionBreakpointOptions } from './debugModel.js';10import { DebugVisualizer, IDebugVisualizerService } from './debugVisualizers.js';1112const nullViewModel: IViewModel = {13getId(): string { return 'root'; },14focusedSession: undefined,15focusedThread: undefined,16focusedStackFrame: undefined,17setVisualizedExpression(): void { },18getVisualizedExpression(): IExpression | string | undefined { return undefined; },19getSelectedExpression(): undefined { return undefined; },20setSelectedExpression(): void { },21updateViews(): void { },22isMultiSessionView(): boolean { return false; },23onDidFocusSession: Event.None,24onDidFocusThread: Event.None,25onDidFocusStackFrame: Event.None,26onDidSelectExpression: Event.None,27onDidEvaluateLazyExpression: Event.None,28onDidChangeVisualization: Event.None,29onWillUpdateViews: Event.None,30evaluateLazyExpression(_expression: IExpressionContainer): void { },31};3233const nullDebugModel: IDebugModel = {34getId(): string { return 'root'; },35getSession(): undefined { return undefined; },36getSessions(): IDebugSession[] { return []; },37getBreakpoints(): readonly IBreakpoint[] { return []; },38areBreakpointsActivated(): boolean { return false; },39getFunctionBreakpoints() { return []; },40getDataBreakpoints() { return []; },41getExceptionBreakpoints() { return []; },42getExceptionBreakpointsForSession() { return []; },43getInstructionBreakpoints() { return []; },44getWatchExpressions() { return []; },45registerBreakpointModes(): void { },46getBreakpointModes() { return []; },47onDidChangeBreakpoints: Event.None,48onDidChangeCallStack: Event.None,49onDidChangeWatchExpressions: Event.None,50onDidChangeWatchExpressionValue: Event.None,51async fetchCallstack(): Promise<void> { },52};5354const nullConfigurationManager: IConfigurationManager = {55selectedConfiguration: {56launch: undefined,57getConfig: () => Promise.resolve(undefined),58name: undefined,59type: undefined,60},61async selectConfiguration(): Promise<void> { },62getLaunches() { return []; },63getLaunch() { return undefined; },64getAllConfigurations() { return []; },65removeRecentDynamicConfigurations(): void { },66getRecentDynamicConfigurations() { return []; },67onDidSelectConfiguration: Event.None,68onDidChangeConfigurationProviders: Event.None,69hasDebugConfigurationProvider(): boolean { return false; },70async getDynamicProviders() { return []; },71async getDynamicConfigurationsByType() { return []; },72registerDebugConfigurationProvider() { return Disposable.None; },73unregisterDebugConfigurationProvider(): void { },74async resolveConfigurationByProviders() { return undefined; },75};7677const nullAdapterManager: IAdapterManager = {78onDidRegisterDebugger: Event.None,79hasEnabledDebuggers(): boolean { return false; },80async getDebugAdapterDescriptor() { return undefined; },81getDebuggerLabel() { return undefined; },82someDebuggerInterestedInLanguage(): boolean { return false; },83getDebugger() { return undefined; },84async activateDebuggers(): Promise<void> { },85registerDebugAdapterFactory() { return Disposable.None; },86createDebugAdapter() { return undefined; },87registerDebugAdapterDescriptorFactory() { return Disposable.None; },88unregisterDebugAdapterDescriptorFactory(): void { },89async substituteVariables(_debugType: string, _folder: undefined, config: IConfig) { return config; },90async runInTerminal() { return undefined; },91getEnabledDebugger() { return undefined; },92async guessDebugger() { return undefined; },93get onDidDebuggersExtPointRead() { return Event.None; },94};9596export class NullDebugService implements IDebugService {9798declare readonly _serviceBrand: undefined;99100readonly state = State.Inactive;101readonly initializingOptions = undefined;102103readonly onDidChangeState = Event.None;104readonly onWillNewSession = Event.None;105readonly onDidNewSession = Event.None;106readonly onDidEndSession = Event.None;107108getConfigurationManager(): IConfigurationManager { return nullConfigurationManager; }109getAdapterManager(): IAdapterManager { return nullAdapterManager; }110getModel(): IDebugModel { return nullDebugModel; }111getViewModel(): IViewModel { return nullViewModel; }112113async focusStackFrame(_focusedStackFrame: IStackFrame | undefined, _thread?: IThread, _session?: IDebugSession, _options?: { explicit?: boolean; preserveFocus?: boolean; sideBySide?: boolean; pinned?: boolean }): Promise<void> { }114canSetBreakpointsIn(): boolean { return false; }115async addBreakpoints(): Promise<IBreakpoint[]> { return []; }116async updateBreakpoints(): Promise<void> { }117async enableOrDisableBreakpoints(_enable: boolean, _breakpoint?: IEnablement): Promise<void> { }118async setBreakpointsActivated(_activated: boolean): Promise<void> { }119async removeBreakpoints(_id?: string | string[]): Promise<void> { }120addFunctionBreakpoint(_opts?: IFunctionBreakpointOptions, _id?: string): void { }121async updateFunctionBreakpoint(_id: string, _update: { name?: string; hitCondition?: string; condition?: string }): Promise<void> { }122async removeFunctionBreakpoints(_id?: string): Promise<void> { }123async addDataBreakpoint(_opts: IDataBreakpointOptions): Promise<void> { }124async updateDataBreakpoint(_id: string, _update: { hitCondition?: string; condition?: string }): Promise<void> { }125async removeDataBreakpoints(_id?: string): Promise<void> { }126async addInstructionBreakpoint(_opts: IInstructionBreakpointOptions): Promise<void> { }127async removeInstructionBreakpoints(_instructionReference?: string, _offset?: number, _address?: bigint): Promise<void> { }128async setExceptionBreakpointCondition(_breakpoint: IExceptionBreakpoint, _condition: string | undefined): Promise<void> { }129setExceptionBreakpointsForSession(_session: IDebugSession, _filters: DebugProtocol.ExceptionBreakpointsFilter[]): void { }130async sendAllBreakpoints(_session?: IDebugSession): Promise<void> { }131async sendBreakpoints(_modelUri: URI, _sourceModified?: boolean, _session?: IDebugSession): Promise<void> { }132addWatchExpression(_name?: string): void { }133renameWatchExpression(_id: string, _newName: string): void { }134moveWatchExpression(_id: string, _position: number): void { }135removeWatchExpressions(_id?: string): void { }136async startDebugging(_launch: ILaunch | undefined, _configOrName?: IConfig | string, _options?: IDebugSessionOptions, _saveBeforeStart?: boolean): Promise<boolean> { return false; }137async restartSession(_session: IDebugSession, _restartData?: unknown): Promise<void> { }138async stopSession(_session: IDebugSession | undefined, _disconnect?: boolean, _suspend?: boolean): Promise<void> { }139sourceIsNotAvailable(): void { }140async runTo(): Promise<void> { }141}142143export class NullDebugVisualizerService implements IDebugVisualizerService {144145declare readonly _serviceBrand: undefined;146147async getApplicableFor(): Promise<IReference<DebugVisualizer[]>> { return { object: [], dispose() { } }; }148register(): IDisposable { return Disposable.None; }149registerTree(): IDisposable { return Disposable.None; }150async getVisualizedNodeFor(): Promise<undefined> { return undefined; }151async getVisualizedChildren(): Promise<IExpression[]> { return []; }152async editTreeItem(): Promise<void> { }153}154155156