123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137moduleReader=struct(** Description of a buffer managed by Merlin *)typebuffer={path:string;(** Path of the buffer in the editor.
The path is absolute if it is backed by a file, although it might not yet
have been saved in the editor.
The path is relative if it is a temporary buffer. *)flags:stringlist;(** Any flag that has been passed to the reader in .merlin file *)text:string(** Content of the buffer *)}(** ASTs exchanged with Merlin *)typeparsetree=|StructureofParsetree.structure(** An implementation, usually coming from a .ml file *)|SignatureofParsetree.signature(** An interface, usually coming from a .mli file *)(** Printing in error messages or completion items *)typeoutcometree=|Out_valueofOutcometree.out_value|Out_typeofOutcometree.out_type|Out_class_typeofOutcometree.out_class_type|Out_module_typeofOutcometree.out_module_type|Out_sig_itemofOutcometree.out_sig_item|Out_signatureofOutcometree.out_sig_itemlist|Out_type_extensionofOutcometree.out_type_extension|Out_phraseofOutcometree.out_phrase(** Printing in case destruction *)typepretty_parsetree=|Pretty_toplevel_phraseofParsetree.toplevel_phrase|Pretty_expressionofParsetree.expression|Pretty_core_typeofParsetree.core_type|Pretty_patternofParsetree.pattern|Pretty_signatureofParsetree.signature|Pretty_structureofParsetree.structure|Pretty_case_listofParsetree.caselist(** Additional information useful for guiding completion *)typecomplete_info={complete_labels:bool(** True if it is appropriate to suggest labels for this completion. *)}moduletypeV0=sig(** Internal representation of a buffer for the extension.
Extension should avoid global state, cached information should be stored
in values of this type. *)typet(** 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.
*)valload:buffer->t(** Get the main parsetree from the buffer.
This should return the AST corresponding to [buffer.source].
*)valparse:t->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.
*)valfor_completion:t->Lexing.position->complete_info*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.
*)valparse_line:t->Lexing.position->string->parsetree(** 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.
*)valident_at:t->Lexing.position->stringLocation.loclist(** 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).
*)valprint_outcome:Format.formatter->outcometree->unit(* This one works on parsetree and is used for case destruction
(merlin-destruct) *)valpretty_print:Format.formatter->pretty_parsetree->unitendtyperequest=|Req_loadofbuffer|Req_parse|Req_parse_lineofLexing.position*string|Req_parse_for_completionofLexing.position|Req_get_ident_atofLexing.position|Req_print_outcomeofoutcometreelist|Req_pretty_printofpretty_parsetreetyperesponse=|Res_loaded|Res_parseofparsetree|Res_parse_for_completionofcomplete_info*parsetree|Res_get_ident_atofstringLocation.loclist|Res_print_outcomeofstringlist|Res_pretty_printofstringend(* Name of the extension *)typedescription={name:string;version:string}(* Services an extension can provide *)typecapabilities={reader:bool}(* Main protocol *)typerequest=Start_communication|Reader_requestofReader.requesttyperesponse=|Notifyofstring|Debugofstring|Exceptionofstring*string|Reader_responseofReader.response