diff --git a/src/commands/config/flowConfig.ml b/src/commands/config/flowConfig.ml index d339573c90d..0d6709b1bc5 100644 --- a/src/commands/config/flowConfig.ml +++ b/src/commands/config/flowConfig.ml @@ -391,7 +391,11 @@ module Opts = struct let autocomplete_mode_parser = enum - [("typed_ast", Options.Ac_typed_ast); ("on_demand", Options.Ac_on_demand_typing)] + [ + ("typed_ast", Options.Ac_typed_ast); + ("on_demand", Options.Ac_on_demand_typing); + ("both", Options.Ac_both); + ] (fun opts v -> Ok { opts with autocomplete_mode = Some v }) let casting_syntax_parser = diff --git a/src/common/options.ml b/src/common/options.ml index 2311a198546..c86d2f4366c 100644 --- a/src/common/options.ml +++ b/src/common/options.ml @@ -38,6 +38,7 @@ type react_rules = type autocomplete_mode = | Ac_typed_ast | Ac_on_demand_typing + | Ac_both (* for comparison purposes *) type format = { opt_bracket_spacing: bool; diff --git a/src/server/command_handler/commandHandler.ml b/src/server/command_handler/commandHandler.ml index 97a6553712d..f78f84e5d47 100644 --- a/src/server/command_handler/commandHandler.ml +++ b/src/server/command_handler/commandHandler.ml @@ -380,10 +380,15 @@ let autocomplete in autocomplete_get_results cx (Typed_ast_utils.ALoc_ast aloc_ast) in - let (token_opt, ac_loc, ac_type_string, results_res) = + let ((token_opt, ac_loc, ac_type_string, results_res), initial_json_props) = match Options.autocomplete_mode options with - | Options.Ac_typed_ast -> autocomplete_fully_type_and_get_results () - | Options.Ac_on_demand_typing -> autocomplete_on_demand_get_results () + | Options.Ac_typed_ast -> (autocomplete_fully_type_and_get_results (), initial_json_props) + | Options.Ac_on_demand_typing -> (autocomplete_on_demand_get_results (), initial_json_props) + | Options.Ac_both -> + let (_, _, _, r1) = autocomplete_on_demand_get_results () in + let ((_, _, _, r2) as result) = autocomplete_fully_type_and_get_results () in + let equal = AutocompleteService_js.equal_autocomplete_service_result r1 r2 in + (result, ("on_demand_compliance", Hh_json.JSON_Bool equal) :: initial_json_props) in (* Make sure hooks are unset *after* we've gotten the results to account for * on-demand type checking. *)