2 * Copyright (c) Facebook, Inc. and its affiliates.
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the "hack" directory of this source tree.
11 let process_parse_result
18 (acc
, errorl
, error_files
)
20 (errorl'
, (ast
, decls
))
22 let start_parse_time = start_time
in
23 let start_process_time = Unix.gettimeofday
() in
24 let { Parser_return.file_mode
; comments
= _
; ast
; content
} = ast
in
27 Relative_path.(is_hhi
(Relative_path.prefix fn
))
28 && ParserOptions.deregister_php_stdlib popt
30 Nast.deregister_ignored_attributes
ast
34 let bytes = String.length content
in
37 File_provider.Ide
content
39 File_provider.Disk
content
41 if Option.is_some file_mode
then (
42 (* If this file was parsed from a tmp directory,
43 save it to the main directory instead *)
45 match Relative_path.prefix
fn with
46 | Relative_path.Tmp
-> Relative_path.to_root
fn
49 if quick
then File_provider.provide_file_hint
fn content;
56 Ast_provider.provide_ast_hint
fn ast mode;
58 Direct_decl_utils.cache_decls ctx
fn decls
.Direct_decl_utils.pfh_decls
;
59 let defs = Direct_decl_parser.decls_to_fileinfo
fn decls
in
60 let acc = Relative_path.Map.add
acc ~key
:fn ~data
:defs in
61 let errorl = Errors.merge
errorl'
errorl in
63 if Errors.is_empty
errorl'
then
66 Relative_path.Set.add
error_files fn
70 "[%dk, %.0f+%.0fms] %s - %s"
72 ((start_process_time -. start_parse_time) *. 1000.0)
73 ((Unix.gettimeofday
() -. start_process_time) *. 1000.0)
74 (Relative_path.suffix
fn)
75 (FileInfo.to_string
defs);
76 (acc, errorl, error_files)
78 File_provider.provide_file_hint
fn content;
79 (* we also now keep in the file_info regular php files
80 * as we need at least their names in hack build
82 let acc = Relative_path.Map.add
acc ~key
:fn ~data
:FileInfo.empty_t
in
83 (acc, errorl, error_files)
86 let parse ctx ~quick ~show_all_errors ~trace ~cache_decls popt
acc fn =
87 if not
@@ FindUtils.path_filter
fn then
90 let start_time = Unix.gettimeofday
() in
92 Errors.do_with_context
fn Errors.Parsing
@@ fun () ->
93 Full_fidelity_ast.ast_and_decls_from_file ~quick ~show_all_errors popt
fn
106 let merge_parse (acc1
, status1
, files1
) (acc2
, status2
, files2
) =
107 ( Relative_path.Map.union acc1 acc2
,
108 Errors.merge status1 status2
,
109 Relative_path.Set.union files1 files2
)
112 (ctx
: Provider_context.t
)
114 ?
(show_all_errors
= false)
115 (workers
: MultiWorker.worker list
option)
116 ~
(get_next
: Relative_path.t list
MultiWorker.Hh_bucket.next
)
117 (popt
: ParserOptions.t
)
119 ~
(cache_decls
: bool)
120 ~
(worker_call
: MultiWorker.call_wrapper
) :
121 FileInfo.t
Relative_path.Map.t
* Errors.t
* Relative_path.Set.t
=
122 worker_call
.MultiWorker.f
127 ~f
:(parse ctx ~quick ~show_all_errors ~trace ~cache_decls popt
))
128 ~neutral
:(Relative_path.Map.empty
, Errors.empty
, Relative_path.Set.empty
)