linol/ocaml-lsp-server/docs/ocamllsp/construct-spec.md
Simon Cruanes 7fbc187548 Squashed 'thirdparty/lsp/' content from commit aae69863
git-subtree-dir: thirdparty/lsp
git-subtree-split: aae6986391a8519de3da6a7a341f2bd3376e0d2f
2025-04-10 15:44:25 -04:00

1.2 KiB

Construct Request

Description

Provides commands to fill typed holes (_). Such holes sometimes appear in the result of other commands like destruct and can also be inserted manually in the source. The command is already accessible via a completion hook, however, in certain situations, invoking construct on a hole via a request allows more control.

Client Capability

There is no client capability relative to this request.

Server capability

  • property name: handleConstruct
  • property type: boolean

Request

  • method: ocamllsp/construct

  • params:

    {
      "uri": TextDocumentIdentifier,
      "position": Position
      "depth?": uinteger (default value: 0)
      "withValues?": <"local" | "none">,
    }
    

The depth parameter allows to recursively construct terms. Note that when depth > 1 partial results of inferior depth will not be returned. The withValues parameter enables the use of values from the environment (local) or not (none), It defaults to none.

Response

{
  "position": Range,
  "result": string[]
}

The result contains the range (position) to be replaced (describing the hole) and the list of possible substitution values (result).