Back to Rustowl

The RustOwl LSP specification

docs/lsp-spec.md

0.4.02.5 KB
Original Source

The RustOwl LSP specification

Table of Contents

<!--toc:start--> <!--toc:end-->

rustowl, is an LSP server which provides RustOwl information. To display various types of decorations, RustOwl supports some custom methods from the client.

Here, we describe the specifications of those custom methods.

Types

Here, we describe the types we will use in this document.

OprType

<!-- prettier-ignore-start -->
typescript
"lifetime" | "definitely_live" | "maybe_initialized"
| "imm_borrow" | "mut_borrow" | "move" | "call"
| "outlive" | "shared_mut"
<!-- prettier-ignore-end -->

definitely_live and maybe_initialized are derived from a CFG-based liveness analysis:

  • definitely_live covers ranges where the local is provably initialized on every path that reaches the location (state is exactly {Initialized}).
  • maybe_initialized covers ranges where the local is initialized on at least one path but may also have been moved, dropped, or be uninitialized on others (state contains Initialized together with other variants). Useful for spotting conditional drops and other resource-management ambiguity.

lifetime is retained for backward compatibility; clients should treat definitely_live as the replacement for the previous "actual lifetime" decoration.

Decoration

<pre><code>{ "type": <a href="#oprtype">OprType</a>, "range": <a href="https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#range">Range</a>, "hover_text": Option&lt;String&gt;, "overlapped": bool } </code></pre>

overlapped field indicates that the decoration is overlapped and should be hidden.

Methods

We describe the custom methods used in RustOwl.

rustowl/cursor

Request payload

<pre><code>{ "position": <a href="https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position">Position</a>, "document": { "uri": <a href="https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#documentUri">DocumentUri</a> } } </code></pre>

Response payload

<pre><code>{ "is_analyzed": bool, "decorations": [<a href="#decoration">Decoration</a>] } </code></pre>