mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 11:38:51 +01:00
add first cut of proposed breakpoints API; fixes #23188
This commit is contained in:
@@ -6,10 +6,10 @@
|
||||
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import uri from 'vs/base/common/uri';
|
||||
import { IDebugService, IConfig, IDebugConfigurationProvider } from 'vs/workbench/parts/debug/common/debug';
|
||||
import { IDebugService, IConfig, IDebugConfigurationProvider, IBreakpoint, IFunctionBreakpoint } from 'vs/workbench/parts/debug/common/debug';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { ExtHostContext, ExtHostDebugServiceShape, MainThreadDebugServiceShape, DebugSessionUUID, MainContext, IExtHostContext } from '../node/extHost.protocol';
|
||||
import { ExtHostContext, ExtHostDebugServiceShape, MainThreadDebugServiceShape, DebugSessionUUID, MainContext, IExtHostContext, IBreakpointsDelta, ISourceBreakpointData, IFunctionBreakpointData } from '../node/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import severity from 'vs/base/common/severity';
|
||||
|
||||
@@ -18,6 +18,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape {
|
||||
|
||||
private _proxy: ExtHostDebugServiceShape;
|
||||
private _toDispose: IDisposable[];
|
||||
private _breakpointEventsActive: boolean;
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@@ -35,6 +36,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape {
|
||||
this._proxy.$acceptDebugSessionActiveChanged(undefined);
|
||||
}
|
||||
}));
|
||||
|
||||
this._toDispose.push(debugService.onDidCustomEvent(event => {
|
||||
if (event && event.sessionId) {
|
||||
const process = this.debugService.getModel().getProcesses().filter(p => p.getId() === event.sessionId).pop();
|
||||
@@ -49,6 +51,75 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
public $startBreakpointEvents(): TPromise<any> {
|
||||
|
||||
if (!this._breakpointEventsActive) {
|
||||
this._breakpointEventsActive = true;
|
||||
|
||||
// set up a handler to send more
|
||||
this._toDispose.push(this.debugService.getModel().onDidChangeBreakpoints(e => {
|
||||
if (e) {
|
||||
const delta: IBreakpointsDelta = {};
|
||||
if (e.added) {
|
||||
delta.added = this.toWire(e.added);
|
||||
}
|
||||
if (e.removed) {
|
||||
delta.removed = e.removed.map(x => x.getId());
|
||||
}
|
||||
if (e.changed) {
|
||||
delta.changed = this.toWire(e.changed);
|
||||
}
|
||||
|
||||
if (delta.added || delta.removed || delta.changed) {
|
||||
this._proxy.$acceptBreakpointsDelta(delta);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
// send all breakpoints
|
||||
const bps = this.debugService.getModel().getBreakpoints();
|
||||
const fbps = this.debugService.getModel().getFunctionBreakpoints();
|
||||
if (bps.length > 0 || fbps.length > 0) {
|
||||
this._proxy.$acceptBreakpointsDelta({
|
||||
added: this.toWire(bps).concat(this.toWire(fbps))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return TPromise.wrap<void>(undefined);
|
||||
}
|
||||
|
||||
private toWire(bps: (IBreakpoint | IFunctionBreakpoint)[]): (ISourceBreakpointData | IFunctionBreakpointData)[] {
|
||||
|
||||
return bps.map(bp => {
|
||||
if ('name' in bp) {
|
||||
const fbp = <IFunctionBreakpoint>bp;
|
||||
return <IFunctionBreakpointData>{
|
||||
type: 'function',
|
||||
id: bp.getId(),
|
||||
enabled: bp.enabled,
|
||||
functionName: fbp.name,
|
||||
hitCondition: bp.hitCondition,
|
||||
/* condition: bp.condition */
|
||||
};
|
||||
} else {
|
||||
const sbp = <IBreakpoint>bp;
|
||||
return <ISourceBreakpointData>{
|
||||
type: 'source',
|
||||
id: bp.getId(),
|
||||
enabled: bp.enabled,
|
||||
condition: sbp.condition,
|
||||
hitCondition: bp.hitCondition,
|
||||
sourceUriStr: sbp.uri.toString(),
|
||||
location: {
|
||||
line: sbp.lineNumber,
|
||||
character: sbp.column
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public $registerDebugConfigurationProvider(debugType: string, hasProvide: boolean, hasResolve: boolean, handle: number): TPromise<void> {
|
||||
|
||||
const provider = <IDebugConfigurationProvider>{
|
||||
|
||||
Reference in New Issue
Block a user