Skip to content

Commit

Permalink
feat: variable paging (#805)
Browse files Browse the repository at this point in the history
* Update vscode imports.

* Variable paging with indexedVariables

* Set breakpoint_include_return_value if supported.

* Lock file update.

* Changelog.
  • Loading branch information
zobo authored Jun 9, 2022
1 parent 8c8bbb9 commit ba7756c
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 68 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

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

## [1.27.0]

- Variable paging with VSCode indexedVariables.
- Enable return value stepping with breakpoint_include_return_value.

## [1.26.1]

- Fixed typo in error message for unexpected env. Extended error message with more detail.
Expand Down
111 changes: 57 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"string-replace-async": "^2.0.0",
"url-relative": "^1.0.0",
"urlencode": "^1.1.0",
"vscode-debugadapter": "^1.51.0",
"vscode-debugprotocol": "^1.51.0",
"@vscode/debugadapter": "^1.51.1",
"@vscode/debugprotocol": "^1.55.1",
"which": "^2.0.2",
"xmldom": "^0.6.0"
},
Expand Down Expand Up @@ -84,7 +84,7 @@
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.6.3",
"vsce": "^2.9.1",
"vscode-debugadapter-testsupport": "^1.51.0"
"@vscode/debugadapter-testsupport": "^1.55.1"
},
"release": {
"branches": [
Expand Down
4 changes: 2 additions & 2 deletions src/breakpoints.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DebugProtocol as VSCodeDebugProtocol } from 'vscode-debugprotocol'
import * as vscode from 'vscode-debugadapter'
import { DebugProtocol as VSCodeDebugProtocol } from '@vscode/debugprotocol'
import * as vscode from '@vscode/debugadapter'
import { EventEmitter } from 'events'
import * as xdebug from './xdebugConnection'
import * as util from 'util'
Expand Down
23 changes: 20 additions & 3 deletions src/phpDebug.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode-debugadapter'
import { DebugProtocol as VSCodeDebugProtocol } from 'vscode-debugprotocol'
import * as vscode from '@vscode/debugadapter'
import { DebugProtocol as VSCodeDebugProtocol } from '@vscode/debugprotocol'
import * as net from 'net'
import * as xdebug from './xdebugConnection'
import moment = require('moment')
Expand Down Expand Up @@ -377,6 +377,10 @@ class PhpDebugSession extends vscode.DebugSession {
initPacket.engineName === 'Xdebug' &&
semver.valid(initPacket.engineVersion, { loose: true }) &&
semver.gte(initPacket.engineVersion, '3.0.0', { loose: true })
const supportedEngine32 =
initPacket.engineName === 'Xdebug' &&
semver.valid(initPacket.engineVersion, { loose: true }) &&
semver.gte(initPacket.engineVersion, '3.2.0', { loose: true })
if (
supportedEngine ||
((feat = await connection.sendFeatureGetCommand('resolved_breakpoints')) &&
Expand All @@ -398,15 +402,25 @@ class PhpDebugSession extends vscode.DebugSession {
) {
await connection.sendFeatureSetCommand('extended_properties', '1')
}
if (
supportedEngine32 ||
((feat = await connection.sendFeatureGetCommand('breakpoint_include_return_value')) &&
feat.supported === '1')
) {
await connection.sendFeatureSetCommand('breakpoint_include_return_value', '1')
}

// override features from launch.json
try {
const xdebugSettings = args.xdebugSettings || {}
// Required defaults for indexedVariables
xdebugSettings.max_children = xdebugSettings.max_children || 100
await Promise.all(
Object.keys(xdebugSettings).map(setting =>
connection.sendFeatureSetCommand(setting, xdebugSettings[setting])
)
)
args.xdebugSettings = xdebugSettings
} catch (error) {
throw new Error(
'Error applying xdebugSettings: ' + (error instanceof Error ? error.message : error)
Expand Down Expand Up @@ -1001,7 +1015,7 @@ class PhpDebugSession extends vscode.DebugSession {
if (property.children.length === property.numberOfChildren) {
properties = property.children
} else {
properties = await property.getChildren()
properties = await property.getChildren((args.start ?? 0) / 100)
}
} else {
properties = []
Expand Down Expand Up @@ -1066,6 +1080,9 @@ class PhpDebugSession extends vscode.DebugSession {
presentationHint,
evaluateName,
}
if (this._args.xdebugSettings?.max_children === 100) {
variable.indexedVariables = property.numberOfChildren
}
return variable
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as chai from 'chai'
import chaiAsPromised = require('chai-as-promised')
import * as path from 'path'
import { DebugClient } from 'vscode-debugadapter-testsupport'
import { DebugProtocol } from 'vscode-debugprotocol'
import { DebugClient } from '@vscode/debugadapter-testsupport'
import { DebugProtocol } from '@vscode/debugprotocol'
import * as semver from 'semver'
import * as net from 'net'
chai.use(chaiAsPromised)
Expand Down
10 changes: 6 additions & 4 deletions src/xdebugConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,11 @@ export class Property extends BaseProperty {
* Returns the child properties of this property by doing another property_get
* @returns Promise.<Property[]>
*/
public async getChildren(): Promise<Property[]> {
public async getChildren(page: number = 0): Promise<Property[]> {
if (!this.hasChildren) {
throw new Error('This property has no children')
}
return (await this.context.stackFrame.connection.sendPropertyGetCommand(this)).children
return (await this.context.stackFrame.connection.sendPropertyGetCommand(this, page)).children
}
}

Expand Down Expand Up @@ -1053,11 +1053,13 @@ export class Connection extends DbgpConnection {
// ------------------------------ property --------------------------------------

/** Sends a property_get command */
public async sendPropertyGetCommand(property: Property): Promise<PropertyGetResponse> {
public async sendPropertyGetCommand(property: Property, page: number = 0): Promise<PropertyGetResponse> {
return new PropertyGetResponse(
await this._enqueueCommand(
'property_get',
`-d ${property.context.stackFrame.level} -c ${property.context.id} -n ${escape(property.fullName)}`
`-d ${property.context.stackFrame.level} -c ${property.context.id} -p ${page} -n ${escape(
property.fullName
)}`
),
property.context
)
Expand Down

0 comments on commit ba7756c

Please sign in to comment.