PageRenderTime 28ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/hack/src/server/serverEnv.ml

https://gitlab.com/iranjith4/hhvm
OCaml | 65 lines | 34 code | 7 blank | 24 comment | 2 complexity | f00bb0cba756f6c40f9fe40e78f73a9f MD5 | raw file
  1. (**
  2. * Copyright (c) 2015, Facebook, Inc.
  3. * All rights reserved.
  4. *
  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.
  8. *
  9. *)
  10. open Core
  11. open Reordered_argument_collections
  12. (*****************************************************************************)
  13. (* The "static" environment, initialized first and then doesn't change *)
  14. (*****************************************************************************)
  15. type genv = {
  16. options : ServerArgs.options;
  17. config : ServerConfig.t;
  18. local_config : ServerLocalConfig.t;
  19. workers : Worker.t list option;
  20. (* Returns the list of files under .hhconfig, subject to a filter *)
  21. indexer : (string -> bool) -> string MultiWorker.nextlist;
  22. (* Each time this is called, it should return the files that have changed
  23. * since the last invocation *)
  24. notifier : unit -> SSet.t;
  25. (* If daemons are spawned as part of the init process, wait for them here *)
  26. wait_until_ready : unit -> unit;
  27. mutable debug_channels : (Timeout.in_channel * out_channel) option;
  28. }
  29. (*****************************************************************************)
  30. (* The environment constantly maintained by the server *)
  31. (*****************************************************************************)
  32. (* In addition to this environment, many functions are storing and
  33. * updating ASTs, NASTs, and types in a shared space
  34. * (see respectively Parser_heap, Naming_heap, Typing_env).
  35. * The Ast.id are keys to index this shared space.
  36. *)
  37. type env = {
  38. files_info : FileInfo.t Relative_path.Map.t;
  39. tcopt : TypecheckerOptions.t;
  40. errorl : Errors.t;
  41. failed_parsing : Relative_path.Set.t;
  42. failed_decl : Relative_path.Set.t;
  43. failed_check : Relative_path.Set.t;
  44. }
  45. let file_filter f =
  46. (FindUtils.is_php f && not (FilesToIgnore.should_ignore f))
  47. || FindUtils.is_js f
  48. let list_files env oc =
  49. let acc = List.fold_right
  50. ~f:begin fun error acc ->
  51. let pos = Errors.get_pos error in
  52. Relative_path.Set.add acc (Pos.filename pos)
  53. end
  54. ~init:Relative_path.Set.empty
  55. (Errors.get_error_list env.errorl) in
  56. Relative_path.Set.iter acc (fun s ->
  57. Printf.fprintf oc "%s\n" (Relative_path.to_absolute s));
  58. flush oc