Remove ServerDfind
[hiphop-php.git] / hphp / hack / src / server / serverRpc.ml
blob707854fbee7873766ef87e546b811af7f7525622
1 (**
2 * Copyright (c) 2015, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the "hack" directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
9 *)
11 open Core
12 open ServerEnv
14 (* The following datatypes can be interpreted as follows:
15 * MESSAGE_TAG : Argument type (sent from client to server) -> return type t *)
16 type _ t =
17 | STATUS : Pos.absolute Errors.error_ list t
18 | INFER_TYPE : ServerUtils.file_input * int * int -> ServerInferType.result t
19 | COVERAGE_LEVELS : ServerUtils.file_input -> ServerColorFile.result t
20 | AUTOCOMPLETE : string -> AutocompleteService.result t
21 | IDENTIFY_FUNCTION : string * int * int -> string t
22 | OUTLINE : string -> (Pos.absolute * string * string) list t
23 | METHOD_JUMP : (string * bool) -> MethodJumps.result list t
24 | FIND_REFS : ServerFindRefs.action -> ServerFindRefs.result t
25 | REFACTOR : ServerRefactor.action -> ServerRefactor.patch list t
26 | DUMP_SYMBOL_INFO : string list -> SymbolInfoService.result list t
27 | ARGUMENT_INFO : string * int * int -> ServerArgumentInfo.result t
28 | PROLOG : string t
29 | SEARCH : string * string -> ServerSearch.result t
30 | COVERAGE_COUNTS : string -> ServerCoverageMetric.result t
31 | LINT : string list -> ServerLint.result t
32 | LINT_ALL : int -> ServerLint.result t
33 | KILL : unit t
35 let handle : type a. genv -> env -> a t -> a =
36 fun genv env -> function
37 | STATUS ->
38 (* Logging can be pretty slow, so do it asynchronously and respond to
39 * the client first *)
40 ServerEnv.async begin fun () ->
41 HackEventLogger.check_response env.errorl;
42 end;
43 let el = ServerError.sort_errorl env.errorl in
44 List.map ~f:Errors.to_absolute el
45 | COVERAGE_LEVELS fn -> ServerColorFile.go env fn
46 | INFER_TYPE (fn, line, char) ->
47 ServerInferType.go env (fn, line, char)
48 | AUTOCOMPLETE content ->
49 ServerAutoComplete.auto_complete env.nenv content
50 | IDENTIFY_FUNCTION (content, line, char) ->
51 ServerIdentifyFunction.go content line char
52 | OUTLINE content ->
53 FileOutline.outline content
54 | METHOD_JUMP (class_, find_children) ->
55 MethodJumps.get_inheritance class_ find_children env genv
56 | FIND_REFS find_refs_action ->
57 ServerFindRefs.go find_refs_action genv env
58 | REFACTOR refactor_action -> ServerRefactor.go refactor_action genv env
59 | DUMP_SYMBOL_INFO file_list ->
60 SymbolInfoService.find_fun_calls genv.workers file_list env
61 | ARGUMENT_INFO (contents, line, col) ->
62 ServerArgumentInfo.go genv env contents line col
63 | PROLOG -> PrologMain.go genv env
64 | SEARCH (query, type_) -> ServerSearch.go query type_
65 | COVERAGE_COUNTS path -> ServerCoverageMetric.go path genv env
66 | LINT fnl -> ServerLint.go genv fnl
67 | LINT_ALL code -> ServerLint.lint_all genv code
68 | KILL -> ServerEnv.async (fun () -> ServerUtils.die_nicely genv)