@@ -193,13 +193,69 @@ module CheckConfiguration = struct
193193 ()
194194end
195195
196+ let with_performance_tracking ~debug f =
197+ let timer = Timer. start () in
198+ let result = f () in
199+ let { Caml.Gc. minor_collections; major_collections; compactions; _ } = Caml.Gc. stat () in
200+ Statistics. performance
201+ ~name: " check"
202+ ~timer
203+ ~integers:
204+ [
205+ " gc_minor_collections" , minor_collections;
206+ " gc_major_collections" , major_collections;
207+ " gc_compactions" , compactions;
208+ ]
209+ ~normals: [" request kind" , " FullCheck" ]
210+ () ;
211+ if debug then
212+ Memory. report_statistics () ;
213+ result
214+
215+
216+ let do_check configuration =
217+ Scheduler. with_scheduler ~configuration ~f: (fun scheduler ->
218+ with_performance_tracking ~debug: configuration.debug (fun () ->
219+ let { Service.Check. errors; environment } =
220+ Service.Check. check
221+ ~scheduler
222+ ~configuration
223+ ~call_graph_builder: (module Analysis.Callgraph. DefaultBuilder )
224+ in
225+ ( errors,
226+ Analysis.TypeEnvironment. ast_environment environment
227+ |> Analysis.AstEnvironment. read_only )))
228+
229+
230+ let compute_errors ~configuration ~build_system () =
231+ let errors, ast_environment = do_check configuration in
232+ List. map
233+ errors
234+ ~f: (Newserver.RequestHandler. instantiate_error ~build_system ~configuration ~ast_environment )
235+
236+
237+ let print_errors errors =
238+ Yojson.Safe. to_string
239+ (`Assoc
240+ [
241+ ( " errors" ,
242+ `List
243+ (List. map ~f: (fun error -> Analysis.AnalysisError.Instantiated. to_yojson error) errors)
244+ );
245+ ])
246+ |> Log. print " %s"
247+
248+
196249let run_check check_configuration =
197250 let { CheckConfiguration. source_paths; _ } = check_configuration in
198- Newserver.BuildSystem. with_build_system source_paths ~f: (fun _build_system ->
199- let _analysis_configuration =
200- CheckConfiguration. analysis_configuration_of check_configuration
251+ Newserver.BuildSystem. with_build_system source_paths ~f: (fun build_system ->
252+ let errors =
253+ compute_errors
254+ ~configuration: (CheckConfiguration. analysis_configuration_of check_configuration)
255+ ~build_system
256+ ()
201257 in
202- Log. warning " Coming soon... " ;
258+ print_errors errors ;
203259 Lwt. return 0 )
204260
205261
0 commit comments