MCPcopy
hub / github.com/microsoft/vscode-js-debug / ExcludedCallersUI

Class ExcludedCallersUI

src/ui/excludedCallersUI.ts:73–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71
72@injectable()
73export class ExcludedCallersUI
74 implements vscode.TreeDataProvider<ExcludedCaller>, IExtensionContribution
75{
76 private readonly _onDidChangeTreeData = new vscode.EventEmitter<ExcludedCaller | undefined>();
77 private allCallers = new Map<string, ExcludedCaller>();
78 private lastHadCallers = false;
79
80 constructor(
81 @inject(DebugSessionTracker) private readonly sessionTracker: DebugSessionTracker,
82 ) {}
83
84 /** @inheritdoc */
85 register(context: vscode.ExtensionContext): void {
86 context.subscriptions.push(
87 vscode.window.createTreeView(CustomViews.ExcludedCallers, {
88 treeDataProvider: this,
89 }),
90 registerCommand(vscode.commands, Commands.CallersAdd, async (_uri, context) => {
91 const stack = await this.sessionTracker
92 .getById(context.sessionId)
93 ?.customRequest('stackTrace', {
94 threadId: 0, // js-debug doesn't do threads, so ID is always 0
95 startFrame: 0,
96 levels: 1,
97 });
98
99 if (!stack?.stackFrames.length) {
100 return;
101 }
102
103 const topOfStack = stack.stackFrames[0];
104 const caller = new ExcludedCaller(
105 {
106 name: context.frameName,
107 column: context.frameLocation.range.startColumn,
108 line: context.frameLocation.range.startLineNumber,
109 source: context.frameLocation.source,
110 },
111 {
112 name: topOfStack.name,
113 column: topOfStack.column,
114 line: topOfStack.line,
115 source: topOfStack.source,
116 },
117 );
118
119 this.allCallers.set(caller.id, caller);
120 this.triggerUpdate();
121 }),
122 registerCommand(vscode.commands, Commands.CallersGoToCaller, c => revealLocation(c.caller)),
123 registerCommand(vscode.commands, Commands.CallersGoToTarget, c => revealLocation(c.target)),
124 registerCommand(vscode.commands, Commands.CallersRemove, async c => {
125 this.allCallers.delete(c.id);
126 this.triggerUpdate();
127 }),
128 registerCommand(vscode.commands, Commands.CallersRemoveAll, () => {
129 this.allCallers.clear();
130 this.triggerUpdate();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected