mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
use classes for breakpoints API; fixes #39639
This commit is contained in:
@@ -554,6 +554,7 @@ export function createApiFactory(
|
||||
scm,
|
||||
debug,
|
||||
// types
|
||||
Breakpoint: extHostTypes.Breakpoint,
|
||||
CancellationTokenSource: CancellationTokenSource,
|
||||
CodeAction: extHostTypes.CodeAction,
|
||||
CodeLens: extHostTypes.CodeLens,
|
||||
@@ -572,6 +573,7 @@ export function createApiFactory(
|
||||
DocumentHighlightKind: extHostTypes.DocumentHighlightKind,
|
||||
DocumentLink: extHostTypes.DocumentLink,
|
||||
EventEmitter: Emitter,
|
||||
FunctionBreakpoint: extHostTypes.FunctionBreakpoint,
|
||||
Hover: extHostTypes.Hover,
|
||||
IndentAction: languageConfiguration.IndentAction,
|
||||
Location: extHostTypes.Location,
|
||||
@@ -584,6 +586,7 @@ export function createApiFactory(
|
||||
SignatureHelp: extHostTypes.SignatureHelp,
|
||||
SignatureInformation: extHostTypes.SignatureInformation,
|
||||
SnippetString: extHostTypes.SnippetString,
|
||||
SourceBreakpoint: extHostTypes.SourceBreakpoint,
|
||||
StatusBarAlignment: extHostTypes.StatusBarAlignment,
|
||||
SymbolInformation: extHostTypes.SymbolInformation,
|
||||
SymbolKind: extHostTypes.SymbolKind,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { Disposable, Position, Location } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { Disposable, Position, Location, SourceBreakpoint, FunctionBreakpoint } from 'vs/workbench/api/node/extHostTypes';
|
||||
|
||||
|
||||
export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
@@ -121,7 +121,9 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
if (delta.changed) {
|
||||
c = delta.changed.map(bpd => {
|
||||
return extendObject(this._breakpoints.get(bpd.id), this.fromWire(bpd));
|
||||
const bp = this.fromWire(bpd);
|
||||
this._breakpoints.set(bpd.id, bp);
|
||||
return bp;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -134,23 +136,9 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
private fromWire(bp: ISourceBreakpointData | IFunctionBreakpointData): vscode.Breakpoint {
|
||||
if (bp.type === 'function') {
|
||||
const fbp: vscode.FunctionBreakpoint = {
|
||||
type: 'function',
|
||||
enabled: bp.enabled,
|
||||
condition: bp.condition,
|
||||
hitCondition: bp.hitCondition,
|
||||
functionName: bp.functionName
|
||||
};
|
||||
return fbp;
|
||||
return new FunctionBreakpoint(bp.enabled, bp.condition, bp.hitCondition, bp.functionName);
|
||||
}
|
||||
const sbp: vscode.SourceBreakpoint = {
|
||||
type: 'source',
|
||||
enabled: bp.enabled,
|
||||
condition: bp.condition,
|
||||
hitCondition: bp.hitCondition,
|
||||
location: new Location(bp.uri, new Position(bp.line, bp.character))
|
||||
};
|
||||
return sbp;
|
||||
return new SourceBreakpoint(bp.enabled, bp.condition, bp.hitCondition, new Location(bp.uri, new Position(bp.line, bp.character)));
|
||||
}
|
||||
|
||||
public registerDebugConfigurationProvider(type: string, provider: vscode.DebugConfigurationProvider): vscode.Disposable {
|
||||
@@ -309,16 +297,3 @@ export class ExtHostDebugConsole implements vscode.DebugConsole {
|
||||
this.append(value + '\n');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy attributes from fromObject to toObject.
|
||||
*/
|
||||
export function extendObject<T>(toObject: T, fromObject: T): T {
|
||||
|
||||
for (let key in fromObject) {
|
||||
if (fromObject.hasOwnProperty(key)) {
|
||||
toObject[key] = fromObject[key];
|
||||
}
|
||||
}
|
||||
return toObject;
|
||||
}
|
||||
|
||||
@@ -1498,3 +1498,36 @@ export class RelativePattern implements IRelativePattern {
|
||||
return relative(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
export class Breakpoint {
|
||||
|
||||
readonly enabled: boolean;
|
||||
readonly condition?: string;
|
||||
readonly hitCondition?: string;
|
||||
|
||||
protected constructor(enabled: boolean, condition: string, hitCondition: string) {
|
||||
this.enabled = enabled;
|
||||
this.condition = condition;
|
||||
this.hitCondition = hitCondition;
|
||||
this.condition = condition;
|
||||
this.hitCondition = hitCondition;
|
||||
}
|
||||
}
|
||||
|
||||
export class SourceBreakpoint extends Breakpoint {
|
||||
readonly location: Location;
|
||||
|
||||
constructor(enabled: boolean, condition: string, hitCondition: string, location: Location) {
|
||||
super(enabled, condition, hitCondition);
|
||||
this.location = location;
|
||||
}
|
||||
}
|
||||
|
||||
export class FunctionBreakpoint extends Breakpoint {
|
||||
readonly functionName: string;
|
||||
|
||||
constructor(enabled: boolean, condition: string, hitCondition: string, functionName: string) {
|
||||
super(enabled, condition, hitCondition);
|
||||
this.functionName = functionName;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user