2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
12 open ServerCommandTypes.Symbol_type
14 module Result_set
= Set.Make
(struct
15 type t
= ServerCommandTypes.Symbol_type.t
16 let compare a b
= Pos.compare a
.pos b
.pos
19 let visitor = object (self
)
20 inherit [_
] Tast_visitor.reduce
as super
22 method zero
= Result_set.empty
23 method plus
= Result_set.union
25 method! on_expr env
(((pos
, ty
), expr_
) as expr
) =
29 | Tast.Dollardollar
(_
, id
) ->
30 Result_set.singleton
{
31 pos
= Pos.to_relative_string pos
;
32 type_
= Tast_env.print_ty env ty
;
33 ident_
= Local_id.to_int id
37 self#plus
acc @@ super#on_expr env expr
39 method! on_fun_param env param
=
41 let (pos
, ty
) = param
.Tast.param_annotation
in
42 Result_set.singleton
{
43 pos
= Pos.to_relative_string pos
;
44 type_
= Tast_env.print_ty env ty
;
45 ident_
= Local_id.to_int
(Local_id.make_unscoped param
.Tast.param_name
);
48 self#plus
acc @@ super#on_fun_param env param
51 let generate_types tasts
=
53 |> List.map ~f
:visitor#go
54 |> List.fold ~init
:Result_set.empty ~f
:Result_set.union
55 |> Result_set.elements