Skip to content

Commit

Permalink
Specification of typeEnclosing and changes entry
Browse files Browse the repository at this point in the history
  • Loading branch information
xvw committed Jun 27, 2024
1 parent 2cb950b commit 61f9000
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
[`ocamllsp/merlinCallCompatible`](https://github.com/ocaml/ocaml-lsp/blob/e165f6a3962c356adc7364b9ca71788e93489dd0/ocaml-lsp-server/docs/ocamllsp/merlinCallCompatible-spec.md)
request (#1265)

- Add custom [`ocamllsp/typeEnclosing`](https://github.com/ocaml/ocaml-lsp/blob/109801e56f2060caf4487427bede28b824f4f1fe/ocaml-lsp-server/docs/ocamllsp/typeEnclosing-spec.md) request (#1304)


## Fixes

Expand Down
59 changes: 59 additions & 0 deletions ocaml-lsp-server/docs/ocamllsp/typeEnclosing-spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Type Enclosing Request

## Description

Merlin has a concept of `type enclosing` that gets the type of ident under the
cursor. It will highlight the ident and display its type. You can climb the
typed-tree and display the type of bigger expressions surrounding the cursor. In
order to keep the request stateless, the manipulation related to growing or
shrinking enclosings is delegated to the client. This request allows to request
type enclosing under the cursor and then its surrounding enclosings.

## Client capability

There is no client capability relative to this request.

## Server capability

- property name: `handleTypeEnclosing`
- property type: `boolean`

## Request

- method: `ocamllsp/typeEnclosing`
- params:

```json
{
"textDocument": TextDocumentIdentifier,
"position": Position,
"index": uinteger,
"verbosity?": uinteger,
"rangeEnd?": Position
}
```

- `index` can be used to print only one type information. This is useful to query
the types lazily: normally, Merlin would return the signature of all enclosing
modules, which can be very expensive.
- `verbosity` determines the number of expansions of aliases in answers.
- `rangeEnd` an optional end position. If provided, only enclosings that contain the
range `[super.position; end[` will be included in the answer.



## Response

```json
{
"enclosings": Range[],
"index": uinteger,
"type": string
}
```

- `enclosings`: The surrounding enclosings
- `index` The index of the provided type result: the index corresponds to a
zero-indexed enclosing in the `enclosings`' array. It is the same value as the
one provided in this request's `TypeEnclosingParams`
- `type`: The type of the enclosing `enclosings[index]` as a raw string

0 comments on commit 61f9000

Please sign in to comment.