7 type connection_response
=
10 type status_liveness
=
14 module Server_status
= struct
16 liveness
: status_liveness
;
17 has_unsaved_changes
: bool;
18 error_list
: Pos.absolute
Errors.error_ list
;
22 module Identify_symbol
= struct
23 type single_result
= (string SymbolOccurrence.t
) * (string SymbolDefinition.t
option)
24 type result
= single_result list
27 module Method_jumps
= struct
30 orig_pos
: Pos.absolute
;
32 dest_pos
: Pos.absolute
;
33 orig_p_name
: string; (* Used for methods to find their parent class *)
44 module Done_or_retry
= struct
45 (* This is an ugly hack to support following case:
46 * - client issues a command that requires full recheck. Server knows not to
47 * accept it until full check is completed .
48 * - while processing the command, it turns out that we need to recheck even
49 * more files for full check to be "good enough" for this command
50 * This can happen when combining prechecked files and find references.
51 * We could store the client with its command somwhere, and come back to it
52 * after this additional rechecking is done, but in practice this is ugly to
53 * implement in current atchitecture. What is easier to do instead, is to
54 * return a special "Retry" response to the client, which will cause it to
55 * re-issue the same request (which will once again not be accepted until full
56 * check is completed. Since command is the same, its second execution should
57 * not add even more files to recheck, hence a limit of only two attempts.
59 * In other words: the goal of this is to avoid implementing even more
60 * server-side client queing mechanisms, but re-use an existing "clients waiting
61 * for full check" queue. *)
62 exception Two_retries_in_a_row
68 (* Note: this is designed to work with calls that always will succeed on second try
69 * (the reason for retrying is a one time event that is resolved during first call).
70 * If this ends up throwing, it's a bug in hh_server. *)
71 let rec call ~
(f
:unit -> 'a t
) ~
(depth
:int) : 'a
=
72 if depth
= 2 then raise Two_retries_in_a_row
;
75 | Retry
-> call ~f ~depth
:(depth
+1)
77 (* Call the function returning Done_or_retry.t with at most one retry, expecting
78 * that this is enough to yield a non-Retry value, which is returned *)
79 let call ~
(f
:unit -> 'a t
) : 'a
= call ~f ~depth
:0
81 (* Helper function useful when mapping over results from functions that (in addition
82 * to Done_or_retry.t result) thread through some kind of environment. *)
85 ((env
, x
) : 'env
* 'a t
)
88 | Done x
-> env
, Done
(f x
)
92 module Find_refs
= struct
96 | Class_const
of string
101 | Member
of string * member
104 | LocalVar
of { filename
: Relative_path.t
; file_content
: string; line
: int; char
: int }
106 type server_result
= (string * Pos.t
) list
107 type result
= (string * Pos.absolute
) list
108 type ide_result
= (string * Pos.absolute list
) option
110 type server_result_or_retry
= server_result
Done_or_retry.t
111 type result_or_retry
= result
Done_or_retry.t
112 type ide_result_or_retry
= ide_result
Done_or_retry.t
115 module Refactor
= struct
116 type ide_result
= ((ServerRefactorTypes.patch list
), string) result
117 type result
= ServerRefactorTypes.patch list
119 type ide_result_or_retry
= ide_result
Done_or_retry.t
120 type result_or_retry
= result
Done_or_retry.t
123 module Symbol_type
= struct
131 module Symbol_info_service
= struct
137 type symbol_fun_call
= {
145 fun_calls
: symbol_fun_call list
;
146 symbol_types
: Symbol_type.t list
;
150 module Outline
= struct
151 type outline
= string SymbolDefinition.t list
154 module Infer_return_type
= struct
157 | Method
of string * string
159 type result
= (string, string) Pervasives.result
162 module Ide_refactor_type
= struct
173 | FileContent
of string
176 | LabelledFileName
of string
177 | LabelledFileContent
of { filename
: string; content
: string }
179 type lint_stdin_input
= { filename
: string; contents
: string }
181 type cst_search_input
= {
184 files_to_search
: string list
option; (* if None, search all files *)
187 (* The following datatypes can be interpreted as follows:
188 * MESSAGE_TAG : Argument type (sent from client to server) -> return type t *)
190 | STATUS
: bool -> Server_status.t t
191 | STATUS_SINGLE
: file_input
-> Pos.absolute
Errors.error_ list t
192 | INFER_TYPE
: file_input
* int * int * bool ->
193 InferAtPosService.result t
194 | INFER_TYPE_BATCH
: (string * int * int * (int * int) option) list
* bool -> string list t
195 | TYPED_AST
: string -> string t
196 | IDE_HOVER
: file_input
* int * int ->
197 HoverService.result t
198 | DOCBLOCK_AT
: (string * int * int * string option) -> DocblockService.result t
199 | IDE_SIGNATURE_HELP
: (file_input
* int * int) -> Lsp.SignatureHelp.result t
200 | COVERAGE_LEVELS
: file_input
-> Coverage_level.result t
201 | AUTOCOMPLETE
: string -> AutocompleteTypes.result t
202 | IDENTIFY_FUNCTION
: file_input
* int * int ->
203 Identify_symbol.result t
204 | METHOD_JUMP
: (string * Method_jumps.filter
* bool) ->
205 Method_jumps.result list t
206 | METHOD_JUMP_BATCH
: (string list
* Method_jumps.filter
) ->
207 Method_jumps.result list t
208 | FIND_REFS
: Find_refs.action
-> Find_refs.result_or_retry t
209 | IDE_FIND_REFS
: labelled_file
* int * int * bool ->
210 Find_refs.ide_result_or_retry t
211 | IDE_HIGHLIGHT_REFS
: file_input
* int * int ->
212 ServerHighlightRefsTypes.result t
213 | REFACTOR
: ServerRefactorTypes.action
-> Refactor.result_or_retry t
214 | IDE_REFACTOR
: Ide_refactor_type.t
-> Refactor.ide_result_or_retry t
215 | DUMP_SYMBOL_INFO
: string list
-> Symbol_info_service.result t
216 | REMOVE_DEAD_FIXMES
: int list
-> [`Ok
of ServerRefactorTypes.patch list
| `Error
of string] t
217 | IN_MEMORY_DEP_TABLE_SIZE
: ((int, string) Pervasives.result
) t
218 | SAVE_STATE
: (string * bool * bool) -> ((int, string) Pervasives.result
) t
219 | SEARCH
: string * string -> HackSearchService.result t
220 | COVERAGE_COUNTS
: string -> ServerCoverageMetricTypes.result t
221 | LINT
: string list
-> ServerLintTypes.result t
222 | LINT_STDIN
: lint_stdin_input
-> ServerLintTypes.result t
223 | LINT_ALL
: int -> ServerLintTypes.result t
224 | CREATE_CHECKPOINT
: string -> unit t
225 | RETRIEVE_CHECKPOINT
: string -> string list
option t
226 | DELETE_CHECKPOINT
: string -> bool t
228 | FORMAT
: ServerFormatTypes.action
-> ServerFormatTypes.result t
229 | AI_QUERY
: string -> string t
230 | DUMP_FULL_FIDELITY_PARSE
: string -> string t
231 | OPEN_FILE
: string * string -> unit t
232 | CLOSE_FILE
: string -> unit t
233 | EDIT_FILE
: string * (text_edit list
) -> unit t
234 | IDE_AUTOCOMPLETE
: string * position
* bool * bool -> AutocompleteTypes.ide_result t
235 | IDE_FFP_AUTOCOMPLETE
: string * position
-> AutocompleteTypes.ide_result t
236 | DISCONNECT
: unit t
237 | SUBSCRIBE_DIAGNOSTIC
: int -> unit t
238 | UNSUBSCRIBE_DIAGNOSTIC
: int -> unit t
239 | OUTLINE
: string -> Outline.outline t
241 | INFER_RETURN_TYPE
: Infer_return_type.t
->
242 Infer_return_type.result t
243 | RAGE
: ServerRageTypes.result t
244 | DYNAMIC_VIEW
: bool -> unit t
245 | CST_SEARCH
: cst_search_input
-> (Hh_json.json
, string) result t
246 | NO_PRECHECKED_FILES
: unit t
247 | GEN_HOT_CLASSES
: int -> string t
248 | FUN_DEPS_BATCH
: (string * int * int) list
* bool -> string list t
251 let is_disconnect_rpc : type a
. a t
-> bool = function
256 let is_critical_rpc : type a
. a t
-> bool = function
257 (* An exception during any critical rpc should shutdown the persistent connection. *)
258 (* The critical ones are those that affect the state. *)
260 | CREATE_CHECKPOINT _
-> true
261 | DELETE_CHECKPOINT _
-> true
262 | OPEN_FILE _
-> true
263 | CLOSE_FILE _
-> true
264 | EDIT_FILE _
-> true
265 | SUBSCRIBE_DIAGNOSTIC _
-> true
266 | UNSUBSCRIBE_DIAGNOSTIC _
-> true
278 | BUILD
of ServerBuild.build_opts
281 | DIAGNOSTIC
of int * (Pos.absolute
Errors.error_ list
) SMap.t
282 | BUSY_STATUS
of busy_status
283 | NEW_CLIENT_CONNECTED
284 | FATAL_EXCEPTION
of Marshal_tools.remote_exception_data
285 | NONFATAL_EXCEPTION
of Marshal_tools.remote_exception_data
288 | Needs_local_typecheck
289 | Doing_local_typecheck
290 | Done_local_typecheck
291 | Doing_global_typecheck
of bool (* interruptible? *)
292 | Done_global_typecheck
of {is_truncated
: bool; shown
: int; total
: int;}
294 type 'a message_type
=
295 | Push
of push
(* Only sent to persistent connections. *)
296 | Response
of 'a
* float (* records the time at which hh_server started handling *)
298 (* Hello is the first message sent after handoff. It's used for both *)
299 (* persistent and non-persistent connections. *)
301 (* Pings can be sent to non-persistent connection after Hello and before
302 * sending RPC response. *)
304 (** Timeout on reading the command from the client - client probably frozen. *)
305 exception Read_command_timeout