Skip to content

Commit ba7756c

Browse files
authored
feat: variable paging (#805)
* Update vscode imports. * Variable paging with indexedVariables * Set breakpoint_include_return_value if supported. * Lock file update. * Changelog.
1 parent 8c8bbb9 commit ba7756c

File tree

7 files changed

+95
-68
lines changed

7 files changed

+95
-68
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [1.27.0]
8+
9+
- Variable paging with VSCode indexedVariables.
10+
- Enable return value stepping with breakpoint_include_return_value.
11+
712
## [1.26.1]
813

914
- Fixed typo in error message for unexpected env. Extended error message with more detail.

package-lock.json

Lines changed: 57 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"string-replace-async": "^2.0.0",
5353
"url-relative": "^1.0.0",
5454
"urlencode": "^1.1.0",
55-
"vscode-debugadapter": "^1.51.0",
56-
"vscode-debugprotocol": "^1.51.0",
55+
"@vscode/debugadapter": "^1.51.1",
56+
"@vscode/debugprotocol": "^1.55.1",
5757
"which": "^2.0.2",
5858
"xmldom": "^0.6.0"
5959
},
@@ -84,7 +84,7 @@
8484
"tslint-config-prettier": "^1.18.0",
8585
"typescript": "^4.6.3",
8686
"vsce": "^2.9.1",
87-
"vscode-debugadapter-testsupport": "^1.51.0"
87+
"@vscode/debugadapter-testsupport": "^1.55.1"
8888
},
8989
"release": {
9090
"branches": [

src/breakpoints.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { DebugProtocol as VSCodeDebugProtocol } from 'vscode-debugprotocol'
2-
import * as vscode from 'vscode-debugadapter'
1+
import { DebugProtocol as VSCodeDebugProtocol } from '@vscode/debugprotocol'
2+
import * as vscode from '@vscode/debugadapter'
33
import { EventEmitter } from 'events'
44
import * as xdebug from './xdebugConnection'
55
import * as util from 'util'

src/phpDebug.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as vscode from 'vscode-debugadapter'
2-
import { DebugProtocol as VSCodeDebugProtocol } from 'vscode-debugprotocol'
1+
import * as vscode from '@vscode/debugadapter'
2+
import { DebugProtocol as VSCodeDebugProtocol } from '@vscode/debugprotocol'
33
import * as net from 'net'
44
import * as xdebug from './xdebugConnection'
55
import moment = require('moment')
@@ -377,6 +377,10 @@ class PhpDebugSession extends vscode.DebugSession {
377377
initPacket.engineName === 'Xdebug' &&
378378
semver.valid(initPacket.engineVersion, { loose: true }) &&
379379
semver.gte(initPacket.engineVersion, '3.0.0', { loose: true })
380+
const supportedEngine32 =
381+
initPacket.engineName === 'Xdebug' &&
382+
semver.valid(initPacket.engineVersion, { loose: true }) &&
383+
semver.gte(initPacket.engineVersion, '3.2.0', { loose: true })
380384
if (
381385
supportedEngine ||
382386
((feat = await connection.sendFeatureGetCommand('resolved_breakpoints')) &&
@@ -398,15 +402,25 @@ class PhpDebugSession extends vscode.DebugSession {
398402
) {
399403
await connection.sendFeatureSetCommand('extended_properties', '1')
400404
}
405+
if (
406+
supportedEngine32 ||
407+
((feat = await connection.sendFeatureGetCommand('breakpoint_include_return_value')) &&
408+
feat.supported === '1')
409+
) {
410+
await connection.sendFeatureSetCommand('breakpoint_include_return_value', '1')
411+
}
401412

402413
// override features from launch.json
403414
try {
404415
const xdebugSettings = args.xdebugSettings || {}
416+
// Required defaults for indexedVariables
417+
xdebugSettings.max_children = xdebugSettings.max_children || 100
405418
await Promise.all(
406419
Object.keys(xdebugSettings).map(setting =>
407420
connection.sendFeatureSetCommand(setting, xdebugSettings[setting])
408421
)
409422
)
423+
args.xdebugSettings = xdebugSettings
410424
} catch (error) {
411425
throw new Error(
412426
'Error applying xdebugSettings: ' + (error instanceof Error ? error.message : error)
@@ -1001,7 +1015,7 @@ class PhpDebugSession extends vscode.DebugSession {
10011015
if (property.children.length === property.numberOfChildren) {
10021016
properties = property.children
10031017
} else {
1004-
properties = await property.getChildren()
1018+
properties = await property.getChildren((args.start ?? 0) / 100)
10051019
}
10061020
} else {
10071021
properties = []
@@ -1066,6 +1080,9 @@ class PhpDebugSession extends vscode.DebugSession {
10661080
presentationHint,
10671081
evaluateName,
10681082
}
1083+
if (this._args.xdebugSettings?.max_children === 100) {
1084+
variable.indexedVariables = property.numberOfChildren
1085+
}
10691086
return variable
10701087
})
10711088
}

src/test/adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as chai from 'chai'
22
import chaiAsPromised = require('chai-as-promised')
33
import * as path from 'path'
4-
import { DebugClient } from 'vscode-debugadapter-testsupport'
5-
import { DebugProtocol } from 'vscode-debugprotocol'
4+
import { DebugClient } from '@vscode/debugadapter-testsupport'
5+
import { DebugProtocol } from '@vscode/debugprotocol'
66
import * as semver from 'semver'
77
import * as net from 'net'
88
chai.use(chaiAsPromised)

src/xdebugConnection.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,11 @@ export class Property extends BaseProperty {
588588
* Returns the child properties of this property by doing another property_get
589589
* @returns Promise.<Property[]>
590590
*/
591-
public async getChildren(): Promise<Property[]> {
591+
public async getChildren(page: number = 0): Promise<Property[]> {
592592
if (!this.hasChildren) {
593593
throw new Error('This property has no children')
594594
}
595-
return (await this.context.stackFrame.connection.sendPropertyGetCommand(this)).children
595+
return (await this.context.stackFrame.connection.sendPropertyGetCommand(this, page)).children
596596
}
597597
}
598598

@@ -1053,11 +1053,13 @@ export class Connection extends DbgpConnection {
10531053
// ------------------------------ property --------------------------------------
10541054

10551055
/** Sends a property_get command */
1056-
public async sendPropertyGetCommand(property: Property): Promise<PropertyGetResponse> {
1056+
public async sendPropertyGetCommand(property: Property, page: number = 0): Promise<PropertyGetResponse> {
10571057
return new PropertyGetResponse(
10581058
await this._enqueueCommand(
10591059
'property_get',
1060-
`-d ${property.context.stackFrame.level} -c ${property.context.id} -n ${escape(property.fullName)}`
1060+
`-d ${property.context.stackFrame.level} -c ${property.context.id} -p ${page} -n ${escape(
1061+
property.fullName
1062+
)}`
10611063
),
10621064
property.context
10631065
)

0 commit comments

Comments
 (0)