regal icon indicating copy to clipboard operation
regal copied to clipboard

Implement "inline value"

Open anderseknert opened this issue 2 months ago • 0 comments

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

This feature allows the language server to return a list of values that should be presented to the right of a line in the editor, presumably from evaluation results. It is not entirely clear to me what events in the client may trigger this request to be sent. I guess it's related to evaluation / debugging, but LSP doesn't do that on it's own... so first thing to figure out here is how to work with this.

Next step is of course to provide some actual values. @johanfylling is looking into having values provided in test assertion failures, which would potentially allow us to piggyback on this in Regal, should bindings be provided in the trace output of evaluation. If that was the case, we could trigger an evaluation from the client (given the input.json file in the workspace or whatever) and have each value(s) from the eval displayed on the line of the binding.

While this requires changes to OPA, there's an interesting intermediate step we could explore, where we don't yet provide values per line but per rule. This could be accomplished today already by simply evaluating the whole data document and see what comes back. For each rule evaluated, we'd display the result to the right of the rule, or undefined if it wasn't present in the result. There are a few caveates here, like not being able to differentiate the result of rules defined incrementally, etc... but I believe this already could provide a massive boost to the Rego debugging experience in the meantime.

anderseknert avatar Apr 23 '24 08:04 anderseknert