phpactor / phpactor

Mainly a PHP Language Server with more features than you can shake a stick at
MIT License
1.41k stars 128 forks source link

Add support for LSP 3.17 inlineValue #2413

Open zobo opened 11 months ago

zobo commented 11 months ago

If the LS exposes the inline value capability, vscode allows the debugger to display those in the editor.

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlineValue

This is already something I implemented and will port to this code-base when possible: https://github.com/zobo/php-language-server/pull/59

dantleech commented 6 months ago

what should this look like?

we can easily evaluate a specific "node" at an offset: f.e. $reflector->reflectOffset($code, 12)->type()->__toString() (e.g. $x<> = 1 + 2 will return 3)

zobo commented 6 months ago

TextDocument inline value is used by IDE to get a list of variables that can be evaluated by the debugger for a range in the document.

These get displayed on the right side of the code when debugging.

dantleech commented 6 months ago

How should it get the list of vars?

zobo commented 6 months ago

Sorry for the late reply, I'll try to be more exact. The Inline values request all evaluatable variables within a document section. The end result is something like this (random picture from SO):

image

So the command would return a list of variables in the document section that the debugger could evaluate in the current live debugger session. These are normally:

Again the LS does not EVALUATE them, it just reports the names (and ranges) for debugger to do the evaluation then.

Does this make more sense?

zobo commented 6 months ago

Related PR https://github.com/phpactor/language-server-protocol/pull/19