Skip to content

Commit ad922e4

Browse files
committed
Improve documentation and consistency
1 parent a27c933 commit ad922e4

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

src/phpDebug.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,21 @@ class PhpDebugSession extends vscode.DebugSession {
6767
private _connections = new Map<number, xdebug.Connection>();
6868
/** The first connection we receive */
6969
private _mainConnection: xdebug.Connection = null;
70-
/** Gets set to true after _runOrStopOnEntry is called the first time, which means all exceptions etc. are set */
70+
/** Gets set to true after _runOrStopOnEntry is called the first time and means all exceptions etc. are set */
7171
private _initialized = false;
7272
/** A map of file URIs to lines: breakpoints received from VS Code */
7373
private _breakpoints = new Map<string, number[]>();
7474
/** Gets set after a setExceptionBreakpointsRequest */
7575
private _breakOnExceptions: boolean;
7676
/** A counter for unique stackframe IDs */
7777
private _stackFrameIdCounter = 1;
78-
/** Maps a stackframe ID to its connection and the level inside the stacktrace for scope requests */
78+
/** A map from unique stackframe IDs (even across connections) to XDebug stackframes */
7979
private _stackFrames = new Map<number, xdebug.StackFrame>();
80-
/** A counter for unique context and variable IDs (as the content of a scope is requested by a VariableRequest from VS Code) */
80+
/** A counter for unique context, property and eval result properties (as these are all requested by a VariableRequest from VS Code) */
8181
private _variableIdCounter = 1;
82-
/** A map that maps a unique VS Code variable ID to an XDebug contextId and an XDebug stackframe */
82+
/** A map from unique VS Code variable IDs to an XDebug contexts */
8383
private _contexts = new Map<number, xdebug.Context>();
84-
/** A map that maps a unique VS Code variable ID to an XDebug scope and an XDebug long variable name */
84+
/** A map from unique VS Code variable IDs to a XDebug properties */
8585
private _properties = new Map<number, xdebug.Property>();
8686
/** A map from unique VS Code variable IDs to XDebug eval result properties, because property children returned from eval commands are always inlined */
8787
private _evalResultProperties = new Map<number, xdebug.EvalResultProperty>();
@@ -114,9 +114,9 @@ class PhpDebugSession extends vscode.DebugSession {
114114
// raise default of 32
115115
.then(() => connection.sendFeatureSetCommand('max_children', '9999'))
116116
// restore all breakpoints for the new connection
117-
.then(() => Promise.all(Array.from(this._breakpoints).map(([file, lines]) =>
117+
.then(() => Promise.all(Array.from(this._breakpoints).map(([fileUri, lines]) =>
118118
Promise.all(lines.map(line =>
119-
connection.sendBreakpointSetCommand({type: 'line', file, line})
119+
connection.sendBreakpointSetCommand({type: 'line', fileUri, line})
120120
))
121121
)))
122122
// restore exception breakpoint settings for the new connection
@@ -217,7 +217,7 @@ class PhpDebugSession extends vscode.DebugSession {
217217

218218
/** This is called for each source file that has breakpoints with all the breakpoints in that file and whenever these change. */
219219
protected setBreakPointsRequest(response: VSCodeDebugProtocol.SetBreakpointsResponse, args: VSCodeDebugProtocol.SetBreakpointsArguments) {
220-
const file = path2uri(args.source.path);
220+
const fileUri = path2uri(args.source.path);
221221
const connections = Array.from(this._connections.values());
222222
let breakpoints: vscode.Breakpoint[];
223223
let breakpointsSetPromise: Promise<any>;
@@ -232,12 +232,12 @@ class PhpDebugSession extends vscode.DebugSession {
232232
connection.sendBreakpointListCommand()
233233
.then(response => Promise.all(
234234
response.breakpoints
235-
.filter(breakpoint => breakpoint.type === 'line' && breakpoint.fileUri === file)
235+
.filter(breakpoint => breakpoint.type === 'line' && breakpoint.fileUri === fileUri)
236236
.map(breakpoint => breakpoint.remove())
237237
))
238238
// set them
239239
.then(() => Promise.all(args.lines.map(line =>
240-
connection.sendBreakpointSetCommand({type: 'line', file, line})
240+
connection.sendBreakpointSetCommand({type: 'line', fileUri, line})
241241
.then(xdebugResponse => {
242242
// only capture each breakpoint once (for the main connection)
243243
if (connection === this._mainConnection) {
@@ -257,7 +257,7 @@ class PhpDebugSession extends vscode.DebugSession {
257257
breakpointsSetPromise
258258
.then(() => {
259259
response.body = {breakpoints};
260-
this._breakpoints.set(file, args.lines);
260+
this._breakpoints.set(fileUri, args.lines);
261261
this.sendResponse(response);
262262
})
263263
.catch(error => {

src/xdebugConnection.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class InitPacket {
3333
}
3434
}
3535

36+
/** Error class for errors returned from XDebug */
3637
export class XDebugError extends Error {
3738
code: number;
3839
constructor(message: string, code: number) {
@@ -339,6 +340,7 @@ export class PropertyGetResponse extends Response {
339340
}
340341
}
341342

343+
/** class for properties returned from eval commands. These don't have a full name or an ID, but have all children already inlined. */
342344
export class EvalResultProperty extends BaseProperty {
343345
children: EvalResultProperty[];
344346
constructor(propertyNode: Element) {
@@ -349,7 +351,9 @@ export class EvalResultProperty extends BaseProperty {
349351
}
350352
}
351353

354+
/** The response to an eval command */
352355
export class EvalResponse extends Response {
356+
/** the result of the expression, if there was any */
353357
result: EvalResultProperty;
354358
constructor(document: XMLDocument, connection: Connection) {
355359
super(document, connection);
@@ -359,7 +363,9 @@ export class EvalResponse extends Response {
359363
}
360364
}
361365

366+
/** The response to an feature_set command */
362367
export class FeatureSetResponse extends Response {
368+
/** the feature that was set */
363369
feature: string;
364370
constructor(document: XMLDocument, connection: Connection) {
365371
super(document, connection);
@@ -538,12 +544,18 @@ export class Connection extends DbgpConnection {
538544
// ---------------------------- breakpoints ------------------------------------
539545

540546
/**
541-
* Sends a breakpoint_set command that sets a line breakpoint.
547+
* Sends a breakpoint_set command that sets a breakpoint.
548+
* @param {object} breakpoint
549+
* @param {string} breakpoint.type - the type of breakpoint. Can be 'line' or 'exception'
550+
* @param {string} [breakpoint.fileUri] - the file URI to break on if type is 'line'
551+
* @param {number} [breakpoint.line] - the line to break on if type is 'line'
552+
* @param {string} [breakpoint.exception] - the exception class name to break on if type is 'exception'
553+
* @returns Promise.<BreakpointSetResponse>
542554
*/
543-
public sendBreakpointSetCommand(breakpoint: {type: string, file?: string, line?: number, exception?: string}): Promise<BreakpointSetResponse> {
555+
public sendBreakpointSetCommand(breakpoint: {type: string, fileUri?: string, line?: number, exception?: string}): Promise<BreakpointSetResponse> {
544556
let args = `-t ${breakpoint.type} `;
545557
if (breakpoint.type === 'line') {
546-
args += `-f ${breakpoint.file} -n ${breakpoint.line}`;
558+
args += `-f ${breakpoint.fileUri} -n ${breakpoint.line}`;
547559
} else if (breakpoint.type === 'exception') {
548560
args += `-x ${breakpoint.exception}`;
549561
} else {
@@ -552,39 +564,46 @@ export class Connection extends DbgpConnection {
552564
return this._enqueueCommand('breakpoint_set', args).then(document => new BreakpointSetResponse(document, this));
553565
}
554566

567+
/** sends a breakpoint_list command */
555568
public sendBreakpointListCommand(): Promise<BreakpointListResponse> {
556569
return this._enqueueCommand('breakpoint_list').then(document => new BreakpointListResponse(document, this));
557570
}
558571

572+
/** sends a breakpoint_remove command */
559573
public sendBreakpointRemoveCommand(breakpoint: Breakpoint): Promise<Response> {
560574
return this._enqueueCommand('breakpoint_remove', `-d ${breakpoint.id}`).then(document => new Response(document, this));
561575
}
562576

563577
// ----------------------------- continuation ---------------------------------
564578

579+
/** sends a run command */
565580
public sendRunCommand(): Promise<StatusResponse> {
566581
return this._enqueueCommand('run').then(document => new StatusResponse(document, this));
567582
}
568583

584+
/** sends a step_into command */
569585
public sendStepIntoCommand(): Promise<StatusResponse> {
570586
return this._enqueueCommand('step_into').then(document => new StatusResponse(document, this));
571587
}
572588

589+
/** sends a step_over command */
573590
public sendStepOverCommand(): Promise<StatusResponse> {
574591
return this._enqueueCommand('step_over').then(document => new StatusResponse(document, this));
575592
}
576593

594+
/** sends a step_out command */
577595
public sendStepOutCommand(): Promise<StatusResponse> {
578596
return this._enqueueCommand('step_out').then(document => new StatusResponse(document, this));
579597
}
580598

599+
/** sends a stop command */
581600
public sendStopCommand(): Promise<StatusResponse> {
582601
return this._enqueueCommand('stop').then(document => new StatusResponse(document, this));
583602
}
584603

585604
// ------------------------------ stack ----------------------------------------
586605

587-
/** Sends a stack_get request */
606+
/** Sends a stack_get command */
588607
public sendStackGetCommand(): Promise<StackGetResponse> {
589608
return this._enqueueCommand('stack_get').then(document => new StackGetResponse(document, this));
590609
}
@@ -608,6 +627,7 @@ export class Connection extends DbgpConnection {
608627

609628
// ------------------------------- eval -----------------------------------------
610629

630+
/** sends an eval command */
611631
public sendEvalCommand(expression: string): Promise<EvalResponse> {
612632
return this._enqueueCommand('eval', null, expression).then(document => new EvalResponse(document, this));
613633
}

0 commit comments

Comments
 (0)