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