Add Linux Mint to `getdeps` Debian package manager options
[hiphop-php.git] / hphp / hack / src / utils / lsp / lsp.ml
blobde288e75ad2bef9edd6f363baf68e14f8d15a949
1 (*
2 * Copyright (c) 2016, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
8 *)
10 open Hh_prelude
12 type lsp_id =
13 | NumberId of int
14 | StringId of string
16 type partial_result_token = PartialResultToken of string
18 module DocumentUri = struct
19 module M = struct
20 type t = Uri of string [@@deriving eq, ord]
21 end
23 include M
24 module Map = WrappedMap.Make (M)
25 end
27 let uri_of_string (s : string) : DocumentUri.t = DocumentUri.Uri s
29 let string_of_uri (DocumentUri.Uri s) : string = s
31 type position = {
32 line: int;
33 character: int;
35 [@@deriving eq]
37 type range = {
38 start: position;
39 end_: position;
41 [@@deriving eq]
43 type textDocumentSaveReason =
44 | Manual [@value 1]
45 | AfterDelay [@value 2]
46 | FocusOut [@value 3]
47 [@@deriving enum]
49 module Location = struct
50 type t = {
51 uri: DocumentUri.t;
52 range: range;
54 [@@deriving eq]
55 end
57 module DefinitionLocation = struct
58 type t = {
59 location: Location.t;
60 title: string option;
62 end
64 type markedString =
65 | MarkedString of string
66 | MarkedCode of string * string
68 module Command = struct
69 type t = {
70 title: string;
71 command: string;
72 arguments: Hh_json.json list;
74 end
76 module TextEdit = struct
77 type t = {
78 range: range;
79 newText: string;
81 end
83 module TextDocumentIdentifier = struct
84 type t = { uri: DocumentUri.t }
85 end
87 module VersionedTextDocumentIdentifier = struct
88 type t = {
89 uri: DocumentUri.t;
90 version: int;
92 end
94 module TextDocumentEdit = struct
95 type t = {
96 textDocument: VersionedTextDocumentIdentifier.t;
97 edits: TextEdit.t list;
99 end
101 module WorkspaceEdit = struct
102 type t = { changes: TextEdit.t list DocumentUri.Map.t }
105 module TextDocumentItem = struct
106 type t = {
107 uri: DocumentUri.t;
108 languageId: string;
109 version: int;
110 text: string;
114 module CodeLens = struct
115 type t = {
116 range: range;
117 command: Command.t;
118 data: Hh_json.json option;
122 module TextDocumentPositionParams = struct
123 type t = {
124 textDocument: TextDocumentIdentifier.t;
125 position: position;
129 module DocumentFilter = struct
130 type t = {
131 language: string option;
132 scheme: string option;
133 pattern: string option;
137 module DocumentSelector = struct
138 type t = DocumentFilter.t list
141 module SymbolInformation = struct
142 type symbolKind =
143 | File [@value 1]
144 | Module [@value 2]
145 | Namespace [@value 3]
146 | Package [@value 4]
147 | Class [@value 5]
148 | Method [@value 6]
149 | Property [@value 7]
150 | Field [@value 8]
151 | Constructor [@value 9]
152 | Enum [@value 10]
153 | Interface [@value 11]
154 | Function [@value 12]
155 | Variable [@value 13]
156 | Constant [@value 14]
157 | String [@value 15]
158 | Number [@value 16]
159 | Boolean [@value 17]
160 | Array [@value 18]
161 | Object [@value 19]
162 | Key [@value 20]
163 | Null [@value 21]
164 | EnumMember [@value 22]
165 | Struct [@value 23]
166 | Event [@value 24]
167 | Operator [@value 25]
168 | TypeParameter [@value 26]
169 [@@deriving enum]
171 type t = {
172 name: string;
173 kind: symbolKind;
174 location: Location.t;
175 detail: string option;
176 containerName: string option;
180 module CallHierarchyItem = struct
181 type t = {
182 name: string;
183 kind: SymbolInformation.symbolKind;
184 detail: string option;
185 uri: DocumentUri.t;
186 range: range;
187 selectionRange: range;
191 module CallHierarchyCallsRequestParam = struct
192 type t = { item: CallHierarchyItem.t }
195 module MessageType = struct
196 type t =
197 | ErrorMessage [@value 1]
198 | WarningMessage [@value 2]
199 | InfoMessage [@value 3]
200 | LogMessage [@value 4]
201 [@@deriving eq, enum]
204 module CodeActionKind = struct
205 (** CodeActionKind.t uses a pair to represent a non-empty list
206 and we provide utility functions for creation, membership, printing.*)
207 type t = string * string list
209 let is_kind : t -> t -> bool =
210 let rec is_prefix_of ks xs =
211 match (ks, xs) with
212 | ([], _) -> true
213 | (k :: ks, x :: xs) when String.equal k x -> is_prefix_of ks xs
214 | (_, _) -> false
216 (fun (k, ks) (x, xs) -> String.equal k x && is_prefix_of ks xs)
218 let contains_kind k ks = List.exists ~f:(is_kind k) ks
220 let contains_kind_opt ~default k ks =
221 match ks with
222 | Some ks -> contains_kind k ks
223 | None -> default
225 let kind_of_string : string -> t =
226 fun s ->
227 match Stdlib.String.split_on_char '.' s with
228 | [] -> failwith "split_on_char does not return an empty list"
229 | k :: ks -> (k, ks)
231 let string_of_kind : t -> string =
232 (fun (k, ks) -> String.concat ~sep:"." (k :: ks))
234 let sub_kind : t -> string -> t =
235 let cons_to_end (ss : string list) (s : string) =
236 Base.List.(fold_right ss ~f:cons ~init:[s])
238 (fun (k, ks) s -> (k, cons_to_end ks s))
240 let quickfix = kind_of_string "quickfix"
242 let refactor = kind_of_string "refactor"
244 let source = kind_of_string "source"
247 module CancelRequest = struct
248 type params = cancelParams
250 and cancelParams = { id: lsp_id }
253 module SetTraceNotification = struct
254 type params =
255 | Verbose
256 | Off
259 module Initialize = struct
260 type textDocumentSyncKind =
261 | NoSync [@value 0]
262 | FullSync [@value 1]
263 | IncrementalSync [@value 2]
264 [@@deriving enum]
266 module CodeActionOptions = struct
267 type t = { resolveProvider: bool }
270 module CompletionOptions = struct
271 type t = {
272 resolveProvider: bool;
273 completion_triggerCharacters: string list;
277 module ServerExperimentalCapabilities = struct
278 type t = {
279 snippetTextEdit: bool;
280 autoCloseJsx: bool;
284 module ClientExperimentalCapabilities = struct
285 type t = {
286 snippetTextEdit: bool;
287 autoCloseJsx: bool;
291 type params = {
292 processId: int option;
293 rootPath: string option;
294 rootUri: DocumentUri.t option;
295 initializationOptions: initializationOptions;
296 client_capabilities: client_capabilities;
297 trace: trace;
300 and result = { server_capabilities: server_capabilities }
302 and errorData = { retry: bool }
304 and trace =
305 | Off
306 | Messages
307 | Verbose
309 and initializationOptions = {
310 namingTableSavedStatePath: string option;
311 namingTableSavedStateTestDelay: float;
312 delayUntilDoneInit: bool;
313 skipLspServerOnTypeFormatting: bool;
316 and client_capabilities = {
317 workspace: workspaceClientCapabilities;
318 textDocument: textDocumentClientCapabilities;
319 window: windowClientCapabilities;
320 telemetry: telemetryClientCapabilities;
321 client_experimental: ClientExperimentalCapabilities.t;
324 and workspaceClientCapabilities = {
325 applyEdit: bool;
326 workspaceEdit: workspaceEdit;
327 didChangeWatchedFiles: dynamicRegistration;
330 and dynamicRegistration = { dynamicRegistration: bool }
332 and workspaceEdit = { documentChanges: bool }
334 and textDocumentClientCapabilities = {
335 synchronization: synchronization;
336 completion: completion;
337 codeAction: codeAction;
338 definition: definition;
339 typeDefinition: typeDefinition;
340 declaration: declaration;
341 implementation: implementation;
344 and synchronization = {
345 can_willSave: bool;
346 can_willSaveWaitUntil: bool;
347 can_didSave: bool;
350 and completion = { completionItem: completionItem }
352 and completionItem = { snippetSupport: bool }
354 and codeAction = {
355 codeAction_dynamicRegistration: bool;
356 codeActionLiteralSupport: codeActionliteralSupport option;
359 and definition = { definitionLinkSupport: bool }
361 and typeDefinition = { typeDefinitionLinkSupport: bool }
363 and declaration = { declarationLinkSupport: bool }
365 and implementation = { implementationLinkSupport: bool }
367 and codeActionliteralSupport = { codeAction_valueSet: CodeActionKind.t list }
369 and windowClientCapabilities = { status: bool }
371 and telemetryClientCapabilities = { connectionStatus: bool }
373 and server_capabilities = {
374 textDocumentSync: textDocumentSyncOptions;
375 hoverProvider: bool;
376 completionProvider: CompletionOptions.t option;
377 signatureHelpProvider: signatureHelpOptions option;
378 definitionProvider: bool;
379 typeDefinitionProvider: bool;
380 referencesProvider: bool;
381 callHierarchyProvider: bool;
382 documentHighlightProvider: bool;
383 documentSymbolProvider: bool;
384 workspaceSymbolProvider: bool;
385 codeActionProvider: CodeActionOptions.t option;
386 codeLensProvider: codeLensOptions option;
387 documentFormattingProvider: bool;
388 documentRangeFormattingProvider: bool;
389 documentOnTypeFormattingProvider: documentOnTypeFormattingOptions option;
390 renameProvider: bool;
391 documentLinkProvider: documentLinkOptions option;
392 executeCommandProvider: executeCommandOptions option;
393 implementationProvider: bool;
394 rageProviderFB: bool; (** Nuclide-specific feature *)
395 server_experimental: ServerExperimentalCapabilities.t option;
398 and signatureHelpOptions = { sighelp_triggerCharacters: string list }
400 and codeLensOptions = { codelens_resolveProvider: bool }
402 and documentOnTypeFormattingOptions = {
403 firstTriggerCharacter: string;
404 moreTriggerCharacter: string list;
407 and documentLinkOptions = { doclink_resolveProvider: bool }
409 and executeCommandOptions = { commands: string list }
411 and textDocumentSyncOptions = {
412 want_openClose: bool;
413 want_change: textDocumentSyncKind;
414 want_willSave: bool;
415 want_willSaveWaitUntil: bool;
416 want_didSave: saveOptions option;
419 and saveOptions = { includeText: bool }
422 module Error = struct
423 type code =
424 | ParseError [@value -32700]
425 | InvalidRequest [@value -32600]
426 | MethodNotFound [@value -32601]
427 | InvalidParams [@value -32602]
428 | InternalError [@value -32603]
429 | ServerErrorStart [@value -32099]
430 | ServerErrorEnd [@value -32000]
431 | ServerNotInitialized [@value -32002]
432 | UnknownErrorCode [@value -32001]
433 | RequestCancelled [@value -32800]
434 | ContentModified [@value -32801]
435 [@@deriving show { with_path = false }, enum]
437 type t = {
438 code: code;
439 message: string;
440 data: Hh_json.json option;
443 exception LspException of t
446 module RageFB = struct
447 type result = rageItem list
449 and rageItem = {
450 title: string option;
451 data: string;
455 module CodeLensResolve = struct
456 type params = CodeLens.t
458 and result = CodeLens.t
461 module Hover = struct
462 type params = TextDocumentPositionParams.t
464 and result = hoverResult option
466 and hoverResult = {
467 contents: markedString list;
468 range: range option;
472 module PublishDiagnostics = struct
473 type diagnosticSeverity =
474 | Error [@value 1]
475 | Warning [@value 2]
476 | Information [@value 3]
477 | Hint [@value 4]
478 [@@deriving eq, enum]
480 type params = publishDiagnosticsParams
482 and publishDiagnosticsParams = {
483 uri: DocumentUri.t;
484 diagnostics: diagnostic list;
485 isStatusFB: bool;
488 and diagnostic = {
489 range: range;
490 severity: diagnosticSeverity option;
491 code: diagnosticCode;
492 source: string option;
493 message: string;
494 relatedInformation: diagnosticRelatedInformation list;
495 relatedLocations: relatedLocation list;
497 [@@deriving eq]
499 and diagnosticCode =
500 | IntCode of int
501 | StringCode of string
502 | NoCode
503 [@@deriving eq]
505 and diagnosticRelatedInformation = {
506 relatedLocation: Location.t;
507 relatedMessage: string;
509 [@@deriving eq]
511 and relatedLocation = diagnosticRelatedInformation
514 module DidOpen = struct
515 type params = didOpenTextDocumentParams
517 and didOpenTextDocumentParams = { textDocument: TextDocumentItem.t }
520 module DidClose = struct
521 type params = didCloseTextDocumentParams
523 and didCloseTextDocumentParams = { textDocument: TextDocumentIdentifier.t }
526 module DidSave = struct
527 type params = didSaveTextDocumentParams
529 and didSaveTextDocumentParams = {
530 textDocument: TextDocumentIdentifier.t;
531 text: string option;
535 module DidChange = struct
536 type params = didChangeTextDocumentParams
538 and didChangeTextDocumentParams = {
539 textDocument: VersionedTextDocumentIdentifier.t;
540 contentChanges: textDocumentContentChangeEvent list;
543 and textDocumentContentChangeEvent = {
544 range: range option;
545 rangeLength: int option;
546 text: string;
550 module WillSaveWaitUntil = struct
551 type params = willSaveWaitUntilTextDocumentParams
553 and willSaveWaitUntilTextDocumentParams = {
554 textDocument: TextDocumentIdentifier.t;
555 reason: textDocumentSaveReason;
558 and result = TextEdit.t list
561 module DidChangeWatchedFiles = struct
562 type registerOptions = { watchers: fileSystemWatcher list }
564 and fileSystemWatcher = { globPattern: string }
566 type fileChangeType =
567 | Created [@value 1]
568 | Updated [@value 2]
569 | Deleted [@value 3]
570 [@@deriving enum]
572 type params = { changes: fileEvent list }
574 and fileEvent = {
575 uri: DocumentUri.t;
576 type_: fileChangeType;
580 module Definition = struct
581 type params = TextDocumentPositionParams.t
583 and result = DefinitionLocation.t list
586 module TypeDefinition = struct
587 type params = TextDocumentPositionParams.t
589 and result = DefinitionLocation.t list
592 module Implementation = struct
593 type params = TextDocumentPositionParams.t
595 and result = Location.t list
598 (* textDocument/codeAction and codeAction/resolve *)
599 module CodeAction = struct
600 type 'a t = {
601 title: string;
602 kind: CodeActionKind.t;
603 diagnostics: PublishDiagnostics.diagnostic list;
604 action: 'a edit_and_or_command;
607 and 'a edit_and_or_command =
608 | EditOnly of WorkspaceEdit.t
609 | CommandOnly of Command.t
610 | BothEditThenCommand of (WorkspaceEdit.t * Command.t)
611 | UnresolvedEdit of 'a
612 (** UnresolvedEdit is for this flow:
613 client --textDocument/codeAction --> server --response_with_unresolved_fields-->
614 client --codeAction/resolve --> server --response_with_all_fields--> client
617 type 'a command_or_action_ =
618 | Command of Command.t
619 | Action of 'a t
621 type resolved_marker = |
623 type resolved_command_or_action = resolved_marker command_or_action_
625 type command_or_action = unit command_or_action_
627 type result = command_or_action list
630 module CodeActionRequest = struct
631 type params = {
632 textDocument: TextDocumentIdentifier.t;
633 range: range;
634 context: codeActionContext;
637 and codeActionContext = {
638 diagnostics: PublishDiagnostics.diagnostic list;
639 only: CodeActionKind.t list option;
643 module CodeActionResolve = struct
644 type result = (CodeAction.resolved_command_or_action, Error.t) Result.t
647 (** method="codeAction/resolve" *)
648 module CodeActionResolveRequest = struct
649 type params = {
650 data: CodeActionRequest.params;
651 title: string;
655 (* Completion request, method="textDocument/completion" *)
656 module Completion = struct
657 type completionItemKind =
658 | Text [@value 1]
659 | Method [@value 2]
660 | Function [@value 3]
661 | Constructor [@value 4]
662 | Field [@value 5]
663 | Variable [@value 6]
664 | Class [@value 7]
665 | Interface [@value 8]
666 | Module [@value 9]
667 | Property [@value 10]
668 | Unit [@value 11]
669 | Value [@value 12]
670 | Enum [@value 13]
671 | Keyword [@value 14]
672 | Snippet [@value 15]
673 | Color [@value 16]
674 | File [@value 17]
675 | Reference [@value 18]
676 | Folder [@value 19]
677 | MemberOf [@value 20]
678 | Constant [@value 21]
679 | Struct [@value 22]
680 | Event [@value 23]
681 | Operator [@value 24]
682 | TypeParameter [@value 25]
683 [@@deriving enum]
685 type insertTextFormat =
686 | PlainText [@value 1]
687 | SnippetFormat [@value 2]
688 [@@deriving enum]
690 type completionTriggerKind =
691 | Invoked [@value 1]
692 | TriggerCharacter [@value 2]
693 | TriggerForIncompleteCompletions [@value 3]
694 [@@deriving enum]
696 let is_invoked = function
697 | Invoked -> true
698 | TriggerCharacter
699 | TriggerForIncompleteCompletions ->
700 false
702 type params = completionParams
704 and completionParams = {
705 loc: TextDocumentPositionParams.t;
706 context: completionContext option;
709 and completionContext = {
710 triggerKind: completionTriggerKind;
711 triggerCharacter: string option;
714 and result = completionList
716 and completionList = {
717 isIncomplete: bool;
718 items: completionItem list;
721 and completionDocumentation =
722 | MarkedStringsDocumentation of markedString list
723 | UnparsedDocumentation of Hh_json.json
725 and completionItem = {
726 label: string;
727 kind: completionItemKind option;
728 detail: string option;
729 documentation: completionDocumentation option;
730 sortText: string option;
731 filterText: string option;
732 insertText: string option;
733 insertTextFormat: insertTextFormat option;
734 textEdit: TextEdit.t option;
735 additionalTextEdits: TextEdit.t list;
736 command: Command.t option;
737 data: Hh_json.json option;
741 module CompletionItemResolve = struct
742 type params = Completion.completionItem
744 and result = Completion.completionItem
747 module WorkspaceSymbol = struct
748 type params = workspaceSymbolParams
750 and result = SymbolInformation.t list
752 and workspaceSymbolParams = { query: string (** a non-empty query string *) }
755 module DocumentSymbol = struct
756 type params = documentSymbolParams
758 and result = SymbolInformation.t list
760 and documentSymbolParams = { textDocument: TextDocumentIdentifier.t }
763 module FindReferences = struct
764 type params = referenceParams
766 and result = Location.t list
768 and referenceParams = {
769 loc: TextDocumentPositionParams.t;
770 context: referenceContext;
771 partialResultToken: partial_result_token option;
774 and referenceContext = {
775 includeDeclaration: bool;
776 includeIndirectReferences: bool;
780 module PrepareCallHierarchy = struct
781 type params = TextDocumentPositionParams.t
783 type result = CallHierarchyItem.t list option
786 module CallHierarchyIncomingCalls = struct
787 type params = CallHierarchyCallsRequestParam.t
789 type result = callHierarchyIncomingCall list option
791 and callHierarchyIncomingCall = {
792 from: CallHierarchyItem.t;
793 fromRanges: range list;
797 module CallHierarchyOutgoingCalls = struct
798 type params = CallHierarchyCallsRequestParam.t
800 type result = callHierarchyOutgoingCall list option
802 and callHierarchyOutgoingCall = {
803 call_to: CallHierarchyItem.t;
804 fromRanges: range list;
808 module DocumentHighlight = struct
809 type params = TextDocumentPositionParams.t
811 type documentHighlightKind =
812 | Text [@value 1]
813 | Read [@value 2]
814 | Write [@value 3]
815 [@@deriving enum]
817 type result = documentHighlight list
819 and documentHighlight = {
820 range: range;
821 kind: documentHighlightKind option;
825 module DocumentFormatting = struct
826 type params = documentFormattingParams
828 and result = TextEdit.t list
830 and documentFormattingParams = {
831 textDocument: TextDocumentIdentifier.t;
832 options: formattingOptions;
835 and formattingOptions = {
836 tabSize: int;
837 insertSpaces: bool;
841 module DocumentRangeFormatting = struct
842 type params = documentRangeFormattingParams
844 and result = TextEdit.t list
846 and documentRangeFormattingParams = {
847 textDocument: TextDocumentIdentifier.t;
848 range: range;
849 options: DocumentFormatting.formattingOptions;
853 (** Document On Type Formatting req., method="textDocument/onTypeFormatting" *)
854 module DocumentOnTypeFormatting = struct
855 type params = documentOnTypeFormattingParams
857 and result = TextEdit.t list
859 and documentOnTypeFormattingParams = {
860 textDocument: TextDocumentIdentifier.t;
861 position: position;
862 ch: string;
863 options: DocumentFormatting.formattingOptions;
867 module SignatureHelp = struct
868 type params = TextDocumentPositionParams.t
870 and result = t option
872 and t = {
873 signatures: signature_information list;
874 activeSignature: int;
875 activeParameter: int;
878 and signature_information = {
879 siginfo_label: string;
880 siginfo_documentation: string option;
881 parameters: parameter_information list;
884 and parameter_information = {
885 parinfo_label: string;
886 parinfo_documentation: string option;
890 (** Auto close tag request, method="flow/autoCloseJsx"
891 This is a non-standard LSP extension. *)
892 module AutoCloseJsx = struct
893 type params = TextDocumentPositionParams.t
895 and result = string option
898 (* Workspace Rename request, method="textDocument/rename" *)
899 module Rename = struct
900 type params = renameParams
902 and result = WorkspaceEdit.t
904 and renameParams = {
905 textDocument: TextDocumentIdentifier.t;
906 position: position;
907 newName: string;
911 (** Code Lens request, method="textDocument/codeLens" *)
912 module DocumentCodeLens = struct
913 type params = codelensParams
915 and result = CodeLens.t list
917 and codelensParams = { textDocument: TextDocumentIdentifier.t }
920 module LogMessage = struct
921 type params = logMessageParams
923 and logMessageParams = {
924 type_: MessageType.t;
925 message: string;
929 module ShowMessage = struct
930 type params = showMessageParams
932 and showMessageParams = {
933 type_: MessageType.t;
934 message: string;
938 module ShowMessageRequest = struct
939 type t =
940 | Present of { id: lsp_id }
941 | Absent
943 and params = showMessageRequestParams
945 and result = messageActionItem option
947 and showMessageRequestParams = {
948 type_: MessageType.t;
949 message: string;
950 actions: messageActionItem list;
953 and messageActionItem = { title: string }
956 module ShowStatusFB = struct
957 type params = showStatusParams
959 and result = unit
961 (** the showStatus LSP request will be handled by our VSCode extension.
962 It's a facebook-specific extension to the LSP spec. How it's rendered
963 is currently [shortMessage] in the status-bar, and "[progress]/[total] [message]"
964 in the tooltip. The [telemetry] field isn't displayed to the user, but might
965 be useful to someone debugging an LSP transcript. *)
966 and showStatusParams = {
967 request: showStatusRequestParams;
968 progress: int option;
969 total: int option;
970 shortMessage: string option;
971 telemetry: Hh_json.json option;
974 and showStatusRequestParams = {
975 type_: MessageType.t;
976 message: string;
980 module ConnectionStatusFB = struct
981 type params = connectionStatusParams
983 and connectionStatusParams = { isConnected: bool }
986 type lsp_registration_options =
987 | DidChangeWatchedFilesRegistrationOptions of
988 DidChangeWatchedFiles.registerOptions
990 module RegisterCapability = struct
991 type params = { registrations: registration list }
993 and registration = {
994 id: string;
995 method_: string;
996 registerOptions: lsp_registration_options;
999 let make_registration (registerOptions : lsp_registration_options) :
1000 registration =
1001 let (id, method_) =
1002 match registerOptions with
1003 | DidChangeWatchedFilesRegistrationOptions _ ->
1004 ("did-change-watched-files", "workspace/didChangeWatchedFiles")
1006 { id; method_; registerOptions }
1010 * Here are gathered-up ADTs for all the messages we handle
1013 type lsp_request =
1014 | InitializeRequest of Initialize.params
1015 | RegisterCapabilityRequest of RegisterCapability.params
1016 | ShutdownRequest
1017 | CodeLensResolveRequest of CodeLensResolve.params
1018 | HoverRequest of Hover.params
1019 | DefinitionRequest of Definition.params
1020 | TypeDefinitionRequest of TypeDefinition.params
1021 | ImplementationRequest of Implementation.params
1022 | CodeActionRequest of CodeActionRequest.params
1023 | CodeActionResolveRequest of CodeActionResolveRequest.params
1024 | CompletionRequest of Completion.params
1025 | CompletionItemResolveRequest of CompletionItemResolve.params
1026 | WorkspaceSymbolRequest of WorkspaceSymbol.params
1027 | DocumentSymbolRequest of DocumentSymbol.params
1028 | FindReferencesRequest of FindReferences.params
1029 | PrepareCallHierarchyRequest of PrepareCallHierarchy.params
1030 | CallHierarchyIncomingCallsRequest of CallHierarchyIncomingCalls.params
1031 | CallHierarchyOutgoingCallsRequest of CallHierarchyOutgoingCalls.params
1032 | DocumentHighlightRequest of DocumentHighlight.params
1033 | DocumentFormattingRequest of DocumentFormatting.params
1034 | DocumentRangeFormattingRequest of DocumentRangeFormatting.params
1035 | DocumentOnTypeFormattingRequest of DocumentOnTypeFormatting.params
1036 | ShowMessageRequestRequest of ShowMessageRequest.params
1037 | ShowStatusRequestFB of ShowStatusFB.params
1038 | RageRequestFB
1039 | RenameRequest of Rename.params
1040 | DocumentCodeLensRequest of DocumentCodeLens.params
1041 | SignatureHelpRequest of SignatureHelp.params
1042 | AutoCloseRequest of AutoCloseJsx.params
1043 | HackTestStartServerRequestFB
1044 | HackTestStopServerRequestFB
1045 | HackTestShutdownServerlessRequestFB
1046 | WillSaveWaitUntilRequest of WillSaveWaitUntil.params
1047 | UnknownRequest of string * Hh_json.json option
1049 type lsp_result =
1050 | InitializeResult of Initialize.result
1051 | ShutdownResult
1052 | CodeLensResolveResult of CodeLensResolve.result
1053 | HoverResult of Hover.result
1054 | DefinitionResult of Definition.result
1055 | TypeDefinitionResult of TypeDefinition.result
1056 | ImplementationResult of Implementation.result
1057 | CodeActionResult of CodeAction.result * CodeActionRequest.params
1058 | CodeActionResolveResult of CodeActionResolve.result
1059 | CompletionResult of Completion.result
1060 | CompletionItemResolveResult of CompletionItemResolve.result
1061 | WorkspaceSymbolResult of WorkspaceSymbol.result
1062 | DocumentSymbolResult of DocumentSymbol.result
1063 | FindReferencesResult of FindReferences.result
1064 | PrepareCallHierarchyResult of PrepareCallHierarchy.result
1065 | CallHierarchyIncomingCallsResult of CallHierarchyIncomingCalls.result
1066 | CallHierarchyOutgoingCallsResult of CallHierarchyOutgoingCalls.result
1067 | DocumentHighlightResult of DocumentHighlight.result
1068 | DocumentFormattingResult of DocumentFormatting.result
1069 | DocumentRangeFormattingResult of DocumentRangeFormatting.result
1070 | DocumentOnTypeFormattingResult of DocumentOnTypeFormatting.result
1071 | ShowMessageRequestResult of ShowMessageRequest.result
1072 | ShowStatusResultFB of ShowStatusFB.result
1073 | RageResultFB of RageFB.result
1074 | RenameResult of Rename.result
1075 | DocumentCodeLensResult of DocumentCodeLens.result
1076 | SignatureHelpResult of SignatureHelp.result
1077 | AutoCloseResult of AutoCloseJsx.result
1078 | HackTestStartServerResultFB
1079 | HackTestStopServerResultFB
1080 | HackTestShutdownServerlessResultFB
1081 | RegisterCapabilityRequestResult
1082 | WillSaveWaitUntilResult of WillSaveWaitUntil.result
1083 | ErrorResult of Error.t
1085 type lsp_notification =
1086 | ExitNotification
1087 | CancelRequestNotification of CancelRequest.params
1088 | PublishDiagnosticsNotification of PublishDiagnostics.params
1089 | DidOpenNotification of DidOpen.params
1090 | DidCloseNotification of DidClose.params
1091 | DidSaveNotification of DidSave.params
1092 | DidChangeNotification of DidChange.params
1093 | DidChangeWatchedFilesNotification of DidChangeWatchedFiles.params
1094 | LogMessageNotification of LogMessage.params
1095 | TelemetryNotification of LogMessage.params * (string * Hh_json.json) list
1096 | ShowMessageNotification of ShowMessage.params
1097 | ConnectionStatusNotificationFB of ConnectionStatusFB.params
1098 | InitializedNotification
1099 | FindReferencesPartialResultNotification of
1100 partial_result_token * FindReferences.result
1101 | SetTraceNotification of SetTraceNotification.params
1102 | LogTraceNotification
1103 | UnknownNotification of string * Hh_json.json option
1105 type lsp_message =
1106 | RequestMessage of lsp_id * lsp_request
1107 | ResponseMessage of lsp_id * lsp_result
1108 | NotificationMessage of lsp_notification
1110 type 'a lsp_handler = 'a lsp_result_handler * 'a lsp_error_handler
1112 and 'a lsp_error_handler = Error.t * string -> 'a -> 'a
1114 and 'a lsp_result_handler =
1115 | ShowMessageHandler of (ShowMessageRequest.result -> 'a -> 'a)
1116 | ShowStatusHandler of (ShowStatusFB.result -> 'a -> 'a)
1118 module IdKey = struct
1119 type t = lsp_id
1121 let compare (x : t) (y : t) =
1122 match (x, y) with
1123 | (NumberId x, NumberId y) -> x - y
1124 | (NumberId _, StringId _) -> -1
1125 | (StringId x, StringId y) -> String.compare x y
1126 | (StringId _, NumberId _) -> 1
1129 module IdSet = Stdlib.Set.Make (IdKey)
1130 module IdMap = WrappedMap.Make (IdKey)
1132 module UriKey = struct
1133 type t = DocumentUri.t
1135 let compare (DocumentUri.Uri x) (DocumentUri.Uri y) = String.compare x y
1138 module UriSet = Stdlib.Set.Make (UriKey)
1139 module UriMap = WrappedMap.Make (UriKey)
1141 let lsp_result_to_log_string = function
1142 | InitializeResult _ -> "InitializeResult"
1143 | ShutdownResult -> "ShutdownResult"
1144 | CodeLensResolveResult _ -> "CodeLensResolveResult"
1145 | HoverResult _ -> "HoverResult"
1146 | DefinitionResult _ -> "DefinitionResult"
1147 | TypeDefinitionResult _ -> "TypeDefinitionResult"
1148 | ImplementationResult _ -> "ImplementationResult"
1149 | CodeActionResult _ -> "CodeActionResult"
1150 | CodeActionResolveResult _ -> "CodeActionResolveResult"
1151 | CompletionResult _ -> "CompletionResult"
1152 | CompletionItemResolveResult _ -> "CompletionItemResolveResult"
1153 | WorkspaceSymbolResult _ -> "WorkspaceSymbolResult"
1154 | DocumentSymbolResult _ -> "DocumentSymbolResult"
1155 | FindReferencesResult _ -> "FindReferencesResult"
1156 | PrepareCallHierarchyResult _ -> "PrepareCallHierarchyResult"
1157 | CallHierarchyIncomingCallsResult _ -> "CallHierarchyIncomingCallsResult"
1158 | CallHierarchyOutgoingCallsResult _ -> "CallHierarchyOutgoingCallsResult"
1159 | DocumentHighlightResult _ -> "DocumentHighlightResult"
1160 | DocumentFormattingResult _ -> "DocumentFormattingResult"
1161 | DocumentRangeFormattingResult _ -> "DocumentRangeFormattingResult"
1162 | DocumentOnTypeFormattingResult _ -> "DocumentOnTypeFormattingResult"
1163 | ShowMessageRequestResult _ -> "ShowMessageRequestResult"
1164 | ShowStatusResultFB _ -> "ShowStatusResultFB"
1165 | RageResultFB _ -> "RageResultFB"
1166 | RenameResult _ -> "RenameResult"
1167 | DocumentCodeLensResult _ -> "DocumentCodeLensResult"
1168 | SignatureHelpResult _ -> "SignatureHelpResult"
1169 | HackTestStartServerResultFB -> "HackTestStartServerResultFB"
1170 | HackTestStopServerResultFB -> "HackTestStopServerResultFB"
1171 | HackTestShutdownServerlessResultFB -> "HackTestShutdownServerlessResultFB"
1172 | RegisterCapabilityRequestResult -> "RegisterCapabilityRequestResult"
1173 | WillSaveWaitUntilResult _ -> "WillSaveWaitUntilResult"
1174 | ErrorResult _ -> "ErrorResult"
1175 | AutoCloseResult _ -> "AutoCloseResult"