diff options
| author | Adenine <adenine.dev@gmail.com> | 2023-07-07 23:03:55 -0400 |
|---|---|---|
| committer | Adenine <adenine.dev@gmail.com> | 2023-07-07 23:12:09 -0400 |
| commit | 4d5c66986ece98fb0015cbca5ee0de1f9870c800 (patch) | |
| tree | d02cbfc6455ba70b9a40eb010f214f9596301931 /docs/dev | |
| parent | c43cfefdd868c92f60d936e8958c0980428a0679 (diff) | |
| download | rust-4d5c66986ece98fb0015cbca5ee0de1f9870c800.tar.gz rust-4d5c66986ece98fb0015cbca5ee0de1f9870c800.zip | |
cleanup + docs + tests
Diffstat (limited to 'docs/dev')
| -rw-r--r-- | docs/dev/lsp-extensions.md | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index bc58aa7220d..8655e954675 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@ <!--- -lsp_ext.rs hash: 2d60bbffe70ae198 +lsp_ext.rs hash: 12bf360ee77cc63d If you need to change the above hash to make the test pass, please check if you need to adjust this doc as well and ping this issue: @@ -886,3 +886,56 @@ export interface FetchDependencyListResult { } ``` Returns all crates from this workspace, so it can be used create a viewTree to help navigate the dependency tree. + +## View Recursive Memory Layout + +**Method:** `rust-analyzer/fetchDependencyList` + +**Request:** + +```typescript +/// Holds a location in a text document, the location may be a datatype or a variable and it will do its best to locate the desired type. +export interface ViewRecursiveMemoryLayoutParams { + textDocument: TextDocumentIdentifier; + position: Position; +} +``` + +**Response:** + +```typescript +export interface RecursiveMemoryLayoutNode = { + /// Name of the item, or [ROOT], `.n` for tuples + item_name: string; + /// Full name of the type (type aliases are ignored) + typename: string; + /// Size of the type in bytes + size: number; + /// Alignment of the type in bytes + alignment: number; + /// Offset of the type relative to its parent (or 0 if its the root) + offset: number; + /// Index of the node's parent (or -1 if its the root) + parent_idx: number; + /// Index of the node's children (or -1 if it does not have children) + children_start: number; + /// Number of child nodes (unspecified it does not have children) + children_len: number; +}; + +export interface RecursiveMemoryLayout = { + nodes: RecursiveMemoryLayoutNode[]; +}; +``` + +Returns a vector of nodes representing items in the datatype as a tree, `RecursiveMemoryLayout::nodes[0]` is the root node. + +If `RecursiveMemoryLayout::nodes::length == 0` we could not find a suitable type. + +Generic Types do not give anything because they are incomplete. Fully specified generic types do not give anything if they are selected directly but do work when a child of other types [this is consistent with other behavior](https://github.com/rust-lang/rust-analyzer/issues/15010). + +### Unresolved questions: + +- How should enums/unions be represented? currently they do not produce any children because they have multiple distinct sets of children. +- Should niches be represented? currently they are not reported. +- A visual representation of the memory layout is not specified, see the provided implementation for an example, however it may not translate well to terminal based editors or other such things. |
