Skip to content

Commit

Permalink
Avoid using privates via cast (microsoft#166722)
Browse files Browse the repository at this point in the history
* Avoid using privates via cast

* Enable instantiating the breakpoint with an id from core without letting extensions do that
  • Loading branch information
roblourens authored Dec 30, 2022
1 parent b5ad508 commit acb9348
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/vs/workbench/api/common/extHostDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { DebugSessionUUID, ExtHostDebugServiceShape, IBreakpointsDeltaDto, IDebu
import { IExtHostEditorTabs } from 'vs/workbench/api/common/extHostEditorTabs';
import { IExtHostExtensionService } from 'vs/workbench/api/common/extHostExtensionService';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { DataBreakpoint, DebugAdapterExecutable, DebugAdapterInlineImplementation, DebugAdapterNamedPipeServer, DebugAdapterServer, DebugConsoleMode, Disposable, FunctionBreakpoint, Location, Position, SourceBreakpoint } from 'vs/workbench/api/common/extHostTypes';
import { DataBreakpoint, DataBreakpointWithId, DebugAdapterExecutable, DebugAdapterInlineImplementation, DebugAdapterNamedPipeServer, DebugAdapterServer, DebugConsoleMode, Disposable, FunctionBreakpoint, FunctionBreakpointWithId, Location, Position, SourceBreakpoint, SourceBreakpointWithId } from 'vs/workbench/api/common/extHostTypes';
import { IExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
import { AbstractDebugAdapter } from 'vs/workbench/contrib/debug/common/abstractDebugAdapter';
import { IAdapterDescriptor, IConfig, IDebugAdapter, IDebugAdapterExecutable, IDebugAdapterNamedPipeServer, IDebugAdapterServer, IDebuggerContribution } from 'vs/workbench/contrib/debug/common/debug';
Expand Down Expand Up @@ -531,14 +531,13 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
if (id && !this._breakpoints.has(id)) {
let bp: vscode.Breakpoint;
if (bpd.type === 'function') {
bp = new FunctionBreakpoint(bpd.functionName, bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage);
bp = new FunctionBreakpointWithId(bpd.functionName, bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage, id);
} else if (bpd.type === 'data') {
bp = new DataBreakpoint(bpd.label, bpd.dataId, bpd.canPersist, bpd.enabled, bpd.hitCondition, bpd.condition, bpd.logMessage);
bp = new DataBreakpointWithId(bpd.label, bpd.dataId, bpd.canPersist, bpd.enabled, bpd.hitCondition, bpd.condition, bpd.logMessage, id);
} else {
const uri = URI.revive(bpd.uri);
bp = new SourceBreakpoint(new Location(uri, new Position(bpd.line, bpd.character)), bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage);
bp = new SourceBreakpointWithId(new Location(uri, new Position(bpd.line, bpd.character)), bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage, id);
}
(bp as any)._id = id;
this._breakpoints.set(id, bp);
a.push(bp);
}
Expand Down
33 changes: 33 additions & 0 deletions src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2807,6 +2807,17 @@ export class SourceBreakpoint extends Breakpoint {
}
}

@es5ClassCompat
export class SourceBreakpointWithId extends SourceBreakpoint {
constructor(location: Location, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string, private readonly _internalId?: string) {
super(location, enabled, condition, hitCondition, logMessage);
}

override get id(): string {
return this._internalId ?? super.id;
}
}

@es5ClassCompat
export class FunctionBreakpoint extends Breakpoint {
readonly functionName: string;
Expand All @@ -2817,6 +2828,17 @@ export class FunctionBreakpoint extends Breakpoint {
}
}

@es5ClassCompat
export class FunctionBreakpointWithId extends FunctionBreakpoint {
constructor(functionName: string, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string, private readonly _internalId?: string) {
super(functionName, enabled, condition, hitCondition, logMessage);
}

override get id(): string {
return this._internalId ?? super.id;
}
}

@es5ClassCompat
export class DataBreakpoint extends Breakpoint {
readonly label: string;
Expand All @@ -2834,6 +2856,17 @@ export class DataBreakpoint extends Breakpoint {
}
}

@es5ClassCompat
export class DataBreakpointWithId extends DataBreakpoint {
constructor(label: string, dataId: string, canPersist: boolean, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string, private readonly _internalId?: string) {
super(label, dataId, canPersist, enabled, condition, hitCondition, logMessage);
}

override get id(): string {
return this._internalId ?? super.id;
}
}


@es5ClassCompat
export class DebugAdapterExecutable implements vscode.DebugAdapterExecutable {
Expand Down

0 comments on commit acb9348

Please sign in to comment.