Skip to content

Commit 60b6926

Browse files
authored
feat: Evaluate watch either through property or eval and use eval_cache (#1008)
1 parent 8c82f65 commit 60b6926

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/phpDebug.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,26 @@ class PhpDebugSession extends vscode.DebugSession {
14891489
response.body = { result: await varExportProperty(res.property), variablesReference: 0 }
14901490
this.sendResponse(response)
14911491
return
1492+
} else if (args.context === 'watch') {
1493+
// if we suspect a function call
1494+
if (args.expression.includes('(')) {
1495+
if (stackFrame.level !== 0) {
1496+
throw new Error('Cannot evaluate function calls when not on top of the stack')
1497+
}
1498+
const uuid = randomUUID()
1499+
await connection.sendEvalCommand(`$GLOBALS['eval_cache']['${uuid}']=${args.expression}`)
1500+
const ctx = await stackFrame.getContexts() // TODO CACHE THIS
1501+
const res = await connection.sendPropertyGetNameCommand(`$eval_cache['${uuid}']`, ctx[1])
1502+
if (res.property) {
1503+
result = res.property
1504+
}
1505+
} else {
1506+
const ctx = await stackFrame.getContexts() // TODO CACHE THIS
1507+
const res = await connection.sendPropertyGetNameCommand(args.expression, ctx[0])
1508+
if (res.property) {
1509+
result = res.property
1510+
}
1511+
}
14921512
} else {
14931513
const res = await connection.sendEvalCommand(args.expression)
14941514
if (res.result) {

0 commit comments

Comments
 (0)