mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
add first cut of proposed breakpoints API; fixes #23188
This commit is contained in:
@@ -515,8 +515,8 @@ export function createApiFactory(
|
||||
get activeDebugConsole() {
|
||||
return extHostDebugService.activeDebugConsole;
|
||||
},
|
||||
startDebugging(folder: vscode.WorkspaceFolder | undefined, nameOrConfig: string | vscode.DebugConfiguration) {
|
||||
return extHostDebugService.startDebugging(folder, nameOrConfig);
|
||||
get breakpoints() {
|
||||
return extHostDebugService.breakpoints;
|
||||
},
|
||||
onDidStartDebugSession(listener, thisArg?, disposables?) {
|
||||
return extHostDebugService.onDidStartDebugSession(listener, thisArg, disposables);
|
||||
@@ -530,6 +530,12 @@ export function createApiFactory(
|
||||
onDidReceiveDebugSessionCustomEvent(listener, thisArg?, disposables?) {
|
||||
return extHostDebugService.onDidReceiveDebugSessionCustomEvent(listener, thisArg, disposables);
|
||||
},
|
||||
onDidChangeBreakpoints: proposedApiFunction(extension, (listener, thisArgs?, disposables?) => {
|
||||
return extHostDebugService.onDidChangeBreakpoints(listener, thisArgs, disposables);
|
||||
}),
|
||||
startDebugging(folder: vscode.WorkspaceFolder | undefined, nameOrConfig: string | vscode.DebugConfiguration) {
|
||||
return extHostDebugService.startDebugging(folder, nameOrConfig);
|
||||
},
|
||||
registerDebugConfigurationProvider(debugType: string, provider: vscode.DebugConfigurationProvider) {
|
||||
return extHostDebugService.registerDebugConfigurationProvider(debugType, provider);
|
||||
}
|
||||
|
||||
@@ -419,6 +419,7 @@ export interface MainThreadDebugServiceShape extends IDisposable {
|
||||
$startDebugging(folder: URI | undefined, nameOrConfig: string | vscode.DebugConfiguration): TPromise<boolean>;
|
||||
$customDebugAdapterRequest(id: DebugSessionUUID, command: string, args: any): TPromise<any>;
|
||||
$appendDebugConsole(value: string): TPromise<any>;
|
||||
$startBreakpointEvents(): TPromise<any>;
|
||||
}
|
||||
|
||||
export interface MainThreadWindowShape extends IDisposable {
|
||||
@@ -623,6 +624,31 @@ export interface ExtHostTaskShape {
|
||||
$provideTasks(handle: number): TPromise<TaskSet>;
|
||||
}
|
||||
|
||||
export interface IBreakpointData {
|
||||
type: 'source' | 'function';
|
||||
id: string;
|
||||
enabled: boolean;
|
||||
condition?: string;
|
||||
hitCondition?: string;
|
||||
}
|
||||
|
||||
export interface ISourceBreakpointData extends IBreakpointData {
|
||||
type: 'source';
|
||||
sourceUriStr: string;
|
||||
location: vscode.Position;
|
||||
}
|
||||
|
||||
export interface IFunctionBreakpointData extends IBreakpointData {
|
||||
type: 'function';
|
||||
functionName: string;
|
||||
}
|
||||
|
||||
export interface IBreakpointsDelta {
|
||||
added?: (ISourceBreakpointData | IFunctionBreakpointData)[];
|
||||
removed?: string[];
|
||||
changed?: (ISourceBreakpointData | IFunctionBreakpointData)[];
|
||||
}
|
||||
|
||||
export interface ExtHostDebugServiceShape {
|
||||
$resolveDebugConfiguration(handle: number, folder: URI | undefined, debugConfiguration: any): TPromise<any>;
|
||||
$provideDebugConfigurations(handle: number, folder: URI | undefined): TPromise<any[]>;
|
||||
@@ -630,6 +656,7 @@ export interface ExtHostDebugServiceShape {
|
||||
$acceptDebugSessionTerminated(id: DebugSessionUUID, type: string, name: string): void;
|
||||
$acceptDebugSessionActiveChanged(id: DebugSessionUUID | undefined, type?: string, name?: string): void;
|
||||
$acceptDebugSessionCustomEvent(id: DebugSessionUUID, type: string, name: string, event: any): void;
|
||||
$acceptBreakpointsDelta(delat: IBreakpointsDelta): void;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
import { MainContext, MainThreadDebugServiceShape, ExtHostDebugServiceShape, DebugSessionUUID, IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { MainContext, MainThreadDebugServiceShape, ExtHostDebugServiceShape, DebugSessionUUID, IMainContext, IBreakpointsDelta, ISourceBreakpointData, IFunctionBreakpointData } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
@@ -43,6 +43,11 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
private _activeDebugConsole: ExtHostDebugConsole;
|
||||
get activeDebugConsole(): ExtHostDebugConsole { return this._activeDebugConsole; }
|
||||
|
||||
private _breakpoints: Map<string, vscode.Breakpoint>;
|
||||
private _breakpointEventsActive: boolean;
|
||||
|
||||
private _onDidChangeBreakpoints: Emitter<vscode.BreakpointsChangeEvent>;
|
||||
|
||||
|
||||
constructor(mainContext: IMainContext, workspace: ExtHostWorkspace) {
|
||||
|
||||
@@ -58,7 +63,84 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
this._debugServiceProxy = mainContext.get(MainContext.MainThreadDebugService);
|
||||
|
||||
this._onDidChangeBreakpoints = new Emitter<vscode.BreakpointsChangeEvent>({
|
||||
onFirstListenerAdd: () => {
|
||||
this.startBreakpoints();
|
||||
}
|
||||
});
|
||||
|
||||
this._activeDebugConsole = new ExtHostDebugConsole(this._debugServiceProxy);
|
||||
|
||||
this._breakpoints = new Map<string, vscode.Breakpoint>();
|
||||
this._breakpointEventsActive = false;
|
||||
}
|
||||
|
||||
private startBreakpoints() {
|
||||
if (!this._breakpointEventsActive) {
|
||||
this._breakpointEventsActive = true;
|
||||
this._debugServiceProxy.$startBreakpointEvents();
|
||||
}
|
||||
}
|
||||
|
||||
get onDidChangeBreakpoints(): Event<vscode.BreakpointsChangeEvent> {
|
||||
return this._onDidChangeBreakpoints.event;
|
||||
}
|
||||
|
||||
get breakpoints(): vscode.Breakpoint[] {
|
||||
|
||||
this.startBreakpoints();
|
||||
|
||||
const result: vscode.Breakpoint[] = [];
|
||||
this._breakpoints.forEach(bp => result.push(bp));
|
||||
return result;
|
||||
}
|
||||
|
||||
public $acceptBreakpointsDelta(delta: IBreakpointsDelta): void {
|
||||
|
||||
let a: vscode.Breakpoint[] = [];
|
||||
let r: vscode.Breakpoint[] = [];
|
||||
let c: vscode.Breakpoint[] = [];
|
||||
|
||||
if (delta.added) {
|
||||
a = delta.added.map(bpd => {
|
||||
const id = bpd.id;
|
||||
this._breakpoints.set(id, this.fromWire(bpd));
|
||||
return bpd;
|
||||
});
|
||||
}
|
||||
|
||||
if (delta.removed) {
|
||||
r = delta.removed.map(id => {
|
||||
const bp = this._breakpoints.get(id);
|
||||
if (bp) {
|
||||
this._breakpoints.delete(id);
|
||||
}
|
||||
return bp;
|
||||
});
|
||||
}
|
||||
|
||||
if (delta.changed) {
|
||||
c = delta.changed.map(bpd => {
|
||||
const id = bpd.id;
|
||||
this._breakpoints.set(id, this.fromWire(bpd));
|
||||
return bpd;
|
||||
});
|
||||
}
|
||||
|
||||
this._onDidChangeBreakpoints.fire(Object.freeze({
|
||||
added: Object.freeze<vscode.Breakpoint[]>(a || []),
|
||||
removed: Object.freeze<vscode.Breakpoint[]>(r || []),
|
||||
changed: Object.freeze<vscode.Breakpoint[]>(c || [])
|
||||
}));
|
||||
}
|
||||
|
||||
private fromWire(bp: ISourceBreakpointData | IFunctionBreakpointData): vscode.Breakpoint {
|
||||
delete bp.id;
|
||||
if (bp.type === 'source') {
|
||||
(<any>bp).source = URI.parse(bp.sourceUriStr);
|
||||
delete bp.sourceUriStr;
|
||||
}
|
||||
return bp;
|
||||
}
|
||||
|
||||
public registerDebugConfigurationProvider(type: string, provider: vscode.DebugConfigurationProvider): vscode.Disposable {
|
||||
@@ -87,7 +169,6 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
return asWinJsPromise(token => handler.provideDebugConfigurations(this.getFolder(folderUri), token));
|
||||
}
|
||||
|
||||
|
||||
public $resolveDebugConfiguration(handle: number, folderUri: URI | undefined, debugConfiguration: vscode.DebugConfiguration): TPromise<vscode.DebugConfiguration> {
|
||||
let handler = this._handlers.get(handle);
|
||||
if (!handler) {
|
||||
|
||||
Reference in New Issue
Block a user