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

Class BrowserOptionsDataProvider

src/ui/customBreakpointsUI.ts:101–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99type BrowserOptionItem = BreakpointItem | FocusEmulationOption;
100
101class BrowserOptionsDataProvider implements vscode.TreeDataProvider<BrowserOptionItem> {
102 private _onDidChangeTreeData = new EventEmitter<BrowserOptionItem | undefined>();
103 readonly onDidChangeTreeData = this._onDidChangeTreeData.event;
104
105 private _debugSessionTracker: DebugSessionTracker;
106
107 private readonly _breakpointsRoot = new BreakpointsRoot();
108 private readonly categories = new Map<string, Category>();
109 xhrBreakpoints: XHRBreakpoint[] = [];
110
111 private readonly _emulationSessions = new Set<string>();
112 private _focusEmulationEnabled = false;
113
114 /** Gets all breakpoint categories */
115 public get allCategories() {
116 return this.categories.values();
117 }
118
119 /** Gets all custom breakpoints */
120 public get allBreakpoints() {
121 return [...this.allCategories].flatMap(c => c.children);
122 }
123
124 constructor(debugSessionTracker: DebugSessionTracker, focusEmulationEnabled: boolean) {
125 this._focusEmulationEnabled = focusEmulationEnabled;
126
127 for (const breakpoint of [...customBreakpoints().values()]) {
128 let category = this.categories.get(breakpoint.group);
129 if (!category) {
130 category = new Category(breakpoint.group);
131 this.categories.set(breakpoint.group, category);
132 }
133 category.children.push(new Breakpoint(breakpoint, category));
134 }
135
136 const xhrCategory = new Category(xhrBreakpointsCategory());
137 xhrCategory.contextValue = 'xhrCategory';
138 xhrCategory.checkboxState = undefined;
139 this.categories.set(xhrBreakpointsCategory(), xhrCategory);
140
141 this.xhrBreakpoints = [];
142
143 this._debugSessionTracker = debugSessionTracker;
144 debugSessionTracker.onSessionAdded(session => {
145 if (!DebugSessionTracker.isConcreteSession(session)) {
146 return;
147 }
148
149 const toEnable = this.allBreakpoints.filter(b => b.checked).map(b => b.id);
150 if (toEnable.length > 0) {
151 session.customRequest('setCustomBreakpoints', {
152 xhr: this.xhrBreakpoints.filter(b => b.checkboxState).map(b => b.id),
153 ids: toEnable,
154 });
155 }
156
157 this._checkEmulationSupport(session);
158 });

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected