vscode-java-debug icon indicating copy to clipboard operation
vscode-java-debug copied to clipboard

Mark function return value as readOnly

Open Trass3r opened this issue 2 years ago • 4 comments
trafficstars

When stepping out of a function the return value is helpfully displayed like a variable: ->equals(): false But when trying to edit it (for lack of #1320) I'm getting image

Environment
  • Operating System: Win11
  • JDK version: GraalVM 22.3 JDK17
  • Visual Studio Code version: 1.77.2
  • Java extension version: v1.16.0
  • Java Debugger extension version: v0.49.1

Trass3r avatar Apr 12 '23 14:04 Trass3r

Editing the return value is not a supported scenario. The return value is a placeholder variable that's read-only.

testforstephen avatar Apr 17 '23 02:04 testforstephen

Ok, but possibly an attribute is missing so VSCode doesn't even let you try to modify it. I don't quite remember if readOnly did the trick: https://microsoft.github.io/debug-adapter-protocol/specification#Types_VariablePresentationHint

Also would it be technically possible to implement this with the java debug API? Then it could be turned into a feature request.

Trass3r avatar Apr 17 '23 08:04 Trass3r

Ok, but possibly an attribute is missing so VSCode doesn't even let you try to modify it. I don't quite remember if readOnly did the trick: https://microsoft.github.io/debug-adapter-protocol/specification#Types_VariablePresentationHint

This is a good finding that we can adopt it to show the return value placeholder as readOnly.

Also would it be technically possible to implement this with the java debug API? Then it could be turned into a feature request.

Pls remember the return value in Variables view is not a real local variable in current call stack. It's captured by debugger when stepping out the previous stack frame. It does not have a variable name. The name -> equals() you see in the Variables view is a placeholder name we created for readability.

testforstephen avatar Apr 18 '23 03:04 testforstephen

Yeah I don't know how Java handles it. In native code it's conceivable to modify the return value. I think VS offers that functionality.

Trass3r avatar Apr 18 '23 09:04 Trass3r