package merlin-extend

  1. Overview
  2. Docs
type t

Internal representation of a buffer for the extension. Extension should avoid global state, cached information should be stored in values of this type.

val load : buffer -> t

Turns a merlin-buffer into an internal buffer.

This function should be total, an exception at this point is a fatal-error.

Simplest implementation is identity, with type t = buffer.

val parse : t -> parsetree

Get the main parsetree from the buffer. This should return the AST corresponding to buffer.source.

val for_completion : t -> Stdlib.Lexing.position -> complete_info * parsetree

Give the opportunity to optimize the parsetree when completing from a specific position.

The simplest implementation is:

let for_completion t _ = ({complete_labels = true}, (tree t))

But it might be worthwhile to specialize the parsetree for a better completion.

val parse_line : t -> Stdlib.Lexing.position -> string -> parsetree

Parse a separate user-input in the context of this buffer. Used when the user manually enters an expression and ask for its type or location.

val ident_at : t -> Stdlib.Lexing.position -> string Location.loc list

Given a buffer and a position, return the components of the identifier (actually the qualified path) under the cursor.

This should return the raw identifier names -- operators should not be surrounded by parentheses.

An empty list is a valid result if no identifiers are under the cursor.

val print_outcome : Stdlib.Format.formatter -> outcometree -> unit

Opposite direction: pretty-print a tree. This works on outcometree and is used for displaying answers to queries. (type errors, signatures of modules in environment, completion candidates, etc).

val pretty_print : Stdlib.Format.formatter -> pretty_parsetree -> unit
OCaml

Innovation. Community. Security.