@@ -637,6 +637,9 @@ let get_errors_for_path (istate : istate) (path : Relative_path.t) : Errors.t =
637
637
let ctx = make_singleton_ctx istate.icommon entry in
638
638
get_user_facing_errors ~ctx ~error_filter: istate.error_filter ~entry
639
639
640
+ let path_to_relative_path path =
641
+ path |> Path. to_string |> Relative_path. create_detect_prefix
642
+
640
643
(* * handle_request invariants: Messages are only ever handled serially; we never
641
644
handle one message while another is being handled. It is a bug if the client sends
642
645
anything other than [Initialize_from_saved_state] as its first message. Upon
@@ -736,16 +739,12 @@ let handle_request
736
739
(Initialized istate, Ok () )
737
740
(* didClose *)
738
741
| (During_init dstate , Did_close file_path ) ->
739
- let path =
740
- file_path |> Path. to_string |> Relative_path. create_detect_prefix
741
- in
742
+ let path = path_to_relative_path file_path in
742
743
( During_init
743
744
{ dstate with dopen_files = close_file dstate.dopen_files path },
744
745
Ok [] )
745
746
| (Initialized istate , Did_close file_path ) ->
746
- let path =
747
- file_path |> Path. to_string |> Relative_path. create_detect_prefix
748
- in
747
+ let path = path_to_relative_path file_path in
749
748
let errors =
750
749
Errors. get_sorted_error_list (get_errors_for_path istate path)
751
750
in
@@ -763,9 +762,7 @@ let handle_request
763
762
Ok diagnostics )
764
763
(* didOpen or didChange *)
765
764
| (During_init dstate , Did_open_or_change { file_path; file_contents } ) ->
766
- let path =
767
- file_path |> Path. to_string |> Relative_path. create_detect_prefix
768
- in
765
+ let path = path_to_relative_path file_path in
769
766
let dstate = open_or_change_file_during_init dstate path file_contents in
770
767
(During_init dstate, Ok () )
771
768
| (Initialized istate , Did_open_or_change document ) ->
@@ -1140,9 +1137,7 @@ let handle_request
1140
1137
Hence, we construct temporary entry to reflect the file which
1141
1138
contained the target of the resolve. *)
1142
1139
HackEventLogger. completion_call ~method_name: " Completion_resolve_location" ;
1143
- let path =
1144
- file_path |> Path. to_string |> Relative_path. create_detect_prefix
1145
- in
1140
+ let path = path_to_relative_path file_path in
1146
1141
let ctx = make_empty_ctx istate.icommon in
1147
1142
let (ctx, entry) = Provider_context. add_entry_if_missing ~ctx ~path in
1148
1143
let result =
0 commit comments