diff --git a/src/codemods/utils/codemod_annotator.ml b/src/codemods/utils/codemod_annotator.ml index 2bfdd6614fe..e980e0b53bc 100644 --- a/src/codemods/utils/codemod_annotator.ml +++ b/src/codemods/utils/codemod_annotator.ml @@ -175,7 +175,7 @@ module Make (Extra : BASE_STATS) = struct Hardcoded_Ty_Fixes.run ~cx ~loc_of_aloc:(Parsing_heaps.Reader_dispatcher.loc_of_aloc ~reader) - ~get_ast:(Parsing_heaps.Reader_dispatcher.get_ast ~reader) + ~get_ast_from_shared_mem:(Parsing_heaps.Reader_dispatcher.get_ast ~reader) ~file_sig ~typed_ast ~lint_severities @@ -218,7 +218,7 @@ module Make (Extra : BASE_STATS) = struct Hardcoded_Ty_Fixes.run ~cx ~loc_of_aloc:(Parsing_heaps.Reader_dispatcher.loc_of_aloc ~reader) - ~get_ast:(Parsing_heaps.Reader_dispatcher.get_ast ~reader) + ~get_ast_from_shared_mem:(Parsing_heaps.Reader_dispatcher.get_ast ~reader) ~file_sig ~typed_ast ~lint_severities diff --git a/src/flow_dot_js.ml b/src/flow_dot_js.ml index 6235dc75438..a00218b3f73 100644 --- a/src/flow_dot_js.ml +++ b/src/flow_dot_js.ml @@ -384,7 +384,7 @@ let autocomplete filename content line col js_config_object : ~layout_options:Js_layout_generator.default_opts ~haste_module_system:false ~loc_of_aloc - ~get_ast:(fun _ -> None) + ~get_ast_from_shared_mem:(fun _ -> None) ~get_haste_name:(fun _ -> None) ~get_package_info:(fun _ -> None) ~is_package_file:(fun _ -> false) diff --git a/src/server/command_handler/commandHandler.ml b/src/server/command_handler/commandHandler.ml index ec0ed53e033..19b2e2e7874 100644 --- a/src/server/command_handler/commandHandler.ml +++ b/src/server/command_handler/commandHandler.ml @@ -389,7 +389,7 @@ let autocomplete ~layout_options:(Code_action_utils.layout_options options) ~haste_module_system:Options.(module_system options = Haste) ~loc_of_aloc:(Parsing_heaps.Reader.loc_of_aloc ~reader) - ~get_ast:(Parsing_heaps.Reader.get_ast ~reader) + ~get_ast_from_shared_mem:(Parsing_heaps.Reader.get_ast ~reader) ~get_haste_name:(get_haste_name ~reader) ~get_package_info:(Parsing_heaps.Reader.get_package_info ~reader) ~is_package_file:(is_package_file ~reader) @@ -707,7 +707,7 @@ let infer_type | Ok [getdef_loc] -> Find_documentation.jsdoc_of_getdef_loc ~ast - ~get_ast:(Parsing_heaps.Reader.get_ast ~reader) + ~get_ast_from_shared_mem:(Parsing_heaps.Reader.get_ast ~reader) getdef_loc |> Base.Option.bind ~f:Find_documentation.documentation_of_jsdoc | _ -> None @@ -748,7 +748,7 @@ let insert_type ~env ~profiling ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_input @@ -765,7 +765,7 @@ let insert_type ~env ~profiling ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_key @@ -776,7 +776,14 @@ let insert_type ~ambiguity_strategy let autofix_exports - ~options ~env ~profiling ~loc_of_aloc ~get_ast ~get_haste_name ~get_type_sig ~input = + ~options + ~env + ~profiling + ~loc_of_aloc + ~get_ast_from_shared_mem + ~get_haste_name + ~get_type_sig + ~input = let file_key = file_key_of_file_input ~options ~env input in File_input.content_of_file_input input >>= fun file_content -> Code_action_service.autofix_exports @@ -784,14 +791,21 @@ let autofix_exports ~master_cx:env.ServerEnv.master_cx ~profiling ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_key ~file_content let autofix_missing_local_annot - ~options ~env ~profiling ~loc_of_aloc ~get_ast ~get_haste_name ~get_type_sig ~input = + ~options + ~env + ~profiling + ~loc_of_aloc + ~get_ast_from_shared_mem + ~get_haste_name + ~get_type_sig + ~input = let file_key = file_key_of_file_input ~options ~env input in File_input.content_of_file_input input >>= fun file_content -> Code_action_service.autofix_missing_local_annot @@ -799,7 +813,7 @@ let autofix_missing_local_annot ~master_cx:env.ServerEnv.master_cx ~profiling ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_key @@ -1179,7 +1193,7 @@ let handle_autocomplete let handle_autofix_exports ~options ~input ~profiling ~env ~reader = let loc_of_aloc = Parsing_heaps.Reader.loc_of_aloc ~reader in - let get_ast = Parsing_heaps.Reader.get_ast ~reader in + let get_ast_from_shared_mem = Parsing_heaps.Reader.get_ast ~reader in let get_haste_name = get_haste_name ~reader in let get_type_sig = Parsing_heaps.Reader.get_type_sig ~reader in let result = @@ -1190,7 +1204,7 @@ let handle_autofix_exports ~options ~input ~profiling ~env ~reader = ~profiling ~input ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ) @@ -1199,7 +1213,7 @@ let handle_autofix_exports ~options ~input ~profiling ~env ~reader = let handle_autofix_missing_local_annot ~options ~input ~profiling ~env ~reader = let loc_of_aloc = Parsing_heaps.Reader.loc_of_aloc ~reader in - let get_ast = Parsing_heaps.Reader.get_ast ~reader in + let get_ast_from_shared_mem = Parsing_heaps.Reader.get_ast ~reader in let get_haste_name = get_haste_name ~reader in let get_type_sig = Parsing_heaps.Reader.get_type_sig ~reader in let result = @@ -1210,7 +1224,7 @@ let handle_autofix_missing_local_annot ~options ~input ~profiling ~env ~reader = ~profiling ~input ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ) @@ -1303,7 +1317,7 @@ let handle_insert_type ~env ~reader = let loc_of_aloc = Parsing_heaps.Reader.loc_of_aloc ~reader in - let get_ast = Parsing_heaps.Reader.get_ast ~reader in + let get_ast_from_shared_mem = Parsing_heaps.Reader.get_ast ~reader in let get_haste_name = get_haste_name ~reader in let get_type_sig = Parsing_heaps.Reader.get_type_sig ~reader in let result = @@ -1313,7 +1327,7 @@ let handle_insert_type ~env ~profiling ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_input @@ -1407,7 +1421,7 @@ let find_code_actions ~reader ~options ~env ~profiling ~params ~client = ~imports_ranked_usage ~env ~loc_of_aloc:(Parsing_heaps.Reader.loc_of_aloc ~reader) - ~get_ast:(Parsing_heaps.Reader.get_ast ~reader) + ~get_ast_from_shared_mem:(Parsing_heaps.Reader.get_ast ~reader) ~get_haste_name:(get_haste_name ~reader) ~get_type_sig:(Parsing_heaps.Reader.get_type_sig ~reader) ~get_package_info:(Parsing_heaps.Reader.get_package_info ~reader) @@ -2420,7 +2434,7 @@ let handle_persistent_signaturehelp_lsp let cursor_loc = Loc.cursor (Some path) line col in Signature_help.find_signatures ~loc_of_aloc:(Parsing_heaps.Reader.loc_of_aloc ~reader) - ~get_ast:(Parsing_heaps.Reader.get_ast ~reader) + ~get_ast_from_shared_mem:(Parsing_heaps.Reader.get_ast ~reader) ~cx ~file_sig ~ast diff --git a/src/services/autocomplete/autocompleteService_js.ml b/src/services/autocomplete/autocompleteService_js.ml index 49bf43acec2..4d027b187b9 100644 --- a/src/services/autocomplete/autocompleteService_js.ml +++ b/src/services/autocomplete/autocompleteService_js.ml @@ -311,7 +311,7 @@ type typing = { layout_options: Js_layout_generator.opts; haste_module_system: bool; loc_of_aloc: ALoc.t -> Loc.t; - get_ast: File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option; + get_ast_from_shared_mem: File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option; get_haste_name: File_key.t -> string option; get_package_info: File_key.t -> (Package_json.t, unit) result option; is_package_file: string -> bool; @@ -329,7 +329,7 @@ let mk_typing_artifacts ~layout_options ~haste_module_system ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_package_info ~is_package_file @@ -351,7 +351,7 @@ let mk_typing_artifacts layout_options; haste_module_system; loc_of_aloc; - get_ast; + get_ast_from_shared_mem; get_haste_name; get_package_info; is_package_file; @@ -376,15 +376,15 @@ type 'r autocomplete_service_result_generic = type autocomplete_service_result = AcCompletion.t autocomplete_service_result_generic -let jsdoc_of_def_loc { loc_of_aloc; get_ast; ast; _ } def_loc = - loc_of_aloc def_loc |> Find_documentation.jsdoc_of_getdef_loc ~ast ~get_ast +let jsdoc_of_def_loc { loc_of_aloc; get_ast_from_shared_mem; ast; _ } def_loc = + loc_of_aloc def_loc |> Find_documentation.jsdoc_of_getdef_loc ~ast ~get_ast_from_shared_mem let jsdoc_of_member typing info = match info.Ty_members.def_locs with | [def_loc] -> jsdoc_of_def_loc typing def_loc | _ -> None -let jsdoc_of_loc ~cx ~loc_of_aloc ~get_ast ~file_sig ~ast ~available_ast loc = +let jsdoc_of_loc ~cx ~loc_of_aloc ~get_ast_from_shared_mem ~file_sig ~ast ~available_ast loc = let open GetDef_js.Get_def_result in match GetDef_js.get_def @@ -400,7 +400,7 @@ let jsdoc_of_loc ~cx ~loc_of_aloc ~get_ast ~file_sig ~ast ~available_ast loc = | Partial (locs, _, _) when LocSet.cardinal locs = 1 -> let getdef_loc = LocSet.choose locs in - Find_documentation.jsdoc_of_getdef_loc ~ast ~get_ast getdef_loc + Find_documentation.jsdoc_of_getdef_loc ~ast ~get_ast_from_shared_mem getdef_loc | _ -> None let documentation_and_tags_of_jsdoc jsdoc = @@ -416,9 +416,10 @@ let documentation_and_tags_of_member typing info = |> Base.Option.value_map ~default:(None, None) ~f:documentation_and_tags_of_jsdoc ) -let documentation_and_tags_of_loc ~cx ~loc_of_aloc ~get_ast ~file_sig ~ast ~available_ast loc = +let documentation_and_tags_of_loc + ~cx ~loc_of_aloc ~get_ast_from_shared_mem ~file_sig ~ast ~available_ast loc = lazy - (jsdoc_of_loc ~get_ast ~cx ~loc_of_aloc ~file_sig ~ast ~available_ast loc + (jsdoc_of_loc ~get_ast_from_shared_mem ~cx ~loc_of_aloc ~file_sig ~ast ~available_ast loc |> Base.Option.value_map ~default:(None, None) ~f:documentation_and_tags_of_jsdoc ) @@ -481,7 +482,7 @@ let members_of_type ) let local_value_identifiers ~typing ~genv ~ac_loc = - let { loc_of_aloc; get_ast; cx; ast; available_ast; file_sig; _ } = typing in + let { loc_of_aloc; get_ast_from_shared_mem; cx; ast; available_ast; file_sig; _ } = typing in let scope_info = Scope_builder.program ~enable_enums:(Context.enable_enums cx) ~with_types:false ast in @@ -526,7 +527,14 @@ let local_value_identifiers ~typing ~genv ~ac_loc = Type_env.checked_find_loc_env_write_opt cx Env_api.OrdinaryNameLoc (ALoc.of_loc loc) in let documentation_and_tags = - documentation_and_tags_of_loc ~get_ast ~cx ~loc_of_aloc ~file_sig ~ast ~available_ast loc + documentation_and_tags_of_loc + ~get_ast_from_shared_mem + ~cx + ~loc_of_aloc + ~file_sig + ~ast + ~available_ast + loc in ((name, documentation_and_tags), type_) ) @@ -1305,7 +1313,7 @@ let autocomplete_unqualified_type ~token = let { loc_of_aloc; - get_ast; + get_ast_from_shared_mem; search_exported_types; cx; file_sig; @@ -1331,7 +1339,7 @@ let autocomplete_unqualified_type (fun (items_rev, errors_to_log) ((name, aloc), ty_result) -> let documentation_and_tags = documentation_and_tags_of_loc - ~get_ast + ~get_ast_from_shared_mem ~loc_of_aloc ~cx ~file_sig @@ -1899,7 +1907,7 @@ let autocomplete_module_exports ~typing ~edit_locs ~token ~kind ?filter_name mod AcResult { result = { AcCompletion.items; is_incomplete = false }; errors_to_log } let unused_super_methods ~typing ~edit_locs ~exclude_keys enclosing_class_t = - let { layout_options; loc_of_aloc; get_ast; _ } = typing in + let { layout_options; loc_of_aloc; get_ast_from_shared_mem; _ } = typing in let open Base.Result.Let_syntax in let%bind (mems, errors_to_log) = members_of_type @@ -1916,7 +1924,8 @@ let unused_super_methods ~typing ~edit_locs ~exclude_keys enclosing_class_t = ~f:(fun (name, documentation_and_tags, { Ty_members.ty; def_locs; _ }) -> let open Base.Option in (* Find the AST node for member we want to override *) - def_locs |> Base.List.hd >>| loc_of_aloc >>= Find_method.find ~get_ast >>| fun method_ -> + def_locs |> Base.List.hd >>| loc_of_aloc >>= Find_method.find ~get_ast_from_shared_mem + >>| fun method_ -> autocomplete_create_result_method ~method_ ~layout_options diff --git a/src/services/autocomplete/autocompleteService_js.mli b/src/services/autocomplete/autocompleteService_js.mli index 6268a1a6a29..987aa7d3ff1 100644 --- a/src/services/autocomplete/autocompleteService_js.mli +++ b/src/services/autocomplete/autocompleteService_js.mli @@ -53,7 +53,7 @@ val mk_typing_artifacts : layout_options:Js_layout_generator.opts -> haste_module_system:bool -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_package_info:(File_key.t -> (Package_json.t, unit) result option) -> is_package_file:(string -> bool) -> diff --git a/src/services/autocomplete/find_method.ml b/src/services/autocomplete/find_method.ml index 7662314ddb6..30223931b9c 100644 --- a/src/services/autocomplete/find_method.ml +++ b/src/services/autocomplete/find_method.ml @@ -70,10 +70,10 @@ let empty_method_of_property_type prop = ) | _ -> None -let find ~get_ast target_loc = +let find ~get_ast_from_shared_mem target_loc = let open Base.Option.Let_syntax in let%bind source = Loc.source target_loc in - let%bind ast = get_ast source in + let%bind ast = get_ast_from_shared_mem source in try ignore ((new finder target_loc)#program ast); None diff --git a/src/services/autocomplete/find_method.mli b/src/services/autocomplete/find_method.mli index 744fbf39a89..8630b2cdc9b 100644 --- a/src/services/autocomplete/find_method.mli +++ b/src/services/autocomplete/find_method.mli @@ -6,6 +6,6 @@ *) val find : - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> Loc.t -> (Loc.t, Loc.t) Flow_ast.Class.Method.t Option.t diff --git a/src/services/code_action/__tests__/refactor_extract_tests.ml b/src/services/code_action/__tests__/refactor_extract_tests.ml index c73c58c02d8..aa13226c24c 100644 --- a/src/services/code_action/__tests__/refactor_extract_tests.ml +++ b/src/services/code_action/__tests__/refactor_extract_tests.ml @@ -30,7 +30,7 @@ let assert_refactored ~file_sig:(file_sig_of_ast ast) ~typed_ast ~loc_of_aloc:(Parsing_heaps.Reader.loc_of_aloc ~reader) - ~get_ast:(Parsing_heaps.Reader.get_ast ~reader) + ~get_ast_from_shared_mem:(Parsing_heaps.Reader.get_ast ~reader) ~get_haste_name:(fun f -> let addr = Parsing_heaps.get_file_addr_unsafe f in Parsing_heaps.Reader.get_haste_name ~reader addr) diff --git a/src/services/code_action/__tests__/refactor_extract_utils_tests.ml b/src/services/code_action/__tests__/refactor_extract_utils_tests.ml index 6fe5667d613..ca4682a8473 100644 --- a/src/services/code_action/__tests__/refactor_extract_utils_tests.ml +++ b/src/services/code_action/__tests__/refactor_extract_utils_tests.ml @@ -1054,7 +1054,7 @@ let type_synthesizer_tests = ~file_sig ~typed_ast ~loc_of_aloc:(Parsing_heaps.Reader.loc_of_aloc ~reader) - ~get_ast:(Parsing_heaps.Reader.get_ast ~reader) + ~get_ast_from_shared_mem:(Parsing_heaps.Reader.get_ast ~reader) ~get_haste_name ~get_type_sig:(Parsing_heaps.Reader.get_type_sig ~reader) ~locs diff --git a/src/services/code_action/autofix_exports.ml b/src/services/code_action/autofix_exports.ml index 66a995513dc..21f790efa4f 100644 --- a/src/services/code_action/autofix_exports.ml +++ b/src/services/code_action/autofix_exports.ml @@ -24,12 +24,19 @@ let set_of_fixable_signature_verification_locations tolerable_errors = List.fold_left add_fixable_sig_ver_error LocSet.empty tolerable_errors let fix_signature_verification_error_at_loc - ?remote_converter ~cx ~loc_of_aloc ~get_ast ~get_haste_name ~get_type_sig ~file_sig ~typed_ast = + ?remote_converter + ~cx + ~loc_of_aloc + ~get_ast_from_shared_mem + ~get_haste_name + ~get_type_sig + ~file_sig + ~typed_ast = let open Insert_type in insert_type ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig @@ -40,7 +47,14 @@ let fix_signature_verification_error_at_loc ~ambiguity_strategy:Autofix_options.Generalize let fix_signature_verification_errors - ~file_key ~cx ~loc_of_aloc ~get_ast ~get_haste_name ~get_type_sig ~file_sig ~typed_ast = + ~file_key + ~cx + ~loc_of_aloc + ~get_ast_from_shared_mem + ~get_haste_name + ~get_type_sig + ~file_sig + ~typed_ast = let open Insert_type in let remote_converter = new Insert_type_imports.ImportsHelper.remote_converter @@ -57,7 +71,7 @@ let fix_signature_verification_errors ~remote_converter ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig diff --git a/src/services/code_action/autofix_exports.mli b/src/services/code_action/autofix_exports.mli index 45c269511c3..c5d3512de81 100644 --- a/src/services/code_action/autofix_exports.mli +++ b/src/services/code_action/autofix_exports.mli @@ -13,7 +13,7 @@ val fix_signature_verification_error_at_loc : ?remote_converter:Insert_type_imports.ImportsHelper.remote_converter -> cx:Context.t -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> file_sig:File_sig.t -> @@ -26,7 +26,7 @@ val fix_signature_verification_errors : file_key:File_key.t -> cx:Context.t -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> file_sig:File_sig.t -> diff --git a/src/services/code_action/autofix_missing_local_annots.ml b/src/services/code_action/autofix_missing_local_annots.ml index 78141ef4029..d0b9cf0520e 100644 --- a/src/services/code_action/autofix_missing_local_annots.ml +++ b/src/services/code_action/autofix_missing_local_annots.ml @@ -35,12 +35,19 @@ let map_of_fixable_missing_local_params cx = Flow_error.ErrorSet.fold add_fixable_missing_local_annot_loc all_errors LocMap.empty let fix_missing_param_annot_at_loc - ?remote_converter ~cx ~loc_of_aloc ~get_ast ~get_haste_name ~get_type_sig ~file_sig ~typed_ast = + ?remote_converter + ~cx + ~loc_of_aloc + ~get_ast_from_shared_mem + ~get_haste_name + ~get_type_sig + ~file_sig + ~typed_ast = let open Insert_type in insert_type_t ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig @@ -51,14 +58,21 @@ let fix_missing_param_annot_at_loc ~ambiguity_strategy:Autofix_options.Generalize let fix_all_missing_param_annot_errors_in_file - ?remote_converter ~cx ~loc_of_aloc ~get_ast ~get_haste_name ~get_type_sig ~file_sig ~typed_ast = + ?remote_converter + ~cx + ~loc_of_aloc + ~get_ast_from_shared_mem + ~get_haste_name + ~get_type_sig + ~file_sig + ~typed_ast = let open Insert_type in let fixable_locs = map_of_fixable_missing_local_params cx in let fix_one_loc = insert_type_t ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig diff --git a/src/services/code_action/autofix_missing_local_annots.mli b/src/services/code_action/autofix_missing_local_annots.mli index c696d7c07ec..d351ed78370 100644 --- a/src/services/code_action/autofix_missing_local_annots.mli +++ b/src/services/code_action/autofix_missing_local_annots.mli @@ -14,7 +14,7 @@ val fix_missing_param_annot_at_loc : ?remote_converter:Insert_type_imports.ImportsHelper.remote_converter -> cx:Context.t -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> file_sig:File_sig.t -> @@ -28,7 +28,7 @@ val fix_all_missing_param_annot_errors_in_file : ?remote_converter:Insert_type_imports.ImportsHelper.remote_converter -> cx:Context.t -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> file_sig:File_sig.t -> diff --git a/src/services/code_action/code_action_service.ml b/src/services/code_action/code_action_service.ml index af9f8353d7a..5eb7ba9ce50 100644 --- a/src/services/code_action/code_action_service.ml +++ b/src/services/code_action/code_action_service.ml @@ -57,7 +57,7 @@ let autofix_exports_code_actions ~options ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~ast @@ -73,7 +73,7 @@ let autofix_exports_code_actions fix_signature_verification_error_at_loc ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig @@ -88,7 +88,7 @@ let autofix_missing_local_annot_code_actions ~options ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~ast @@ -108,7 +108,7 @@ let autofix_missing_local_annot_code_actions fix_missing_param_annot_at_loc ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig @@ -128,7 +128,7 @@ let refactor_extract_code_actions ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~only @@ -196,7 +196,7 @@ let refactor_extract_code_actions ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~support_experimental_snippet_text_edit @@ -366,7 +366,7 @@ let untyped_ast_transform transform ~cx:_ ~file_sig:_ ~ast ~typed_ast:_ loc = let autofix_in_upstream_file ~cx - ~get_ast + ~get_ast_from_shared_mem ~file_sig ~diagnostics ~ast @@ -384,7 +384,7 @@ let autofix_in_upstream_file (* load ast of upstream file In order to appear in an error, a loc must have a source *) let source_file = Base.Option.value_exn src in - match get_ast source_file with + match get_ast_from_shared_mem source_file with | None -> (ast, uri) | Some ast -> (ast, source_file |> File_key.to_string |> File_url.create |> Lsp.DocumentUri.of_string) @@ -830,7 +830,7 @@ let ast_transforms_of_error ~loc_of_aloc ?loc = function let code_actions_of_errors ~options ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_package_info ~is_package_file @@ -884,7 +884,7 @@ let code_actions_of_errors |> Base.List.filter_map ~f:(fun { title; diagnostic_title; transform; target_loc } -> autofix_in_upstream_file ~cx - ~get_ast + ~get_ast_from_shared_mem ~file_sig ~diagnostics ~ast @@ -1049,7 +1049,7 @@ let code_actions_at_loc ~imports_ranked_usage ~env ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~get_package_info @@ -1071,7 +1071,7 @@ let code_actions_at_loc ~options ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~ast @@ -1091,7 +1091,7 @@ let code_actions_at_loc ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~only @@ -1101,7 +1101,7 @@ let code_actions_at_loc ~options ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~ast @@ -1118,7 +1118,7 @@ let code_actions_at_loc code_actions_of_errors ~options ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_package_info ~is_package_file @@ -1258,7 +1258,7 @@ let autofix_exports ~master_cx ~profiling ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_key @@ -1284,7 +1284,7 @@ let autofix_exports ~file_key ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig @@ -1301,7 +1301,7 @@ let autofix_missing_local_annot ~master_cx ~profiling ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_key @@ -1325,7 +1325,7 @@ let autofix_missing_local_annot fix_all_missing_param_annot_errors_in_file ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig @@ -1341,7 +1341,7 @@ let insert_type ~env ~profiling ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_key @@ -1378,7 +1378,7 @@ let insert_type Insert_type.insert_type ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig diff --git a/src/services/code_action/code_action_service.mli b/src/services/code_action/code_action_service.mli index 3dc7d43c096..0ee428cfaec 100644 --- a/src/services/code_action/code_action_service.mli +++ b/src/services/code_action/code_action_service.mli @@ -37,7 +37,7 @@ val code_actions_at_loc : imports_ranked_usage:bool -> env:ServerEnv.env -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> get_package_info:(File_key.t -> (Package_json.t, unit) result option) -> @@ -73,7 +73,7 @@ val autofix_exports : master_cx:Context.master_context -> profiling:Profiling_js.running -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> file_key:File_key.t -> @@ -85,7 +85,7 @@ val autofix_missing_local_annot : master_cx:Context.master_context -> profiling:Profiling_js.running -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> file_key:File_key.t -> @@ -97,7 +97,7 @@ val insert_type : env:ServerEnv.env -> profiling:Profiling_js.running -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> file_key:File_key.t -> diff --git a/src/services/code_action/insert_type.ml b/src/services/code_action/insert_type.ml index 688be8f6e13..82b8650dc9c 100644 --- a/src/services/code_action/insert_type.ml +++ b/src/services/code_action/insert_type.ml @@ -190,13 +190,20 @@ let simplify = Ty_utils.simplify_type ~merge_kinds:true ~sort:true (* Generate an equivalent Flow_ast.Type *) let serialize - ~cx ~loc_of_aloc ~get_ast ~file_sig ~typed_ast ?(imports_react = false) ~exact_by_default loc ty - = + ~cx + ~loc_of_aloc + ~get_ast_from_shared_mem + ~file_sig + ~typed_ast + ?(imports_react = false) + ~exact_by_default + loc + ty = let mapper = new Utils.type_normalization_hardcoded_fixes_mapper ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~file_sig ~typed_ast ~lint_severities:LintSettings.empty_severities @@ -214,7 +221,15 @@ let serialize | Error msg -> raise (unexpected (FailedToSerialize { ty; error_message = msg })) let remove_ambiguous_types - ~cx ~loc_of_aloc ~get_ast ~file_sig ~typed_ast ~ambiguity_strategy ~exact_by_default ty loc = + ~cx + ~loc_of_aloc + ~get_ast_from_shared_mem + ~file_sig + ~typed_ast + ~ambiguity_strategy + ~exact_by_default + ty + loc = let open Autofix_options in match ambiguity_strategy with | Fail -> begin @@ -226,10 +241,24 @@ let remove_ambiguous_types { specialized = specialize_temporary_types ty - |> serialize ~cx ~loc_of_aloc ~get_ast ~file_sig ~typed_ast ~exact_by_default loc; + |> serialize + ~cx + ~loc_of_aloc + ~get_ast_from_shared_mem + ~file_sig + ~typed_ast + ~exact_by_default + loc; generalized = generalize_temporary_types ty - |> serialize ~cx ~loc_of_aloc ~get_ast ~file_sig ~typed_ast ~exact_by_default loc; + |> serialize + ~cx + ~loc_of_aloc + ~get_ast_from_shared_mem + ~file_sig + ~typed_ast + ~exact_by_default + loc; } end | Generalize -> generalize_temporary_types ty @@ -404,7 +433,7 @@ let synth_type ?(size_limit = 30) ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~file_sig ~typed_ast ~omit_targ_defaults @@ -427,7 +456,7 @@ let synth_type remove_ambiguous_types ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~file_sig ~typed_ast ~ambiguity_strategy @@ -457,7 +486,7 @@ let synth_type serialize ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~file_sig ~typed_ast ~imports_react @@ -527,7 +556,7 @@ let add_imports remote_converter stmts = let insert_type_ ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig @@ -563,7 +592,7 @@ let insert_type_ synth_type ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~file_sig ~typed_ast ~omit_targ_defaults @@ -581,7 +610,7 @@ let insert_type_ let insert_type ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig @@ -595,7 +624,7 @@ let insert_type insert_type_ ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig @@ -612,7 +641,7 @@ let insert_type let insert_type_t ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig @@ -627,7 +656,7 @@ let insert_type_t insert_type_ ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~file_sig diff --git a/src/services/code_action/insert_type.mli b/src/services/code_action/insert_type.mli index 781aeb7a28d..213a1791b43 100644 --- a/src/services/code_action/insert_type.mli +++ b/src/services/code_action/insert_type.mli @@ -54,7 +54,7 @@ val synth_type : ?size_limit:int -> cx:Context.t -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> file_sig:File_sig.t -> typed_ast:(ALoc.t, ALoc.t * Type.t) Flow_ast.Program.t -> omit_targ_defaults:bool -> @@ -77,7 +77,7 @@ val add_imports : val insert_type : cx:Context.t -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> file_sig:File_sig.t -> @@ -93,7 +93,7 @@ val insert_type : val insert_type_t : cx:Context.t -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> file_sig:File_sig.t -> diff --git a/src/services/code_action/insert_type_utils.ml b/src/services/code_action/insert_type_utils.ml index 76585f4ec4b..ec33b2f8edc 100644 --- a/src/services/code_action/insert_type_utils.ml +++ b/src/services/code_action/insert_type_utils.ml @@ -772,7 +772,7 @@ module GraphQL : sig val extract_graphql_fragment : Context.t -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Ast.Program.t option) -> File_sig.t -> (ALoc.t, ALoc.t * Type.t) Ast.Program.t -> ALoc.t -> @@ -930,9 +930,10 @@ end = struct in (loc_of_aloc (TypeUtil.def_loc_of_t t), (loc, local_name, import_mode)) - let extract_graphql_fragment cx ~loc_of_aloc ~get_ast file_sig typed_ast tgt_aloc = + let extract_graphql_fragment cx ~loc_of_aloc ~get_ast_from_shared_mem file_sig typed_ast tgt_aloc + = let graphql_file = Base.Option.value_exn (ALoc.source tgt_aloc) in - match get_ast graphql_file with + match get_ast_from_shared_mem graphql_file with | None -> None | Some graphql_ast -> (* Collect information about imports in currect file to accurately compute @@ -952,7 +953,7 @@ end class type_normalization_hardcoded_fixes_mapper ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~file_sig ~typed_ast ~lint_severities @@ -1319,7 +1320,13 @@ class type_normalization_hardcoded_fixes_mapper let remote_file = Base.Option.value_exn (ALoc.source aloc) in if String.ends_with (File_key.to_string remote_file) ~suffix:"graphql.js" then match - GraphQL.extract_graphql_fragment cx ~loc_of_aloc ~get_ast file_sig typed_ast aloc + GraphQL.extract_graphql_fragment + cx + ~loc_of_aloc + ~get_ast_from_shared_mem + file_sig + typed_ast + aloc with | Some t -> t | None -> super#on_t env t @@ -1369,7 +1376,7 @@ module MakeHardcodedFixes (Extra : BASE_STATS) = struct let run ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~file_sig ~typed_ast ~preserve_literals @@ -1388,7 +1395,7 @@ module MakeHardcodedFixes (Extra : BASE_STATS) = struct new type_normalization_hardcoded_fixes_mapper ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~file_sig ~typed_ast ~lint_severities diff --git a/src/services/code_action/refactor_extract.ml b/src/services/code_action/refactor_extract.ml index fd5f492af94..ccd453b9e02 100644 --- a/src/services/code_action/refactor_extract.ml +++ b/src/services/code_action/refactor_extract.ml @@ -457,7 +457,7 @@ let extract_from_statements_refactors ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~create_unique_name @@ -518,7 +518,7 @@ let extract_from_statements_refactors ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~locs @@ -791,7 +791,7 @@ let extract_from_expression_refactors ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~create_unique_name @@ -831,7 +831,7 @@ let extract_from_expression_refactors ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~locs @@ -898,7 +898,7 @@ let extract_from_type_refactors ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~create_unique_name @@ -924,7 +924,7 @@ let extract_from_type_refactors ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~locs:(LocSet.singleton type_loc) @@ -992,7 +992,7 @@ let provide_available_refactors ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~support_experimental_snippet_text_edit @@ -1013,7 +1013,7 @@ let provide_available_refactors ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~create_unique_name @@ -1031,7 +1031,7 @@ let provide_available_refactors ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~create_unique_name @@ -1049,7 +1049,7 @@ let provide_available_refactors ~file_sig ~typed_ast ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~get_haste_name ~get_type_sig ~create_unique_name diff --git a/src/services/code_action/refactor_extract.mli b/src/services/code_action/refactor_extract.mli index dbce0fef092..c56fef4df12 100644 --- a/src/services/code_action/refactor_extract.mli +++ b/src/services/code_action/refactor_extract.mli @@ -19,7 +19,7 @@ val provide_available_refactors : file_sig:File_sig.t -> typed_ast:(ALoc.t, ALoc.t * Type.t) Flow_ast.Program.t -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> support_experimental_snippet_text_edit:bool -> diff --git a/src/services/code_action/refactor_extract_utils.ml b/src/services/code_action/refactor_extract_utils.ml index f95155bba1d..97f11f8c3be 100644 --- a/src/services/code_action/refactor_extract_utils.ml +++ b/src/services/code_action/refactor_extract_utils.ml @@ -971,7 +971,7 @@ module TypeSynthesizer = struct file_sig: File_sig.t; typed_ast: (ALoc.t, ALoc.t * Type.t) Flow_ast.Program.t; loc_of_aloc: ALoc.t -> Loc.t; - get_ast: File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option; + get_ast_from_shared_mem: File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option; get_haste_name: File_key.t -> string option; get_type_sig: File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option; type_at_loc_map: (Type.typeparam list * Type.t) LocMap.t; @@ -1043,7 +1043,15 @@ module TypeSynthesizer = struct |> List.rev let create_synthesizer_context - ~cx ~file ~file_sig ~typed_ast ~loc_of_aloc ~get_ast ~get_haste_name ~get_type_sig ~locs = + ~cx + ~file + ~file_sig + ~typed_ast + ~loc_of_aloc + ~get_ast_from_shared_mem + ~get_haste_name + ~get_type_sig + ~locs = let collector = new type_collector ~loc_of_aloc locs in ignore (collector#program typed_ast); let type_at_loc_map = collector#collected_types in @@ -1053,7 +1061,7 @@ module TypeSynthesizer = struct file_sig; typed_ast; loc_of_aloc; - get_ast; + get_ast_from_shared_mem; get_haste_name; get_type_sig; type_at_loc_map; @@ -1075,7 +1083,7 @@ module TypeSynthesizer = struct file_sig; typed_ast; loc_of_aloc; - get_ast; + get_ast_from_shared_mem; get_haste_name; get_type_sig; type_at_loc_map; @@ -1095,7 +1103,7 @@ module TypeSynthesizer = struct (Insert_type.synth_type ~cx ~loc_of_aloc - ~get_ast + ~get_ast_from_shared_mem ~file_sig ~typed_ast ~omit_targ_defaults:false diff --git a/src/services/code_action/refactor_extract_utils.mli b/src/services/code_action/refactor_extract_utils.mli index 56f1f3d4569..97babf2e3b9 100644 --- a/src/services/code_action/refactor_extract_utils.mli +++ b/src/services/code_action/refactor_extract_utils.mli @@ -186,7 +186,7 @@ module TypeSynthesizer : sig file_sig:File_sig.t -> typed_ast:(ALoc.t, ALoc.t * Type.t) Flow_ast.Program.t -> loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> get_haste_name:(File_key.t -> string option) -> get_type_sig:(File_key.t -> Type_sig_collections.Locs.index Packed_type_sig.Module.t option) -> locs:Loc_collections.LocSet.t -> diff --git a/src/services/jsdoc/find_documentation.ml b/src/services/jsdoc/find_documentation.ml index 12ef67a87f0..49f0775c969 100644 --- a/src/services/jsdoc/find_documentation.ml +++ b/src/services/jsdoc/find_documentation.ml @@ -316,7 +316,7 @@ let search_jsdoc def_loc ast = with | FoundJsdoc documentation -> Some documentation -let jsdoc_of_getdef_loc ~ast ~get_ast def_loc = +let jsdoc_of_getdef_loc ~ast ~get_ast_from_shared_mem def_loc = let open Base.Option.Let_syntax in let%bind source = Loc.source def_loc in let current_ast_if_should_use = @@ -330,7 +330,7 @@ let jsdoc_of_getdef_loc ~ast ~get_ast def_loc = let%bind ast = match current_ast_if_should_use with | Some _ as some_ast -> some_ast - | None -> get_ast source + | None -> get_ast_from_shared_mem source in search_jsdoc def_loc ast diff --git a/src/services/jsdoc/find_documentation.mli b/src/services/jsdoc/find_documentation.mli index 67a4df79af0..45e685dd131 100644 --- a/src/services/jsdoc/find_documentation.mli +++ b/src/services/jsdoc/find_documentation.mli @@ -7,7 +7,7 @@ val jsdoc_of_getdef_loc : ast:(Loc.t, Loc.t) Flow_ast.Program.t -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> Loc.t -> Jsdoc.t option diff --git a/src/services/type_info/signature_help.ml b/src/services/type_info/signature_help.ml index 4179c9ee273..e96193a92a3 100644 --- a/src/services/type_info/signature_help.ml +++ b/src/services/type_info/signature_help.ml @@ -300,7 +300,7 @@ let rec fix_alias_reason cx t = IntersectionT (r, InterRep.make t0 t1 ts) | _ -> t' -let find_signatures ~loc_of_aloc ~get_ast ~cx ~file_sig ~ast ~typed_ast loc = +let find_signatures ~loc_of_aloc ~get_ast_from_shared_mem ~cx ~file_sig ~ast ~typed_ast loc = match Callee_finder.find_opt ~loc_of_aloc ~cx ~typed_ast loc with | Some (t, active_parameter, callee_loc) -> let t' = fix_alias_reason cx t in @@ -324,7 +324,7 @@ let find_signatures ~loc_of_aloc ~get_ast ~cx ~file_sig ~ast ~typed_ast loc = | GetDef_js.Get_def_result.Partial (locs, _, _) when LocSet.cardinal locs = 1 -> let getdef_loc = LocSet.choose locs in - Find_documentation.jsdoc_of_getdef_loc ~ast ~get_ast getdef_loc + Find_documentation.jsdoc_of_getdef_loc ~ast ~get_ast_from_shared_mem getdef_loc | _ -> None in (match ty with diff --git a/src/services/type_info/signature_help.mli b/src/services/type_info/signature_help.mli index 43be3005b5e..139c1191904 100644 --- a/src/services/type_info/signature_help.mli +++ b/src/services/type_info/signature_help.mli @@ -27,7 +27,7 @@ val func_details : val find_signatures : loc_of_aloc:(ALoc.t -> Loc.t) -> - get_ast:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> + get_ast_from_shared_mem:(File_key.t -> (Loc.t, Loc.t) Flow_ast.Program.t option) -> cx:Context.t -> file_sig:File_sig.t -> ast:(Loc.t, Loc.t) Flow_ast.Program.t ->