Summary: Adds option `--summary-stats` to `infer report`. The formatting is not perfect yet but it gives what I want. Reviewed By: ngorogiannis Differential Revision: D15064162 fbshipit-source-id: 56c4b4929master
parent
109a587654
commit
4333d5f9cc
@ -0,0 +1,37 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) 2019-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
open! IStd
|
||||||
|
module StringMap = Map.Make (String)
|
||||||
|
|
||||||
|
type ('r, 'a) user = {f: 'f. string -> ('r -> 'f) -> 'a} [@@unboxed]
|
||||||
|
|
||||||
|
type 'r elt = E : {name: string; get: 'r -> 'a} -> 'r elt
|
||||||
|
|
||||||
|
type 'r t = 'r elt list
|
||||||
|
|
||||||
|
type 'r sub = S : ('r, 'f) Field.t * 'f t -> 'r sub
|
||||||
|
|
||||||
|
let make ?(subfields = []) (map_poly : _ Field.user -> _) =
|
||||||
|
let subfields =
|
||||||
|
List.fold subfields ~init:StringMap.empty ~f:(fun acc (S (field, elts)) ->
|
||||||
|
let name = Field.name field in
|
||||||
|
let prefix = name ^ "." in
|
||||||
|
let get = Field.get field in
|
||||||
|
let elts =
|
||||||
|
List.map elts ~f:(fun (E {name= subname; get= subget}) ->
|
||||||
|
E {name= prefix ^ subname; get= (fun r -> get r |> subget)} )
|
||||||
|
in
|
||||||
|
StringMap.add_exn acc ~key:name ~data:elts )
|
||||||
|
in
|
||||||
|
let f field =
|
||||||
|
let name = Field.name field in
|
||||||
|
StringMap.find subfields name |> Option.value ~default:[E {name; get= Field.get field}]
|
||||||
|
in
|
||||||
|
E {name= "ALL"; get= Fn.id} :: List.concat (map_poly {f})
|
||||||
|
|
||||||
|
|
||||||
|
let map elts {f} = List.map elts ~f:(fun (E {name; get}) -> f name get)
|
@ -0,0 +1,33 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) 2019-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
|
||||||
|
open! IStd
|
||||||
|
|
||||||
|
(** Datastructure for polymorphic getters of record fields *)
|
||||||
|
type 'r t
|
||||||
|
|
||||||
|
type 'r sub = S : ('r, 'f) Field.t * 'f t -> 'r sub
|
||||||
|
|
||||||
|
type ('r, 'a) user = {f: 'f. string -> ('r -> 'f) -> 'a} [@@unboxed]
|
||||||
|
|
||||||
|
val make : ?subfields:'r sub list -> ((_, 'r, 'r t) Field.user -> 'r t list) -> 'r t
|
||||||
|
(**
|
||||||
|
Pass [Fields.map_poly] generated by [@@deriving fields] for the record ['r] you are interested
|
||||||
|
in to get the polymorphic getters of the fields of ['r].
|
||||||
|
A dummy field "ALL" is added too.
|
||||||
|
|
||||||
|
Subfields appearing in [subfields] will be added too.
|
||||||
|
Each subfield is specified by [S (field, poly_fields)] where [field] is the corresponding
|
||||||
|
[Field.t] value (generated by [@@deriving fields]) and [poly_fields] is the result of this
|
||||||
|
function for the field record type.
|
||||||
|
*)
|
||||||
|
|
||||||
|
val map : 'r t -> ('r, 'a) user -> 'a list
|
||||||
|
(**
|
||||||
|
[map r f] maps each field of [r] with the function [f].
|
||||||
|
[f] is called with two arguments: the name and the getter of the field.
|
||||||
|
*)
|
Loading…
Reference in new issue