/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
- (**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the "hack" directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- *)
- open Core
- open Reordered_argument_collections
- (*****************************************************************************)
- (* The "static" environment, initialized first and then doesn't change *)
- (*****************************************************************************)
- type genv = {
- options : ServerArgs.options;
- config : ServerConfig.t;
- local_config : ServerLocalConfig.t;
- workers : Worker.t list option;
- (* Returns the list of files under .hhconfig, subject to a filter *)
- indexer : (string -> bool) -> string MultiWorker.nextlist;
- (* Each time this is called, it should return the files that have changed
- * since the last invocation *)
- notifier : unit -> SSet.t;
- (* If daemons are spawned as part of the init process, wait for them here *)
- wait_until_ready : unit -> unit;
- mutable debug_channels : (Timeout.in_channel * out_channel) option;
- }
- (*****************************************************************************)
- (* The environment constantly maintained by the server *)
- (*****************************************************************************)
- (* In addition to this environment, many functions are storing and
- * updating ASTs, NASTs, and types in a shared space
- * (see respectively Parser_heap, Naming_heap, Typing_env).
- * The Ast.id are keys to index this shared space.
- *)
- type env = {
- files_info : FileInfo.t Relative_path.Map.t;
- tcopt : TypecheckerOptions.t;
- errorl : Errors.t;
- failed_parsing : Relative_path.Set.t;
- failed_decl : Relative_path.Set.t;
- failed_check : Relative_path.Set.t;
- }
- let file_filter f =
- (FindUtils.is_php f && not (FilesToIgnore.should_ignore f))
- || FindUtils.is_js f
- let list_files env oc =
- let acc = List.fold_right
- ~f:begin fun error acc ->
- let pos = Errors.get_pos error in
- Relative_path.Set.add acc (Pos.filename pos)
- end
- ~init:Relative_path.Set.empty
- (Errors.get_error_list env.errorl) in
- Relative_path.Set.iter acc (fun s ->
- Printf.fprintf oc "%s\n" (Relative_path.to_absolute s));
- flush oc